use of com.alibaba.dubbo.registry.common.domain.Access in project dubbo by alibaba.
the class Accesses method index.
public void index(Map<String, Object> context) throws Exception {
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) {
routes = routeService.findForceRouteByService(service);
} else if (address != null && address.length() > 0) {
routes = routeService.findForceRouteByAddress(address);
} else {
routes = routeService.findAllForceRoute();
}
List<Access> accesses = new ArrayList<Access>();
if (routes == null) {
context.put("accesses", accesses);
return;
}
for (Route route : routes) {
Map<String, MatchPair> rule = RouteRule.parseRule(route.getMatchRule());
MatchPair pair = rule.get("consumer.host");
if (pair != null) {
for (String host : pair.getMatches()) {
Access access = new Access();
access.setAddress(host);
access.setService(route.getService());
access.setAllow(false);
accesses.add(access);
}
for (String host : pair.getUnmatches()) {
Access access = new Access();
access.setAddress(host);
access.setService(route.getService());
access.setAllow(true);
accesses.add(access);
}
}
}
context.put("accesses", accesses);
}