Class ResourceLoaderResourceResolver
java.lang.Object
org.springframework.geode.core.io.support.ResourceLoaderResourceResolver
- All Implemented Interfaces:
org.springframework.beans.factory.Aware
,org.springframework.context.ResourceLoaderAware
,ResourceResolver
- Direct Known Subclasses:
ResourceCapableCacheDataImporterExporter.AbstractCacheResourceResolver
public class ResourceLoaderResourceResolver
extends Object
implements org.springframework.context.ResourceLoaderAware, ResourceResolver
- Since:
- 1.3.1
- See Also:
-
ApplicationContext
ResourceLoaderAware
ClassPathResource
DefaultResourceLoader
Resource
ResourceLoader
ResourceResolver
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionGets anOptional
ClassLoader
used by theResourceLoader
to resolve and loadResources
located on the classpath.protected org.springframework.core.io.ResourceLoader
Returns a reference to the configuredResourceLoader
used to loadResources
.protected boolean
isQualified
(org.springframework.core.io.Resource resource) Determines whether theResource
is a qualifiedResource
.protected org.springframework.core.io.Resource
newResource
(String location) Constructs a newResource
handle at the givenlocation
.protected org.springframework.core.io.ResourceLoader
Constructs a new, default instance ofResourceLoader
to loadResources
.protected org.springframework.core.io.Resource
onMissingResource
(org.springframework.core.io.Resource resource, String location) protected org.springframework.core.io.Resource
postProcess
(org.springframework.core.io.Resource resource) Method used by subclasses to process the loadedResource
as determined by theResourceLoader
.Optional<org.springframework.core.io.Resource>
Tries to resolve aResource
at the givenlocation
using a SpringResourceLoader
, such as a SpringApplicationContext
.void
setResourceLoader
(org.springframework.core.io.ResourceLoader resourceLoader) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.springframework.geode.core.io.ResourceResolver
require
-
Constructor Details
-
ResourceLoaderResourceResolver
public ResourceLoaderResourceResolver()
-
-
Method Details
-
getClassLoader
Gets anOptional
ClassLoader
used by theResourceLoader
to resolve and loadResources
located on the classpath. Returns theClassLoader
from the configuredResourceLoader
, if present. Otherwise, returns aClassLoader
determined byClassUtils.getDefaultClassLoader()
, which first tries to return theThread.getContextClassLoader()
, thenClass.getClassLoader()
, and finally,ClassLoader.getSystemClassLoader()
.- Specified by:
getClassLoader
in interfaceResourceResolver
- Returns:
- an
Optional
ClassLoader
to resolve and loadResources
. - See Also:
-
ResourceLoader.getClassLoader()
ClassLoader
Optional
-
setResourceLoader
public void setResourceLoader(@Nullable org.springframework.core.io.ResourceLoader resourceLoader) - Specified by:
setResourceLoader
in interfaceorg.springframework.context.ResourceLoaderAware
- Parameters:
resourceLoader
-ResourceLoader
used to resolve and loadResources
.- See Also:
-
ResourceLoader
-
getResourceLoader
@NonNull protected org.springframework.core.io.ResourceLoader getResourceLoader()Returns a reference to the configuredResourceLoader
used to loadResources
. If aResourceLoader
was not explicitly configured, then a defaultResourceLoader
using a defaultClassLoader
is provided.- Returns:
- a reference to the configured
ResourceLoader
; never null. - See Also:
-
ResourceLoader
newResourceLoader()
-
newResourceLoader
@NonNull protected org.springframework.core.io.ResourceLoader newResourceLoader()Constructs a new, default instance ofResourceLoader
to loadResources
. Specifically, creates a standaloneDefaultResourceLoader
initialized with a defaultClassLoader
as determined bygetClassLoader()
.- Returns:
- a new, default instance of
ResourceLoader
. - See Also:
-
ResourceLoader
-
newResource
Constructs a newResource
handle at the givenlocation
. By default, aClassPathResource
is constructed.- Parameters:
location
-location
of the newResource
; must not be null.- Returns:
- a new
Resource
handle at the givenlocation
. - Throws:
IllegalArgumentException
- iflocation
is not specified.- See Also:
-
Resource
-
isQualified
protected boolean isQualified(@Nullable org.springframework.core.io.Resource resource) Determines whether theResource
is a qualifiedResource
. Qualifications are determined by the application Requirements and Use Case (UC) at time of resolution. For example, it maybe that theResource
mustexist
to qualify, or that theResource
must have a valid protocol, path and name. This default implementation requires the targetResource
to not be null.- Parameters:
resource
-Resource
to qualify.- Returns:
- a boolean value indicating whether the
Resource
is qualified. - See Also:
-
Resource
-
onMissingResource
@Nullable protected org.springframework.core.io.Resource onMissingResource(@Nullable org.springframework.core.io.Resource resource, @NonNull String location) Action to perform when theResource
identified at the specifiedlocation
is missing, or was notqualified
.- Parameters:
resource
- missingResource
.location
-String
containing the location identifying the missingResource
.- Returns:
- a different
Resource
, possibly. Alternatively, this method may throw aResourceNotFoundException
. - Throws:
ResourceNotFoundException
- if theResource
cannot be found at the specifiedlocation
.- See Also:
-
postProcess
protected org.springframework.core.io.Resource postProcess(org.springframework.core.io.Resource resource) Method used by subclasses to process the loadedResource
as determined by theResourceLoader
.- Parameters:
resource
-Resource
to post-process.- Returns:
- the
Resource
. - See Also:
-
Resource
-
resolve
Tries to resolve aResource
at the givenlocation
using a SpringResourceLoader
, such as a SpringApplicationContext
. The targeted, identifiedResource
can be furtherqualified
by subclasses based on application requirements or use case (UC). In the event that aResource
cannot be identified at the givenlocation
, then applications have 1 last opportunity to handle the missingResource
event, and either return a different or defaultResource
or throw aResourceNotFoundException
.- Specified by:
resolve
in interfaceResourceResolver
- Parameters:
location
-location
identifying theResource
to resolve; must not be null.- Returns:
- an
Optional
Resource
handle for the givenlocation
. - Throws:
IllegalArgumentException
- iflocation
is not specified.- See Also:
-