public class SafeServiceLoader extends Object
META-INF/services
using a given class loader,
avoiding the system class loader used by java.util.ServiceLoader
.Constructor and Description |
---|
SafeServiceLoader(ClassLoader classLoader)
Constructs a service loader using the given class loader.
|
Modifier and Type | Method and Description |
---|---|
<T> List<T> |
load(String serviceType)
Returns a list of service instances for the given a service type, finding all
META-INF/services resources for the given type and loading and instantiating all classes
listed in these resources.
|
public SafeServiceLoader(ClassLoader classLoader)
classLoader
- public <T> List<T> load(String serviceType)
A class that cannot be loaded by the class loader passed to the constructor of this class is silently ignored.
serviceType
- fully qualified service class nameNoServiceProviderException
- if a resource cannot be read or if a loaded class cannot
be instantiatedCopyright © 2006–2019 OPS4J - Open Participation Software for Java. All rights reserved.