org.hibernate.search.engine.service.spi

## Interface ServiceManager

- All Known Implementing Classes:
    StandardServiceManager

      public interface ServiceManager

  The `ServiceManager` is used to manage services in and runtime discovery of service implementations in the scope of a single `SearchFactory`.

  Services are divided into discovered services (via `ServiceLoader` and provided services. The latter occurs via `SearchConfiguration.getProvidedServices()` and `SearchConfiguration.getClassLoaderService()`.

  It is the responsibility of the provider of these services to manage their life cycle: even if they implement `Startable` or `Stoppable`, they will not be started or stopped automatically, while the methods on these interfaces will be invoked for the services discovered via the serviceloader.

  Any service requested should be released using `releaseService(Class)` when it's not needed anymore.

  Author:
    Hardy Ferentschik

- - ### Method Summary

    All Methods Instance Methods Abstract Methods
    Modifier and Type | Method and Description
    --- | ---
    `BeanResolver` | `getBeanResolver()` Provides direct access to the `BeanResolver`.
    `ClassLoaderService` | `getClassLoaderService()` Provides direct access to the `ClassLoaderService`.
    `void` | `releaseAllServices()` Stops and releases all services.
    `<S extends Service> void` | `releaseService(Class<S> serviceRole)` Releases the service in the specified service role.
    `<S extends Service> ServiceReference<S>` | `requestReference(Class<S> serviceRole)` Gets a reference to the service with the requested role.
    `<S extends Service> S` | `requestService(Class<S> serviceRole)` Gets the service in the specified service role.

- - ### Method Detail

    - #### requestService

          <S extends Service> S requestService(Class<S> serviceRole)

      Gets the service in the specified service role.
      Type Parameters:
        `S` - the type of the service
      Parameters:
        `serviceRole` - the service to retrieve. Cannot be `null`.
      Returns:
        the single service fulfilling the specified role.
      Throws:
        `IllegalArgumentException` - in case the `serviceRole` is `null`
        `SearchException` - in case no service fulfilling the role could be located
        `IllegalStateException` - in case this method is called after `releaseService(Class)`

    - #### requestReference

          <S extends Service> ServiceReference<S> requestReference(Class<S> serviceRole)

      Gets a reference to the service with the requested role.
      Type Parameters:
        `S` - the type of the service
      Parameters:
        `serviceRole` - the service to retrieve. Cannot be `null`.
      Returns:
        the single service fulfilling the specified role.
      Throws:
        `IllegalArgumentException` - in case the `serviceRole` is `null`
        `SearchException` - in case no service fulfilling the role could be located
        `IllegalStateException` - in case this method is called after `releaseService(Class)`

    - #### releaseService

          <S extends Service> void releaseService(Class<S> serviceRole)

      Releases the service in the specified service role.
      Type Parameters:
        `S` - the type of the service
      Parameters:
        `serviceRole` - the service to be released. Cannot be `null`.
      Throws:
        `IllegalArgumentException` - in case the `serviceRole` is `null`

    - #### releaseAllServices

          void releaseAllServices()

      Stops and releases all services. After this method is called no further services can be requested. An `IllegalStateException` will be thrown in this case.

    - #### getClassLoaderService

          ClassLoaderService getClassLoaderService()

      Provides direct access to the `ClassLoaderService`. This service lookup is treated as a special case both for convenience and performance reasons.
      Returns:
        the `ClassLoaderService`

    - #### getBeanResolver

          BeanResolver getBeanResolver()

      Provides direct access to the `BeanResolver`. This service lookup is treated as a special case for convenience.
      Returns:
        the `BeanResolver`

Copyright © 2006-2017 Red Hat, Inc. All Rights Reserved