Package org.distributeme.core
Class ServiceLocator
java.lang.Object
org.distributeme.core.ServiceLocator
A utility for convenient lookup of implementations for interfaces. This utility helps to reduce amount of code to instantiate a service if you
follow the naming patterns.
- Version:
- $Id: $Id
- Author:
- lrosenberg
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic <T extends net.anotheria.anoprise.metafactory.Service>
TgetAsynchRemote(Class<T> pattern) Returns a remote instance of a service aka stub.static <T extends net.anotheria.anoprise.metafactory.Service>
TReturns a local instance of T.static <T extends net.anotheria.anoprise.metafactory.Service>
TgetMonitoredLocal(Class<T> pattern, Class<?>... monitorableInterfaces) Returns a moskito-monitored local instance of the requested interface.static <T extends net.anotheria.anoprise.metafactory.Service>
TReturns a remote instance of a service aka stub.
-
Constructor Details
-
ServiceLocator
public ServiceLocator()
-
-
Method Details
-
getAsynchRemote
public static <T extends net.anotheria.anoprise.metafactory.Service> T getAsynchRemote(Class<T> pattern) Returns a remote instance of a service aka stub. This is only useful for interface annotated with @DistributeMe and generated by the apt processor.- Parameters:
pattern- aClassobject.- Returns:
- a T object.
-
getRemote
Returns a remote instance of a service aka stub. This is only useful for interface annotated with @DistributeMe and generated by the apt processor.- Parameters:
pattern- aClassobject.- Returns:
- a T object.
-
getLocal
Returns a local instance of T. First this method tries to lookup T in the MetaFactory. If this fails it tries to lookup a factory for T or a direct implementation of T. In success case it will register a factory for T in the MetaFactory and create an instance.- Parameters:
pattern- class of T.- Returns:
- a T object.
-
getMonitoredLocal
public static <T extends net.anotheria.anoprise.metafactory.Service> T getMonitoredLocal(Class<T> pattern, Class<?>... monitorableInterfaces) Returns a moskito-monitored local instance of the requested interface.- Parameters:
pattern- aClassobject.monitorableInterfaces- - additional interfaces the impl may implement. Since the returned instance will be proxied, the proxies should know of all interfaces that you are going to use to call the returned instance. Therefor they all have to be submitted. However, in most cases you can just omit this parameter.- Returns:
- a T object.
-