Package ej.service
Interface ServiceLoader
-
- All Known Subinterfaces:
ServiceRegistry,SharedServiceRegistry
- All Known Implementing Classes:
CompositeServiceLoader,DependencyInjectionServiceLoader,FilePropertiesServiceLoader,MetaInfServiceLoader,ServiceLoaderKF,ServiceRegistryKF,SharedServiceRegistryKF,SimpleServiceLoader,SimpleServiceRegistry,SystemPropertiesServiceLoader
public interface ServiceLoaderA simple service loading facility.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:
- dependency injection: the implementation of the service is described in a configuration file (properties file for example) and this implementation is instantiated on demand. Once the instance is created, it is kept for ever.
- service registration: the instance is explicitly registered at runtime by a service provider.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description <T> TgetService(Class<T> service)Gets the instance of the given service.
-
-
-
Method Detail
-
getService
@Nullable <T> T getService(Class<T> service)
Gets the instance of the given service.If there is already an instance in cache, it is returned otherwise a new one is created.
May return
nullif the service is not defined.- Type Parameters:
T- the service type.- Parameters:
service- the service.- Returns:
- the instance of the given service.
- Throws:
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.
-
-