Class ServiceFactory

java.lang.Object
loci.common.services.ServiceFactory

public class ServiceFactory
extends java.lang.Object
Runtime instantiation of services.
  • Constructor Summary

    Constructors 
    Constructor Description
    ServiceFactory()
    Constructor loading service configuration from the default location.
    ServiceFactory​(java.lang.String path)
    Constructor loading service configuration from a given location.
  • Method Summary

    Modifier and Type Method Description
    <T extends Service>
    T
    getInstance​(java.lang.Class<T> type)
    Retrieves an instance of a given service.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • ServiceFactory

      public ServiceFactory() throws DependencyException
      Constructor loading service configuration from the default location.
      Throws:
      DependencyException - If there is an error locating or reading from the default configuration location.
    • ServiceFactory

      public ServiceFactory​(java.lang.String path) throws DependencyException
      Constructor loading service configuration from a given location.
      Parameters:
      path - Location to load service configuration from.
      Throws:
      DependencyException - If there is an error locating or reading from path.
  • Method Details

    • getInstance

      public <T extends Service> T getInstance​(java.lang.Class<T> type) throws DependencyException
      Retrieves an instance of a given service.
      Type Parameters:
      T - generic service type
      Parameters:
      type - Interface type of the service.
      Returns:
      A newly instantiated service.
      Throws:
      DependencyException - If there is an error instantiating the service instance requested.