public class SharedServiceRegistryKF extends SimpleServiceRegistry implements SharedServiceRegistry, FeatureStateListener
This service registry is able to handle the following kind of services:
Proxy
instancesservices
Constructor and Description |
---|
SharedServiceRegistryKF()
Creates a shared service registry.
|
Modifier and Type | Method and Description |
---|---|
<T> T |
getService(Class<T> serviceClass)
Gets the registered implementation for the given service.
|
<T> void |
register(Class<T> serviceClass,
T implementation)
Registers a service instance.
|
void |
stateChanged(Feature feature,
Feature.State previousState)
Called when the state of a Feature has changed.
|
<T> void |
unregister(Class<T> serviceClass,
T implementation)
Unregisters a service instance.
|
checkServicePermission, createAlternativeImplementation, putService
public SharedServiceRegistryKF()
@Nullable public <T> T getService(Class<T> serviceClass)
getService
in interface ServiceLoader
getService
in class SimpleServiceLoader
T
- the service type.serviceClass
- the service to found.null
if no implementation is available.public <T> void register(Class<T> serviceClass, 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
register
in class SimpleServiceRegistry
T
- the service type.serviceClass
- the implemented service.implementation
- the service instance.public void stateChanged(@Nullable Feature feature, @Nullable Feature.State previousState)
FeatureStateListener
stateChanged
in interface FeatureStateListener
feature
- the Feature which state has changedpreviousState
- the previous state, null
if Feature state is Feature.State.INSTALLED
public <T> void unregister(Class<T> serviceClass, T implementation)
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.serviceClass
- the implemented service.implementation
- the service instance.