本文整理汇总了Java中com.alibaba.dubbo.registry.common.domain.Provider类的典型用法代码示例。如果您正苦于以下问题:Java Provider类的具体用法?Java Provider怎么用?Java Provider使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Provider类属于com.alibaba.dubbo.registry.common.domain包,在下文中一共展示了Provider类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: doExecute
import com.alibaba.dubbo.registry.common.domain.Provider; //导入依赖的package包/类
@SuppressWarnings("unchecked")
protected String doExecute(Map<String,Object> context) throws Exception {
Map<String, String[]> params = request.getParameterMap();
if (params == null || params.size() == 0) {
throw new IllegalArgumentException("The url parameters is null! Usage: " + request.getRequestURL().toString() + "?com.xxx.XxxService=http://" + operatorAddress + "/xxxService");
}
for (Map.Entry<String, String[]> entry : params.entrySet()) {
if (entry.getKey() != null && entry.getKey().length() > 0
&& entry.getValue() != null && entry.getValue().length > 0
&& entry.getValue()[0] != null && entry.getValue()[0].length() > 0) {
if (! currentUser.hasServicePrivilege(entry.getKey())) {
throw new IllegalStateException("The user " + operator + " have no privilege of service " + entry.getKey());
}
for(Entry<String,String> e : CollectionUtils.split(Arrays.asList(entry.getValue()), "?").entrySet()){
Provider provider = providervice.findByServiceAndAddress(entry.getKey(), e.getKey());
if (provider != null) {
providervice.deleteStaticProvider(provider.getId());
}
}
}
}
return "Unregister " + params.size() + " services.";
}
示例2: add
import com.alibaba.dubbo.registry.common.domain.Provider; //导入依赖的package包/类
/**
* load页面供新增操作
* @param context
*/
public void add(Map<String, Object> context) {
String service = (String)context.get("service");
if (service != null && service.length() > 0 && !service.contains("*")) {
List<Provider> providerList = providerService.findByService(service);
List<String> addressList = new ArrayList<String>();
for(Provider provider : providerList){
addressList.add(provider.getUrl().split("://")[1].split("/")[0]);
}
context.put("addressList", addressList);
context.put("service", service);
context.put("methods", CollectionUtils.sort(providerService.findMethodsByService(service)));
} else {
List<String> serviceList = Tool.sortSimpleName(providerService.findServices());
context.put("serviceList", serviceList);
}
if(context.get("input") != null) context.put("input", context.get("input"));
}
示例3: create
import com.alibaba.dubbo.registry.common.domain.Provider; //导入依赖的package包/类
public boolean create(Provider provider, Map<String, Object> context) {
String service = provider.getService();
if (!super.currentUser.hasServicePrivilege(service)) {
context.put("message", getMessage("HaveNoServicePrivilege", service));
return false;
}
if (provider.getParameters() == null) {
String url = provider.getUrl();
if (url != null) {
int i = url.indexOf('?');
if (i > 0) {
provider.setUrl(url.substring(0, i));
provider.setParameters(url.substring(i + 1));
}
}
}
provider.setDynamic(false); // 页面上添加的一定是静态的Provider
providerService.create(provider);
return true;
}
示例4: url2Provider
import com.alibaba.dubbo.registry.common.domain.Provider; //导入依赖的package包/类
public static Provider url2Provider(Pair<Long, URL> pair) {
if (pair == null) {
return null;
}
Long id = pair.getKey();
URL url = pair.getValue();
if (url == null)
return null;
Provider p = new Provider();
p.setId(id);
p.setService(url.getServiceKey());
p.setAddress(url.getAddress());
p.setApplication(url.getParameter(Constants.APPLICATION_KEY));
p.setUrl(url.toIdentityString());
p.setParameters(url.toParameterString());
p.setDynamic(url.getParameter("dynamic", true));
p.setEnabled(url.getParameter(Constants.ENABLED_KEY, true));
p.setWeight(url.getParameter(Constants.WEIGHT_KEY, Constants.DEFAULT_WEIGHT));
p.setUsername(url.getParameter("owner"));
return p;
}
示例5: add
import com.alibaba.dubbo.registry.common.domain.Provider; //导入依赖的package包/类
public void add(Map<String, Object> context) {
String service = (String)context.get("service");
if (service != null && service.length() > 0 && !service.contains("*")) {
List<Provider> providerList = providerService.findByService(service);
List<String> addressList = new ArrayList<String>();
for(Provider provider : providerList){
addressList.add(provider.getUrl().split("://")[1].split("/")[0]);
}
context.put("addressList", addressList);
context.put("service", service);
context.put("methods", CollectionUtils.sort(providerService.findMethodsByService(service)));
} else {
List<String> serviceList = Tool.sortSimpleName(providerService.findServices());
context.put("serviceList", serviceList);
}
if(context.get("input") != null) context.put("input", context.get("input"));
}
示例6: url2Provider
import com.alibaba.dubbo.registry.common.domain.Provider; //导入依赖的package包/类
public static Provider url2Provider(Pair<Long, URL> pair) {
if (pair == null) {
return null;
}
Long id = pair.getKey();
URL url = pair.getValue();
if (url == null)
return null;
Provider p = new Provider();
p.setId(id);
p.setService(url.getServiceKey());
p.setAddress(url.getAddress());
p.setApplication(url.getParameter(Constants.APPLICATION_KEY));
p.setUrl(url.toIdentityString());
p.setParameters(url.toParameterString());
p.setDynamic(url.getParameter("dynamic", true));
p.setEnabled(url.getParameter(Constants.ENABLED_KEY, true));
p.setWeight(url.getParameter(Constants.WEIGHT_KEY, Constants.DEFAULT_WEIGHT));
p.setUsername(url.getParameter("owner"));
return p;
}
示例7: add
import com.alibaba.dubbo.registry.common.domain.Provider; //导入依赖的package包/类
/**
* 装载新增服务页面,获取所有的服务名称
*
* @param context
*/
public void add(Long id, Map<String, Object> context) {
if (context.get("service") == null) {
List<String> serviceList = Tool.sortSimpleName(new ArrayList<String>(providerService.findServices()));
context.put("serviceList", serviceList);
}
if (id != null) {
Provider p = providerService.findProvider(id);
if (p != null) {
context.put("provider", p);
String parameters = p.getParameters();
if (parameters != null && parameters.length() > 0) {
Map<String, String> map = StringUtils.parseQueryString(parameters);
map.put("timestamp", String.valueOf(System.currentTimeMillis()));
map.remove("pid");
p.setParameters(StringUtils.toQueryString(map));
}
}
}
}
示例8: create
import com.alibaba.dubbo.registry.common.domain.Provider; //导入依赖的package包/类
public boolean create(Provider provider, Map<String, Object> context) {
String service = provider.getService();
if (!super.currentUser.hasServicePrivilege(service)) {
context.put("message", getMessage("HaveNoServicePrivilege", service));
return false;
}
if (provider.getParameters() == null) {
String url = provider.getUrl();
if (url != null) {
int i = url.indexOf('?');
if (i > 0) {
provider.setUrl(url.substring(0, i));
provider.setParameters(url.substring(i + 1));
}
}
}
provider.setDynamic(false); // 页面上添加的一定是静态的Provider
providerService.create(provider);
return true;
}
示例9: add
import com.alibaba.dubbo.registry.common.domain.Provider; //导入依赖的package包/类
public void add(Map<String, Object> context) {
String service = (String) context.get("service");
if (service != null && service.length() > 0 && !service.contains("*")) {
List<Provider> providerList = providerService.findByService(service);
List<String> addressList = new ArrayList<String>();
for (Provider provider : providerList) {
addressList.add(provider.getUrl().split("://")[1].split("/")[0]);
}
context.put("addressList", addressList);
context.put("service", service);
context.put("methods", CollectionUtils.sort(providerService.findMethodsByService(service)));
} else {
List<String> serviceList = Tool.sortSimpleName(providerService.findServices());
context.put("serviceList", serviceList);
}
if (context.get("input") != null) context.put("input", context.get("input"));
}
示例10: index
import com.alibaba.dubbo.registry.common.domain.Provider; //导入依赖的package包/类
public void index(Map<String, Object> context) {
List<Provider> providers = providerService.findAll();
List<Consumer> consumers = consumerService.findAll();
Set<String> parametersSet = new HashSet<String>();
for (Provider provider : providers) {
parametersSet.add(provider.getParameters());
}
for (Consumer consumer : consumers) {
parametersSet.add(consumer.getParameters());
}
Map<String, Set<String>> versions = new HashMap<String, Set<String>>();
Iterator<String> temp = parametersSet.iterator();
while (temp.hasNext()) {
Map<String, String> parameter = StringUtils.parseQueryString(temp.next());
if (parameter != null) {
String dubbo = parameter.get("dubbo");
if(dubbo == null) dubbo = "0.0.0";
String application = parameter.get("application");
if (versions.get(dubbo) == null) {
Set<String> apps = new HashSet<String>();
versions.put(dubbo, apps);
}
versions.get(dubbo).add(application);
}
}
context.put("versions", versions);
}
示例11: show
import com.alibaba.dubbo.registry.common.domain.Provider; //导入依赖的package包/类
public void show(Long[] ids, Map<String, Object> context) {
String version =(String)context.get("version");
if (version != null && version.length() > 0) {
List<Provider> providers = providerService.findAll();
List<Consumer> consumers = consumerService.findAll();
Set<String> parametersSet = new HashSet<String>();
Set<String> applications = new HashSet<String>();
for (Provider provider : providers) {
parametersSet.add(provider.getParameters());
}
for (Consumer consumer : consumers) {
parametersSet.add(consumer.getParameters());
}
Iterator<String> temp = parametersSet.iterator();
while (temp.hasNext()) {
Map<String, String> parameter = StringUtils.parseQueryString(temp.next());
if (parameter != null) {
String dubbo = parameter.get("dubbo");
if(dubbo == null) dubbo = "0.0.0";
String application = parameter.get("application");
if (version.equals(dubbo)) {
applications.add(application);
}
}
}
context.put("applications", applications);
}
}
示例12: show
import com.alibaba.dubbo.registry.common.domain.Provider; //导入依赖的package包/类
public void show(Long id, Map<String, Object> context) {
Provider provider = providerService.findProvider(id);
if (provider != null && provider.isDynamic()) {
List<Override> overrides = overrideService.findByServiceAndAddress(provider.getService(), provider.getAddress());
OverrideUtils.setProviderOverrides(provider, overrides);
}
context.put("provider", provider);
}
示例13: isProviderEnabled
import com.alibaba.dubbo.registry.common.domain.Provider; //导入依赖的package包/类
public static boolean isProviderEnabled(Provider provider, List<Override> oList){
for(Override o : oList){
if (o.isMatch(provider)) {
Map<String, String> params = StringUtils.parseQueryString(o.getParams());
String disbaled = params.get(Constants.DISABLED_KEY);
if(disbaled != null && disbaled.length() > 0){
return ! "true".equals(disbaled);
}
}
}
return provider.isEnabled();
}
示例14: getProviderWeight
import com.alibaba.dubbo.registry.common.domain.Provider; //导入依赖的package包/类
public static int getProviderWeight(Provider provider, List<Override> oList) {
for(Override o : oList){
if (o.isMatch(provider)) {
Map<String, String> params = StringUtils.parseQueryString(o.getParams());
String weight = params.get(Constants.WEIGHT_KEY);
if(weight != null && weight.length() > 0){
return Integer.parseInt(weight);
}
}
}
return provider.getWeight();
}
示例15: enableProvider
import com.alibaba.dubbo.registry.common.domain.Provider; //导入依赖的package包/类
public void enableProvider(Long id) {
if(id == null) {
throw new IllegalStateException("no provider id");
}
Provider oldProvider = findProvider(id);
if(oldProvider == null) {
throw new IllegalStateException("Provider was changed!");
}
if (oldProvider.isDynamic()) {
//保证disable的override唯一
if(!oldProvider.isEnabled()){
Override override = new Override();
override.setAddress(oldProvider.getAddress());
override.setService(oldProvider.getService());
override.setEnabled(true);
override.setParams(Constants.DISABLED_KEY+"=false");
overrideService.saveOverride(override);
return;
}
List<Override> oList = overrideService.findByServiceAndAddress(oldProvider.getService(), oldProvider.getAddress());
for(Override o : oList){
Map<String, String> params = StringUtils.parseQueryString(o.getParams());
if(params.containsKey(Constants.DISABLED_KEY)){
if(params.get(Constants.DISABLED_KEY) .equals("true")){
overrideService.deleteOverride(o.getId());
}
}
}
} else {
oldProvider.setEnabled(true);
updateProvider(oldProvider);
}
}