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()
.
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.
Modifier and Type | Method and Description |
---|---|
ClassLoaderService |
getClassLoaderService()
Provides direct access to the
ClassLoaderService . |
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> |
requestReference(Class<S> serviceRole)
Gets a reference to the service with the requested 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 null
SearchException
- in case no service fulfilling the role could be locatedIllegalStateException
- in case this method is called after releaseService(Class)
<S extends Service> ServiceReference<S> requestReference(Class<S> serviceRole)
S
- the type of the serviceserviceRole
- the service to retrieve. Cannot be null
.IllegalArgumentException
- in case the serviceRole
is null
SearchException
- 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 null
void releaseAllServices()
IllegalStateException
will be thrown in this case.ClassLoaderService getClassLoaderService()
ClassLoaderService
.
This service lookup is treated as a special case both for convenience and performance reasons.ClassLoaderService
Copyright © 2006-2017 Red Hat, Inc. All Rights Reserved