Package ej.service.loader
Class DependencyInjectionServiceLoader
- java.lang.Object
-
- ej.service.loader.SimpleServiceLoader
-
- ej.service.loader.DependencyInjectionServiceLoader
-
- All Implemented Interfaces:
ServiceLoader
- Direct Known Subclasses:
FilePropertiesServiceLoader,MetaInfServiceLoader,SystemPropertiesServiceLoader
public abstract class DependencyInjectionServiceLoader extends SimpleServiceLoader
Service loader implementation that creates service instance from a declared implementation class name.Subclasses need to provide the implementation class name matching the requested services. The implementation is then instantiated using
Class.forName(String)andClass.newInstance(). The singletons are stored in a map.
-
-
Field Summary
-
Fields inherited from class ej.service.loader.SimpleServiceLoader
services
-
-
Constructor Summary
Constructors Constructor Description DependencyInjectionServiceLoader()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected <T> TcreateAlternativeImplementation(Class<T> service)Creates an implementation for the given service and save it in the cache.protected abstract StringgetImplementationName(String serviceName)Gets the implementation class name for the given service name.-
Methods inherited from class ej.service.loader.SimpleServiceLoader
checkServicePermission, getService, putService
-
-
-
-
Method Detail
-
createAlternativeImplementation
@Nullable protected <T> T createAlternativeImplementation(Class<T> service)
Description copied from class:SimpleServiceLoaderCreates an implementation for the given service and save it in the cache.- Overrides:
createAlternativeImplementationin classSimpleServiceLoader- Type Parameters:
T- the service type.- Parameters:
service- the service.- Returns:
- a new instance of the given service or
null.
-
-