Interface ServiceProvider<T extends Service>

Type Parameters:
T - The type of services this provider returns

public interface ServiceProvider<T extends Service>
A repository of Service instances that can be used to look them up by type.
  • Method Summary

    Modifier and Type
    Method
    Description
    <U extends T>
    U
    getService(Class<U> serviceType)
    Looks up the Service of the given serviceType.
    <U extends T>
    Collection<U>
    getServicesOfType(Class<U> serviceType)
    Looks up all Service instances that are subtypes of the given serviceType supplied.
  • Method Details

    • getService

      <U extends T> U getService(Class<U> serviceType)
      Looks up the Service of the given serviceType.

      There is no guarantee that services returned here will be started.

      Type Parameters:
      U - the Service type
      Parameters:
      serviceType - the class of the service being looked up
      Returns:
      a service instance of type T, or null if it couldn't be located
      Throws:
      IllegalArgumentException - if serviceType is marked with the PluralService annotation
      See Also:
    • getServicesOfType

      <U extends T> Collection<U> getServicesOfType(Class<U> serviceType)
      Looks up all Service instances that are subtypes of the given serviceType supplied.

      This method must be used to retrieves service types marked with the PluralService annotation.

      Type Parameters:
      U - the Service type
      Parameters:
      serviceType - the class of the service being looked up
      Returns:
      all the service instances assignable to serviceType