/** * Create a new registry. */ public MultiServiceRegistry()//RegistrySearchFunctionality searchfunc) { this.searchfunc = new RegistrySearchFunctionality(this); }
/** * Search for services. */ // read public <T> ISubscriptionIntermediateFuture<T> searchServices(ClassInfo type, IComponentIdentifier cid, String scope, IAsyncFilter<T> filter) { final SubscriptionIntermediateFuture<T> ret = new SubscriptionIntermediateFuture<T>(); Iterator<T> sers = (Iterator<T>)getServices(type); if(sers!=null && sers.hasNext() && !RequiredServiceInfo.SCOPE_NONE.equals(scope)) { Collection<T> ssers = checkScope(sers, cid, scope, false); checkAsyncFilters(filter, ssers.iterator()).addResultListener(new IntermediateDelegationResultListener<T>(ret)); // filter checks in loop are possibly performed outside of synchornized block // searchLoopServices(filter, sers, cid, scope).addResultListener(new IntermediateDelegationResultListener<T>(ret)); } else { ret.setFinished(); } return ret; }
/** * Search for services. */ // read public <T> T searchService(ClassInfo type, IComponentIdentifier cid, String scope, boolean excluded) { // if(type!=null && type.getName().indexOf("IRegistrySer")!=-1) // System.out.println("search: "+type+" - "+cid); T ret = null; Iterator<IService> sers = getServices(type); if(sers!=null && sers.hasNext() && !RequiredServiceInfo.SCOPE_NONE.equals(scope)) { while(sers.hasNext()) { IService ser = sers.next(); if(checkSearchScope(cid, ser, scope, excluded) && checkPublicationScope(cid, ser)) { // if(ret!=null) // System.out.println("found another: "+ser.getServiceIdentifier()); ret = (T)ser; break; } } } return ret; }
/** * Check the services according the the scope. * @param it The services. * @param cid The component id. * @param scope The scope. * @return The services that fit to the scope. */ // read protected <T> Collection<T> checkScope(final Iterator<T> it, final IComponentIdentifier cid, final String scope, boolean oneresult) { Collection<T> ret = new LinkedHashSet<T>(); while(it.hasNext()) { final T ser = it.next(); if(checkSearchScope(cid, (IService)ser, scope, false) && checkPublicationScope(cid, (IService)ser)) { ret.add(ser); if(oneresult) break; } } return ret; }
&& getApplicationName(sercid).equals(getApplicationName(cid)); ret = getDotName(cid).endsWith(getDotName(sercid)); String subname = getSubcomponentName(sercid); ret = getDotName(cid).endsWith(subname);
Set<ServiceQueryInfo<?>> sqis = (Set)getQueries(ser.getServiceIdentifier().getServiceType()); checkQueriesLoop(clone.iterator(), ser).addResultListener(new DelegationResultListener<Void>(ret));
Collection<T> ssers = searchfunc.checkScope(sers, query.getOwner(), query.getScope(), false); searchfunc.checkAsyncFilters(query.getFilter(), ssers.iterator()) .addIntermediateResultListener(new UnlimitedIntermediateDelegationResultListener<T>(ret));
public void exceptionOccurred(Exception exception) { checkAsyncFilters(filter, it).addResultListener(new IntermediateDelegationResultListener<T>(ret)); } });
return searchfunc.checkQueries(service);
/** * Test if a service is included. * @param ser The service. * @return True if is included. */ public boolean isIncluded(IComponentIdentifier cid, IService ser) { boolean ret = true; if(excluded!=null && excluded.contains(ser.getServiceIdentifier().getProviderId()) && cid!=null) { IComponentIdentifier target = ser.getServiceIdentifier().getProviderId(); if(target!=null) ret = RegistrySearchFunctionality.getDotName(cid).endsWith(RegistrySearchFunctionality.getDotName(target)); } return ret; }
checkQuery(sqi, service).addResultListener(new ExceptionDelegationResultListener<Boolean, Void>(ret)
checkQueriesLoop(it, service).addResultListener(new DelegationResultListener<Void>(ret));
&& getApplicationName(sercid).equals(getApplicationName(cid)); ret = getDotName(sercid).endsWith(getDotName(cid)); String subname = getSubcomponentName(cid); ret = sercid.getName().endsWith(subname);
String scope = queryinfo.getQuery().getScope(); IAsyncFilter<IService> filter = (IAsyncFilter)queryinfo.getQuery().getFilter(); if(!checkSearchScope(cid, service, scope, false) || !checkPublicationScope(cid, service))
public void resultAvailable(Boolean result) { if(result!=null && result.booleanValue()) { ret.addIntermediateResult(ser); } checkAsyncFilters(filter, it).addResultListener(new IntermediateDelegationResultListener<T>(ret)); }
for(IService ser: exs) searchfunc.checkQueries(ser).addResultListener(lis);
/** * Search for services. */ // read public <T> Collection<T> searchServices(ClassInfo type, IComponentIdentifier cid, String scope) { Set<T> ret = null; Iterator<IService> sers = getServices(type); if(sers!=null && sers.hasNext() && !RequiredServiceInfo.SCOPE_NONE.equals(scope)) { ret = new HashSet<T>(); while(sers.hasNext()) { IService ser = sers.next(); if(checkSearchScope(cid, ser, scope, false) && checkPublicationScope(cid, ser)) { ret.add((T)ser); } } } return ret; }
Iterator<T> sers = (Iterator<T>)getServices(type); if(sers!=null && sers.hasNext() && !RequiredServiceInfo.SCOPE_NONE.equals(scope)) Collection<T> ssers = checkScope(sers, cid, scope, false); checkAsyncFilters(filter, ssers.iterator()).addResultListener(new IIntermediateResultListener<T>()
checkAsyncFilters(filter, it).addResultListener(new IntermediateDelegationResultListener<T>(ret));
/** * Create a new registry. */ public ServiceRegistry()//RegistrySearchFunctionality searchfunc) { this.searchfunc = new RegistrySearchFunctionality(this); this.excluded = new HashSet<IComponentIdentifier>(); }