/** * Removes all service providers from the domain with the specified name. * @param serviceName qualified name of the service */ public void removeService(QName serviceName) { for (Service service : getServiceDomain().getServices(serviceName)) { service.unregister(); } }
/** * Removes all service providers from the domain with the specified name. * @param serviceName qualified name of the service */ public void removeService(QName serviceName) { for (Service service : getServiceDomain().getServices(serviceName)) { service.unregister(); } }
/** * 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()); }
@Test public void testUnregister() { Service service = _domain.registerService(new QName("TestService"), new InOnlyService(), new MockHandler()); // test that it was added to the registry Assert.assertEquals(1, _domain.getServiceRegistry().getServices().size()); service.unregister(); // confirm that it was removed Assert.assertEquals(0, _domain.getServiceRegistry().getServices().size()); }
@Test public void testServiceEvents() { _domain.addEventObserver(_observer, ServiceRegistrationEvent.class) .addEventObserver(_observer, ServiceUnregistrationEvent.class); Service service = _domain.registerService(new QName("test"), new InOutService(), new BaseHandler()); Assert.assertTrue(_observer.serviceRegistrationCalled); service.unregister(); Assert.assertTrue(_observer.serviceUnregistrationCalled); } }
BaseDeployLogger.ROOT_LOGGER.errorDeactivatingService(e); service.unregister(); service.unregister();
private void undeployReferenceBindings() { _log.debug("Undeploying reference bindings for deployment " + getName()); try { for (Activation activation : _referenceBindings) { try { activation.getHandler().stop(); } catch (Throwable e) { BaseDeployLogger.ROOT_LOGGER.errorStoppingReferenceBinding(e); } try { activation.getActivator().deactivateBinding(activation.getName(), activation.getHandler()); } catch (Throwable e) { BaseDeployLogger.ROOT_LOGGER.errorDeactivatingReferenceBinding(e); } for (Service service : activation.getServices()) { service.unregister(); } } } finally { _referenceBindings.clear(); } }