/** * Replaces an existing service registration (e.g. reference binding) with a test handler using * the same contract as the existing service provider. If multiple services are registered with * the specified name, the first one found is used. Generally speaking, it's not a good idea * to use this method if you have multiple services registered with the same name. In that * situation, use the removeService() and registerService() methods instead. * @param name name of the service to replace * @param handler implementation to use as the service provider * @throws SwitchYardException if a service with the specified name does not exist */ public void replaceService(QName name, ExchangeHandler handler) throws SwitchYardException { List<Service> services = getServiceDomain().getServices(name); if (services.isEmpty()) { throw new SwitchYardException("Failed to replace service: " + name + ". No service is registered with that name."); } // select the service to replace Service replacedService = services.get(0); replacedService.unregister(); // add the replacement service getServiceDomain().registerService(name, replacedService.getInterface(), handler, replacedService.getServiceMetadata()); }
/** * Replaces an existing service registration (e.g. reference binding) with a test handler using * the same contract as the existing service provider. If multiple services are registered with * the specified name, the first one found is used. Generally speaking, it's not a good idea * to use this method if you have multiple services registered with the same name. In that * situation, use the removeService() and registerService() methods instead. * @param name name of the service to replace * @param handler implementation to use as the service provider * @throws SwitchYardException if a service with the specified name does not exist */ public void replaceService(QName name, ExchangeHandler handler) throws SwitchYardException { List<Service> services = getServiceDomain().getServices(name); if (services.isEmpty()) { throw new SwitchYardException("Failed to replace service: " + name + ". No service is registered with that name."); } // select the service to replace Service replacedService = services.get(0); replacedService.unregister(); // add the replacement service getServiceDomain().registerService(name, replacedService.getInterface(), handler, replacedService.getServiceMetadata()); }
public void handleMessage(final Exchange exchange) throws HandlerException { final Service service = exchange.getProvider(); ServiceSecurity serviceSecurity = service.getServiceMetadata().getSecurity(); if (serviceSecurity != null) { SecurityContext securityContext = _securityContextManager.getContext(exchange);
public void handleMessage(final Exchange exchange) throws HandlerException { final Service service = exchange.getProvider(); ServiceSecurity serviceSecurity = service.getServiceMetadata().getSecurity(); if (serviceSecurity != null) { SecurityContext securityContext = _securityContextManager.getContext(exchange);
for (Policy policy : service.getServiceMetadata().getRequiredPolicies()) { PolicyUtil.require(exchange, policy);
for (Policy policy : service.getServiceMetadata().getRequiredPolicies()) { PolicyUtil.require(exchange, policy);
/** * Gets the SecurityMetadata from the Exchange. * @param exchange the Exchange * @return the SecurityMetadata */ public static final SecurityMetadata getSecurityMetadata(Exchange exchange) { Source source = null; ServiceDomain serviceDomain = null; ServiceSecurity serviceSecurity = null; Service service = exchange.getProvider(); if (service != null) { source = Source.PROVIDER; serviceDomain = service.getDomain(); serviceSecurity = service.getServiceMetadata().getSecurity(); } if (serviceSecurity == null) { ServiceReference serviceReference = exchange.getConsumer(); if (serviceReference != null) { source = Source.CONSUMER; serviceDomain = serviceReference.getDomain(); serviceSecurity = serviceReference.getServiceMetadata().getSecurity(); } } return new SecurityMetadata(source, serviceDomain, serviceSecurity); }
/** * Gets the SecurityMetadata from the Exchange. * @param exchange the Exchange * @return the SecurityMetadata */ public static final SecurityMetadata getSecurityMetadata(Exchange exchange) { Source source = null; ServiceDomain serviceDomain = null; ServiceSecurity serviceSecurity = null; Service service = exchange.getProvider(); if (service != null) { source = Source.PROVIDER; serviceDomain = service.getDomain(); serviceSecurity = service.getServiceMetadata().getSecurity(); } if (serviceSecurity == null) { ServiceReference serviceReference = exchange.getConsumer(); if (serviceReference != null) { source = Source.CONSUMER; serviceDomain = serviceReference.getDomain(); serviceSecurity = serviceReference.getServiceMetadata().getSecurity(); } } return new SecurityMetadata(source, serviceDomain, serviceSecurity); }