public interface ServiceLoader extends ServiceProvider
Modifier and Type | Method and Description |
---|---|
<T> T |
getService(Class<T> service)
Gets the instance of the given service.
|
<T> T |
getService(Class<T> service,
boolean singleton)
Gets the registered implementation for the given service.
|
<T> T |
getService(Class<T> service,
Class<? extends T> defaultImplementation)
Gets the registered implementation for the given service.
|
<T> T |
getService(Class<T> service,
Class<? extends T> defaultImplementation,
boolean singleton)
Gets the registered implementation for the given service.
|
<T> T getService(Class<T> service)
Equivalent to calling getService(Class, boolean)
passing @{code true} as @{code singleton}.
getService
in interface ServiceProvider
T
- the service type.service
- the service.<T> T getService(Class<T> service, boolean singleton) throws ServiceLoadingException
If a singleton is asked and if an instance of this service has already been created, this instance is returned. Otherwise, creates a new instance of the implementation type.
T
- the service type.service
- the service.singleton
- if true
returns an already created instance if any, creates a new one otherwise.null
if no implementation is available.ServiceLoadingException
- if an error occurs while instantiating the service implementation.<T> T getService(Class<T> service, Class<? extends T> defaultImplementation)
T
- the service type.service
- the service.defaultImplementation
- the default implementation to use.<T> T getService(Class<T> service, Class<? extends T> defaultImplementation, boolean singleton)
If a singleton is asked and if an instance of this service has already been created, this instance is returned. Otherwise, creates a new instance of the implementation type.
T
- the service type.service
- the service.defaultImplementation
- the default implementation to use.singleton
- if true
returns an already created instance if any, creates a new one otherwise.null
if no implementation is available.ServiceLoadingException
- if an error occurs while instantiating the service implementation.