@FunctionalInterface
public interface ResourceResolver
Resources
.FunctionalInterface
,
Resource
Modifier and Type | Method and Description |
---|---|
default java.util.Optional<java.lang.ClassLoader> |
getClassLoader()
|
default org.springframework.core.io.Resource |
require(java.lang.String location)
Returns a non-null, existing
Resource handle resolved from the given,
non-null location (e.g. |
java.util.Optional<org.springframework.core.io.Resource> |
resolve(java.lang.String location)
Tries to resolve a
Resource handle from the given, non-null location
(e.g. |
default java.util.Optional<java.lang.ClassLoader> getClassLoader()
ClassLoader
used by this ResourceResolver
to resolve classpath
Resources
.
By default, this method will return a ClassLoader
determined by ClassUtils.getDefaultClassLoader()
,
which first tries to return the Thread.getContextClassLoader()
, then Class.getClassLoader()
,
and finally, ClassLoader.getSystemClassLoader()
.Optional
ClassLoader
used to resolve classpath Resources
.ClassUtils.getDefaultClassLoader()
,
ClassLoader
,
Optional
java.util.Optional<org.springframework.core.io.Resource> resolve(@NonNull java.lang.String location)
Resource
handle from the given, non-null location
(e.g. filesystem path
).location
- location
identifying the Resource
to resolve;
must not be null.Optional
Resource
handle for the given location
.Resource
,
Optional
@NonNull default org.springframework.core.io.Resource require(@NonNull java.lang.String location)
Resource
handle resolved from the given,
non-null location
(e.g. filesystem path
).location
- location
identifying the Resource
to resolve;
must not be null.Resource
handle for
the resolved location
.ResourceNotFoundException
- if a Resource
cannot be resolved from the given location
.
A Resource
is unresolvable if the given location
does not exist (physically);
see Resource.exists()
.Resource
,
resolve(String)