Package com.microej.kf.util.service
Class SharedServiceRegistryKF
- java.lang.Object
-
- ej.service.loader.SimpleServiceLoader
-
- ej.service.registry.SimpleServiceRegistry
-
- com.microej.kf.util.service.SharedServiceRegistryKF
-
- All Implemented Interfaces:
SharedServiceRegistry,ej.kf.FeatureStateListener,ej.service.ServiceLoader,ej.service.ServiceRegistry
public class SharedServiceRegistryKF extends ej.service.registry.SimpleServiceRegistry implements SharedServiceRegistry, ej.kf.FeatureStateListener
Implementation of the shared service registry over Kernel and Features.This service registry is able to handle the following kind of services:
- Services owned by the kernel, available to the kernel and the features (provided that the type is part of the API)
- Services owned by a feature using shared interfaces mechanism, available to other features through
Proxyinstances - Services owned by a feature using an interface owned by the kernel, only available to the kernel (kernel extensions)
- Services owned by a feature using a type owned by the feature, only available to the feature
-
-
Constructor Summary
Constructors Constructor Description SharedServiceRegistryKF()Creates a shared service registry.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <T> TgetService(java.lang.Class<T> serviceClass)Gets the registered implementation for the given service.<T> voidregister(java.lang.Class<T> serviceClass, T implementation)voidstateChanged(ej.kf.Feature feature, ej.kf.Feature.State previousState)<T> voidunregister(java.lang.Class<T> serviceClass, T implementation)
-
-
-
Method Detail
-
register
public <T> void register(java.lang.Class<T> serviceClass, T implementation)- Specified by:
registerin interfaceej.service.ServiceRegistry- Overrides:
registerin classej.service.registry.SimpleServiceRegistry
-
unregister
public <T> void unregister(java.lang.Class<T> serviceClass, T implementation)- Specified by:
unregisterin interfaceej.service.ServiceRegistry- Overrides:
unregisterin classej.service.registry.SimpleServiceRegistry
-
getService
@Nullable public <T> T getService(java.lang.Class<T> serviceClass)
Gets the registered implementation for the given service. This implementation depends on who request it. if it is a feature we search the service with the following order:- We search it in the shared services provided by the current feature.
- We search it in the shared services provided by the kernel.
- We search it in the shared services provided by the trusted features.
- We search it in the shared services provided by the non trusted features.
- We search it in the shared services provided by the kernel.
- We search it in the shared services provided by the trusted features.
- We search it in the shared services provided by the non trusted features.
- Specified by:
getServicein interfaceej.service.ServiceLoader- Overrides:
getServicein classej.service.loader.SimpleServiceLoader- Type Parameters:
T- the service type.- Parameters:
serviceClass- the service to found.- Returns:
- an instance of the given service or
nullif no implementation is available.
-
stateChanged
public void stateChanged(@Nullable ej.kf.Feature feature, @Nullable ej.kf.Feature.State previousState)- Specified by:
stateChangedin interfaceej.kf.FeatureStateListener
-
-