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:
-
ResourceLoaderResourceResolver
ApplicationContextAware
EnvironmentAware
ResourceCapableCacheDataImporterExporter.CacheResourceResolver
-
Constructor Summary
ConstructorDescriptionConstructs a new instance ofResourceCapableCacheDataImporterExporter.AbstractCacheResourceResolver
. -
Method Summary
Modifier and TypeMethodDescriptionprotected String
Evaluates the given SpELexpression
.protected Optional<org.springframework.context.ApplicationContext>
Returns anOptional
reference to a SpringApplicationContext
.protected Optional<org.springframework.core.env.Environment>
Returns anOptional
reference to the SpringEnvironment
.protected org.springframework.expression.ExpressionParser
Gets the configuredExpressionParser
used to parse SpELexpressions
.protected String
getFullyQualifiedResourceLocation
(org.apache.geode.cache.Region<?, ?> region) Determines a fully-qualifiedresource location
for the givenRegion
.protected org.slf4j.Logger
Return the configuredLogger
to log messages.protected org.springframework.expression.ParserContext
Gets the configuredParserContext
used by theExpressionParser
to identify SpEL expressions.protected String
getResourceLocation
(org.apache.geode.cache.Region<?, ?> region, String propertyName) protected String
getResourceName
(String name) Determines aresource name
for the givenname
.protected String
getResourceName
(org.apache.geode.cache.Region<?, ?> region) Determines aresource name
for the givenRegion
.protected abstract String
Get thebase path
for the targetedResource
.protected boolean
isQualified
(org.springframework.core.io.Resource resource) Determines whether theResource
is a qualifiedResource
.protected org.springframework.expression.EvaluationContext
Constructs a newEvaluationContext
used during the evaluation of SpELexpressions
.protected org.springframework.expression.Expression
Parses the givenexpressionString
.void
setApplicationContext
(org.springframework.context.ApplicationContext applicationContext) Configures a reference to the SpringApplicationContext
.void
setEnvironment
(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, setResourceLoader
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.data.support.ResourceCapableCacheDataImporterExporter.CacheResourceResolver
resolve, resolve
Methods 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 resolveResource
locations
defined 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 newEvaluationContext
used 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:
setApplicationContext
in interfaceorg.springframework.context.ApplicationContextAware
- Parameters:
applicationContext
- reference to theApplicationContext
.- See Also:
-
ApplicationContext
-
getApplicationContext
Returns anOptional
reference to a SpringApplicationContext
. -
setEnvironment
public void setEnvironment(org.springframework.core.env.Environment environment) Configures a reference to the SpringEnvironment
.- Specified by:
setEnvironment
in interfaceorg.springframework.context.EnvironmentAware
- Parameters:
environment
- reference to theEnvironment
.- See Also:
-
Environment
-
getEnvironment
Returns anOptional
reference to the SpringEnvironment
. -
getExpressionParser
@NonNull protected org.springframework.expression.ExpressionParser getExpressionParser()Gets the configuredExpressionParser
used to parse SpELexpressions
.- Returns:
- the configured
ExpressionParser
; never null. - See Also:
-
ExpressionParser
-
getLogger
protected org.slf4j.Logger getLogger()Return the configuredLogger
to log messages.- Returns:
- the configured
Logger
. - See Also:
-
Logger
-
getParserContext
@NonNull protected org.springframework.expression.ParserContext getParserContext()Gets the configuredParserContext
used by theExpressionParser
to identify SpEL expressions.- Returns:
- the configured
ParserContext
. - See Also:
-
ParserContext
-
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.- Overrides:
isQualified
in classResourceLoaderResourceResolver
- 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-qualifiedresource location
for the givenRegion
.- Parameters:
region
-Region
to evaluate; must not be null.- Returns:
- a fully-qualified
resource location
for the givenRegion
. - See Also:
-
getResourceLocation
@NonNull protected String getResourceLocation(@NonNull org.apache.geode.cache.Region<?, ?> region, @NonNull String propertyName) - Parameters:
region
-Region
used to locate the desiredResource
; must not be null.- Returns:
- a
Resource
location
for the givenRegion
. - Throws:
IllegalArgumentException
- ifRegion
is 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
-String
containing the SpEL expression to evaluate; must not be null.region
-Region
used to resolve regionName variable references in theexpression
; must not be null.- Returns:
- the value of the evaluated
expression
. - See Also:
-
Expression.getValue(EvaluationContext, Object)
Region
parse(String)
-
parse
Parses the givenexpressionString
. This method will cache parsedExpressions
to speed up the evaluation process.- Parameters:
expressionString
-String
containing the SpEL expression to parse.- Returns:
- an
Expression
object parsed from the givenexpression
. - See Also:
-
ExpressionParser.parseExpression(String, ParserContext)
Expression
getExpressionParser()
getParserContext()
-
getResourceName
Determines aresource name
for the givenRegion
. The default implementation bases theresource name
on theRegion's lowercase name
.- Parameters:
region
-Region
to evaluate; must not be null.- Returns:
- a
resource name
for the givenRegion
. - See Also:
-
Region
getResourceName(String)
-
getResourceName
Determines aresource name
for the givenname
.- Parameters:
name
-String
containing the name to evaluate; must not be null.- Returns:
- a
resource name
from the givenname
.
-
getResourcePath
Get thebase path
for the targetedResource
.- Returns:
- the
base path
for the targetedResource
.
-