Package com.microej.kf.util.service
Class ServiceRegistryKF
- java.lang.Object
-
- ej.service.loader.SimpleServiceLoader
-
- ej.service.registry.SimpleServiceRegistry
-
- com.microej.kf.util.service.ServiceRegistryKF
-
- All Implemented Interfaces:
ServiceLoader,ServiceRegistry
public class ServiceRegistryKF extends SimpleServiceRegistry implements ServiceRegistry
The Class ServiceRegistryKF which contains the Local Service mapping for each context.
-
-
Field Summary
-
Fields inherited from class ej.service.loader.SimpleServiceLoader
services
-
-
Constructor Summary
Constructors Constructor Description ServiceRegistryKF()Instantiates a new service registry KF.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <T> TgetService(Class<T> service)Gets the instance of the given service.<T> voidregister(Class<T> service, T instance)Registers a service instance.<T> voidregister(Class<T> service, T instance, boolean isKernelLocal)Registers a Service Instance for the Kernel.<T> voidunregister(Class<T> service, T instance)Unregisters a service instance.<T> voidunregister(Class<T> service, T instance, boolean isKernelLocal)Unregisters a Service Instance from the Kernel.-
Methods inherited from class ej.service.loader.SimpleServiceLoader
checkServicePermission, createAlternativeImplementation, putService
-
-
-
-
Method Detail
-
getService
public <T> T getService(Class<T> service)
Description copied from interface:ServiceLoaderGets the instance of the given service.If there is already an instance in cache, it is returned otherwise a new one is created.
May return
nullif the service is not defined.- Specified by:
getServicein interfaceServiceLoader- Overrides:
getServicein classSimpleServiceLoader- Type Parameters:
T- the service type.- Parameters:
service- the service.- Returns:
- the instance of the given service.
-
register
public <T> void register(Class<T> service, T instance)
Description copied from interface:ServiceRegistryRegisters a service instance.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.
- Specified by:
registerin interfaceServiceRegistry- Overrides:
registerin classSimpleServiceRegistry- Type Parameters:
T- the service type.- Parameters:
service- the implemented service.instance- the service instance.
-
register
public <T> void register(Class<T> service, T instance, boolean isKernelLocal)
Registers a Service Instance for the Kernel.- Parameters:
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 features
-
unregister
public <T> void unregister(Class<T> service, T instance)
Description copied from interface:ServiceRegistryUnregisters a service instance.If the given instance is not the one currently registered for the given service, nothing is done.
- Specified by:
unregisterin interfaceServiceRegistry- Overrides:
unregisterin classSimpleServiceRegistry- Type Parameters:
T- the service type.- Parameters:
service- the implemented service.instance- the service instance.
-
unregister
public <T> void unregister(Class<T> service, T instance, boolean isKernelLocal)
Unregisters a Service Instance from the Kernel.- Parameters:
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
-
-