public class ClasspathDependencyInjectorService extends Object implements DependencyInjectorService
DependencyInjector discovered in the classpath.
Thread safety is achieved as the findDependencyInjectors() method
operates only on local variables, therefore eliminating risks of
shared mutable state. However, the thread safety of the returned
DependencyInjector instances will depend on their individual
implementations.
It uses ServiceLoader under the hood to load the implementations
of DependencyInjector.
Usage:
ClasspathDependencyInjectorService service = new ClasspathDependencyInjectorService(); Listinjectors = service.findDependencyInjectors();
| Constructor and Description |
|---|
ClasspathDependencyInjectorService() |
| Modifier and Type | Method and Description |
|---|---|
List<DependencyInjector> |
findDependencyInjectors()
Finds and returns all instances of
DependencyInjector available
in the classpath at the time of invocation. |
public List<DependencyInjector> findDependencyInjectors()
DependencyInjector available
in the classpath at the time of invocation.
The ServiceLoader.load(Class) method is used to discover and
instantiate the DependencyInjector implementations.findDependencyInjectors in interface DependencyInjectorServiceDependencyInjector instances. If no implementations
are found, an empty list is returned.Copyright © 2023. All rights reserved.