Class CachingStdEvaluationContextFactory
- java.lang.Object
-
- com.broadleafcommerce.rulesengine.expression.context.factory.CachingStdEvaluationContextFactory
-
- All Implemented Interfaces:
EvaluationContextFactory
public class CachingStdEvaluationContextFactory extends Object implements EvaluationContextFactory
Default implementation of
EvaluationContextFactory
that caches theEvaluationContext
s it creates. By default, the key is generated from the root object and theExpressionContext
. The factory uses aSupplier
with the generic typeStandardEvaluationContext
to generate new contexts.The
EvaluationContexts
created by this factory support SpEL expressions evaluations on concrete objects orMaps
.- Author:
- Nathan Moore (nathanmoore).
- See Also:
- SPeL
documentation,
MapAccessor
,MapAccessor
-
-
Field Summary
Fields Modifier and Type Field Description protected static Map<Serializable,org.springframework.expression.EvaluationContext>
CONTEXT_CACHE
protected Map<String,Object>
defaultExpressionVariables
protected List<org.springframework.expression.PropertyAccessor>
defaultPropertyAccessors
protected Supplier<org.springframework.expression.spel.support.StandardEvaluationContext>
evaluationContextSupplier
-
Constructor Summary
Constructors Constructor Description CachingStdEvaluationContextFactory(List<org.springframework.expression.PropertyAccessor> blDefaultPropertyAccessors, Map<String,Object> blDefaultExpressionVariables, Supplier<org.springframework.expression.spel.support.StandardEvaluationContext> blEvaluationContextSupplier)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected org.springframework.expression.EvaluationContext
buildEvaluationContext(Object rootObject, ExpressionContext expressionContext)
org.springframework.expression.EvaluationContext
getEvaluationContext(Object rootObject, ExpressionContext expressionContext)
Gets anEvaluationContext
.
-
-
-
Field Detail
-
CONTEXT_CACHE
protected static final Map<Serializable,org.springframework.expression.EvaluationContext> CONTEXT_CACHE
-
evaluationContextSupplier
protected final Supplier<org.springframework.expression.spel.support.StandardEvaluationContext> evaluationContextSupplier
-
defaultPropertyAccessors
protected final List<org.springframework.expression.PropertyAccessor> defaultPropertyAccessors
-
-
Constructor Detail
-
CachingStdEvaluationContextFactory
public CachingStdEvaluationContextFactory(List<org.springframework.expression.PropertyAccessor> blDefaultPropertyAccessors, Map<String,Object> blDefaultExpressionVariables, Supplier<org.springframework.expression.spel.support.StandardEvaluationContext> blEvaluationContextSupplier)
-
-
Method Detail
-
getEvaluationContext
public org.springframework.expression.EvaluationContext getEvaluationContext(Object rootObject, ExpressionContext expressionContext)
Gets anEvaluationContext
.- Specified by:
getEvaluationContext
in interfaceEvaluationContextFactory
- Parameters:
rootObject
- root object to evaluate an expression againstexpressionContext
- DTO for data required to evaluate an expression- Returns:
- an
EvaluationContext
-
buildEvaluationContext
protected org.springframework.expression.EvaluationContext buildEvaluationContext(Object rootObject, ExpressionContext expressionContext)
-
-