Class ServiceLocator

java.lang.Object
org.distributeme.core.ServiceLocator

public class ServiceLocator extends Object
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
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static <T extends net.anotheria.anoprise.metafactory.Service>
    T
    getAsynchRemote(Class<T> pattern)
    Returns a remote instance of a service aka stub.
    static <T extends net.anotheria.anoprise.metafactory.Service>
    T
    getLocal(Class<T> pattern)
    Returns a local instance of T.
    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.
    static <T extends net.anotheria.anoprise.metafactory.Service>
    T
    getRemote(Class<T> pattern)
    Returns a remote instance of a service aka stub.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 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 - a Class object.
      Returns:
      a T object.
    • getRemote

      public static <T extends net.anotheria.anoprise.metafactory.Service> T getRemote(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 - a Class object.
      Returns:
      a T object.
    • getLocal

      public static <T extends net.anotheria.anoprise.metafactory.Service> T getLocal(Class<T> pattern)
      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 - a Class object.
      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.