Browse Source

Revise signature of SpringFactoriesLoader.forResourceLocation(...)

When an overloaded method accepts additional "optional" arguments, we
typically declare the optional arguments after the required arguments.
For example, see the constructors for ClassPathResource.

This commit therefore revises the signature of the overloaded
forResourceLocation() method so that the optional ClassLoader argument
follows the required `String resourceLocation` argument.
pull/26393/head
Sam Brannen 4 years ago
parent
commit
789329fa3b
  1. 4
      spring-beans/src/main/java/org/springframework/beans/factory/aot/AotFactoriesLoader.java
  2. 10
      spring-core/src/main/java/org/springframework/core/io/support/SpringFactoriesLoader.java

4
spring-beans/src/main/java/org/springframework/beans/factory/aot/AotFactoriesLoader.java

@ -62,8 +62,8 @@ public class AotFactoriesLoader { @@ -62,8 +62,8 @@ public class AotFactoriesLoader {
ClassLoader classLoader = (beanFactory instanceof ConfigurableBeanFactory configurableBeanFactory)
? configurableBeanFactory.getBeanClassLoader() : null;
this.beanFactory = beanFactory;
this.factoriesLoader = SpringFactoriesLoader.forResourceLocation(classLoader,
FACTORIES_RESOURCE_LOCATION);
this.factoriesLoader = SpringFactoriesLoader.forResourceLocation(FACTORIES_RESOURCE_LOCATION,
classLoader);
}
/**

10
spring-core/src/main/java/org/springframework/core/io/support/SpringFactoriesLoader.java

@ -296,7 +296,7 @@ public class SpringFactoriesLoader { @@ -296,7 +296,7 @@ public class SpringFactoriesLoader {
* @see #forDefaultResourceLocation()
*/
public static SpringFactoriesLoader forDefaultResourceLocation(@Nullable ClassLoader classLoader) {
return forResourceLocation(classLoader, FACTORIES_RESOURCE_LOCATION);
return forResourceLocation(FACTORIES_RESOURCE_LOCATION, classLoader);
}
/**
@ -306,24 +306,24 @@ public class SpringFactoriesLoader { @@ -306,24 +306,24 @@ public class SpringFactoriesLoader {
* @param resourceLocation the resource location to look for factories
* @return a {@link SpringFactoriesLoader} instance
* @since 6.0
* @see #forResourceLocation(ClassLoader, String)
* @see #forResourceLocation(String, ClassLoader)
*/
public static SpringFactoriesLoader forResourceLocation(String resourceLocation) {
return forResourceLocation(null, resourceLocation);
return forResourceLocation(resourceLocation, null);
}
/**
* Create a {@link SpringFactoriesLoader} instance that will load and
* instantiate the factory implementations from the given location, using
* the given class loader.
* @param resourceLocation the resource location to look for factories
* @param classLoader the ClassLoader to use for loading resources; can be
* {@code null} to use the default
* @param resourceLocation the resource location to look for factories
* @return a {@link SpringFactoriesLoader} instance
* @since 6.0
* @see #forResourceLocation(String)
*/
public static SpringFactoriesLoader forResourceLocation(@Nullable ClassLoader classLoader, String resourceLocation) {
public static SpringFactoriesLoader forResourceLocation(String resourceLocation, @Nullable ClassLoader classLoader) {
Assert.hasText(resourceLocation, "'resourceLocation' must not be empty");
ClassLoader resourceClassLoader = (classLoader != null ? classLoader :
SpringFactoriesLoader.class.getClassLoader());

Loading…
Cancel
Save