public IFuture<Void> execute(Void args) { delegate.removeService(key, service); return IFuture.DONE; }
/** * Remove an existing registry. * @param cid The component id to remove. */ public void removeSubregistry(IComponentIdentifier cid) { if(registries==null || !registries.containsKey(cid)) throw new RuntimeException("Registry not contained: "+cid); // Remove all services to trigger removed events IServiceRegistry reg = registries.get(cid); Map<ClassInfo, Set<IService>> sers = reg.getServiceMap(); if(sers!=null) { for(Map.Entry<ClassInfo, Set<IService>> entry: sers.entrySet()) { for(IService ser: entry.getValue()) { reg.removeService(entry.getKey(), ser); } } } registries.remove(cid); }
/** * Remove a service from the registry. * @param sid The service id. */ public void removeService(ClassInfo key, IService service) { IServiceRegistry reg = getSubregistry(service.getServiceIdentifier().getProviderId()); reg.removeService(key, service); }
/** * Remove a service. * @param service The service object. * @param info The service info. */ protected void removeService(IInternalService service) { // Find service types Class<?> type = service.getServiceIdentifier().getServiceType().getType(component.getClassLoader(), component.getModel().getAllImports()); Set<Class<?>> types = new LinkedHashSet<Class<?>>(); types.add(type); for(Class<?> sin: SReflect.getSuperInterfaces(new Class[]{type})) { if(sin.isAnnotationPresent(Service.class)) { types.add(sin); } } IServiceRegistry registry = ServiceRegistry.getRegistry(component.getComponentIdentifier()); if(registry!=null) // Maybe null on rescue thread (todo: why remove() on rescue thread?) { for(Class<?> servicetype: types) { registry.removeService(new ClassInfo(servicetype), service); } } }