Top Description Fields Constructors Methods
org.springframework.cache.interceptor

pack-priv Class CacheEvaluationContext

extends MethodBasedEvaluationContext
Class Inheritance
Imports
java.lang.reflect.Method, java.util.HashSet, .Set, org.springframework.context.expression.MethodBasedEvaluationContext, org.springframework.core.ParameterNameDiscoverer, org.springframework.lang.Nullable

Cache-specific evaluation context that adds method parameters as SpEL variables, in a lazy manner. The lazy nature avoids unnecessary parsing of a class's byte code for parameter discovery.

Also defines a set of "unavailable variables" (i.e. variables that should lead to an exception as soon as they are accessed). This can be useful to verify a condition does not match even when not all potential variables are present.

To limit the creation of objects, an ugly constructor is used (rather than a dedicated 'closure'-like class for deferred execution).

Authors
Costin Leau, Stephane Nicoll, Juergen Hoeller
Since
3.1

Field Summary

Modifier and TypeField and Description
private final Set<String>

Constructor Summary

AccessConstructor and Description
pack-priv
CacheEvaluationContext(Object rootObject, Method method, Object[] arguments, ParameterNameDiscoverer parameterNameDiscoverer)

Method Summary

Modifier and TypeMethod and Description
public void
addUnavailableVariable(String name)

Add the specified variable name as unavailable for this context.

public Object
lookupVariable(String
the name of the variable or function to look up
name
)

Overrides org.springframework.context.expression.MethodBasedEvaluationContext.lookupVariable.

Implements org.springframework.expression.EvaluationContext.lookupVariable.

Load the param information only when needed.
Inherited from org.springframework.context.expression.MethodBasedEvaluationContext:
lazyLoadArguments

Field Detail

unavailableVariablesback to summary
private final Set<String> unavailableVariables

Constructor Detail

CacheEvaluationContextback to summary
pack-priv CacheEvaluationContext(Object rootObject, Method method, Object[] arguments, ParameterNameDiscoverer parameterNameDiscoverer)

Method Detail

addUnavailableVariableback to summary
public void addUnavailableVariable(String name)

Add the specified variable name as unavailable for this context.

Any expression trying to access this variable should lead to an exception.

This permits the validation of expressions that could potentially access a variable even when such a variable isn't available yet. Any expression trying to use that variable should therefore fail to evaluate.

lookupVariableback to summary
public Object lookupVariable(String name)

Overrides org.springframework.context.expression.MethodBasedEvaluationContext.lookupVariable.

Implements org.springframework.expression.EvaluationContext.lookupVariable.

Load the param information only when needed.

Parameters
name:String

Doc from org.springframework.expression.spel.support.StandardEvaluationContext.lookupVariable.

the name of the variable or function to look up

Returns:Object

Doc from org.springframework.expression.spel.support.StandardEvaluationContext.lookupVariable.

the value of the variable or function, or null if not found

Annotations
@Override
@Nullable