org.springframework.core.io.support
Class SpringFactoriesLoader
- java.lang.Object
-
- org.springframework.core.io.support.SpringFactoriesLoader
public abstract class SpringFactoriesLoader extends Object
General purpose factory loading mechanism for internal use within the framework.The
SpringFactoriesLoader
loads and instantiates factories of a given type from "META-INF/spring.factories" files. The file should be inProperties
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.MyServiceImpl2
whereMyService
is the name of the interface, andMyServiceImpl1
andMyServiceImpl2
are the two implementations.- Since:
- 3.2
- Author:
- Arjen Poutsma, Juergen Hoeller
-
Constructor Summary
Constructors Constructor and Description SpringFactoriesLoader()
Method Summary
Methods 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)
-
Method Detail
loadFactories
public 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.The returned factories are ordered in accordance with the
OrderComparator
.- Parameters:
-
factoryClass
- the interface or abstract class representing the factory -
classLoader
- the ClassLoader to use for loading (can benull
to use the default)
loadFactoryNames
public static List<String> loadFactoryNames(Class<?> factoryClass, ClassLoader classLoader)