Package ej.service.loader
Class CompositeServiceLoader
- java.lang.Object
-
- ej.service.loader.SimpleServiceLoader
-
- ej.service.loader.CompositeServiceLoader
-
- All Implemented Interfaces:
ServiceLoader
- Direct Known Subclasses:
ServiceLoaderKF
public class CompositeServiceLoader extends SimpleServiceLoader
A composite service loader contains a list a service loaders. It searches the requested services in its children sequentially respecting the order they are added.
-
-
Field Summary
-
Fields inherited from class ej.service.loader.SimpleServiceLoader
services
-
-
Constructor Summary
Constructors Constructor Description CompositeServiceLoader()Creates a new empty composite service loader.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddServiceLoader(ServiceLoader serviceLoader)Adds a service loader at the end of the list a service loaders used by this composite service loader.<T> TgetService(Class<T> service)Gets the instance of the given service.-
Methods inherited from class ej.service.loader.SimpleServiceLoader
checkServicePermission, createAlternativeImplementation, putService
-
-
-
-
Method Detail
-
addServiceLoader
public void addServiceLoader(ServiceLoader serviceLoader)
Adds a service loader at the end of the list a service loaders used by this composite service loader.- Parameters:
serviceLoader- the service loader to add.- Throws:
NullPointerException- if the given service loader isnull.
-
getService
@Nullable public <T> T getService(Class<T> service)
Description copied from interface:ServiceLoaderGets 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.- Specified by:
getServicein interfaceServiceLoader- Overrides:
getServicein classSimpleServiceLoader- Type Parameters:
T- the service type.- Parameters:
service- the service.- Returns:
- the instance of the given service.
-
-