public class SimpleServiceManager extends Object implements ServiceManager
ServiceManager
.Constructor and Description |
---|
SimpleServiceManager(PluginManager pluginManager)
Construct a simple
ServiceManager . |
Modifier and Type | Method and Description |
---|---|
<T> Optional<ProviderRegistration<T>> |
getRegistration(Class<T> service)
Gets the
ProviderRegistration for the given service, if available. |
<T> Optional<T> |
provide(Class<T> service)
Return a provider for the given service, if one is available.
|
<T> T |
provideUnchecked(Class<T> service)
Return a provider for the given service, raising an unchecked exception
if a provider does not exist.
|
<T> void |
setProvider(Object plugin,
Class<T> service,
T provider)
Register a provider with the service manager.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
isRegistered
@Inject public SimpleServiceManager(PluginManager pluginManager)
ServiceManager
.pluginManager
- The plugin manager to get the
PluginContainer
for a given pluginpublic <T> void setProvider(Object plugin, Class<T> service, T provider)
ServiceManager
Services are by definition replaceable at any given time.
Services should only be registered during initialization. If services are registered later, then they may not be utilized.
setProvider
in interface ServiceManager
T
- The type of serviceplugin
- The instance of a pluginservice
- The serviceprovider
- The implementationpublic <T> Optional<T> provide(Class<T> service)
ServiceManager
The returned provider may be a proxy to the real underlying proxy, depending on the implementation of the service manager.
provide
in interface ServiceManager
T
- The type of serviceservice
- The servicepublic <T> Optional<ProviderRegistration<T>> getRegistration(Class<T> service)
ServiceManager
ProviderRegistration
for the given service, if available.getRegistration
in interface ServiceManager
T
- The type of serviceservice
- The serviceProviderRegistration
, if available.public <T> T provideUnchecked(Class<T> service) throws ProvisioningException
ServiceManager
The returned provider may be a proxy to the real underlying proxy, depending on the implementation of the service manager.
provideUnchecked
in interface ServiceManager
T
- The type of serviceservice
- The serviceProvisioningException
- Thrown if a provider cannot be provisioned