com.alibaba.dubbo.registry.common.util.Tool Java Examples

The following examples show how to use com.alibaba.dubbo.registry.common.util.Tool. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Routes.java    From dubbox with Apache License 2.0 6 votes vote down vote up
/**
 * 路由模块首页
 * @param context
 */
public void index(Map<String, Object> context) {
    String service = (String) context.get("service");
    String address = (String) context.get("address");
    address = Tool.getIP(address);
    List<Route> routes;
    if (service != null && service.length() > 0
    		&& address != null && address.length() > 0) {
        routes = routeService.findByServiceAndAddress(service, address);
    } else if (service != null && service.length() > 0) {
        routes = routeService.findByService(service);
    } else if (address != null && address.length() > 0) {
        routes = routeService.findByAddress(address);
    } else {
        routes = routeService.findAll();
    }
    context.put("routes", routes);
}
 
Example #2
Source File: Loadbalances.java    From dubbox with Apache License 2.0 6 votes vote down vote up
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"));
}
 
Example #3
Source File: Providers.java    From dubbox with Apache License 2.0 6 votes vote down vote up
/**
   * 装载新增服务页面,获取所有的服务名称
   * @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));
		}
	}
}
  }
 
Example #4
Source File: Routes.java    From dubbox with Apache License 2.0 6 votes vote down vote up
/**
 * 路由模块首页
 * @param context
 */
public void index(Map<String, Object> context) {
    String service = (String) context.get("service");
    String address = (String) context.get("address");
    address = Tool.getIP(address);
    List<Route> routes;
    if (service != null && service.length() > 0
    		&& address != null && address.length() > 0) {
        routes = routeService.findByServiceAndAddress(service, address);
    } else if (service != null && service.length() > 0) {
        routes = routeService.findByService(service);
    } else if (address != null && address.length() > 0) {
        routes = routeService.findByAddress(address);
    } else {
        routes = routeService.findAll();
    }
    context.put("routes", routes);
}
 
Example #5
Source File: Weights.java    From dubbox with Apache License 2.0 6 votes vote down vote up
/**
 * 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"));
}
 
Example #6
Source File: Routes.java    From dubbox with Apache License 2.0 6 votes vote down vote up
/**
 * 路由模块首页
 * @param context
 */
public void index(Map<String, Object> context) {
    String service = (String) context.get("service");
    String address = (String) context.get("address");
    address = Tool.getIP(address);
    List<Route> routes;
    if (service != null && service.length() > 0
    		&& address != null && address.length() > 0) {
        routes = routeService.findByServiceAndAddress(service, address);
    } else if (service != null && service.length() > 0) {
        routes = routeService.findByService(service);
    } else if (address != null && address.length() > 0) {
        routes = routeService.findByAddress(address);
    } else {
        routes = routeService.findAll();
    }
    context.put("routes", routes);
}
 
Example #7
Source File: Loadbalances.java    From dubbo3 with Apache License 2.0 6 votes vote down vote up
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"));
}
 
Example #8
Source File: Providers.java    From dubbo3 with Apache License 2.0 6 votes vote down vote up
/**
   * 装载新增服务页面,获取所有的服务名称
   * @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));
		}
	}
}
  }
 
Example #9
Source File: Weights.java    From dubbox with Apache License 2.0 6 votes vote down vote up
/**
 * 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"));
}
 
Example #10
Source File: Weights.java    From dubbo3 with Apache License 2.0 6 votes vote down vote up
/**
 * 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"));
}
 
Example #11
Source File: Routes.java    From dubbo3 with Apache License 2.0 6 votes vote down vote up
/**
 * 路由模块首页
 * @param context
 */
public void index(Map<String, Object> context) {
    String service = (String) context.get("service");
    String address = (String) context.get("address");
    address = Tool.getIP(address);
    List<Route> routes;
    if (service != null && service.length() > 0
    		&& address != null && address.length() > 0) {
        routes = routeService.findByServiceAndAddress(service, address);
    } else if (service != null && service.length() > 0) {
        routes = routeService.findByService(service);
    } else if (address != null && address.length() > 0) {
        routes = routeService.findByAddress(address);
    } else {
        routes = routeService.findAll();
    }
    context.put("routes", routes);
}
 
Example #12
Source File: Loadbalances.java    From dubbox-hystrix with Apache License 2.0 6 votes vote down vote up
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"));
}
 
Example #13
Source File: Providers.java    From dubbox-hystrix with Apache License 2.0 6 votes vote down vote up
/**
   * 装载新增服务页面,获取所有的服务名称
   * @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));
		}
	}
}
  }
 
Example #14
Source File: Providers.java    From dubbox with Apache License 2.0 6 votes vote down vote up
/**
   * 装载新增服务页面,获取所有的服务名称
   * @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));
		}
	}
}
  }
 
Example #15
Source File: Weights.java    From dubbox-hystrix with Apache License 2.0 6 votes vote down vote up
/**
 * 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"));
}
 
Example #16
Source File: Routes.java    From dubbox-hystrix with Apache License 2.0 6 votes vote down vote up
/**
 * 路由模块首页
 * @param context
 */
public void index(Map<String, Object> context) {
    String service = (String) context.get("service");
    String address = (String) context.get("address");
    address = Tool.getIP(address);
    List<Route> routes;
    if (service != null && service.length() > 0
    		&& address != null && address.length() > 0) {
        routes = routeService.findByServiceAndAddress(service, address);
    } else if (service != null && service.length() > 0) {
        routes = routeService.findByService(service);
    } else if (address != null && address.length() > 0) {
        routes = routeService.findByAddress(address);
    } else {
        routes = routeService.findAll();
    }
    context.put("routes", routes);
}
 
Example #17
Source File: Weights.java    From dubbox with Apache License 2.0 6 votes vote down vote up
/**
 * 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"));
}
 
Example #18
Source File: Loadbalances.java    From dubbox with Apache License 2.0 6 votes vote down vote up
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"));
}
 
Example #19
Source File: Loadbalances.java    From dubbox with Apache License 2.0 6 votes vote down vote up
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"));
}
 
Example #20
Source File: Providers.java    From dubbox with Apache License 2.0 6 votes vote down vote up
/**
   * 装载新增服务页面,获取所有的服务名称
   * @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));
		}
	}
}
  }
 
Example #21
Source File: Routes.java    From dubbox-hystrix with Apache License 2.0 5 votes vote down vote up
/**
 * 载入新增路由页面
 * @param context
 */
public void add(Map<String, Object> context) {
    String service = (String)context.get("service");
    if (service != null && service.length() > 0 && !service.contains("*")) {
        context.put("service", service);
        context.put("methods", CollectionUtils.sort(new ArrayList<String>(providerService.findMethodsByService(service))));
    } else {
        List<String> serviceList = Tool.sortSimpleName(new ArrayList<String>(providerService.findServices()));
        context.put("serviceList", serviceList);
    }
    
    if(context.get("input") != null) context.put("input", context.get("input"));
    
}
 
Example #22
Source File: Owners.java    From dubbox with Apache License 2.0 5 votes vote down vote up
public void add(Map<String, Object> context) {
	String service = (String) context.get("service");
	if (service == null || service.length() == 0) {
           List<String> serviceList = Tool.sortSimpleName(new ArrayList<String>(providerService.findServices()));
           context.put("serviceList", serviceList);
       }
}
 
Example #23
Source File: Routes.java    From dubbox with Apache License 2.0 5 votes vote down vote up
/**
 * 载入新增路由页面
 * @param context
 */
public void add(Map<String, Object> context) {
    String service = (String)context.get("service");
    if (service != null && service.length() > 0 && !service.contains("*")) {
        context.put("service", service);
        context.put("methods", CollectionUtils.sort(new ArrayList<String>(providerService.findMethodsByService(service))));
    } else {
        List<String> serviceList = Tool.sortSimpleName(new ArrayList<String>(providerService.findServices()));
        context.put("serviceList", serviceList);
    }
    
    if(context.get("input") != null) context.put("input", context.get("input"));
    
}
 
Example #24
Source File: Weights.java    From dubbox with Apache License 2.0 5 votes vote down vote up
public boolean update(Weight weight, Map<String, Object> context) {
    if (!super.currentUser.hasServicePrivilege(weight.getService())) {
        context.put("message", getMessage("HaveNoServicePrivilege", weight.getService()));
        return false;
    }
    weight.setAddress(Tool.getIP(weight.getAddress()));
	overrideService.updateOverride(OverrideUtils.weightToOverride(weight));
    return true;
}
 
Example #25
Source File: Weights.java    From dubbox with Apache License 2.0 5 votes vote down vote up
public void index(Map<String, Object> context) {
    final String service = StringUtils.trimToNull((String) context.get("service"));
    String address = (String) context.get("address");
    address = Tool.getIP(address);
    List<Weight> weights;
    if (service != null && service.length() > 0) {
        weights = OverrideUtils.overridesToWeights(overrideService.findByService(service));
    } else if (address != null && address.length() > 0) {
        weights = OverrideUtils.overridesToWeights(overrideService.findByAddress(address));
    } else {
        weights = OverrideUtils.overridesToWeights(overrideService.findAll());
    }
    context.put("weights", weights);
}
 
Example #26
Source File: Weights.java    From dubbox with Apache License 2.0 5 votes vote down vote up
public void index(Map<String, Object> context) {
    final String service = StringUtils.trimToNull((String) context.get("service"));
    String address = (String) context.get("address");
    address = Tool.getIP(address);
    List<Weight> weights;
    if (service != null && service.length() > 0) {
        weights = OverrideUtils.overridesToWeights(overrideService.findByService(service));
    } else if (address != null && address.length() > 0) {
        weights = OverrideUtils.overridesToWeights(overrideService.findByAddress(address));
    } else {
        weights = OverrideUtils.overridesToWeights(overrideService.findAll());
    }
    context.put("weights", weights);
}
 
Example #27
Source File: Routes.java    From dubbox with Apache License 2.0 5 votes vote down vote up
/**
 * 载入新增路由页面
 * @param context
 */
public void add(Map<String, Object> context) {
    String service = (String)context.get("service");
    if (service != null && service.length() > 0 && !service.contains("*")) {
        context.put("service", service);
        context.put("methods", CollectionUtils.sort(new ArrayList<String>(providerService.findMethodsByService(service))));
    } else {
        List<String> serviceList = Tool.sortSimpleName(new ArrayList<String>(providerService.findServices()));
        context.put("serviceList", serviceList);
    }
    
    if(context.get("input") != null) context.put("input", context.get("input"));
    
}
 
Example #28
Source File: Owners.java    From dubbox with Apache License 2.0 5 votes vote down vote up
public void add(Map<String, Object> context) {
	String service = (String) context.get("service");
	if (service == null || service.length() == 0) {
           List<String> serviceList = Tool.sortSimpleName(new ArrayList<String>(providerService.findServices()));
           context.put("serviceList", serviceList);
       }
}
 
Example #29
Source File: Owners.java    From dubbox with Apache License 2.0 5 votes vote down vote up
public void add(Map<String, Object> context) {
	String service = (String) context.get("service");
	if (service == null || service.length() == 0) {
           List<String> serviceList = Tool.sortSimpleName(new ArrayList<String>(providerService.findServices()));
           context.put("serviceList", serviceList);
       }
}
 
Example #30
Source File: Routes.java    From dubbox with Apache License 2.0 5 votes vote down vote up
/**
 * 载入新增路由页面
 * @param context
 */
public void add(Map<String, Object> context) {
    String service = (String)context.get("service");
    if (service != null && service.length() > 0 && !service.contains("*")) {
        context.put("service", service);
        context.put("methods", CollectionUtils.sort(new ArrayList<String>(providerService.findMethodsByService(service))));
    } else {
        List<String> serviceList = Tool.sortSimpleName(new ArrayList<String>(providerService.findServices()));
        context.put("serviceList", serviceList);
    }
    
    if(context.get("input") != null) context.put("input", context.get("input"));
    
}