jadex.bridge.service.search.SServiceProvider Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jadex-platform-bridge Show documentation
Show all versions of jadex-platform-bridge Show documentation
Jadex bridge is a base package for kernels and platforms, i.e., it is used by both and provides commonly used interfaces and classes for active components and their management.
package jadex.bridge.service.search;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import jadex.bridge.IComponentIdentifier;
import jadex.bridge.IExternalAccess;
import jadex.bridge.IInternalAccess;
import jadex.bridge.ProxyFactory;
import jadex.bridge.SFuture;
import jadex.bridge.nonfunctional.search.IRankingSearchTerminationDecider;
import jadex.bridge.nonfunctional.search.IServiceRanker;
import jadex.bridge.nonfunctional.search.ServiceRankingDelegationResultListener;
import jadex.bridge.nonfunctional.search.ServiceRankingDelegationResultListener2;
import jadex.bridge.service.types.cms.SComponentManagementService;
import jadex.commons.SReflect;
import jadex.commons.Tuple2;
import jadex.commons.future.DelegationResultListener;
import jadex.commons.future.Future;
import jadex.commons.future.IFuture;
import jadex.commons.future.IResultListener;
import jadex.commons.future.ITerminableIntermediateFuture;
import jadex.commons.future.TerminableIntermediateDelegationFuture;
/**
* Static helper class for searching services.
* Has the same search and query methods like IRequiredServicesFeature,
* but requires an external access.
*/
public class SServiceProvider
{
//-------- old --------
// /** The reference method cache (method -> boolean[] (is reference)). */
// public static final Map methodreferences = Collections.synchronizedMap(new LRU(500));
//
// //-------- sync method (only local search) --------
//
// /**
// * Get one service of a type.
// * (Returns required service proxy).
// * @param type The class.
// * @return The corresponding service.
// */
// public static T getLocalService(IComponentIdentifier component, Class type)
// {
// return getLocalService(component, type, null);
// }
//
// /**
// * Get one service of a type.
// * (Returns required service proxy).
// * @param type The class.
// * @return The corresponding service.
// */
// public static T getLocalService(IComponentIdentifier component, Class type, final String scope)
// {
// return getLocalService(component, type, scope, null);
// }
//
// /**
// * Get one service of a type.
// * (Returns required service proxy).
// * @param type The class.
// * @return The corresponding service.
// */
// public static T getLocalService(IComponentIdentifier component, final Class type, final String scope, final IFilter filter)
// {
//// return ServiceRegistry.getRegistry(component.getRoot()).searchService(new ClassInfo(type), component, scope, filter);
// ServiceQuery query = new ServiceQuery(type, scope, null, component, filter);
// return ServiceRegistry.getRegistry(component.getRoot()).searchService(query);
// }
//
// /**
// * Get all declared services of the given provider.
//// * (Returns required service proxy).
// * @return The corresponding services.
// */
// public static IFuture getDeclaredService(IInternalAccess component, Class type)
// {
// return getService(component, type, ServiceScope.LOCAL, true);
// }
//
// /**
// * Get all declared services of the given provider.
//// * (Returns required service proxy).
// * @return The corresponding services.
// */
// public static IIntermediateFuture getDeclaredServices(IInternalAccess component)
// {
// return getDeclaredServices(component, true);
// }
//
// /**
// * Get all declared services of the given provider.
//// * (Returns required service proxy).
// * @return The corresponding services.
// */
// public static IFuture getDeclaredService(IInternalAccess component, Class type, boolean proxy)
// {
// return getService(component, type, ServiceScope.LOCAL, proxy);
// }
//
// /**
// * Get all declared services of the given provider.
//// * (Returns required service proxy).
// * @return The corresponding services.
// */
// public static IIntermediateFuture getDeclaredServices(final IInternalAccess component, final boolean proxy)
// {
// final IntermediateFuture ret = new IntermediateFuture();
//
// ensureThreadAccess(component, proxy).addResultListener(new ExceptionDelegationResultListener>(ret)
// {
// public void customResultAvailable(Void result)
// {
// try
// {
// for(Object s: component.getComponentFeature(IProvidedServicesFeature.class).getProvidedServices(null))
// {
// if(proxy)
// {
// s = createRequiredProxy(component, (IService)s,
// ((IService)s).getServiceIdentifier().getServiceType().getType(component.getClassLoader()));
// }
// ret.addIntermediateResult((IService)s);
// }
// ret.setFinished();
// }
// catch(Exception e)
// {
// ret.setException(e);
// }
// }
// });
//
// return ret;
// }
//
// //-------- external access method duplicates --------
//
// /**
// * Get one service of a type.
// * @param type The class.
// * @return The corresponding service.
// */
// public static IFuture getService(IExternalAccess provider, Class type)
// {
// return getService(provider, type, null);
// }
//
// /**
// * Get one service of a type.
// * @param type The class.
// * @return The corresponding service.
// */
// public static IFuture getService(IExternalAccess provider, Class type, String scope)
// {
// return getService(provider, type, scope, (IAsyncFilter)null);
// }
//
// /**
// * Get one service of a type.
// * @param type The class.
// * @return The corresponding service.
// */
// public static IFuture getService(IExternalAccess provider, final Class type, final String scope, final IAsyncFilter filter)
// {
// return provider.scheduleStep(new ImmediateComponentStep()
// {
// @Classname("getService(IExternalAccess provider, final Class type, final String scope, final IAsyncFilter filter)")
// public IFuture execute(IInternalAccess ia)
// {
// return getService(ia, type, scope, filter, false);
// }
// });
// }
//
// /**
// * Get one service with id.
// * @param clazz The class.
// * @return The corresponding service.
// */
// public static IFuture getService(IExternalAccess provider, final IServiceIdentifier sid)
// {
// return provider.scheduleStep(new ImmediateComponentStep()
// {
// @Classname("getService(IExternalAccess provider, final IServiceIdentifier sid)")
// public IFuture execute(IInternalAccess ia)
// {
// return getService(ia, sid, false);
// }
// });
// }
//
// /**
// * Get a service from a specific component.
// * @param access The external access.
// * @param cid The target component identifier.
// * @param type The service type.
// * @return The corresponding service.
// */
// public static IFuture getService(IExternalAccess access, final IComponentIdentifier cid, final Class type)
// {
// return access.scheduleStep(new ImmediateComponentStep()
// {
// @Classname("getService(IExternalAccess provider, final IComponentIdentifier cid, final Class type)")
// public IFuture execute(IInternalAccess ia)
// {
// return getService(ia, cid, type, false);
// }
// });
// }
//
// /**
// * Get a service from a specific component with defined scope.
// * @param access The external access.
// * @param cid The target component identifier.
// * @param scope The search scope.
// * @param type The service type.
// * @return The corresponding service.
// */
//// public static IFuture getService(IExternalAccess access, final IComponentIdentifier cid, final String scope, final Class type)
//// {
//// return access.scheduleStep(new ImmediateComponentStep()
//// {
//// @Classname("getService(IExternalAccess provider, final IComponentIdentifier cid, final String scope, final Class type)")
//// public IFuture execute(IInternalAccess ia)
//// {
//// return getService(ia, cid, scope, type, false);
//// }
//// });
//// }
//
// /**
// * Get all services of a type.
// * @param type The class.
// * @return The corresponding services.
// */
// public static ITerminableIntermediateFuture getServices(IExternalAccess provider, Class type)
// {
// return getServices(provider, type, null);
// }
//
// /**
// * Get all services of a type.
// * @param type The class.
// * @return The corresponding services.
// */
// public static ITerminableIntermediateFuture getServices(IExternalAccess provider, Class type, String scope)
// {
// return getServices(provider, type, scope, (IAsyncFilter)null);
// }
//
// /**
// * Get all services of a type.
// * @param type The class.
// * @return The corresponding services.
// */
// public static ITerminableIntermediateFuture getServices(IExternalAccess provider, final Class type, final String scope, final IAsyncFilter filter)
// {
// return (ITerminableIntermediateFuture)provider.scheduleStep(new ImmediateComponentStep>()
// {
// @Classname("getServices(IExternalAccess provider, final Class type, final String scope, final IAsyncFilter filter)")
// public ITerminableIntermediateFuture execute(IInternalAccess ia)
// {
// return getServices(ia, type, scope, filter);
// }
// });
// }
//
//// /**
//// * Get one service of a type and only search upwards (parents).
//// * @param type The class.
//// * @return The corresponding service.
//// */
//// public static IFuture getServiceUpwards(IExternalAccess provider, Class type)
//// {
//// return getService(provider, type, ServiceScope.UPWARDS);
//// }
//
// /**
// * Get all declared services of the given provider.
// * @return The corresponding services.
// */
// public static IFuture getDeclaredService(IExternalAccess provider, Class type)
// {
// return getService(provider, type, ServiceScope.LOCAL);
// }
//
// /**
// * Get all declared services of the given provider.
// * @return The corresponding services.
// */
// public static IIntermediateFuture getDeclaredServices(IExternalAccess provider)
// {
// return (IIntermediateFuture)provider.scheduleStep(new ImmediateComponentStep>()
// {
// @Classname("getDeclaredServices(IExternalAccess provider)")
// public IIntermediateFuture execute(IInternalAccess ia)
// {
// return getDeclaredServices(ia, false);
// }
// });
// }
//
// /**
// * Get a service of a type.
// * @param type The class.
// * @return The corresponding services.
// */
// public static IFuture getTaggedService(IExternalAccess provider, final Class type, final String scope, final String... tags)
// {
// return getTaggedService(provider, type, scope, null, tags);
// }
//
// /**
// * Get a service of a type.
// * @param type The class.
// * @return The corresponding services.
// */
// public static IFuture getTaggedService(IExternalAccess provider, final Class type, final String scope, final Object filter, final String... tags)
// {
// return (IFuture)provider.scheduleStep(new ImmediateComponentStep()
// {
// @Classname("getService(IExternalAccess provider, final Class type, final String scope, final String... args)")
// public IFuture execute(IInternalAccess ia)
// {
// return getTaggedService(ia, type, scope, filter, tags);
// }
// });
// }
//
// /**
// * Get all services of a type and tags. Services must have all the tags.
// * @param type The class.
// * @return The corresponding services.
// */
// public static ITerminableIntermediateFuture getTaggedServices(IExternalAccess component, final Class type, final String scope, final String... tags)
// {
// return getTaggedServices(component, type, scope, null, tags);
// }
//
// /**
// * Get all services of a type and tags. Services must have all the tags.
// * @param type The class.
// * @return The corresponding services.
// */
// public static ITerminableIntermediateFuture getTaggedServices(IExternalAccess component, final Class type, final String scope, Object filter, final String... tags)
// {
// ServiceQuery query = new ServiceQuery(type, scope, null, component.getComponentIdentifier(), null);
// query.setServiceTags(tags, component);
// return ServiceRegistry.getRegistry(component.getComponentIdentifier()).searchServicesAsync(query);
//
//// return (ITerminableIntermediateFuture)component.scheduleStep(new ImmediateComponentStep>()
//// {
//// @Classname("getServices(IExternalAccess provider, final Class type, final String scope, final String... args)")
//// public ITerminableIntermediateFuture execute(IInternalAccess ia)
//// {
//// return getTaggedServices(ia, type, scope, tags);
//// }
//// });
// }
//
// /**
// * Find services by type and tags. Service must have all the tags.
// * @param component The component.
// * @param type The service type.
// * @param scope The search scope.
// * @param tags The tags.
// * @return A matching service
// */
// public static ITerminableIntermediateFuture getTaggedServices(final IInternalAccess component, Class type, String scope, final String... tags)
// {
// ServiceQuery query = new ServiceQuery(type, scope, null, component.getComponentIdentifier(), null);
// query.setServiceTags(tags, component.getExternalAccess());
// return ServiceRegistry.getRegistry(component.getComponentIdentifier()).searchServicesAsync(query);
//// return getServices(component, type, scope, new TagFilter(component.getExternalAccess(), tags));
// }
//
// /**
// * Get one service of a type.
//// * (Returns required service proxy).
// * @param type The class.
// * @return The corresponding service.
// */
// public static IFuture getTaggedService(final IInternalAccess component, final Class type, final String scope, final IAsyncFilter filter, final boolean proxy, final String... tags)
// {
// final Future ret = new Future();
// ensureThreadAccess(component, proxy).addResultListener(new ExceptionDelegationResultListener(ret)
// {
// public void customResultAvailable(Void result)
// {
//// if((""+type).indexOf("AutoTerminate")!=-1)
//// System.out.println("getTaggedService: "+type+", "+scope);
// ServiceQuery query = new ServiceQuery(type, scope, null, component.getComponentIdentifier(), filter, null);
// query.setServiceTags(tags, component.getExternalAccess());
// IResultListener lis = proxy? new ProxyResultListener(ret, component, type): new DelegationResultListener(ret);
// ServiceRegistry.getRegistry(component).searchServiceAsync(query).addResultListener(new ComponentResultListener(lis, component));;
// }
// });
//
// return ret;
// }
//
// //-------- other methods --------
//
/**
* Rank the services of a search with a specific ranker.
*/
public static ITerminableIntermediateFuture rankServices(ITerminableIntermediateFuture searchfut,
IServiceRanker ranker, IRankingSearchTerminationDecider decider)
{
TerminableIntermediateDelegationFuture ret = new TerminableIntermediateDelegationFuture();
searchfut.addResultListener(new ServiceRankingDelegationResultListener(ret, searchfut, ranker, decider));
return ret;
}
/**
* Rank the services of a search with a specific ranker and emit the scores.
*/
public static ITerminableIntermediateFuture> rankServicesWithScores(ITerminableIntermediateFuture searchfut,
IServiceRanker ranker, IRankingSearchTerminationDecider decider)
{
TerminableIntermediateDelegationFuture> ret = new TerminableIntermediateDelegationFuture>();
searchfut.addResultListener(new ServiceRankingDelegationResultListener2(ret, searchfut, ranker, decider));
return ret;
}
// // todo: remove these methods, move to marshal service
//
// /**
// * Get the copy info for method parameters.
// */
// public static boolean[] getLocalReferenceInfo(Method method, boolean refdef)
// {
// return getReferenceInfo(method, refdef, true);
// }
//
// /**
// * Get the copy info for method parameters.
// */
// public static boolean[] getRemoteReferenceInfo(Method method, boolean refdef)
// {
// return getReferenceInfo(method, refdef, false);
// }
//
// /**
// * Get the copy info for method parameters.
// */
// public static boolean[] getReferenceInfo(Method method, boolean refdef, boolean local)
// {
// boolean[] ret;
// Object[] tmp = (Object[])methodreferences.get(method);
// if(tmp!=null)
// {
// ret = (boolean[])tmp[local? 0: 1];
// }
// else
// {
// int params = method.getParameterTypes().length;
// boolean[] localret = new boolean[params];
// boolean[] remoteret = new boolean[params];
//
// for(int i=0; i T createRequiredProxy(IInternalAccess component, T ser, Class> type)
// {
// return (T)BasicServiceInvocationHandler.createRequiredServiceProxy(component,
// (IService)ser, null, new RequiredServiceInfo(type), null, Starter.isRealtimeTimeout(component.getComponentIdentifier()));
// }
//
// /**
// * Create a required service proxy.
// */
// protected static T createRequiredProxy(IInternalAccess component, T ser, ClassInfo type)
// {
// return createRequiredProxy(component, ser, type.getType(component.getClassLoader()));
// }
//
// /**
// * Create a required service proxies.
// */
// protected static Collection createRequiredProxies(IInternalAccess component, Collection sers, Class> type)
// {
// Collection ret = new ArrayList();
// RequiredServiceInfo reinfo = new RequiredServiceInfo(type);
// reinfo.setMultiple(true);
// if(sers!=null)
// {
// for(T t: sers)
// {
// ret.add((T)BasicServiceInvocationHandler.createRequiredServiceProxy(component,
// (IService)t, null, reinfo, null, Starter.isRealtimeTimeout(component.getComponentIdentifier())));
// }
// }
// return ret;
// }
//
// /**
// * Create a required service proxies.
// */
// protected static Collection createRequiredProxies(IInternalAccess component, Collection sers, ClassInfo type)
// {
// return createRequiredProxies(component, sers, type.getType(component.getClassLoader()));
// }
//
// /**
// * Proxy result listener class.
// */
// public static class ProxyResultListener extends DelegationResultListener
// {
// protected IInternalAccess component;
// protected Class> type;
//
// public ProxyResultListener(Future future, IInternalAccess component, Class> type)
// {
// super(future);
// this.component = component;
// this.type = type;
// }
//
// public void customResultAvailable(T result)
// {
// super.customResultAvailable(SServiceProvider.createRequiredProxy(component, result, type));
// }
// }
//
// /**
// * Proxy result listener.
// */
// public static class IntermediateProxyResultListener extends IntermediateDelegationResultListener
// {
// protected IInternalAccess component;
// protected Class> type;
//
// public IntermediateProxyResultListener(IntermediateFuture future, IInternalAccess component, Class> type)
// {
// super(future);
// this.component = component;
// this.type = type;
// }
//
// public void customResultAvailable(Collection result)
// {
// for(T t: result)
// {
// customIntermediateResultAvailable(t);
// }
// finished();
//// super.customResultAvailable(result);
// }
//
// public void customIntermediateResultAvailable(T result)
// {
// super.customIntermediateResultAvailable(SServiceProvider.createRequiredProxy(component, result, type));
// }
// }
//
// /**
// * Check thread access and throw exception if is not component thread.
// */
// protected static void checkThreadAccess(IInternalAccess component, boolean proxy)
// {
// checkComponent(component);
// if(proxy && !component.getComponentFeature(IExecutionFeature.class).isComponentThread())
// throw new RuntimeException("Must be called on component thread. Called component is "+component+" calling component is "+IComponentIdentifier.LOCAL.get()+". Use methods with external access otherwise.");
// }
//
// /**
// * Check access not null and throw exception otherwise.
// */
// protected static void checkComponent(IInternalAccess component)
// {
// if(component==null)
// throw new IllegalArgumentException("Access must not be null");
// }
//
// /**
// * Check access not null and throw exception otherwise.
// */
// protected static IFuture ensureThreadAccess(final IInternalAccess component, boolean proxy)
// {
// final Future ret = new Future();
// if(component==null)
// {
// ret.setException(new IllegalArgumentException("Access must not be null"));
// }
// else
// {
// if(!component.getComponentFeature(IExecutionFeature.class).isComponentThread())
// {
// if(proxy)
// {
//// ret.setException(new RuntimeException("Wrong calling thread: "+Thread.currentThread()));
//// System.out.println("ensureThreadAccess scheduleStep "+component);
// component.getComponentFeature(IExecutionFeature.class).scheduleStep(new IComponentStep()
// {
// public IFuture execute(IInternalAccess ia)
// {
//// System.out.println("ensureThreadAccess execute "+component);
// ret.setResult(null);
// return IFuture.DONE;
// }
// });
// }
// else
// {
// ret.setResult(null);
// }
// }
// else
// {
// ret.setResult(null);
// }
// }
// return ret;
// }
//
// /**
// * Get the service call service with delay.
// */
// public static IFuture waitForService(final IInternalAccess agent, final String reqservicename, final int max, final int delay)
// {
// IResultCommand, Void> searchcmd = new IResultCommand, Void>()
// {
// public IFuture execute(Void args)
// {
// return agent.getComponentFeature(IRequiredServicesFeature.class).getService(reqservicename);
// }
// };
//
// return waitForService(agent, searchcmd, max, delay);
// }
//
// /**
// * Get the service call service with delay.
// */
// public static IFuture waitForService(final IExternalAccess agent, final String reqservicename, final int max, final int delay)
// {
// IResultCommand, Void> searchcmd = new IResultCommand, Void>()
// {
// public IFuture execute(Void args)
// {
// return agent.scheduleStep(new IComponentStep()
// {
// public IFuture execute(IInternalAccess ia)
// {
// return ia.getComponentFeature(IRequiredServicesFeature.class).getService(reqservicename);
// }
// });
// }
// };
//
// return waitForService(agent, searchcmd, max, delay);
// }
//
// /**
// * Get the service call service with delay.
// */
// public static IFuture waitForService(final IExternalAccess agent, final IResultCommand, Void> searchcmd, final int max, final int delay)
// {
// return agent.scheduleStep(new IComponentStep()
// {
// public IFuture execute(IInternalAccess ia)
// {
// return waitForService(ia, searchcmd, 0, max, delay);
// }
// });
// }
//
// /**
// * Get the service call service with delay.
// */
// public static IFuture waitForService(final IInternalAccess agent, final IResultCommand, Void> searchcmd, final int max, final int delay)
// {
// return waitForService(agent, searchcmd, 0, max, delay);
// }
//
// /**
// * Get the service call service with delay.
// */
// protected static IFuture waitForService(final IInternalAccess agent, final IResultCommand, Void> searchcmd, final int cnt, final int max, final int delay)
// {
// final Future ret = new Future();
//
//// final IFuture fut = agent.getComponentFeature(IRequiredServicesFeature.class).getService(servicename);
// final IFuture fut = searchcmd.execute(null);
//
// fut.addResultListener(new DelegationResultListener(ret)
// {
// public void exceptionOccurred(Exception exception)
// {
// if(cnt()
// {
// public IFuture execute(IInternalAccess ia)
// {
// waitForService(agent, searchcmd, cnt+1, max, delay).addResultListener(new DelegationResultListener(ret));
//
// return IFuture.DONE;
// }
// }, true);
// }
// else
// {
// ret.setException(exception);
// }
// }
// });
//
// return ret;
// }
//
// //--------------------------------------------------
// // A copy of methods with classinfo instead of class
// //--------------------------------------------------
//
//
// /**
// * Get one service of a type.
// * (Returns required service proxy).
// * @param type The class.
// * @return The corresponding service.
// */
// public static T getLocalService(IComponentIdentifier component, ClassInfo type)
// {
// return getLocalService(component, type, null);
// }
//
// /**
// * Get one service of a type.
// * (Returns required service proxy).
// * @param type The class.
// * @return The corresponding service.
// */
// public static T getLocalService(IComponentIdentifier component, ClassInfo type, final String scope)
// {
// return getLocalService(component, type, scope, null);
// }
//
// /**
// * Get one service of a type.
// * (Returns required service proxy).
// * @param type The class.
// * @return The corresponding service.
// */
// public static T getLocalService(IComponentIdentifier component, final ClassInfo type, final String scope, final IFilter filter)
// {
// ServiceQuery query = new ServiceQuery(type, scope, null, component, filter, null);
// return ServiceRegistry.getRegistry(component.getRoot()).searchService(query);
//// 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 getLocalService(final IInternalAccess component, final ClassInfo type)
// {
// return getLocalService(component, type, (String)null, true);
// }
//
// /**
// * Get one service of a type.
// * (Returns required service proxy).
// * @param type The class.
// * @return The corresponding service.
// */
// public static T getLocalService(final IInternalAccess component, final ClassInfo type, final String scope)
// {
// return getLocalService(component, type, scope, null, true);
// }
//
// /**
// * 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 getLocalService(final IInternalAccess component, final ClassInfo type, final String scope, final IFilter filter)
// {
// return getLocalService(component, type, scope, filter, true);
// }
//
// /**
// * 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 getLocalService(final IInternalAccess component, final ClassInfo type, final IComponentIdentifier target)
// {
// return getLocalService(component, type, target, true);
// }
//
// /**
// * Get one service of a type.
// * (Returns required service proxy).
// * @param type The class.
// * @return The corresponding service.
// */
// public static Collection getLocalServices(final IInternalAccess component, final ClassInfo type)
// {
// return getLocalServices(component, type, null, true);
// }
//
// /**
// * Get one service of a type.
// * (Returns required service proxy).
// * @param type The class.
// * @return The corresponding service.
// */
// public static Collection getLocalServices(final IInternalAccess component, final ClassInfo type, final String scope)
// {
// return getLocalServices(component, type, scope, null, true);
// }
//
// /**
// * Get one service of a type.
// * (Returns required service proxy).
// * @param type The class.
// * @return The corresponding service.
// */
// public static Collection getLocalServices(final IInternalAccess component, final ClassInfo type, final String scope, final IFilter filter)
// {
// return getLocalServices(component, type, scope, filter, true);
// }
//
// /**
// * Get one service of a type.
// * (Returns required service proxy).
// * @param type The class.
// * @return The corresponding service.
// */
// public static T getLocalService(final IInternalAccess component, final ClassInfo type, boolean proxy)
// {
// return getLocalService(component, type, (String)null, proxy);
// }
//
// /**
// * Get one service of a type.
// * (Returns required service proxy).
// * @param type The class.
// * @return The corresponding service.
// */
// public static T getLocalService(final IInternalAccess component, final ClassInfo type, final String scope, boolean proxy)
// {
// return getLocalService(component, type, scope, null, proxy);
// }
//
// /**
// * 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 getLocalService(final IInternalAccess component, final ClassInfo type, final String scope, final IFilter filter, boolean proxy)
// {
// checkThreadAccess(component, proxy);
//
// ServiceQuery query = new ServiceQuery(type, scope, null, component.getComponentIdentifier(), filter, null);
// T ret = ServiceRegistry.getRegistry(component).searchService(query);
//// 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;
// }
//
// /**
// * 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 getLocalService0(final IInternalAccess component, final ClassInfo type, final String scope, final IFilter filter, boolean proxy)
// {
// checkThreadAccess(component, proxy);
//
// ServiceQuery query = new ServiceQuery(type, scope, null, component.getComponentIdentifier(), filter, null);
// T ret = ServiceRegistry.getRegistry(component).searchService(query);
//// T ret = SynchronizedServiceRegistry.getRegistry(component).searchService(type, component.getComponentIdentifier(), scope, filter);
// return proxy && ret!=null? createRequiredProxy(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 getLocalService(final IInternalAccess component, final ClassInfo type, final IComponentIdentifier target, boolean proxy)
// {
// checkThreadAccess(component, proxy);
//
// ServiceQuery query = new ServiceQuery(type, ServiceScope.PLATFORM, target, component.getComponentIdentifier(), null, null);
// T ret = ServiceRegistry.getRegistry(component).searchService(query);
//// T ret = SynchronizedServiceRegistry.getRegistry(component).searchService(type, component.getComponentIdentifier(), ServiceScope.PLATFORM, new IFilter()
//// {
//// 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;
// }
//
// /**
// * Get one service of a type.
// * (Returns required service proxy).
// * @param type The class.
// * @return The corresponding service.
// */
// public static Collection getLocalServices(final IInternalAccess component, final ClassInfo type, boolean proxy)
// {
// return getLocalServices(component, type, null, proxy);
// }
//
// /**
// * Get one service of a type.
// * (Returns required service proxy).
// * @param type The class.
// * @return The corresponding service.
// */
// public static Collection getLocalServices(final IInternalAccess component, final ClassInfo type, final String scope, boolean proxy)
// {
// return getLocalServices(component, type, scope, null, proxy);
// }
//
// /**
// * Get one service of a type.
// * (Returns required service proxy).
// * @param type The class.
// * @return The corresponding service.
// */
// public static Collection getLocalServices(final IInternalAccess component, final ClassInfo type, final String scope, final IFilter filter, boolean proxy)
// {
// checkThreadAccess(component, proxy);
//
// ServiceQuery query = new ServiceQuery(type, scope, null, component.getComponentIdentifier(), filter, null);
// Collection ret = ServiceRegistry.getRegistry(component).searchServices(query);
//// Collection 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;
// }
//
//
// //-------- async methods --------
//
// /**
// * Get one service of a type.
//// * (Returns required service proxy).
// * @param type The class.
// * @return The corresponding service.
// */
// public static IFuture getService(IInternalAccess component, ClassInfo type)
// {
// return getService(component, type, null, true);
// }
//
// /**
// * Get one service of a type.
//// * (Returns required service proxy).
// * @param type The class.
// * @return The corresponding service.
// */
// public static IFuture getService(IInternalAccess component, ClassInfo type, String scope)
// {
// return getService(component, type, scope, (IAsyncFilter)null, true);
// }
//
// /**
// * Get one service of a type.
//// * (Returns required service proxy).
// * @param type The class.
// * @return The corresponding service.
// */
// public static IFuture getService(final IInternalAccess component, final ClassInfo type, final String scope, final IAsyncFilter filter)
// {
// return getService(component, type, scope, filter, true);
// }
//
//
// /**
// * Get a service from a specific component.
// * @param component The component.
// * @param cid The target component identifier.
// * @param type The service type.
// * @return The corresponding service.
// */
// public static IFuture getService(final IInternalAccess component, final IComponentIdentifier cid, final ClassInfo type)
// {
// return getService(component, cid, type, true);
// }
//
// /**
// * Get all services of a type.
// * @param type The class.
// * @return The corresponding services.
// */
// public static ITerminableIntermediateFuture getServices(IInternalAccess component, ClassInfo type)
// {
// return getServices(component, type, null, true);
// }
//
// /**
// * Get all services of a type.
// * @param type The class.
// * @return The corresponding services.
// */
// public static ITerminableIntermediateFuture getServices(IInternalAccess component, ClassInfo type, String scope)
// {
// return getServices(component, type, scope, (IAsyncFilter)null, true);
// }
//
// /**
// * Get all services of a type.
// * @param type The class.
// * @return The corresponding services.
// */
// public static ITerminableIntermediateFuture getServices(IInternalAccess component, ClassInfo type, String scope, IAsyncFilter filter)
// {
// return getServices(component, type, scope, filter, true);
// }
//
//// /**
//// * Get one service of a type and only search upwards (parents).
//// * @param type The class.
//// * @return The corresponding service.
//// */
//// public static IFuture getServiceUpwards(IInternalAccess provider, Class type)
//// {
//// return getService(provider, type, ServiceScope.UPWARDS);
//// }
//
// /**
// * Get all declared services of the given provider.
// * @return The corresponding services.
// */
// public static