All Downloads are FREE. Search and download functionalities are using the official Maven repository.

jadex.bridge.service.search.SServiceProvider Maven / Gradle / Ivy

Go to download

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.

There is a newer version: 4.0.267
Show newest version
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  IFuture getDeclaredService(IInternalAccess component, ClassInfo type)
//	{
//		return getService(component, type, ServiceScope.LOCAL, true);
//	}
//	
//	
//	/**
//	 *  Get one service of a type.
//	 *  @param type The class.
//	 *  @return The corresponding service.
//	 */
//	public static  IFuture getService(IInternalAccess component, ClassInfo type, boolean proxy)
//	{
//		return getService(component, type, null, proxy);
//	}
//	
//	/**
//	 *  Get one service of a type.
//	 *  @param type The class.
//	 *  @return The corresponding service.
//	 */
//	public static  IFuture getService(IInternalAccess component, ClassInfo type, String scope, boolean proxy)
//	{
//		return getService(component, type, scope, (IAsyncFilter)null, proxy);
//	}
//	
//	/**
//	 *  Get one service of a type.
//	 *  @param type The class.
//	 *  @return The corresponding service.
//	 */
//	public static  IFuture getService(final IInternalAccess component, final ClassInfo type, final String scope, final IAsyncFilter filter, final boolean proxy)
//	{
//		final Future ret = new Future();
//		
//		ensureThreadAccess(component, proxy).addResultListener(new ExceptionDelegationResultListener(ret)
//		{
//			public void customResultAvailable(Void result)
//			{
//				ServiceQuery query = new ServiceQuery(type, scope, null, component.getComponentIdentifier(), filter, null);
//				IResultListener lis = proxy? new ProxyResultListener(ret, component, type.getType(component.getClassLoader())): new DelegationResultListener(ret);
//				ServiceRegistry.getRegistry(component).searchServiceAsync(query).addResultListener(new ComponentResultListener(lis, component));
////				if(!ServiceScope.GLOBAL.equals(scope))
////				{
////					if(filter==null)
////					{
////						IServiceRegistry reg = ServiceRegistry.getRegistry(component);
////						T ser = reg==null? null: (T)reg.searchService(type, component.getComponentIdentifier(), scope);
//////							T ser = PlatformServiceRegistry.getRegistry(component).searchService(type, component.getComponentIdentifier(), scope);
////						if(ser!=null)
////						{
////							if(proxy)
////								ser = createRequiredProxy(component, ser, type);
////							ret.setResult(ser);
////						}
////						else
////						{
////							ret.setException(new ServiceNotFoundException(type.getTypeName()));
////						}
////					}
////					else
////					{
////						IResultListener lis = proxy? new ProxyResultListener(ret, component, type.getType(component.getClassLoader())): new DelegationResultListener(ret);
////						SynchronizedServiceRegistry.getRegistry(component).searchService(type, component.getComponentIdentifier(), scope, filter)
////							.addResultListener(new ComponentResultListener(lis, component));
////					}
////				}
////				else
////				{
////					IResultListener lis = proxy? new ProxyResultListener(ret, component, type.getType(component.getClassLoader())): new DelegationResultListener(ret);
////					SynchronizedServiceRegistry.getRegistry(component).searchGlobalService(type, component.getComponentIdentifier(), filter)
////						.addResultListener(new ComponentResultListener(lis, component));
////				}
//			}
//		});
//		
//		return ret;
//	}
//	
//	/**
//	 *  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, final boolean proxy)
//	{
//		final Future ret = new Future();
//		
//		ensureThreadAccess(component, proxy).addResultListener(new ExceptionDelegationResultListener(ret)
//		{
//			public void customResultAvailable(Void result)
//			{
//				IResultListener lis = proxy? new ProxyResultListener(ret, component, type.getType(component.getClassLoader())): new DelegationResultListener(ret);
//				IServiceRegistry reg = ServiceRegistry.getRegistry(component.getComponentIdentifier().getRoot());
//				String scope = component.getComponentIdentifier().getRoot().equals(cid.getRoot()) ? ServiceScope.PLATFORM : ServiceScope.GLOBAL;
//				ServiceQuery query = new ServiceQuery(type, scope, cid, component.getComponentIdentifier(), null);
//				reg.searchServiceAsync(query).addResultListener(lis);
//			}
//		});
//		
//		return ret;
////		return getService(component, cid, ServiceScope.LOCAL, type, proxy);
//	}
//	
//	/**
//	 *  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 String scope, final ClassInfo type, final boolean proxy)
//	{
//		final Future ret = new Future();
//		
//		ensureThreadAccess(component, proxy).addResultListener(new ExceptionDelegationResultListener(ret)
//		{
//			public void customResultAvailable(Void result)
//			{
//				IResultListener lis = proxy? new ProxyResultListener(ret, component, type.getType(component.getClassLoader())): new DelegationResultListener(ret);
//				IServiceRegistry reg = ServiceRegistry.getRegistry(component.getComponentIdentifier().getRoot());
//				ServiceQuery query = new ServiceQuery(type, scope, cid, component.getComponentIdentifier(), null);
//				reg.searchServiceAsync(query).addResultListener(lis);
//				
////				// component itself?
////				if(cid.equals(component.getComponentIdentifier()))
////				{
////					T res = (T)component.getComponentFeature(IProvidedServicesFeature.class).getProvidedService(type.getType(component.getClassLoader()));
////					if(res!=null)
////					{
////						if(proxy)
////							res = createRequiredProxy(component, res, type);
////						ret.setResult(res);
////					}
////					else
////					{
////						ret.setException(new ServiceNotFoundException(""+type));
////					}
////				}
////				
////				// local component?
////				else if(cid.getRoot().equals(component.getComponentIdentifier().getRoot()))
////				{
////					component.getComponentFeature(IRequiredServicesFeature.class).searchService(new ServiceQuery<>( IComponentManagementService.class, ServiceScope.PLATFORM))
////						.addResultListener(new ExceptionDelegationResultListener(ret)
////					{
////						public void customResultAvailable(IComponentManagementService cms)
////						{
////							cms.getExternalAccess(cid).addResultListener(new ExceptionDelegationResultListener(ret)
////							{
////								public void customResultAvailable(IExternalAccess ea)
////								{
////									final Class	ftype = (Class)type.getType(component.getClassLoader());
////									IResultListener lis = proxy? new ProxyResultListener(ret, component, ftype): new DelegationResultListener(ret);
////									
////									final IComponentIdentifier	fcid	= cid;
////									
////									ea.scheduleStep(new ImmediateComponentStep()
////									{
////										@Classname("getService(final IInternalAccess provider, final IComponentIdentifier cid, final Class type)")
////										
////										public IFuture execute(IInternalAccess ia)
////										{
////											return getService(ia, fcid, ftype, false);
////										}
////									}).addResultListener(new ComponentResultListener(lis, component));
////								}
////							});
////						}
////					});
////				}
////					
////				// For remote use rms, to allow correct security settings due to not using getExternalAccess()
////				else
////				{
////					IResultListener lis = proxy? new ProxyResultListener(ret, component, type.getType(component.getClassLoader())): new DelegationResultListener(ret);
////					
////					IRemoteServiceManagementService rms	= component.getComponentFeature(IRequiredServicesFeature.class).getLocalService(new ServiceQuery<>( IRemoteServiceManagementService.class, ServiceScope.PLATFORM));
////					IFuture fut = rms.getServiceProxy(component.getComponentIdentifier(), cid, type, scope, null);
////					fut.addResultListener(new ComponentResultListener(lis, component));
////				}
//			}
//		});
//		
//		return ret;
//	}
//	
//	
//	/**
//	 *  Get all services of a type.
//	 *  @param type The class.
//	 *  @return The corresponding services.
//	 */
//	public static  ITerminableIntermediateFuture getServices(IInternalAccess component, ClassInfo type, boolean proxy)
//	{
//		return getServices(component, type, null, proxy);
//	}
//	
//	/**
//	 *  Get all services of a type.
//	 *  @param type The class.
//	 *  @return The corresponding services.
//	 */
//	public static  ITerminableIntermediateFuture getServices(IInternalAccess component, ClassInfo type, String scope, boolean proxy)
//	{
//		return getServices(component, type, scope, (IAsyncFilter)null, proxy);
//	}
//	
//	/**
//	 *  Get all services of a type.
//	 *  @param type The class.
//	 *  @return The corresponding services.
//	 */
//	public static  ITerminableIntermediateFuture getServices(final IInternalAccess component, final ClassInfo type, final String scope, final IAsyncFilter filter, final boolean proxy)
//	{
//		final TerminableIntermediateDelegationFuture ret = new TerminableIntermediateDelegationFuture();
//		
//		ensureThreadAccess(component, proxy).addResultListener(new ExceptionDelegationResultListener>(ret)
//		{
//			public void customResultAvailable(Void result)
//			{
//				ServiceQuery query = new ServiceQuery(type, scope, null, component.getComponentIdentifier(), filter, null);
//				IIntermediateResultListener lis = proxy? new IntermediateProxyResultListener(ret, component, type.getType(component.getClassLoader())): new IntermediateDelegationResultListener(ret);
//				ServiceRegistry.getRegistry(component).searchServicesAsync(query).addResultListener(new IntermediateComponentResultListener(lis, component));
////				if(!ServiceScope.GLOBAL.equals(scope))
////				{
////					if(filter==null)
////					{
////						Collection 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 lis = proxy? new IntermediateProxyResultListener(ret, component, type.getType(component.getClassLoader())): new IntermediateDelegationResultListener(ret); 
////						SynchronizedServiceRegistry.getRegistry(component).searchServices(type, component.getComponentIdentifier(), scope, filter)
////							.addResultListener(new IntermediateComponentResultListener(lis, component));
////					}
////				}
////				else
////				{
////					IIntermediateResultListener lis = proxy? new IntermediateProxyResultListener(ret, component, type.getType(component.getClassLoader())): new IntermediateDelegationResultListener(ret); 
////					ISubscriptionIntermediateFuture fut = SynchronizedServiceRegistry.getRegistry(component).searchGlobalServices(type, component.getComponentIdentifier(), filter);
////					fut.addResultListener(new IntermediateComponentResultListener(lis, component));
////				}
//			}
//		});
//		
//		return ret;
//	}
//	
//	/**
//	 *  Get all declared services of the given provider.
////	 *  (Returns required service proxy).
//	 *  @return The corresponding services.
//	 */
//	public static  IFuture getDeclaredService(IInternalAccess component, ClassInfo type, boolean proxy)
//	{
//		return getService(component, type, ServiceScope.LOCAL, proxy);
//	}
//	
//	//-------- external access method duplicates --------
//	
//	/**
//	 *  Get one service of a type.
//	 *  @param type The class.
//	 *  @return The corresponding service.
//	 */
//	public static  IFuture getService(IExternalAccess provider, ClassInfo 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, ClassInfo 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 ClassInfo 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 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 ClassInfo 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 ClassInfo 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, ClassInfo 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, ClassInfo 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 ClassInfo 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 all declared services of the given provider.
//	 *  @return The corresponding services.
//	 */
//	public static  IFuture getDeclaredService(IExternalAccess provider, ClassInfo type)
//	{
//		return getService(provider, type, ServiceScope.LOCAL);
//	}
//	
//	/**
//	 *  Get a service of a type.
//	 *  @param type The class.
//	 *  @return The corresponding services.
//	 */
//	public static  IFuture getTaggedService(IExternalAccess provider, final ClassInfo type, final String scope, 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, 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 ClassInfo type, final String scope, final String... tags)
//	{
//		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);
//			}
//		});
//	}
//	
//	/**
//	 *  Add a service query to the registry.
//	 *  @param type The service type.
//	 *  @param scope The scope.
//	 *  @param filter The filter.
//	 */
//	public static  ISubscriptionIntermediateFuture addQuery(final IExternalAccess component, Class type, String scope, IAsyncFilter filter)
//	{
//		return addQuery(component.getComponentIdentifier(), type, scope, filter);
//	}
//	
//	/**
//	 *  Add a service query to the registry.
//	 *  @param type The service type.
//	 *  @param scope The scope.
//	 *  @param filter The filter.
//	 */
//	public static  ISubscriptionIntermediateFuture addQuery(final IComponentIdentifier cid, Class type, String scope, IAsyncFilter filter)
//	{
//		ServiceQuery query = new ServiceQuery(type, scope, null, cid, filter);
//		
//		return addQuery(cid, query);
//	}
//	
//	/**
//	 *  Add a service query to the registry.
//	 *  @param type The service type.
//	 *  @param scope The scope.
//	 *  @param filter The filter.
//	 */
//	public static  ISubscriptionIntermediateFuture addQuery(final IComponentIdentifier cid, ServiceQuery query)
//	{
//		return ServiceRegistry.getRegistry(cid).addQuery(query);
//	}
//	
	
	/**
	 *  Gets a external access proxy for a known component.
	 *  @return External access proxy.
	 */
	// TODO: remove?
	// NO!!! YES!
//	public static IExternalAccess getExternalAccessProxy(final IInternalAccess component, final IComponentIdentifier providerid)
//	{
//		return SComponentManagementService.getExternalAccess(providerid, component);
//		Object ret = ProxyFactory.newProxyInstance(component.getClassLoader(), 
//			new Class[]{IExternalAccess.class}, new InvocationHandler()
//		{
//			protected IExternalAccess access;
//			
//			public Object invoke(final Object proxy, final Method method, final Object[] args) throws Throwable
//			{
//				Object ret = null;
//				
//				if(access==null)
//				{
////					System.out.println("comp is: "+component+" prov: "+providerid);
////					IComponentManagementService cms = component.getFeature(IRequiredServicesFeature.class).getLocalService(new ServiceQuery<>(IComponentManagementService.class));
//
//					if(SReflect.isSupertype(IFuture.class, method.getReturnType()))
//					{
//						ret = SFuture.getFuture(method.getReturnType());
//						final Future sret = (Future)ret;
//						
//						component.getExternalAccessAsync(providerid).addResultListener(new IResultListener()
//						{
//							public void resultAvailable(IExternalAccess result) 
//							{
//								access = result;
//								Object res;
//								try
//								{
//									res = method.invoke(access, args);
//									((Future)res).addResultListener(new DelegationResultListener((Future)sret));
//								}
//								catch(Exception e)
//								{
//									((Future)sret).setException(e);
//								}
//							}
//	
//							public void exceptionOccurred(Exception exception)
//							{
//								component.getLogger().warning(exception.getMessage());
//							}
//						});
//						
//					}
//					else
//					{
//						access = component.getExternalAccessAsync(providerid).get();
//						ret = method.invoke(access, args);
//					}
//				}
//				else
//				{
//					ret = method.invoke(access, args);
//				}
//				
//				return ret;
//			}
//		});
//		
//		return (IExternalAccess)ret;
//	}
}