public interface ServiceLoader
A service is usually defined by an interface (but that may be a class). The service loader associates a service with an instance of this service. This instance may be retrieved in different ways:
Modifier and Type | Method and Description |
---|---|
<T> T |
getService(Class<T> service)
Gets the instance of the given service.
|
@Nullable <T> T getService(Class<T> service)
If there is already an instance in cache, it is returned otherwise a new one is created.
May return null
if the service is not defined.
T
- the service type.service
- the service.ServiceLoadingException
- if an error occurs while instantiating the service instance.SecurityException
- if a security manager exists and does not allow the caller to retrieve the given service instance.