public abstract class SpringFactoriesLoader extends Object
The SpringFactoriesLoader
loads and instantiates factories of a given type
from "META-INF/spring.factories" files. The file should be in Properties
format,
where the key is the fully qualified interface or abstract class name, and the value
is a comma-separated list of implementation class names. For instance:
example.MyService=example.MyServiceImpl1,example.MyServiceImpl2where
MyService
is the name of the interface, and MyServiceImpl1
and
MyServiceImpl2
are the two implementations.Constructor and Description |
---|
SpringFactoriesLoader() |
Modifier and Type | Method and Description |
---|---|
static <T> List<T> |
loadFactories(Class<T> factoryClass,
ClassLoader classLoader)
Load the factory implementations of the given type from the default location,
using the given class loader.
|
static List<String> |
loadFactoryNames(Class<?> factoryClass,
ClassLoader classLoader) |
public static <T> List<T> loadFactories(Class<T> factoryClass, ClassLoader classLoader)
The returned factories are ordered in accordance with the OrderComparator
.
factoryClass
- the interface or abstract class representing the factoryclassLoader
- the ClassLoader to use for loading (can be null
to use the default)public static List<String> loadFactoryNames(Class<?> factoryClass, ClassLoader classLoader)