Class ApplicationResourceLoader
java.lang.Object
org.springframework.core.io.DefaultResourceLoader
org.springframework.boot.io.ApplicationResourceLoader
- All Implemented Interfaces:
ResourceLoader
Class can be used to obtain
ResourceLoaders supporting
additional ProtocolResolvers registered in
spring.factories.
When not delegating to an existing resource loader, plain paths without a qualifier
will resolve to file system resources. This is different from
DefaultResourceLoader, which resolves unqualified paths to classpath resources.
- Since:
- 3.3.0
- Author:
- Scott Frederick, Moritz Halbritter, Phillip Webb
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceStrategy interface registered inspring.factoriesand used byApplicationResourceLoaderto determine the file path of loaded resource when it can also be represented as aFileSystemResource.Nested classes/interfaces inherited from class DefaultResourceLoader
DefaultResourceLoader.ClassPathContextResource -
Field Summary
Fields inherited from interface ResourceLoader
CLASSPATH_URL_PREFIX -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic ResourceLoaderget()static ResourceLoaderget(@Nullable ClassLoader classLoader) static ResourceLoaderget(@Nullable ClassLoader classLoader, SpringFactoriesLoader springFactoriesLoader) static ResourceLoaderget(@Nullable ClassLoader classLoader, SpringFactoriesLoader springFactoriesLoader, @Nullable Path workingDirectory) static ResourceLoaderget(ResourceLoader resourceLoader) Return aResourceLoaderdelegating to the given resource loader and supporting additionalProtocolResolversregistered inspring.factories.static ResourceLoaderget(ResourceLoader resourceLoader, boolean preferFileResolution) Return aResourceLoaderdelegating to the given resource loader and supporting additionalProtocolResolversregistered inspring.factories.static ResourceLoaderget(ResourceLoader resourceLoader, SpringFactoriesLoader springFactoriesLoader) Return aResourceLoaderdelegating to the given resource loader and supporting additionalProtocolResolversregistered inspring.factories.protected ResourcegetResourceByPath(String path) Methods inherited from class DefaultResourceLoader
addProtocolResolver, clearResourceCaches, getClassLoader, getProtocolResolvers, getResource, getResourceCache, setClassLoader
-
Constructor Details
-
ApplicationResourceLoader
public ApplicationResourceLoader()
-
-
Method Details
-
getResourceByPath
- Overrides:
getResourceByPathin classDefaultResourceLoader
-
get
Return aResourceLoadersupporting additionalProtocolResolversregistered inspring.factories. The factories file will be resolved using the default class loader at the time this call is made. Resources will be resolved using the default class loader at the time they are resolved.- Returns:
- a
ResourceLoaderinstance - Since:
- 3.4.0
-
get
Return aResourceLoadersupporting additionalProtocolResolversregistered inspring.factories. The factories files and resources will be resolved using the specified class loader.- Parameters:
classLoader- the class loader to use ornullto use the default class loader- Returns:
- a
ResourceLoaderinstance - Since:
- 3.4.0
-
get
public static ResourceLoader get(@Nullable ClassLoader classLoader, SpringFactoriesLoader springFactoriesLoader) - Parameters:
classLoader- the class loader to use ornullto use the default class loaderspringFactoriesLoader- theSpringFactoriesLoaderused to loadProtocolResolvers- Returns:
- a
ResourceLoaderinstance - Since:
- 3.4.0
-
get
public static ResourceLoader get(@Nullable ClassLoader classLoader, SpringFactoriesLoader springFactoriesLoader, @Nullable Path workingDirectory) - Parameters:
classLoader- the class loader to use ornullto use the default class loaderspringFactoriesLoader- theSpringFactoriesLoaderused to loadProtocolResolversworkingDirectory- the working directory- Returns:
- a
ResourceLoaderinstance - Since:
- 3.5.0
-
get
Return aResourceLoaderdelegating to the given resource loader and supporting additionalProtocolResolversregistered inspring.factories. The factories file will be resolved using the default class loader at the time this call is made.- Parameters:
resourceLoader- the delegate resource loader- Returns:
- a
ResourceLoaderinstance - Since:
- 3.4.0
-
get
Return aResourceLoaderdelegating to the given resource loader and supporting additionalProtocolResolversregistered inspring.factories. The factories file will be resolved using the default class loader at the time this call is made.- Parameters:
resourceLoader- the delegate resource loaderpreferFileResolution- if file based resolution is preferred when a suitableApplicationResourceLoader.FilePathResolversupport the resource- Returns:
- a
ResourceLoaderinstance - Since:
- 3.4.1
-
get
public static ResourceLoader get(ResourceLoader resourceLoader, SpringFactoriesLoader springFactoriesLoader) Return aResourceLoaderdelegating to the given resource loader and supporting additionalProtocolResolversregistered inspring.factories.- Parameters:
resourceLoader- the delegate resource loaderspringFactoriesLoader- theSpringFactoriesLoaderused to loadProtocolResolvers- Returns:
- a
ResourceLoaderinstance - Since:
- 3.4.0
-