Package io.micronaut.core.io.scan
Class DefaultClassPathResourceLoader
java.lang.Object
io.micronaut.core.io.scan.DefaultClassPathResourceLoader
- All Implemented Interfaces:
ResourceLoader
,ClassPathResourceLoader
Loads resources from the classpath.
- Since:
- 1.0
- Author:
- James Kleeh, graemerocher
-
Constructor Summary
ConstructorDescriptionDefaultClassPathResourceLoader
(ClassLoader classLoader) Default constructor.DefaultClassPathResourceLoader
(ClassLoader classLoader, String basePath) Use when resources should have a standard base path.DefaultClassPathResourceLoader
(ClassLoader classLoader, String basePath, boolean checkBase) Use when resources should have a standard base path.DefaultClassPathResourceLoader
(ClassLoader classLoader, String basePath, boolean checkBase, boolean logEnabled) Use when resources should have a standard base path. -
Method Summary
Modifier and TypeMethodDescriptionConstructs a new resource loader designed to load resources from the given path.Need this method to ability disable Slf4J initizalization.getResource
(String path) Obtains a resource URL.getResourceAsStream
(String path) Obtains a resource as a stream.getResources
(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
Methods inherited from interface io.micronaut.core.io.scan.ClassPathResourceLoader
supportsPrefix
-
Constructor Details
-
DefaultClassPathResourceLoader
Default constructor.- Parameters:
classLoader
- The class loader for loading resources
-
DefaultClassPathResourceLoader
Use when resources should have a standard base path.- Parameters:
classLoader
- The class loader for loading resourcesbasePath
- The path to look for resources under
-
DefaultClassPathResourceLoader
Use when resources should have a standard base path.- Parameters:
classLoader
- The class loader for loading resourcesbasePath
- The path to look for resources undercheckBase
- If set totrue
an extended check for the base path is performed otherwise paths with relative URLs like../
are prohibited.
-
DefaultClassPathResourceLoader
public DefaultClassPathResourceLoader(ClassLoader classLoader, String basePath, boolean checkBase, boolean logEnabled) Use when resources should have a standard base path.- Parameters:
classLoader
- The class loader for loading resourcesbasePath
- The path to look for resources undercheckBase
- If set totrue
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 Details
-
getResourceAsStream
Obtains a resource as a stream.- Specified by:
getResourceAsStream
in interfaceResourceLoader
- Parameters:
path
- The path- Returns:
- An optional resource
-
getResource
Obtains a resource URL.- Specified by:
getResource
in interfaceResourceLoader
- Parameters:
path
- The path- Returns:
- An optional resource
-
getResources
Obtains a stream of resource URLs.- Specified by:
getResources
in interfaceResourceLoader
- Parameters:
path
- The path- Returns:
- A resource stream
-
getClassLoader
- Specified by:
getClassLoader
in interfaceClassPathResourceLoader
- Returns:
- The class loader used to retrieve resources
-
forBase
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 interfaceResourceLoader
- Parameters:
basePath
- The path to load resources- Returns:
- The resource loader
-
forBase
Need this method to ability disable Slf4J initizalization.- Parameters:
basePath
- The path to load resourceslogEnabled
- flag to enable or disable logger- Returns:
- The resource loader
-