@Override public void unregisterService(ServiceState serviceState) { List<ServiceName> serviceNames = serviceState.getServiceNames(); log.debug("Unregister service: " + serviceNames); AbstractBundle serviceOwner = serviceState.getServiceOwner(); // This event is synchronously delivered before the service has completed unregistering. eventsPlugin.fireServiceEvent(serviceOwner, ServiceEvent.UNREGISTERING, serviceState); // Remove from using bundles for (AbstractBundle bundleState : serviceState.getUsingBundlesInternal()) { while (ungetService(bundleState, serviceState)) ; } // Remove from owner bundle serviceOwner.removeRegisteredService(serviceState); // Unregister name associations for (ServiceName serviceName : serviceNames) { String[] clazzes = (String[]) serviceState.getProperty(Constants.OBJECTCLASS); for (String clazz : clazzes) unregisterNameAssociation(clazz, serviceName); } // Remove from controller ServiceName rootServiceName = serviceNames.get(0); try { ServiceController<?> controller = serviceContainer.getService(rootServiceName); controller.setMode(Mode.REMOVE); } catch (RuntimeException ex) { log.error("Cannot remove service: " + rootServiceName, ex); } }
@Override public Set<AbstractBundle> getUsingBundles(ServiceState serviceState) { return serviceState.getUsingBundlesInternal(); }