public interface ServiceRegistry extends ServiceLoader
| Modifier and Type | Method and Description | 
|---|---|
| <T> void | register(Class<T> service,
        T instance)Registers a service instance. | 
| <T> void | unregister(Class<T> service,
          T instance)Unregisters a service instance. | 
getService<T> void register(Class<T> service, T 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.
T - the service type.service - the implemented service.instance - the service instance.SecurityException - if a security manager exists and does not allow the caller to register the given service instance.<T> void unregister(Class<T> service, T instance)
If the given instance is not the one currently registered for the given service, nothing is done.
T - the service type.service - the implemented service.instance - the service instance.SecurityException - if a security manager exists and does not allow the caller to unregister the given service instance.