private void addDispatchFilter( DeploymentContext context, Service service, ResourceDescriptor resource, Route binding) { CustomDispatch customDispatch = binding.getDispatch(); if (customDispatch == null) { customDispatch = serviceDefinition.getDispatch(); } if (customDispatch != null) { boolean isHaEnabled = isHaEnabled(context); String haContributorName = customDispatch.getHaContributorName(); String haClassName = customDispatch.getHaClassName(); if (isHaEnabled && (haContributorName != null || haClassName != null)) { if (haContributorName != null) { addDispatchFilter(context, service, resource, DISPATCH_ROLE, haContributorName); } else { addDispatchFilterForClass(context, service, resource, haClassName); } } else { String contributorName = customDispatch.getContributorName(); if (contributorName != null) { addDispatchFilter(context, service, resource, DISPATCH_ROLE, contributorName); } else { String className = customDispatch.getClassName(); if (className != null) { addDispatchFilterForClass(context, service, resource, className); } } } } else { addDispatchFilter(context, service, resource, DISPATCH_ROLE, "http-client"); } }
private void contributeResources(DeploymentContext context, Service service) { Map<String, String> filterParams = new HashMap<String, String>(); List<Route> bindings = serviceDefinition.getRoutes(); for (Route binding : bindings) { List<Rewrite> filters = binding.getRewrites(); if (filters != null && !filters.isEmpty()) { filterParams.clear(); for (Rewrite filter : filters) { filterParams.put(filter.getTo(), filter.getApply()); } } try { contributeResource(context, service, binding, filterParams); } catch (URISyntaxException e) { e.printStackTrace(); } } }
private void contributeResource( DeploymentContext context, Service service, Route binding, Map<String, String> filterParams) throws URISyntaxException { List<FilterParamDescriptor> params = new ArrayList<FilterParamDescriptor>(); ResourceDescriptor resource = context.getGatewayDescriptor().addResource(); resource.role(service.getRole()); resource.pattern(binding.getPath()); List<Policy> policyBindings = binding.getPolicies(); if (policyBindings == null) { policyBindings = serviceDefinition.getPolicies(); } if (policyBindings == null) { // add default set addDefaultPolicies(context, service, filterParams, params, resource); } else { addPolicies(context, service, filterParams, params, resource, policyBindings); } addDispatchFilter(context, service, resource, binding); }
@Override public Version getVersion() { return new Version(serviceDefinition.getVersion()); }
@Override public String getName() { return serviceDefinition.getName(); }