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
ResourceResolver implementation using Spring's ResourceLoader to resolve and load Resources.
Since:
1.3.1
See Also:
  • ApplicationContext
  • ResourceLoaderAware
  • ClassPathResource
  • DefaultResourceLoader
  • Resource
  • ResourceLoader
  • ResourceResolver
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    Gets an Optional ClassLoader used by the ResourceLoader to resolve and load Resources located on the classpath.
    protected org.springframework.core.io.ResourceLoader
    Returns a reference to the configured ResourceLoader used to load Resources.
    protected boolean
    isQualified(org.springframework.core.io.Resource resource)
    Determines whether the Resource is a qualified Resource.
    protected org.springframework.core.io.Resource
    newResource(String location)
    Constructs a new Resource handle at the given location.
    protected org.springframework.core.io.ResourceLoader
    Constructs a new, default instance of ResourceLoader to load Resources.
    protected org.springframework.core.io.Resource
    onMissingResource(org.springframework.core.io.Resource resource, String location)
    Action to perform when the Resource identified at the specified location is missing, or was not qualified.
    protected org.springframework.core.io.Resource
    postProcess(org.springframework.core.io.Resource resource)
    Method used by subclasses to process the loaded Resource as determined by the ResourceLoader.
    Optional<org.springframework.core.io.Resource>
    resolve(String location)
    Tries to resolve a Resource at the given location using a Spring ResourceLoader, such as a Spring ApplicationContext.
    void
    setResourceLoader(org.springframework.core.io.ResourceLoader resourceLoader)
    Configures the ResourceLoader used by this ResourceResolver to resolve and load Resources.

    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

      public Optional<ClassLoader> getClassLoader()
      Gets an Optional ClassLoader used by the ResourceLoader to resolve and load Resources located on the classpath. Returns the ClassLoader from the configured ResourceLoader, if present. Otherwise, returns a ClassLoader determined by ClassUtils.getDefaultClassLoader(), which first tries to return the Thread.getContextClassLoader(), then Class.getClassLoader(), and finally, ClassLoader.getSystemClassLoader().
      Specified by:
      getClassLoader in interface ResourceResolver
      Returns:
      an Optional ClassLoader to resolve and load Resources.
      See Also:
    • setResourceLoader

      public void setResourceLoader(@Nullable org.springframework.core.io.ResourceLoader resourceLoader)
      Configures the ResourceLoader used by this ResourceResolver to resolve and load Resources.
      Specified by:
      setResourceLoader in interface org.springframework.context.ResourceLoaderAware
      Parameters:
      resourceLoader - ResourceLoader used to resolve and load Resources.
      See Also:
      • ResourceLoader
    • getResourceLoader

      @NonNull protected org.springframework.core.io.ResourceLoader getResourceLoader()
      Returns a reference to the configured ResourceLoader used to load Resources. If a ResourceLoader was not explicitly configured, then a default ResourceLoader using a default ClassLoader is provided.
      Returns:
      a reference to the configured ResourceLoader; never null.
      See Also:
    • newResourceLoader

      @NonNull protected org.springframework.core.io.ResourceLoader newResourceLoader()
      Constructs a new, default instance of ResourceLoader to load Resources. Specifically, creates a standalone DefaultResourceLoader initialized with a default ClassLoader as determined by getClassLoader().
      Returns:
      a new, default instance of ResourceLoader.
      See Also:
      • ResourceLoader
    • newResource

      @NonNull protected org.springframework.core.io.Resource newResource(@NonNull String location)
      Constructs a new Resource handle at the given location. By default, a ClassPathResource is constructed.
      Parameters:
      location - location of the new Resource; must not be null.
      Returns:
      a new Resource handle at the given location.
      Throws:
      IllegalArgumentException - if location is not specified.
      See Also:
      • Resource
    • isQualified

      protected boolean isQualified(@Nullable org.springframework.core.io.Resource resource)
      Determines whether the Resource is a qualified Resource. Qualifications are determined by the application Requirements and Use Case (UC) at time of resolution. For example, it maybe that the Resource must exist to qualify, or that the Resource must have a valid protocol, path and name. This default implementation requires the target Resource 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 the Resource identified at the specified location is missing, or was not qualified.
      Parameters:
      resource - missing Resource.
      location - String containing the location identifying the missing Resource.
      Returns:
      a different Resource, possibly. Alternatively, this method may throw a ResourceNotFoundException.
      Throws:
      ResourceNotFoundException - if the Resource cannot be found at the specified location.
      See Also:
    • postProcess

      protected org.springframework.core.io.Resource postProcess(org.springframework.core.io.Resource resource)
      Method used by subclasses to process the loaded Resource as determined by the ResourceLoader.
      Parameters:
      resource - Resource to post-process.
      Returns:
      the Resource.
      See Also:
      • Resource
    • resolve

      public Optional<org.springframework.core.io.Resource> resolve(@NonNull String location)
      Tries to resolve a Resource at the given location using a Spring ResourceLoader, such as a Spring ApplicationContext. The targeted, identified Resource can be further qualified by subclasses based on application requirements or use case (UC). In the event that a Resource cannot be identified at the given location, then applications have 1 last opportunity to handle the missing Resource event, and either return a different or default Resource or throw a ResourceNotFoundException.
      Specified by:
      resolve in interface ResourceResolver
      Parameters:
      location - location identifying the Resource to resolve; must not be null.
      Returns:
      an Optional Resource handle for the given location.
      Throws:
      IllegalArgumentException - if location is not specified.
      See Also: