/** * Get the registry from a component. */ public static SynchronizedServiceRegistry getRegistry(IInternalAccess ia) { return getRegistry(ia.getComponentIdentifier()); }
/** * Add a service query to the registry. * @param type The service type. * @param scope The scope. * @param filter The filter. */ public static <T> ISubscriptionIntermediateFuture<T> addQuery(final IComponentIdentifier cid, Class<T> type, String scope, IAsyncFilter<T> filter) { ServiceQuery<T> query = new ServiceQuery<T>(type, scope, filter, cid); return SynchronizedServiceRegistry.getRegistry(cid).addQuery(query); } }
/** * Called when the feature is shutdowned. */ public IFuture<Void> shutdown() { // Remove the persistent queries SynchronizedServiceRegistry.getRegistry(component).removeQueries(getId()); return IFuture.DONE; }
/** * Get one service of a type. * (Returns required service proxy). * @param type The class. * @return The corresponding service. */ public static <T> T getLocalService(IComponentIdentifier component, final ClassInfo type, final String scope, final IFilter<T> filter) { return SynchronizedServiceRegistry.getRegistry(component.getRoot()).searchService(type, component, scope, filter); }
/** * Get one service of a type. * (Returns required service proxy). * @param type The class. * @return The corresponding service. */ public static <T> T getLocalService(IComponentIdentifier component, final Class<T> type, final String scope, final IFilter<T> filter) { return SynchronizedServiceRegistry.getRegistry(component.getRoot()).searchService(new ClassInfo(type), component, scope, filter); }
/** * Get one service of a type. * (Returns required service proxy). * @param type The class. * @return The corresponding service. */ public static <T> Collection<T> getLocalServices(final IInternalAccess component, final ClassInfo type, final String scope, final IFilter<T> filter, boolean proxy) { checkThreadAccess(component, proxy); Collection<T> ret = SynchronizedServiceRegistry.getRegistry(component).searchServices(type, component.getComponentIdentifier(), scope, filter); // Fixing the bug by changing createRequiredProxy -> createRequiredProxies leads to not compiling the main class return proxy? createRequiredProxies(component, ret, type): ret; }
/** * Get one service of a type. * (Returns required service proxy). * @param component The internal access. * @param type The class. * @return The corresponding service. */ public static <T> T getLocalService0(final IInternalAccess component, final ClassInfo type, final String scope, final IFilter<T> filter, boolean proxy) { checkThreadAccess(component, proxy); T ret = SynchronizedServiceRegistry.getRegistry(component).searchService(type, component.getComponentIdentifier(), scope, filter); return proxy && ret!=null? createRequiredProxy(component, ret, type): ret; }
/** * Add a service query to the registry. * @param type The service type. * @param scope The scope. * @param filter The filter. */ public <T> ISubscriptionIntermediateFuture<T> addQuery(Class<T> type, String scope, IAsyncFilter<T> filter) { ServiceQuery<T> query = new ServiceQuery<T>(type, scope, filter, getComponent().getComponentIdentifier()); return SynchronizedServiceRegistry.getRegistry(getComponent()).addQuery(query); } }
/** * Get one service of a type. * (Returns required service proxy). * @param component The internal access. * @param type The class. * @return The corresponding service. */ public static <T> T getLocalService0(final IInternalAccess component, final Class<T> type, final String scope, final IFilter<T> filter, boolean proxy) { checkThreadAccess(component, proxy); T ret = SynchronizedServiceRegistry.getRegistry(component).searchService(new ClassInfo(type), component.getComponentIdentifier(), scope, filter); return proxy && ret!=null? createRequiredProxy(component, ret, type): ret; }
bar.addFuture(SynchronizedServiceRegistry.getRegistry(component.getComponentIdentifier()).addService(new ClassInfo(servicetype), service));
/** * Get one service of a type. * (Returns required service proxy). * @param component The internal access. * @param type The class. * @return The corresponding service. */ public static <T> T getLocalService(final IInternalAccess component, final Class<T> type, final String scope, final IFilter<T> filter, boolean proxy) { checkThreadAccess(component, proxy); T ret = SynchronizedServiceRegistry.getRegistry(component).searchService(new ClassInfo(type), component.getComponentIdentifier(), scope, filter); if(ret==null) throw new ServiceNotFoundException(type.getName()); return proxy? createRequiredProxy(component, ret, type): ret; }
@Override public IFuture<Void> execute(IInternalAccess ia) { IAwarenessManagementService awa = SynchronizedServiceRegistry.getRegistry(ia) .searchService(new ClassInfo(IAwarenessManagementService.class), ia.getComponentIdentifier(), Binding.SCOPE_PLATFORM, true); if(awa!=null) { try { AwarenessInfo info = (AwarenessInfo)MapSendTask.decodeMessage(data, codecs, getClass().getClassLoader(), IErrorReporter.IGNORE); // System.out.println("Received awareness info: "+info); awa.addAwarenessInfo(info); } catch(Exception e) { ia.getLogger().info("Error receiving awareness info: "+SUtil.getExceptionStacktrace(e)); } } else { // No awa service -> ignore awa infos. } return IFuture.DONE; } });
/** * Get one service of a type. * (Returns required service proxy). * @param type The class. * @return The corresponding service. */ public static <T> Collection<T> getLocalServices(final IInternalAccess component, final Class<T> type, final String scope, final IFilter<T> filter, boolean proxy) { checkThreadAccess(component, proxy); Collection<T> ret = SynchronizedServiceRegistry.getRegistry(component).searchServices(new ClassInfo(type), component.getComponentIdentifier(), scope, filter); // Fixing the bug by changing createRequiredProxy -> createRequiredProxies leads to not compiling the main class return proxy? createRequiredProxies(component, ret, type): ret; }
/** * Get one service of a type. * (Returns required service proxy). * @param component The internal access. * @param type The class. * @return The corresponding service. */ public static <T> T getLocalService(final IInternalAccess component, final Class<T> type, final IComponentIdentifier target, boolean proxy) { checkThreadAccess(component, proxy); T ret = SynchronizedServiceRegistry.getRegistry(component).searchService(new ClassInfo(type), component.getComponentIdentifier(), RequiredServiceInfo.SCOPE_PLATFORM, new IFilter<T>() { public boolean filter(T obj) { return ((IService)obj).getServiceIdentifier().getProviderId().equals(target); } }); if(ret==null) throw new ServiceNotFoundException(type.getName()); return proxy? createRequiredProxy(component, ret, type): ret; }
public void customResultAvailable(Void result) { if(!RequiredServiceInfo.SCOPE_GLOBAL.equals(scope)) { if(filter==null) { Collection<T> sers = SynchronizedServiceRegistry.getRegistry(component).searchServices(new ClassInfo(type), cid, scope); if(proxy) sers = createRequiredProxies(component, sers, type); ret.setResult(sers==null? Collections.EMPTY_SET: sers); } else { IIntermediateResultListener<T> lis = proxy? new IntermediateProxyResultListener<T>(ret, component, type): new IntermediateDelegationResultListener<T>(ret); SynchronizedServiceRegistry.getRegistry(component).searchServices(new ClassInfo(type), cid, scope, filter) .addResultListener(new IntermediateComponentResultListener<T>(lis, component)); } } else { IIntermediateResultListener<T> lis = proxy? new IntermediateProxyResultListener<T>(ret, component, type): new IntermediateDelegationResultListener<T>(ret); ISubscriptionIntermediateFuture<T> fut = SynchronizedServiceRegistry.getRegistry(component).searchGlobalServices(new ClassInfo(type), cid, filter); fut.addResultListener(new IntermediateComponentResultListener<T>(lis, component)); } } });
/** * Get one service of a type. * (Returns required service proxy). * @param component The internal access. * @param type The class. * @return The corresponding service. */ public static <T> T getLocalService(final IInternalAccess component, final ClassInfo type, final String scope, final IFilter<T> filter, boolean proxy) { checkThreadAccess(component, proxy); T ret = SynchronizedServiceRegistry.getRegistry(component).searchService(type, component.getComponentIdentifier(), scope, filter); if(ret==null) throw new ServiceNotFoundException(type.getTypeName()); return proxy? createRequiredProxy(component, ret, type): ret; }
public void customResultAvailable(Void result) { if(!RequiredServiceInfo.SCOPE_GLOBAL.equals(scope)) { if(filter==null) { Collection<T> sers = SynchronizedServiceRegistry.getRegistry(component).searchServices(type, component.getComponentIdentifier(), scope); if(proxy) sers = createRequiredProxies(component, sers, type); ret.setResult(sers==null? Collections.EMPTY_SET: sers); } else { IIntermediateResultListener<T> lis = proxy? new IntermediateProxyResultListener<T>(ret, component, type.getType(component.getClassLoader())): new IntermediateDelegationResultListener<T>(ret); SynchronizedServiceRegistry.getRegistry(component).searchServices(type, component.getComponentIdentifier(), scope, filter) .addResultListener(new IntermediateComponentResultListener<T>(lis, component)); } } else { IIntermediateResultListener<T> lis = proxy? new IntermediateProxyResultListener<T>(ret, component, type.getType(component.getClassLoader())): new IntermediateDelegationResultListener<T>(ret); ISubscriptionIntermediateFuture<T> fut = SynchronizedServiceRegistry.getRegistry(component).searchGlobalServices(type, component.getComponentIdentifier(), filter); fut.addResultListener(new IntermediateComponentResultListener<T>(lis, component)); } } });
/** * Get one service of a type. * (Returns required service proxy). * @param component The internal access. * @param type The class. * @return The corresponding service. */ public static <T> T getLocalService(final IInternalAccess component, final ClassInfo type, final IComponentIdentifier target, boolean proxy) { checkThreadAccess(component, proxy); T ret = SynchronizedServiceRegistry.getRegistry(component).searchService(type, component.getComponentIdentifier(), RequiredServiceInfo.SCOPE_PLATFORM, new IFilter<T>() { public boolean filter(T obj) { return ((IService)obj).getServiceIdentifier().getProviderId().equals(target); } }); if(ret==null) throw new ServiceNotFoundException(type.getTypeName()); return proxy? createRequiredProxy(component, ret, type): ret; }
SynchronizedServiceRegistry.getRegistry(component).searchService(new ClassInfo(type), component.getComponentIdentifier(), scope, filter) .addResultListener(new ComponentResultListener<T>(lis, component)); SynchronizedServiceRegistry.getRegistry(component).searchGlobalService(new ClassInfo(type), component.getComponentIdentifier(), filter) .addResultListener(new ComponentResultListener<T>(lis, component));
SynchronizedServiceRegistry.getRegistry(component).searchService(type, component.getComponentIdentifier(), scope, filter) .addResultListener(new ComponentResultListener<T>(lis, component)); SynchronizedServiceRegistry.getRegistry(component).searchGlobalService(type, component.getComponentIdentifier(), filter) .addResultListener(new ComponentResultListener<T>(lis, component));