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:
-
ResourceLoaderResourceResolverApplicationContextAwareEnvironmentAwareResourceCapableCacheDataImporterExporter.CacheResourceResolver
-
Constructor Summary
ConstructorsConstructorDescriptionConstructs a new instance ofResourceCapableCacheDataImporterExporter.AbstractCacheResourceResolver. -
Method Summary
Modifier and TypeMethodDescriptionprotected StringEvaluates the given SpELexpression.protected Optional<org.springframework.context.ApplicationContext>Returns anOptionalreference to a SpringApplicationContext.protected Optional<org.springframework.core.env.Environment>Returns anOptionalreference to the SpringEnvironment.protected org.springframework.expression.ExpressionParserGets the configuredExpressionParserused to parse SpELexpressions.protected StringgetFullyQualifiedResourceLocation(org.apache.geode.cache.Region<?, ?> region) Determines a fully-qualifiedresource locationfor the givenRegion.protected org.slf4j.LoggerReturn the configuredLoggerto log messages.protected org.springframework.expression.ParserContextGets the configuredParserContextused by theExpressionParserto identify SpEL expressions.protected StringgetResourceLocation(org.apache.geode.cache.Region<?, ?> region, String propertyName) protected StringgetResourceName(String name) Determines aresource namefor the givenname.protected StringgetResourceName(org.apache.geode.cache.Region<?, ?> region) Determines aresource namefor the givenRegion.protected abstract StringGet thebase pathfor the targetedResource.protected booleanisQualified(org.springframework.core.io.Resource resource) Determines whether theResourceis a qualifiedResource.protected org.springframework.expression.EvaluationContextConstructs a newEvaluationContextused during the evaluation of SpELexpressions.protected org.springframework.expression.ExpressionParses the givenexpressionString.voidsetApplicationContext(org.springframework.context.ApplicationContext applicationContext) Configures a reference to the SpringApplicationContext.voidsetEnvironment(org.springframework.core.env.Environment environment) Configures a reference to the SpringEnvironment.Methods inherited from class org.springframework.geode.core.io.support.ResourceLoaderResourceResolver
getClassLoader, getResourceLoader, newResource, newResourceLoader, onMissingResource, postProcess, resolve, setResourceLoaderMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.springframework.geode.data.support.ResourceCapableCacheDataImporterExporter.CacheResourceResolver
resolve, resolveMethods inherited from interface org.springframework.geode.core.io.ResourceResolver
getClassLoader, require
-
Constructor Details
-
AbstractCacheResourceResolver
public AbstractCacheResourceResolver()Constructs a new instance ofResourceCapableCacheDataImporterExporter.AbstractCacheResourceResolver. This constructor initializes the SpEL objects used to parse and evaluate SpEL expressions in order to fully qualify and resolveResourcelocationsdefined as properties in Spring Boot application.properties for Import and ExportResources.- See Also:
-
newExpressionParser()newEvaluationContextBuilder()
-
-
Method Details
-
newEvaluationContext
@NonNull protected org.springframework.expression.EvaluationContext newEvaluationContext()Constructs a newEvaluationContextused during the evaluation of SpELexpressions.- Returns:
- a new
EvaluationContext; never null. - See Also:
-
EvaluationContext
-
setApplicationContext
public void setApplicationContext(@Nullable org.springframework.context.ApplicationContext applicationContext) Configures a reference to the SpringApplicationContext.- Specified by:
setApplicationContextin interfaceorg.springframework.context.ApplicationContextAware- Parameters:
applicationContext- reference to theApplicationContext.- See Also:
-
ApplicationContext
-
getApplicationContext
Returns anOptionalreference to a SpringApplicationContext. -
setEnvironment
public void setEnvironment(org.springframework.core.env.Environment environment) Configures a reference to the SpringEnvironment.- Specified by:
setEnvironmentin interfaceorg.springframework.context.EnvironmentAware- Parameters:
environment- reference to theEnvironment.- See Also:
-
Environment
-
getEnvironment
Returns anOptionalreference to the SpringEnvironment. -
getExpressionParser
@NonNull protected org.springframework.expression.ExpressionParser getExpressionParser()Gets the configuredExpressionParserused to parse SpELexpressions.- Returns:
- the configured
ExpressionParser; never null. - See Also:
-
ExpressionParser
-
getLogger
protected org.slf4j.Logger getLogger()Return the configuredLoggerto log messages.- Returns:
- the configured
Logger. - See Also:
-
Logger
-
getParserContext
@NonNull protected org.springframework.expression.ParserContext getParserContext()Gets the configuredParserContextused by theExpressionParserto identify SpEL expressions.- Returns:
- the configured
ParserContext. - See Also:
-
ParserContext
-
isQualified
protected boolean isQualified(@Nullable org.springframework.core.io.Resource resource) Description copied from class:ResourceLoaderResourceResolverDetermines 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.- Overrides:
isQualifiedin classResourceLoaderResourceResolver- Parameters:
resource-Resourceto qualify.- Returns:
- a boolean value indicating whether the
Resourceis qualified. - See Also:
-
Resource
-
getFullyQualifiedResourceLocation
@NonNull protected String getFullyQualifiedResourceLocation(@NonNull org.apache.geode.cache.Region<?, ?> region) Determines a fully-qualifiedresource locationfor the givenRegion.- Parameters:
region-Regionto evaluate; must not be null.- Returns:
- a fully-qualified
resource locationfor the givenRegion. - See Also:
-
getResourceLocation
@NonNull protected String getResourceLocation(@NonNull org.apache.geode.cache.Region<?, ?> region, @NonNull String propertyName) - Parameters:
region-Regionused to locate the desiredResource; must not be null.- Returns:
- a
Resourcelocationfor the givenRegion. - Throws:
IllegalArgumentException- ifRegionis null.- See Also:
-
Region
-
evaluate
@Nullable protected String evaluate(@NonNull String expressionString, @NonNull org.apache.geode.cache.Region<?, ?> region) Evaluates the given SpELexpression.- Parameters:
expressionString-Stringcontaining the SpEL expression to evaluate; must not be null.region-Regionused to resolve regionName variable references in theexpression; must not be null.- Returns:
- the value of the evaluated
expression. - See Also:
-
Expression.getValue(EvaluationContext, Object)Regionparse(String)
-
parse
Parses the givenexpressionString. This method will cache parsedExpressionsto speed up the evaluation process.- Parameters:
expressionString-Stringcontaining the SpEL expression to parse.- Returns:
- an
Expressionobject parsed from the givenexpression. - See Also:
-
ExpressionParser.parseExpression(String, ParserContext)ExpressiongetExpressionParser()getParserContext()
-
getResourceName
Determines aresource namefor the givenRegion. The default implementation bases theresource nameon theRegion's lowercase name.- Parameters:
region-Regionto evaluate; must not be null.- Returns:
- a
resource namefor the givenRegion. - See Also:
-
RegiongetResourceName(String)
-
getResourceName
Determines aresource namefor the givenname.- Parameters:
name-Stringcontaining the name to evaluate; must not be null.- Returns:
- a
resource namefrom the givenname.
-
getResourcePath
Get thebase pathfor the targetedResource.- Returns:
- the
base pathfor the targetedResource.
-