Class ApplicationResourceLoader

java.lang.Object
org.springframework.core.io.DefaultResourceLoader
org.springframework.boot.io.ApplicationResourceLoader
All Implemented Interfaces:
org.springframework.core.io.ResourceLoader

public class ApplicationResourceLoader extends org.springframework.core.io.DefaultResourceLoader
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
  • Nested Class Summary

    Nested classes/interfaces inherited from class org.springframework.core.io.DefaultResourceLoader

    org.springframework.core.io.DefaultResourceLoader.ClassPathContextResource
  • Field Summary

    Fields inherited from interface org.springframework.core.io.ResourceLoader

    CLASSPATH_URL_PREFIX
  • Constructor Summary

    Constructors
    Constructor
    Description
    Deprecated, for removal: This API element is subject to removal in a future version.
    since 3.4.0 for removal in 3.6.0 in favor of get()
    Deprecated, for removal: This API element is subject to removal in a future version.
    since 3.4.0 for removal in 3.6.0 in favor of get(ClassLoader)
  • Method Summary

    Modifier and Type
    Method
    Description
    static org.springframework.core.io.ResourceLoader
    get()
    Return a ResourceLoader supporting additional ProtocolResolvers registered in spring.factories.
    static org.springframework.core.io.ResourceLoader
    get(ClassLoader classLoader)
    Return a ResourceLoader supporting additional ProtocolResolvers registered in spring.factories.
    static org.springframework.core.io.ResourceLoader
    get(ClassLoader classLoader, org.springframework.core.io.support.SpringFactoriesLoader springFactoriesLoader)
    Return a ResourceLoader supporting additional ProtocolResolvers registered in spring.factories.
    static org.springframework.core.io.ResourceLoader
    get(org.springframework.core.io.ResourceLoader resourceLoader)
    Return a ResourceLoader delegating to the given resource loader and supporting additional ProtocolResolvers registered in spring.factories.
    static org.springframework.core.io.ResourceLoader
    get(org.springframework.core.io.ResourceLoader resourceLoader, boolean preferFileResolution)
    Return a ResourceLoader delegating to the given resource loader and supporting additional ProtocolResolvers registered in spring.factories.
    static org.springframework.core.io.ResourceLoader
    get(org.springframework.core.io.ResourceLoader resourceLoader, org.springframework.core.io.support.SpringFactoriesLoader springFactoriesLoader)
    Return a ResourceLoader delegating to the given resource loader and supporting additional ProtocolResolvers registered in spring.factories.
    protected org.springframework.core.io.Resource
     

    Methods inherited from class org.springframework.core.io.DefaultResourceLoader

    addProtocolResolver, clearResourceCaches, getClassLoader, getProtocolResolvers, getResource, getResourceCache, setClassLoader

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • ApplicationResourceLoader

      @Deprecated(since="3.4.0", forRemoval=true) public ApplicationResourceLoader()
      Deprecated, for removal: This API element is subject to removal in a future version.
      since 3.4.0 for removal in 3.6.0 in favor of get()
      Create a new ApplicationResourceLoader.
    • ApplicationResourceLoader

      @Deprecated(since="3.4.0", forRemoval=true) public ApplicationResourceLoader(ClassLoader classLoader)
      Deprecated, for removal: This API element is subject to removal in a future version.
      since 3.4.0 for removal in 3.6.0 in favor of get(ClassLoader)
      Create a new ApplicationResourceLoader.
      Parameters:
      classLoader - the ClassLoader to load class path resources with, or null for using the thread context class loader at the time of actual resource access
  • Method Details

    • getResourceByPath

      protected org.springframework.core.io.Resource getResourceByPath(String path)
      Overrides:
      getResourceByPath in class org.springframework.core.io.DefaultResourceLoader
    • get

      public static org.springframework.core.io.ResourceLoader get()
      Return a ResourceLoader supporting additional ProtocolResolvers registered in spring.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 ResourceLoader instance
      Since:
      3.4.0
    • get

      public static org.springframework.core.io.ResourceLoader get(ClassLoader classLoader)
      Return a ResourceLoader supporting additional ProtocolResolvers registered in spring.factories. The factories files and resources will be resolved using the specified class loader.
      Parameters:
      classLoader - the class loader to use or null to use the default class loader
      Returns:
      a ResourceLoader instance
      Since:
      3.4.0
    • get

      public static org.springframework.core.io.ResourceLoader get(ClassLoader classLoader, org.springframework.core.io.support.SpringFactoriesLoader springFactoriesLoader)
      Return a ResourceLoader supporting additional ProtocolResolvers registered in spring.factories.
      Parameters:
      classLoader - the class loader to use or null to use the default class loader
      springFactoriesLoader - the SpringFactoriesLoader used to load ProtocolResolvers
      Returns:
      a ResourceLoader instance
      Since:
      3.4.0
    • get

      public static org.springframework.core.io.ResourceLoader get(org.springframework.core.io.ResourceLoader resourceLoader)
      Return a ResourceLoader delegating to the given resource loader and supporting additional ProtocolResolvers registered in spring.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 ResourceLoader instance
      Since:
      3.4.0
    • get

      public static org.springframework.core.io.ResourceLoader get(org.springframework.core.io.ResourceLoader resourceLoader, boolean preferFileResolution)
      Return a ResourceLoader delegating to the given resource loader and supporting additional ProtocolResolvers registered in spring.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
      preferFileResolution - if file based resolution is preferred over ServletContextResource or ClassPathResource when no resource prefix is provided.
      Returns:
      a ResourceLoader instance
      Since:
      3.4.1
    • get

      public static org.springframework.core.io.ResourceLoader get(org.springframework.core.io.ResourceLoader resourceLoader, org.springframework.core.io.support.SpringFactoriesLoader springFactoriesLoader)
      Return a ResourceLoader delegating to the given resource loader and supporting additional ProtocolResolvers registered in spring.factories.
      Parameters:
      resourceLoader - the delegate resource loader
      springFactoriesLoader - the SpringFactoriesLoader used to load ProtocolResolvers
      Returns:
      a ResourceLoader instance
      Since:
      3.4.0