/** * 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); }
/** * 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); } }
/** * Get the lock and decrement the readers variable. */ protected void readerDec() { // let readers wait until no write operation is performed lock(); // readers.remove(readercnt); readercnt--; if(readercnt==0) performWrites(); // else if(readercnt>1) // System.out.println("readers: "+readercnt);//+" "+readers); unlock(); }
/** * Get the lock and increment the readers variable. */ protected void readerInc(String op) { // System.out.println("readerInc: "+lock.isLocked()+" "+readercnt); // let readers wait until no write operation is performed lock(); // lock2(); // System.out.println("reader enters: "+readercnt+" "+writeactions.size()); // readers.put(readercnt, op+": "+System.currentTimeMillis()); readercnt++; // unlock2(); unlock(); }
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));
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 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; }
/** * Called when the feature is shutdowned. */ public IFuture<Void> shutdown() { // Remove the persistent queries SynchronizedServiceRegistry.getRegistry(component).removeQueries(getId()); return IFuture.DONE; }
/** * Get a subregistry. * @param cid The platform id. * @return The registry. */ public IServiceRegistry getSubregistry(final IComponentIdentifier cid) { return (IServiceRegistry)readActionSync(new IResultCommand<Object, Void>() { public Object execute(Void args) { IServiceRegistry ret = delegate.getSubregistry(cid); return ret; } }, "getSubregistry"); }
bar.addFuture(SynchronizedServiceRegistry.getRegistry(component.getComponentIdentifier()).addService(new ClassInfo(servicetype), service));
/** * Search for services. */ public <T> T searchService(ClassInfo type, IComponentIdentifier cid, String scope) { return searchService(type, cid, scope, false); }
/** * Get the registry from a component. */ public static SynchronizedServiceRegistry getRegistry(IInternalAccess ia) { return getRegistry(ia.getComponentIdentifier()); }
PlatformConfiguration.putPlatformValue(cid, PlatformConfiguration.DATA_SERVICEREGISTRY, new SynchronizedServiceRegistry(true, new MultiServiceRegistry())); PlatformConfiguration.putPlatformValue(cid, PlatformConfiguration.DATA_SERVICEREGISTRY, new SynchronizedServiceRegistry(false, new GlobalQueryServiceRegistry(5000)));
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));
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 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; }
/** * Search for services. */ public <T> Collection<T> searchServices(final ClassInfo type, final IComponentIdentifier cid, final String scope) { return (Collection<T>)readActionSync(new IResultCommand<Object, Void>() { public Object execute(Void args) { return delegate.searchServices(type, cid, scope); } public String toString() { return "searchServicesStep: "+type+" "+readercnt; } }, "searchServices"); }
/** * 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); }