Package ej.service
Interface ServiceRegistry
-
- All Superinterfaces:
ServiceLoader
- All Known Subinterfaces:
SharedServiceRegistry
- All Known Implementing Classes:
ServiceRegistryKF,SharedServiceRegistryKF,SimpleServiceRegistry
public interface ServiceRegistry extends ServiceLoader
An extension of service loader that allows to register services dynamically.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description <T> voidregister(Class<T> service, T instance)Registers a service instance.<T> voidunregister(Class<T> service, T instance)Unregisters a service instance.-
Methods inherited from interface ej.service.ServiceLoader
getService
-
-
-
-
Method Detail
-
register
<T> void register(Class<T> service, T instance)
Registers 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.
- Type Parameters:
T- the service type.- Parameters:
service- the implemented service.instance- the service instance.- Throws:
SecurityException- if a security manager exists and does not allow the caller to register the given service instance.
-
unregister
<T> void unregister(Class<T> service, T instance)
Unregisters a service instance.If the given instance is not the one currently registered for the given service, nothing is done.
- Type Parameters:
T- the service type.- Parameters:
service- the implemented service.instance- the service instance.- Throws:
SecurityException- if a security manager exists and does not allow the caller to unregister the given service instance.
-
-