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

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      <U extends T>
      U
      getService​(java.lang.Class<U> serviceType)
      Looks up the Service of the given serviceType.
      <U extends T>
      java.util.Collection<U>
      getServicesOfType​(java.lang.Class<U> serviceType)
      Looks up all Service instances that are subtypes of the given serviceType supplied.
    • Method Detail

      • getService

        <U extends T> U getService​(java.lang.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:
        java.lang.IllegalArgumentException - if serviceType is marked with the PluralService annotation
        See Also:
        Service.start(ServiceProvider)
      • getServicesOfType

        <U extends T> java.util.Collection<U> getServicesOfType​(java.lang.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