public class SimpleServiceRegistry extends SimpleServiceLoader implements ServiceRegistry
services
Constructor and Description |
---|
SimpleServiceRegistry() |
Modifier and Type | Method and Description |
---|---|
<T> void |
register(Class<T> service,
T implementation)
Registers a service instance.
|
<T> void |
unregister(Class<T> service,
T implementation)
Unregisters a service instance.
|
checkServicePermission, createAlternativeImplementation, getService, putService
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getService
public <T> void register(Class<T> service, T implementation)
ServiceRegistry
The given instance is returned each time the service is requested by ServiceLoader.getService(Class)
.
If the service already has a registered instance, the previous one is replaced.
register
in interface ServiceRegistry
T
- the service type.service
- the implemented service.implementation
- the service instance.public <T> void unregister(Class<T> service, T implementation)
ServiceRegistry
If the given instance is not the one currently registered for the given service, nothing is done.
unregister
in interface ServiceRegistry
T
- the service type.service
- the implemented service.implementation
- the service instance.