Interface ResourceResolver
- All Known Subinterfaces:
ResourceCapableCacheDataImporterExporter.CacheResourceResolver,ResourceCapableCacheDataImporterExporter.ExportResourceResolver,ResourceCapableCacheDataImporterExporter.ImportResourceResolver
- All Known Implementing Classes:
ResourceCapableCacheDataImporterExporter.AbstractCacheResourceResolver,ResourceCapableCacheDataImporterExporter.AbstractExportResourceResolver,ResourceCapableCacheDataImporterExporter.AbstractImportResourceResolver,ResourceCapableCacheDataImporterExporter.ClassPathImportResourceResolver,ResourceCapableCacheDataImporterExporter.FileSystemExportResourceResolver,ResourceLoaderResourceResolver,SingleResourceResolver
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
Interface defining a contract encapsulating an algorithm/strategy for resolving
Resources.- Since:
- 1.3.1.
- See Also:
-
FunctionalInterfaceResource
-
Method Summary
Modifier and TypeMethodDescriptiondefault Optional<ClassLoader>default org.springframework.core.io.ResourceReturns a non-null, existingResourcehandle resolved from the given, non-nulllocation(e.g.Optional<org.springframework.core.io.Resource>Tries to resolve aResourcehandle from the given, non-nulllocation(e.g.
-
Method Details
-
getClassLoader
Gets theClassLoaderused by thisResourceResolverto resolve classpathResources. By default, this method will return aClassLoaderdetermined byClassUtils.getDefaultClassLoader(), which first tries to return theThread.getContextClassLoader(), thenClass.getClassLoader(), and finally,ClassLoader.getSystemClassLoader().- Returns:
- an
OptionalClassLoaderused to resolve classpathResources. - See Also:
-
ClassUtils.getDefaultClassLoader()ClassLoaderOptional
-
resolve
-
require
Returns a non-null, existingResourcehandle resolved from the given, non-nulllocation(e.g.filesystem path).- Parameters:
location-locationidentifying theResourceto resolve; must not be null.- Returns:
- a non-null, existing
Resourcehandle for the resolvedlocation. - Throws:
ResourceNotFoundException- if aResourcecannot be resolved from the givenlocation. AResourceis unresolvable if the givenlocationdoes not exist (physically); seeResource.exists().- See Also:
-
Resourceresolve(String)
-