Skip to content

io microsphere spring core io support SpringFactoriesLoaderUtils

github-actions[bot] edited this page Jul 11, 2026 · 26 revisions

SpringFactoriesLoaderUtils

Type: Class | Module: microsphere-spring-context | Package: io.microsphere.spring.core.io.support | Since: 1.0.0

Source: microsphere-spring-context/src/main/java/io/microsphere/spring/core/io/support/SpringFactoriesLoaderUtils.java

Overview

The utilities class for SpringFactoriesLoader

Declaration

public abstract class SpringFactoriesLoaderUtils implements Utils

Author: Mercy

Version Information

  • Introduced in: 1.0.0
  • Current Project Version: 0.2.36-SNAPSHOT

Version Compatibility

This component is tested and compatible with the following Java versions:

Java Version Status
Java 17 ✅ Compatible
Java 21 ✅ Compatible
Java 25 ✅ Compatible

Usage

Maven Dependency

Add the following dependency to your pom.xml:

<dependency>
    <groupId>io.github.microsphere-projects</groupId>
    <artifactId>microsphere-spring-context</artifactId>
    <version>${microsphere-spring.version}</version>
</dependency>

Tip: Use the BOM (microsphere-spring-dependencies) for consistent version management. See the Getting Started guide.

Import

import io.microsphere.spring.core.io.support.SpringFactoriesLoaderUtils;

API Reference

Public Methods

Method Description
loadFactoryClasses Load the fully qualified classes of factory implementations of the
loadFactoryClasses Load the fully qualified classes of factory implementations of the
loadFactoryNames Load the fully qualified class names of factory implementations of the
loadFactoryNames Load the fully qualified class names of factory implementations of the
loadFactories Load the factory implementations of the given type from SpringFactoriesLoader#FACTORIES_RESOURCE_LOCATION,
loadFactories Load the factory implementations of the given type from SpringFactoriesLoader#FACTORIES_RESOURCE_LOCATION,
loadFactories Load the factory implementations of the given type from SpringFactoriesLoader#FACTORIES_RESOURCE_LOCATION,
loadFactories Load the factory implementations of the given type from SpringFactoriesLoader#FACTORIES_RESOURCE_LOCATION,

Method Details

loadFactoryClasses

public static <T> Set<Class<T>> loadFactoryClasses(Class<T> factoryType)

Load the fully qualified classes of factory implementations of the given type from SpringFactoriesLoader#FACTORIES_RESOURCE_LOCATION, using the default class loader.

If a particular implementation class name is discovered more than once for the given factory type, duplicates will be ignored.

loadFactoryClasses

public static <T> Set<Class<T>> loadFactoryClasses(Class<?> factoryType, @Nullable ClassLoader classLoader)

Load the fully qualified classes of factory implementations of the given type from SpringFactoriesLoader#FACTORIES_RESOURCE_LOCATION, using the given class loader.

If a particular implementation class name is discovered more than once for the given factory type, duplicates will be ignored.

loadFactoryNames

public static List<String> loadFactoryNames(Class<?> factoryType)

Load the fully qualified class names of factory implementations of the given type from SpringFactoriesLoader#FACTORIES_RESOURCE_LOCATION, using the default class loader.

If a particular implementation class name is discovered more than once for the given factory type, duplicates will be ignored.

loadFactoryNames

public static List<String> loadFactoryNames(Class<?> factoryType, @Nullable ClassLoader classLoader)

Load the fully qualified class names of factory implementations of the given type from SpringFactoriesLoader#FACTORIES_RESOURCE_LOCATION, using the given class loader.

If a particular implementation class name is discovered more than once for the given factory type, duplicates will be ignored.

loadFactories

public static <T> List<T> loadFactories(@Nullable ApplicationContext context, Class<T> factoryType)

Load the factory implementations of the given type from SpringFactoriesLoader#FACTORIES_RESOURCE_LOCATION, using the given ApplicationContext's class loader.

The returned factories will be invoked with org.springframework.beans.factory.Aware interfaces and other bean lifecycle callbacks if the context is a ConfigurableApplicationContext.

loadFactories

public static <T> List<T> loadFactories(@Nullable ConfigurableApplicationContext context, Class<T> factoryType)

Load the factory implementations of the given type from SpringFactoriesLoader#FACTORIES_RESOURCE_LOCATION, using the given ConfigurableApplicationContext's class loader.

The returned factories will be invoked with org.springframework.beans.factory.Aware interfaces and other bean lifecycle callbacks.

loadFactories

public static <T> List<T> loadFactories(@Nullable ConfigurableApplicationContext context, Class<T> factoryType, Object... args)

Load the factory implementations of the given type from SpringFactoriesLoader#FACTORIES_RESOURCE_LOCATION, using the given ConfigurableApplicationContext's class loader and constructor arguments.

The returned factories will be invoked with org.springframework.beans.factory.Aware interfaces and other bean lifecycle callbacks.

This method attempts to find a matching constructor for each factory implementation class based on the provided arguments. If no arguments are provided, it delegates to #loadFactories(ConfigurableApplicationContext, Class).

loadFactories

public static <T> List<T> loadFactories(@Nullable BeanFactory beanFactory, Class<T> factoryType)

Load the factory implementations of the given type from SpringFactoriesLoader#FACTORIES_RESOURCE_LOCATION, using the given BeanFactory's class loader.

If the BeanFactory is an ApplicationContext, it delegates to #loadFactories(ApplicationContext, Class). Otherwise, it uses the BeanFactory's bean class loader to load factories and invokes org.springframework.beans.factory.Aware interfaces on the instantiated factories.

See Also

  • SpringFactoriesLoader

This documentation was auto-generated from the source code of microsphere-spring.

Home

spring-context

spring-guice

spring-jdbc

spring-test

spring-web

spring-webflux

spring-webmvc

Clone this wiki locally