本文整理汇总了Java中com.alibaba.dubbo.registry.common.route.OverrideUtils.setConsumerOverrides方法的典型用法代码示例。如果您正苦于以下问题:Java OverrideUtils.setConsumerOverrides方法的具体用法?Java OverrideUtils.setConsumerOverrides怎么用?Java OverrideUtils.setConsumerOverrides使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.alibaba.dubbo.registry.common.route.OverrideUtils
的用法示例。
在下文中一共展示了OverrideUtils.setConsumerOverrides方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: show
import com.alibaba.dubbo.registry.common.route.OverrideUtils; //导入方法依赖的package包/类
public void show(Long id, Map<String, Object> context) {
Consumer consumer = consumerService.findConsumer(id);
List<Provider> providers = providerService.findByService(consumer.getService());
List<Route> routes = routeService.findByService(consumer.getService());
List<Override> overrides = overrideService.findByService(consumer.getService());
List<Route> routed = new ArrayList<Route>();
consumer.setProviders(RouteUtils.route(consumer.getService(), consumer.getAddress(), consumer.getParameters(), providers, overrides, routes, null, routed));
consumer.setRoutes(routed);
OverrideUtils.setConsumerOverrides(consumer, overrides);
context.put("consumer", consumer);
context.put("providers", consumer.getProviders());
context.put("routes", consumer.getRoutes());
context.put("overrides", consumer.getOverrides());
}
示例2: show
import com.alibaba.dubbo.registry.common.route.OverrideUtils; //导入方法依赖的package包/类
public void show(Long id, Map<String, Object> context) {
Consumer consumer = consumerService.findConsumer(id);
List<Provider> providers = providerService.findByService(consumer.getService());
List<Route> routes = routeService.findByService(consumer.getService());
List<Override> overrides = overrideService.findByService(consumer.getService());
List<Route> routed = new ArrayList<Route>();
consumer.setProviders(RouteUtils.route(consumer.getService(), consumer.getAddress(), consumer.getParameters(), providers, overrides, routes, null, routed));
consumer.setRoutes(routed);
OverrideUtils.setConsumerOverrides(consumer, overrides);
context.put("consumer", consumer);
context.put("providers", consumer.getProviders());
context.put("routes", consumer.getRoutes());
context.put("overrides", consumer.getOverrides());
}
示例3: index
import com.alibaba.dubbo.registry.common.route.OverrideUtils; //导入方法依赖的package包/类
public void index(Map<String, Object> context) throws Exception {
String service = (String) context.get("service");
String application = (String) context.get("application");
String address = (String) context.get("address");
List<Consumer> consumers;
List<Override> overrides;
List<Provider> providers = null;
List<Route> routes = null;
// service
if (service != null && service.length() > 0) {
consumers = consumerService.findByService(service);
overrides = overrideService.findByService(service);
providers = providerService.findByService(service);
routes = routeService.findByService(service);
}
// address
else if (address != null && address.length() > 0) {
consumers = consumerService.findByAddress(address);
overrides = overrideService.findByAddress(Tool.getIP(address));
}
// application
else if (application != null && application.length() > 0) {
consumers = consumerService.findByApplication(application);
overrides = overrideService.findByApplication(application);
}
// all
else {
consumers = consumerService.findAll();
overrides = overrideService.findAll();
}
if (consumers != null && consumers.size() > 0) {
for (Consumer consumer : consumers) {
if (service == null || service.length() == 0) {
providers = providerService.findByService(consumer.getService());
routes = routeService.findByService(consumer.getService());
}
List<Route> routed = new ArrayList<Route>();
consumer.setProviders(RouteUtils.route(consumer.getService(), consumer.getAddress(), consumer.getParameters(), providers, overrides, routes, null, routed));
consumer.setRoutes(routed);
OverrideUtils.setConsumerOverrides(consumer, overrides);
}
}
context.put("consumers", consumers);
}
示例4: index
import com.alibaba.dubbo.registry.common.route.OverrideUtils; //导入方法依赖的package包/类
public void index(Map<String, Object> context) throws Exception {
String service = (String) context.get("service");
String application = (String) context.get("application");
String address = (String) context.get("address");
List<Consumer> consumers;
List<Override> overrides;
List<Provider> providers = null;
List<Route> routes = null;
// service
if (service != null && service.length() > 0) {
consumers = consumerService.findByService(service);
overrides = overrideService.findByService(service);
providers = providerService.findByService(service);
routes = routeService.findByService(service);
}
// address
else if (address != null && address.length() > 0) {
consumers = consumerService.findByAddress(address);
overrides = overrideService.findByAddress(Tool.getIP(address));
}
// application
else if (application != null && application.length() > 0) {
consumers = consumerService.findByApplication(application);
overrides = overrideService.findByApplication(application);
}
// all
else {
consumers = consumerService.findAll();
overrides = overrideService.findAll();
}
if (consumers != null && consumers.size() > 0) {
for (Consumer consumer : consumers) {
if (service == null || service.length() == 0) {
providers = providerService.findByService(consumer.getService());
routes = routeService.findByService(consumer.getService());
}
List<Route> routed = new ArrayList<Route>();
consumer.setProviders(RouteUtils.route(consumer.getService(), consumer.getAddress(), consumer.getParameters(), providers, overrides, routes, null, routed));
consumer.setRoutes(routed);
OverrideUtils.setConsumerOverrides(consumer, overrides);
}
}
context.put("consumers", consumers);
}
示例5: update
import com.alibaba.dubbo.registry.common.route.OverrideUtils; //导入方法依赖的package包/类
public boolean update(Consumer newConsumer, Map<String, Object> context) {
Long id = newConsumer.getId();
String parameters = newConsumer.getParameters();
Consumer consumer = consumerService.findConsumer(id);
if (consumer == null) {
context.put("message", getMessage("NoSuchOperationData", id));
return false;
}
String service = consumer.getService();
if (!super.currentUser.hasServicePrivilege(service)) {
context.put("message", getMessage("HaveNoServicePrivilege", service));
return false;
}
Map<String, String> oldMap = StringUtils.parseQueryString(consumer.getParameters());
Map<String, String> newMap = StringUtils.parseQueryString(parameters);
for (Map.Entry<String, String> entry : oldMap.entrySet()) {
if (entry.getValue().equals(newMap.get(entry.getKey()))) {
newMap.remove(entry.getKey());
}
}
String address = consumer.getAddress();
List<Override> overrides = overrideService.findByServiceAndAddress(consumer.getService(), consumer.getAddress());
OverrideUtils.setConsumerOverrides(consumer, overrides);
Override override = consumer.getOverride();
if (override != null) {
if (newMap.size() > 0) {
override.setParams(StringUtils.toQueryString(newMap));
override.setEnabled(true);
override.setOperator(operator);
override.setOperatorAddress(operatorAddress);
overrideService.updateOverride(override);
} else {
overrideService.deleteOverride(override.getId());
}
} else {
override = new Override();
override.setService(service);
override.setAddress(address);
override.setParams(StringUtils.toQueryString(newMap));
override.setEnabled(true);
override.setOperator(operator);
override.setOperatorAddress(operatorAddress);
overrideService.saveOverride(override);
}
return true;
}
示例6: update
import com.alibaba.dubbo.registry.common.route.OverrideUtils; //导入方法依赖的package包/类
public boolean update(Consumer newConsumer, Map<String, Object> context) {
Long id = newConsumer.getId();
String parameters = newConsumer.getParameters();
Consumer consumer = consumerService.findConsumer(id);
if (consumer == null) {
context.put("message", getMessage("NoSuchOperationData", id));
return false;
}
String service = consumer.getService();
if (!super.currentUser.hasServicePrivilege(service)) {
context.put("message", getMessage("HaveNoServicePrivilege", service));
return false;
}
Map<String, String> oldMap = StringUtils.parseQueryString(consumer.getParameters());
Map<String, String> newMap = StringUtils.parseQueryString(parameters);
for (Map.Entry<String, String> entry : oldMap.entrySet()) {
if (entry.getValue().equals(newMap.get(entry.getKey()))) {
newMap.remove(entry.getKey());
}
}
String address = consumer.getAddress();
List<Override> overrides = overrideService.findByServiceAndAddress(consumer.getService(), consumer.getAddress());
OverrideUtils.setConsumerOverrides(consumer, overrides);
Override override = consumer.getOverride();
if (override != null) {
if (newMap.size() > 0) {
override.setParams(StringUtils.toQueryString(newMap));
override.setEnabled(true);
override.setOperator(operator);
override.setOperatorAddress(operatorAddress);
overrideService.updateOverride(override);
} else {
overrideService.deleteOverride(override.getId());
}
} else {
override = new Override();
override.setService(service);
override.setAddress(address);
override.setParams(StringUtils.toQueryString(newMap));
override.setEnabled(true);
override.setOperator(operator);
override.setOperatorAddress(operatorAddress);
overrideService.saveOverride(override);
}
return true;
}