public class ServiceRegistryKF extends SimpleServiceRegistry implements ServiceRegistry
services
Constructor and Description |
---|
ServiceRegistryKF()
Instantiates a new service registry KF.
|
Modifier and Type | Method and Description |
---|---|
<T> T |
getService(Class<T> service)
Gets the instance of the given service.
|
<T> void |
register(Class<T> service,
T instance)
Registers a service instance.
|
<T> void |
register(Class<T> service,
T instance,
boolean isKernelLocal)
Registers a Service Instance for the Kernel.
|
<T> void |
unregister(Class<T> service,
T instance)
Unregisters a service instance.
|
<T> void |
unregister(Class<T> service,
T instance,
boolean isKernelLocal)
Unregisters a Service Instance from the Kernel.
|
checkServicePermission, createAlternativeImplementation, putService
public ServiceRegistryKF()
public <T> T getService(Class<T> service)
ServiceLoader
If there is already an instance in cache, it is returned otherwise a new one is created.
May return null
if the service is not defined.
getService
in interface ServiceLoader
getService
in class SimpleServiceLoader
T
- the service type.service
- the service.public <T> void register(Class<T> service, T instance)
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
register
in class SimpleServiceRegistry
T
- the service type.service
- the implemented service.instance
- the service instance.public <T> void register(Class<T> service, T instance, boolean isKernelLocal)
service
- the class type of the serviceinstance
- the instance of the serviceisKernelLocal
- if the service should be stored in the local context of
the Kernel or shared with other featurespublic <T> void unregister(Class<T> service, T instance)
ServiceRegistry
If the given instance is not the one currently registered for the given service, nothing is done.
unregister
in interface ServiceRegistry
unregister
in class SimpleServiceRegistry
T
- the service type.service
- the implemented service.instance
- the service instance.public <T> void unregister(Class<T> service, T instance, boolean isKernelLocal)
service
- the class type of the serviceinstance
- the instance of the serviceisKernelLocal
- if the service should be removed from the local context
of the Kernel or shared with other features