net.thucydides.core.fixtureservices.ClasspathFixtureProviderService Maven / Gradle / Ivy
package net.thucydides.core.fixtureservices;
import java.util.ArrayList;
import java.util.List;
import java.util.ServiceLoader;
/**
* Load any implementations of the FixtureService class declared on the classpath.
* FixtureService implementations must be declared in a file called net.thucydides.core.fixtureservices.FixtureService
* in the META-INF/services directory somewhere on the classpath.
*/
public class ClasspathFixtureProviderService implements FixtureProviderService {
private volatile List fixtureServices;
@Override
public List getFixtureServices() {
List result = fixtureServices;
if (result == null) {
synchronized (this) {
result = fixtureServices;
if (result == null) {
result = new ArrayList<>();
ServiceLoader fixtureServiceLoader = ServiceLoader.load(FixtureService.class);
for (FixtureService fixtureService : fixtureServiceLoader) {
result.add(fixtureService);
}
fixtureServices = result;
}
}
}
return result;
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy