org.qi4j.api.service

## Interface ServiceFinder

- All Known Subinterfaces:
    Module, ModuleSpi

      public interface ServiceFinder

  Interface used to query for ServiceReferences.

  Each ServiceFinder is obtained from a specific Module, and the lookup rules are the following:

  1. First look in the same Module as the ServiceFinder
  2. Then look in the same Layer as the ServiceFinder. Any Services declared with Visibility Layer and Application should be included
  3. Then look in the used Layers. Any Services declared with Visibility Application should be included

  Both native Zest services and imported services are considered, with preference to native services.

- - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `<T> ServiceReference<T>` | `findService(Class<T> serviceType)` Find a ServiceReference that implements the given type.
    `<T> ServiceReference<T>` | `findService(Type serviceType)` Find a ServiceReference that implements the given type.
    `<T> Iterable<ServiceReference<T>>` | `findServices(Class<T> serviceType)` Find ServiceReferences that implements the given type.
    `<T> Iterable<ServiceReference<T>>` | `findServices(Type serviceType)` Find ServiceReferences that implements the given type.

- - ### Method Detail

    - #### findService

          <T> ServiceReference<T> findService(Class<T> serviceType)
                                          throws NoSuchServiceException

      Find a ServiceReference that implements the given type.
      Parameters:
        `serviceType` - the type that the Service must implement
      Returns:
        a ServiceReference if one is found
      Throws:
        `NoSuchServiceException` - if no service of serviceType is found

    - #### findService

          <T> ServiceReference<T> findService(Type serviceType)
                                          throws NoSuchServiceException

      Find a ServiceReference that implements the given type.
      Parameters:
        `serviceType` - the type that the Service must implement
      Returns:
        a ServiceReference if one is found
      Throws:
        `NoSuchServiceException` - if no service of serviceType is found

    - #### findServices

          <T> Iterable<ServiceReference<T>> findServices(Class<T> serviceType)

      Find ServiceReferences that implements the given type.

      The order of the references is such that Services more local to the querying Module is earlier in the list.

      Parameters:
        `serviceType` - the type that the Services must implement
      Returns:
        an iterable of ServiceReferences for the given type. It is empty if none exist

    - #### findServices

          <T> Iterable<ServiceReference<T>> findServices(Type serviceType)

      Find ServiceReferences that implements the given type.

      The order of the references is such that Services more local to the querying Module is earlier in the list.

      Parameters:
        `serviceType` - the type that the Services must implement
      Returns:
        an iterable of ServiceReferences for the given type. It is empty if none exist