Spring Boot for VMware GemFire
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:
-
ApplicationContextResourceLoaderAwareClassPathResourceDefaultResourceLoaderResourceResourceLoaderResourceResolver
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionGets anOptionalClassLoaderused by theResourceLoaderto resolve and loadResourceslocated on the classpath.protected org.springframework.core.io.ResourceLoaderReturns a reference to the configuredResourceLoaderused to loadResources.protected booleanisQualified(org.springframework.core.io.Resource resource) Determines whether theResourceis a qualifiedResource.protected org.springframework.core.io.ResourcenewResource(String location) Constructs a newResourcehandle at the givenlocation.protected org.springframework.core.io.ResourceLoaderConstructs a new, default instance ofResourceLoaderto loadResources.protected org.springframework.core.io.ResourceonMissingResource(org.springframework.core.io.Resource resource, String location) protected org.springframework.core.io.ResourcepostProcess(org.springframework.core.io.Resource resource) Method used by subclasses to process the loadedResourceas determined by theResourceLoader.Optional<org.springframework.core.io.Resource>Tries to resolve aResourceat the givenlocationusing a SpringResourceLoader, such as a SpringApplicationContext.voidsetResourceLoader(org.springframework.core.io.ResourceLoader resourceLoader) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.springframework.geode.core.io.ResourceResolver
require
-
Constructor Details
-
ResourceLoaderResourceResolver
public ResourceLoaderResourceResolver()
-
-
Method Details
-
getClassLoader
Gets anOptionalClassLoaderused by theResourceLoaderto resolve and loadResourceslocated on the classpath. Returns theClassLoaderfrom the configuredResourceLoader, if present. Otherwise, returns aClassLoaderdetermined byClassUtils.getDefaultClassLoader(), which first tries to return theThread.getContextClassLoader(), thenClass.getClassLoader(), and finally,ClassLoader.getSystemClassLoader().- Specified by:
getClassLoaderin interfaceResourceResolver- Returns:
- an
OptionalClassLoaderto resolve and loadResources. - See Also:
-
ResourceLoader.getClassLoader()ClassLoaderOptional
-
setResourceLoader
public void setResourceLoader(@Nullable org.springframework.core.io.ResourceLoader resourceLoader) - Specified by:
setResourceLoaderin interfaceorg.springframework.context.ResourceLoaderAware- Parameters:
resourceLoader-ResourceLoaderused to resolve and loadResources.- See Also:
-
ResourceLoader
-
getResourceLoader
@NonNull protected org.springframework.core.io.ResourceLoader getResourceLoader()Returns a reference to the configuredResourceLoaderused to loadResources. If aResourceLoaderwas not explicitly configured, then a defaultResourceLoaderusing a defaultClassLoaderis provided.- Returns:
- a reference to the configured
ResourceLoader; never null. - See Also:
-
ResourceLoadernewResourceLoader()
-
newResourceLoader
@NonNull protected org.springframework.core.io.ResourceLoader newResourceLoader()Constructs a new, default instance ofResourceLoaderto loadResources. Specifically, creates a standaloneDefaultResourceLoaderinitialized with a defaultClassLoaderas determined bygetClassLoader().- Returns:
- a new, default instance of
ResourceLoader. - See Also:
-
ResourceLoader
-
newResource
Constructs a newResourcehandle at the givenlocation. By default, aClassPathResourceis constructed.- Parameters:
location-locationof the newResource; must not be null.- Returns:
- a new
Resourcehandle at the givenlocation. - Throws:
IllegalArgumentException- iflocationis not specified.- See Also:
-
Resource
-
isQualified
protected boolean isQualified(@Nullable org.springframework.core.io.Resource resource) Determines whether theResourceis a qualifiedResource. Qualifications are determined by the application Requirements and Use Case (UC) at time of resolution. For example, it maybe that theResourcemustexistto qualify, or that theResourcemust have a valid protocol, path and name. This default implementation requires the targetResourceto not be null.- Parameters:
resource-Resourceto qualify.- Returns:
- a boolean value indicating whether the
Resourceis 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 theResourceidentified at the specifiedlocationis missing, or was notqualified.- Parameters:
resource- missingResource.location-Stringcontaining the location identifying the missingResource.- Returns:
- a different
Resource, possibly. Alternatively, this method may throw aResourceNotFoundException. - Throws:
ResourceNotFoundException- if theResourcecannot 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 loadedResourceas determined by theResourceLoader.- Parameters:
resource-Resourceto post-process.- Returns:
- the
Resource. - See Also:
-
Resource
-
resolve
Tries to resolve aResourceat the givenlocationusing a SpringResourceLoader, such as a SpringApplicationContext. The targeted, identifiedResourcecan be furtherqualifiedby subclasses based on application requirements or use case (UC). In the event that aResourcecannot be identified at the givenlocation, then applications have 1 last opportunity to handle the missingResourceevent, and either return a different or defaultResourceor throw aResourceNotFoundException.- Specified by:
resolvein interfaceResourceResolver- Parameters:
location-locationidentifying theResourceto resolve; must not be null.- Returns:
- an
OptionalResourcehandle for the givenlocation. - Throws:
IllegalArgumentException- iflocationis not specified.- See Also:
-