Package net.thucydides.model.steps.di
Class ClasspathDependencyInjectorService
java.lang.Object
net.thucydides.model.steps.di.ClasspathDependencyInjectorService
- All Implemented Interfaces:
DependencyInjectorService
This class is responsible for loading and returning instances of
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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionFinds and returns all instances ofDependencyInjectoravailable in the classpath at the time of invocation.
-
Constructor Details
-
ClasspathDependencyInjectorService
public ClasspathDependencyInjectorService()
-
-
Method Details
-
findDependencyInjectors
Finds and returns all instances ofDependencyInjectoravailable in the classpath at the time of invocation. TheServiceLoader.load(Class)method is used to discover and instantiate theDependencyInjectorimplementations.- Specified by:
findDependencyInjectorsin interfaceDependencyInjectorService- Returns:
- a list of
DependencyInjectorinstances. If no implementations are found, an empty list is returned.
-