Class ResourceCapableCacheDataImporterExporter.AbstractCacheResourceResolver

java.lang.Object
org.springframework.geode.core.io.support.ResourceLoaderResourceResolver
org.springframework.geode.data.support.ResourceCapableCacheDataImporterExporter.AbstractCacheResourceResolver
All Implemented Interfaces:
org.springframework.beans.factory.Aware, org.springframework.context.ApplicationContextAware, org.springframework.context.EnvironmentAware, org.springframework.context.ResourceLoaderAware, ResourceResolver, ResourceCapableCacheDataImporterExporter.CacheResourceResolver
Direct Known Subclasses:
ResourceCapableCacheDataImporterExporter.AbstractExportResourceResolver, ResourceCapableCacheDataImporterExporter.AbstractImportResourceResolver
Enclosing class:
ResourceCapableCacheDataImporterExporter

protected abstract static class ResourceCapableCacheDataImporterExporter.AbstractCacheResourceResolver extends ResourceLoaderResourceResolver implements org.springframework.context.ApplicationContextAware, ResourceCapableCacheDataImporterExporter.CacheResourceResolver, org.springframework.context.EnvironmentAware
Abstract base class containing functionality common to all cache based ResourceResolvers, whether for import or export.
See Also:
  • Constructor Details

    • AbstractCacheResourceResolver

      public AbstractCacheResourceResolver()
      Constructs a new instance of ResourceCapableCacheDataImporterExporter.AbstractCacheResourceResolver. This constructor initializes the SpEL objects used to parse and evaluate SpEL expressions in order to fully qualify and resolve Resource locations defined as properties in Spring Boot application.properties for Import and Export Resources.
      See Also:
      • newExpressionParser()
      • newEvaluationContextBuilder()
  • Method Details

    • newEvaluationContext

      @NonNull protected org.springframework.expression.EvaluationContext newEvaluationContext()
      Constructs a new EvaluationContext used during the evaluation of SpEL expressions.
      Returns:
      a new EvaluationContext; never null.
      See Also:
      • EvaluationContext
    • setApplicationContext

      public void setApplicationContext(@Nullable org.springframework.context.ApplicationContext applicationContext)
      Configures a reference to the Spring ApplicationContext.
      Specified by:
      setApplicationContext in interface org.springframework.context.ApplicationContextAware
      Parameters:
      applicationContext - reference to the ApplicationContext.
      See Also:
      • ApplicationContext
    • getApplicationContext

      protected Optional<org.springframework.context.ApplicationContext> getApplicationContext()
      Returns an Optional reference to a Spring ApplicationContext.
      Returns:
      an Optional reference to a Spring ApplicationContext.
      See Also:
    • setEnvironment

      public void setEnvironment(org.springframework.core.env.Environment environment)
      Configures a reference to the Spring Environment.
      Specified by:
      setEnvironment in interface org.springframework.context.EnvironmentAware
      Parameters:
      environment - reference to the Environment.
      See Also:
      • Environment
    • getEnvironment

      protected Optional<org.springframework.core.env.Environment> getEnvironment()
      Returns an Optional reference to the Spring Environment.
      Returns:
      an Optional reference to the Spring Environment.
      See Also:
    • getExpressionParser

      @NonNull protected org.springframework.expression.ExpressionParser getExpressionParser()
      Gets the configured ExpressionParser used to parse SpEL expressions.
      Returns:
      the configured ExpressionParser; never null.
      See Also:
      • ExpressionParser
    • getLogger

      protected org.slf4j.Logger getLogger()
      Return the configured Logger to log messages.
      Returns:
      the configured Logger.
      See Also:
      • Logger
    • getParserContext

      @NonNull protected org.springframework.expression.ParserContext getParserContext()
      Gets the configured ParserContext used by the ExpressionParser to identify SpEL expressions.
      Returns:
      the configured ParserContext.
      See Also:
      • ParserContext
    • 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.
      Overrides:
      isQualified in class ResourceLoaderResourceResolver
      Parameters:
      resource - Resource to qualify.
      Returns:
      a boolean value indicating whether the Resource is qualified.
      See Also:
      • Resource
    • getFullyQualifiedResourceLocation

      @NonNull protected String getFullyQualifiedResourceLocation(@NonNull org.apache.geode.cache.Region<?,?> region)
      Determines a fully-qualified resource location for the given Region.
      Parameters:
      region - Region to evaluate; must not be null.
      Returns:
      a fully-qualified resource location for the given Region.
      See Also:
    • getResourceLocation

      @NonNull protected String getResourceLocation(@NonNull org.apache.geode.cache.Region<?,?> region, @NonNull String propertyName)
      Determines the location of a Resource for the given Region.
      Parameters:
      region - Region used to locate the desired Resource; must not be null.
      Returns:
      a Resource location for the given Region.
      Throws:
      IllegalArgumentException - if Region is null.
      See Also:
      • Region
    • evaluate

      @Nullable protected String evaluate(@NonNull String expressionString, @NonNull org.apache.geode.cache.Region<?,?> region)
      Evaluates the given SpEL expression.
      Parameters:
      expressionString - String containing the SpEL expression to evaluate; must not be null.
      region - Region used to resolve regionName variable references in the expression; must not be null.
      Returns:
      the value of the evaluated expression.
      See Also:
      • Expression.getValue(EvaluationContext, Object)
      • Region
      • parse(String)
    • parse

      protected org.springframework.expression.Expression parse(String expressionString)
      Parses the given expressionString. This method will cache parsed Expressions to speed up the evaluation process.
      Parameters:
      expressionString - String containing the SpEL expression to parse.
      Returns:
      an Expression object parsed from the given expression.
      See Also:
    • getResourceName

      @NonNull protected String getResourceName(@NonNull org.apache.geode.cache.Region<?,?> region)
      Determines a resource name for the given Region. The default implementation bases the resource name on the Region's lowercase name.
      Parameters:
      region - Region to evaluate; must not be null.
      Returns:
      a resource name for the given Region.
      See Also:
    • getResourceName

      @NonNull protected String getResourceName(@NonNull String name)
      Determines a resource name for the given name.
      Parameters:
      name - String containing the name to evaluate; must not be null.
      Returns:
      a resource name from the given name.
    • getResourcePath

      @NonNull protected abstract String getResourcePath()
      Get the base path for the targeted Resource.
      Returns:
      the base path for the targeted Resource.