public interface ServiceManager
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(). Provided services are also treated
special in the sense that they are not allowed to implemented Startable or
Stoppable (an exception is thrown if they do so).
It is the responsibility of the provider of these services to manage their life cycle. This also prevents circular
dependencies where a service where a service during bootstrapping could request other (uninitialized) services via
the Startable.start(java.util.Properties, org.hibernate.search.spi.BuildContext)
callback.
Any service requested should be released using releaseService(Class) when it's not needed anymore.
| Modifier and Type | Method and Description |
|---|---|
void |
releaseAllServices()
Stops and releases all services.
|
<S extends Service> |
releaseService(Class<S> serviceRole)
Releases the service in the specified service role.
|
<S extends Service> |
requestService(Class<S> serviceRole)
Gets the service in the specified service role.
|
<S extends Service> S requestService(Class<S> serviceRole)
S - the type of the serviceserviceRole - the service to retrieve. Cannot be null.IllegalArgumentException - in case the serviceRole is nullSearchException - in case no service fulfilling the role could be locatedIllegalStateException - in case this method is called after releaseService(Class)<S extends Service> void releaseService(Class<S> serviceRole)
S - the type of the serviceserviceRole - the service to be released. Cannot be null.IllegalArgumentException - in case the serviceRole is nullvoid releaseAllServices()
IllegalStateException will be thrown in this case.Copyright © 2006–2017 Hibernate. All rights reserved.