Class DefaultClassPathResourceLoader

    • Constructor Summary

      Constructors 
      Constructor Description
      DefaultClassPathResourceLoader​(java.lang.ClassLoader classLoader)
      Default constructor.
      DefaultClassPathResourceLoader​(java.lang.ClassLoader classLoader, java.lang.String basePath)
      Use when resources should have a standard base path.
      DefaultClassPathResourceLoader​(java.lang.ClassLoader classLoader, java.lang.String basePath, boolean checkBase)
      Use when resources should have a standard base path.
      DefaultClassPathResourceLoader​(java.lang.ClassLoader classLoader, java.lang.String basePath, boolean checkBase, boolean logEnabled)
      Use when resources should have a standard base path.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      ResourceLoader forBase​(java.lang.String basePath)
      Constructs a new resource loader designed to load resources from the given path.
      ResourceLoader forBase​(java.lang.String basePath, boolean logEnabled)
      Need this method to ability disable Slf4J initizalization.
      java.lang.ClassLoader getClassLoader()  
      java.util.Optional<java.net.URL> getResource​(java.lang.String path)
      Obtains a resource URL.
      java.util.Optional<java.io.InputStream> getResourceAsStream​(java.lang.String path)
      Obtains a resource as a stream.
      java.util.stream.Stream<java.net.URL> getResources​(java.lang.String path)
      Obtains a stream of resource URLs.
      • Methods inherited from class java.lang.Object

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

      • DefaultClassPathResourceLoader

        public DefaultClassPathResourceLoader​(java.lang.ClassLoader classLoader)
        Default constructor.
        Parameters:
        classLoader - The class loader for loading resources
      • DefaultClassPathResourceLoader

        public DefaultClassPathResourceLoader​(java.lang.ClassLoader classLoader,
                                              java.lang.String basePath)
        Use when resources should have a standard base path.
        Parameters:
        classLoader - The class loader for loading resources
        basePath - The path to look for resources under
      • DefaultClassPathResourceLoader

        public DefaultClassPathResourceLoader​(java.lang.ClassLoader classLoader,
                                              java.lang.String basePath,
                                              boolean checkBase)
        Use when resources should have a standard base path.
        Parameters:
        classLoader - The class loader for loading resources
        basePath - The path to look for resources under
        checkBase - If set to true an extended check for the base path is performed otherwise paths with relative URLs like ../ are prohibited.
      • DefaultClassPathResourceLoader

        public DefaultClassPathResourceLoader​(java.lang.ClassLoader classLoader,
                                              java.lang.String basePath,
                                              boolean checkBase,
                                              boolean logEnabled)
        Use when resources should have a standard base path.
        Parameters:
        classLoader - The class loader for loading resources
        basePath - The path to look for resources under
        checkBase - If set to true an extended check for the base path is performed otherwise paths with relative URLs like ../ are prohibited.
        logEnabled - flag to enable or disable logger
    • Method Detail

      • getResourceAsStream

        public java.util.Optional<java.io.InputStream> getResourceAsStream​(java.lang.String path)
        Obtains a resource as a stream.
        Specified by:
        getResourceAsStream in interface ResourceLoader
        Parameters:
        path - The path
        Returns:
        An optional resource
      • getResource

        public java.util.Optional<java.net.URL> getResource​(java.lang.String path)
        Obtains a resource URL.
        Specified by:
        getResource in interface ResourceLoader
        Parameters:
        path - The path
        Returns:
        An optional resource
      • getResources

        public java.util.stream.Stream<java.net.URL> getResources​(java.lang.String path)
        Obtains a stream of resource URLs.
        Specified by:
        getResources in interface ResourceLoader
        Parameters:
        path - The path
        Returns:
        A resource stream
      • getClassLoader

        public java.lang.ClassLoader getClassLoader()
        Specified by:
        getClassLoader in interface ClassPathResourceLoader
        Returns:
        The class loader used to retrieve resources
      • forBase

        public ResourceLoader forBase​(java.lang.String basePath)
        Description copied from interface: ResourceLoader
        Constructs a new resource loader designed to load resources from the given path. Requested resources will be loaded within the context of the given path.
        Specified by:
        forBase in interface ResourceLoader
        Parameters:
        basePath - The path to load resources
        Returns:
        The resource loader
      • forBase

        public ResourceLoader forBase​(java.lang.String basePath,
                                      boolean logEnabled)
        Need this method to ability disable Slf4J initizalization.
        Parameters:
        basePath - The path to load resources
        logEnabled - flag to enable or disable logger
        Returns:
        The resource loader