java.lang.Object
com.io7m.looseleaf.server.internal.services.LLServices
All Implemented Interfaces:
Closeable, AutoCloseable

public final class LLServices extends Object implements Closeable
The main service directory implementation.
  • Constructor Details

    • LLServices

      public LLServices()
      Construct a service directory.
  • Method Details

    • register

      public <T extends LLServiceType> void register(Class<T> clazz, T service)
      Register the given service.
      Type Parameters:
      T - The type of service
      Parameters:
      clazz - The service interface
      service - The service
    • optionalService

      public <T extends LLServiceType> Optional<T> optionalService(Class<T> clazz)
      Fetch an optional service reference.
      Type Parameters:
      T - The type of service
      Parameters:
      clazz - The service class
      Returns:
      A service, if one is registered
    • requireService

      public <T extends LLServiceType> T requireService(Class<T> clazz) throws LLServiceException
      Fetch a required service reference.
      Type Parameters:
      T - The type of service
      Parameters:
      clazz - The service class
      Returns:
      A service, if one is registered
      Throws:
      LLServiceException - If no service is registered of the given type
    • optionalServices

      public <T extends LLServiceType> List<? extends T> optionalServices(Class<T> clazz) throws LLServiceException
      Fetch a set of optional service references.
      Type Parameters:
      T - The type of service
      Parameters:
      clazz - The service class
      Returns:
      The registered services, if any
      Throws:
      LLServiceException - On errors
    • services

      public List<LLServiceType> services()
      Returns:
      The list of registered services
    • close

      public void close() throws IOException
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Throws:
      IOException