Skip to content

Commit

Permalink
add parseConext param for CachedExpressionEvaluator#getExpression
Browse files Browse the repository at this point in the history
  • Loading branch information
Xjzon committed Oct 24, 2021
1 parent e4e667a commit 145e9b8
Showing 1 changed file with 15 additions and 1 deletion.
Expand Up @@ -21,6 +21,7 @@
import org.springframework.core.DefaultParameterNameDiscoverer;
import org.springframework.core.ParameterNameDiscoverer;
import org.springframework.expression.Expression;
import org.springframework.expression.ParserContext;
import org.springframework.expression.spel.standard.SpelExpressionParser;
import org.springframework.lang.Nullable;
import org.springframework.util.Assert;
Expand Down Expand Up @@ -82,11 +83,24 @@ protected ParameterNameDiscoverer getParameterNameDiscoverer() {
*/
protected Expression getExpression(Map<ExpressionKey, Expression> cache,
AnnotatedElementKey elementKey, String expression) {
return getExpression(cache, elementKey, expression, null);
}

/**
* Return the {@link Expression} for the specified SpEL value
* <p>Parse the expression if it hasn't been already.
* @param cache the cache to use
* @param elementKey the element on which the expression is defined
* @param expression the expression to parse
* @param parserContext the context provided to an expression parser that can influence an expression
*/
protected Expression getExpression(Map<ExpressionKey, Expression> cache,
AnnotatedElementKey elementKey, String expression, ParserContext parserContext) {

ExpressionKey expressionKey = createKey(elementKey, expression);
Expression expr = cache.get(expressionKey);
if (expr == null) {
expr = getParser().parseExpression(expression);
expr = getParser().parseExpression(expression, parserContext);
cache.put(expressionKey, expr);
}
return expr;
Expand Down

0 comments on commit 145e9b8

Please sign in to comment.