本文整理汇总了Java中com.alibaba.dubbo.registry.common.domain.Route.getService方法的典型用法代码示例。如果您正苦于以下问题:Java Route.getService方法的具体用法?Java Route.getService怎么用?Java Route.getService使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.alibaba.dubbo.registry.common.domain.Route
的用法示例。
在下文中一共展示了Route.getService方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: show
import com.alibaba.dubbo.registry.common.domain.Route; //导入方法依赖的package包/类
/**
* 显示路由详细信息
* @param context
*/
public void show(Map<String, Object> context) {
try {
Route route = routeService.findRoute(Long.parseLong((String)context.get("id")));
if (route == null) {
throw new IllegalArgumentException("The route is not existed.");
}
if(route.getService()!=null && !route.getService().isEmpty()){
context.put("service", route.getService());
}
RouteRule routeRule= RouteRule.parse(route);
@SuppressWarnings("unchecked")
Map<String, RouteRule.MatchPair>[] paramArray = new Map[] {
routeRule.getWhenCondition(), routeRule.getThenCondition()};
String[][][] namesArray = new String[][][] {when_names, then_names };
for(int i=0; i<paramArray.length; ++i) {
Map<String, RouteRule.MatchPair> param = paramArray[i];
String[][] names = namesArray[i];
for(String[] name : names) {
RouteRule.MatchPair matchPair = param.get(name[0]);
if(matchPair == null) {
continue;
}
if(!matchPair.getMatches().isEmpty()) {
String m = RouteRule.join(matchPair.getMatches());
context.put(name[1], m);
}
if(!matchPair.getUnmatches().isEmpty()) {
String u = RouteRule.join(matchPair.getUnmatches());
context.put(name[2], u);
}
}
}
context.put("route", route);
context.put("methods", CollectionUtils.sort(new ArrayList<String>(providerService.findMethodsByService(route.getService()))));
} catch (ParseException e) {
e.printStackTrace();
}
}
示例2: show
import com.alibaba.dubbo.registry.common.domain.Route; //导入方法依赖的package包/类
/**
* 显示路由详细信息
*
* @param context
*/
public void show(Map<String, Object> context) {
try {
Route route = routeService.findRoute(Long.parseLong((String) context.get("id")));
if (route == null) {
throw new IllegalArgumentException("The route is not existed.");
}
if (route.getService() != null && !route.getService().isEmpty()) {
context.put("service", route.getService());
}
RouteRule routeRule = RouteRule.parse(route);
@SuppressWarnings("unchecked")
Map<String, RouteRule.MatchPair>[] paramArray = new Map[]{
routeRule.getWhenCondition(), routeRule.getThenCondition()};
String[][][] namesArray = new String[][][]{when_names, then_names};
for (int i = 0; i < paramArray.length; ++i) {
Map<String, RouteRule.MatchPair> param = paramArray[i];
String[][] names = namesArray[i];
for (String[] name : names) {
RouteRule.MatchPair matchPair = param.get(name[0]);
if (matchPair == null) {
continue;
}
if (!matchPair.getMatches().isEmpty()) {
String m = RouteRule.join(matchPair.getMatches());
context.put(name[1], m);
}
if (!matchPair.getUnmatches().isEmpty()) {
String u = RouteRule.join(matchPair.getUnmatches());
context.put(name[2], u);
}
}
}
context.put("route", route);
context.put("methods", CollectionUtils.sort(new ArrayList<String>(providerService.findMethodsByService(route.getService()))));
} catch (ParseException e) {
e.printStackTrace();
}
}