Class Services<T>


  • public class Services<T>
    extends java.lang.Object
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static <T> java.util.Optional<T> get​(java.lang.Class<T> service)
      Returns an optional with a service, if previously a ServiceFactory was registered.
      static <T> void registerServiceFactory​(ServiceFactory<T> factory)
      Required call to register a ServiceFactory for a given service of type T.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • registerServiceFactory

        public static <T> void registerServiceFactory​(ServiceFactory<T> factory)
        Required call to register a ServiceFactory for a given service of type T. ServiceFactory instance is cached. In case a service is called without its ServiceFactory being registered first, a Runtime Exception will be thrown
        Type Parameters:
        T - The type of service
        Parameters:
        factory - The ServiceFactory instance
      • get

        public static <T> java.util.Optional<T> get​(java.lang.Class<T> service)
        Returns an optional with a service, if previously a ServiceFactory was registered. Otherwise, it will try to find a service factory in the same package as the service, and otherwise a Runtime Exception will be thrown. Both serviceFactory and service instances are cached, so only one service is created for the given factory
        Type Parameters:
        T - the type of service
        Parameters:
        service - the class of service
        Returns:
        An optional with the service