org.springframework.core.io.support

Class 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 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.MyServiceImpl2
    where MyService is the name of the interface, and MyServiceImpl1 and MyServiceImpl2 are the two implementations.
    Since:
    3.2
    Author:
    Arjen Poutsma, Juergen Hoeller
    • Constructor Detail

      • SpringFactoriesLoader

        public SpringFactoriesLoader()
    • 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 be null to use the default)