/** * Get the fitting search manager. * @param multiple The multiple flag (i.e. one vs. multiple services required) */ public static ISearchManager getSearchManager(boolean multiple) { return getSearchManager(multiple, null); }
/** * Get all declared services of the given provider. * @return The corresponding services. */ public static IIntermediateFuture<IService> getDeclaredServices(IServiceProvider provider) { // synchronized(profiling) // { // Integer cnt = (Integer)profiling.get(type); // profiling.put(type, Integer.valueOf(cnt!=null ? cnt.intValue()+1 : 1)); // } final IntermediateFuture<IService> ret = new IntermediateFuture<IService>(); // Hack->remove // IVisitDecider contdecider = new DefaultVisitDecider(false); // if(Proxy.isProxyClass(provider.getClass())) // System.out.println("herere"); provider.getServices(getSearchManager(false, RequiredServiceInfo.SCOPE_LOCAL), contdecider, contanyselector) .addResultListener(new IntermediateDelegationResultListener<IService>(ret)); return ret; }
/** * Get all service proxies from a remote component. * (called from arbitrary components) * @param cid The remote provider id. * @param service The service type. * @param scope The search scope. * @return The service proxy. */ public <T> IFuture<T> getServiceProxies(IComponentIdentifier cid, Class<T> service, String scope) { final Future<T> ret = new Future<T>(); getServiceProxies(cid, SServiceProvider.getSearchManager(true, scope), SServiceProvider.getVisitDecider(false, scope), new TypeResultSelector(service, true)) .addResultListener(new ExceptionDelegationResultListener<Object, T>(ret) { public void customResultAvailable(Object result) { ret.setResult((T)result); } }); return ret; }
/** * Get all service proxies from a remote component. * (called from arbitrary components) * @param cid The remote provider id. * @param service The service type. * @param scope The search scope. * @return The service proxy. */ public <T> IFuture<T> getServiceProxies(IComponentIdentifier cid, Class<T> service, String scope) { final Future<T> ret = new Future<T>(); getServiceProxies(cid, SServiceProvider.getSearchManager(true, scope), SServiceProvider.getVisitDecider(false, scope), new TypeResultSelector(service, true)) .addResultListener(new ExceptionDelegationResultListener<Collection<IService>, T>(ret) { public void customResultAvailable(Collection<IService> result) { ret.setResult((T)result); } }); return ret; }
ITerminableIntermediateFuture fut = provider.getServices(getSearchManager(true, scope), getVisitDecider(false, scope), new TypeResultSelector(type, false, RequiredServiceInfo.SCOPE_GLOBAL.equals(scope), filter));
/** * Get a service proxy from a remote component. * (called from arbitrary components) * @param cid The remote provider id. * @param service The service type. * @param scope The search scope. * @return The service proxy. */ public <T> IFuture<T> getServiceProxy(final IComponentIdentifier cid, final Class<T> service, String scope) { final Future<T> ret = new Future<T>(); getServiceProxies(cid, SServiceProvider.getSearchManager(false, scope), SServiceProvider.getVisitDecider(true, scope), new TypeResultSelector(service, true)).addResultListener(new ExceptionDelegationResultListener<Object, T>(ret) { public void customResultAvailable(Object result) { if(result!=null && !((Collection<?>)result).isEmpty()) { Object o = ((Collection<?>)result).iterator().next(); ret.setResult((T)o); } else { super.exceptionOccurred(new ServiceNotFoundException("No proxy for service found: "+cid+", "+service.getName())); } } }); return ret; }
getServiceProxies(cid, SServiceProvider.getSearchManager(false, scope), SServiceProvider.getVisitDecider(true, scope), new TypeResultSelector(service, true)).addResultListener(new ExceptionDelegationResultListener<Collection<IService>, T>(ret)
provider.getServices(getSearchManager(false, RequiredServiceInfo.SCOPE_PLATFORM), getVisitDecider(true, RequiredServiceInfo.SCOPE_PLATFORM), selector) .addResultListener(new DelegationResultListener(ret)
provider.getServices(getSearchManager(false, scope), getVisitDecider(true, scope), new TypeResultSelector(type, true, RequiredServiceInfo.SCOPE_GLOBAL.equals(scope), filter)) .addResultListener(new IIntermediateResultListener<IService>()