org.springframework.core.io

Class DefaultResourceLoader

    • Constructor Detail

      • DefaultResourceLoader

        public DefaultResourceLoader()
        Create a new DefaultResourceLoader.

        ClassLoader access will happen using the thread context class loader at the time of this ResourceLoader's initialization.

        See Also:
        Thread.getContextClassLoader()
      • DefaultResourceLoader

        public DefaultResourceLoader(ClassLoader classLoader)
        Create a new DefaultResourceLoader.
        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 Detail

      • setClassLoader

        public void setClassLoader(ClassLoader classLoader)
        Specify the ClassLoader to load class path resources with, or null for using the thread context class loader at the time of actual resource access.

        The default is that ClassLoader access will happen using the thread context class loader at the time of this ResourceLoader's initialization.

      • getClassLoader

        public ClassLoader getClassLoader()
        Return the ClassLoader to load class path resources with.

        Will get passed to ClassPathResource's constructor for all ClassPathResource objects created by this resource loader.

        Specified by:
        getClassLoader in interface  ResourceLoader
        Returns:
        the ClassLoader (only null if even the system ClassLoader isn't accessible)
        See Also:
        ClassPathResource
      • getResourceByPath

        protected Resource getResourceByPath(String path)
        Return a Resource handle for the resource at the given path.

        The default implementation supports class path locations. This should be appropriate for standalone implementations but can be overridden, e.g. for implementations targeted at a Servlet container.

        Parameters:
        path - the path to the resource
        Returns:
        the corresponding Resource handle
        See Also:
        ClassPathResource, org.springframework.context.support.FileSystemXmlApplicationContext#getResourceByPath, org.springframework.web.context.support.XmlWebApplicationContext#getResourceByPath