Package io.micronaut.core.io
Class ResourceResolver
java.lang.Object
io.micronaut.core.io.ResourceResolver
Resolves resources from a set of
ResourceLoader
instances.- Since:
- 1.0
- Author:
- James Kleeh, graemerocher
-
Constructor Summary
ConstructorDescriptionDefault constructor.ResourceResolver
(ResourceLoader[] resourceLoaders) ResourceResolver
(List<ResourceLoader> resourceLoaders) -
Method Summary
Modifier and TypeMethodDescription<T extends ResourceLoader>
Optional<T>Searches resource loaders for one that matches or is a subclass of the specified type.getLoaderForBasePath
(String basePath) Searches resource loaders for one that supports the given path.getResource
(String path) Searches resource loaders for one that supports the given path.getResourceAsStream
(String path) Searches resource loaders for one that supports the given path.getResources
(String path) Searches resource loaders for one that supports the given path.getSupportingLoader
(String prefix) Searches resource loaders for one that supports the given prefix.
-
Constructor Details
-
ResourceResolver
- Parameters:
resourceLoaders
- The resource loaders
-
ResourceResolver
- Parameters:
resourceLoaders
- The resource loaders
-
ResourceResolver
public ResourceResolver()Default constructor.
-
-
Method Details
-
getLoader
Searches resource loaders for one that matches or is a subclass of the specified type.- Type Parameters:
T
- The type- Parameters:
resolverType
- The type of resolver to retrieve- Returns:
- An optional resource loader
-
getSupportingLoader
Searches resource loaders for one that supports the given prefix.- Parameters:
prefix
- The prefix the loader should support. (classpath:, file:, etc)- Returns:
- An optional resource loader
-
getLoaderForBasePath
Searches resource loaders for one that supports the given path. If found, create a new loader with the context of the base path.- Parameters:
basePath
- The path to load resources from- Returns:
- An optional resource loader
-
getResourceAsStream
Searches resource loaders for one that supports the given path. If found, return the resource stream.- Parameters:
path
- The path to the resource- Returns:
- An optional input stream
-
getResource
Searches resource loaders for one that supports the given path. If found, return the resource URL.- Parameters:
path
- The path to the resource- Returns:
- An optional URL
-
getResources
Searches resource loaders for one that supports the given path. If found, return a stream of matching resources.- Parameters:
path
- The path to the resource- Returns:
- A stream of URLs
-