Java Code Examples for com.alibaba.dubbo.registry.common.route.RouteRule#join()

The following examples show how to use com.alibaba.dubbo.registry.common.route.RouteRule#join() . 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 4 votes vote down vote up
/**
   * 显示路由详细信息
   * @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();
}
  }
 
Example 2
Source File: Routes.java    From dubbox-hystrix with Apache License 2.0 4 votes vote down vote up
/**
   * 显示路由详细信息
   * @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();
}
  }
 
Example 3
Source File: Routes.java    From dubbo3 with Apache License 2.0 4 votes vote down vote up
/**
   * 显示路由详细信息
   * @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();
}
  }
 
Example 4
Source File: Routes.java    From dubbox with Apache License 2.0 4 votes vote down vote up
/**
   * 显示路由详细信息
   * @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();
}
  }
 
Example 5
Source File: Routes.java    From dubbox with Apache License 2.0 4 votes vote down vote up
/**
   * 显示路由详细信息
   * @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();
}
  }