mirror of
https://github.com/spring-projects/spring-framework.git
synced 2026-05-04 05:17:15 +01:00
Merge pull request #27604 from Xjzon
* pr/27604: Polish "Add support for custom expression parsing" Add support for custom expression parsing Closes gh-27604
This commit is contained in:
+11
-2
@@ -75,7 +75,7 @@ public abstract class CachedExpressionEvaluator {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the {@link Expression} for the specified SpEL value
|
* Return the {@link Expression} for the specified SpEL value
|
||||||
* <p>Parse the expression if it hasn't been already.
|
* <p>{@link #parseExpression(String) Parse the expression} if it hasn't been already.
|
||||||
* @param cache the cache to use
|
* @param cache the cache to use
|
||||||
* @param elementKey the element on which the expression is defined
|
* @param elementKey the element on which the expression is defined
|
||||||
* @param expression the expression to parse
|
* @param expression the expression to parse
|
||||||
@@ -86,12 +86,21 @@ public abstract class CachedExpressionEvaluator {
|
|||||||
ExpressionKey expressionKey = createKey(elementKey, expression);
|
ExpressionKey expressionKey = createKey(elementKey, expression);
|
||||||
Expression expr = cache.get(expressionKey);
|
Expression expr = cache.get(expressionKey);
|
||||||
if (expr == null) {
|
if (expr == null) {
|
||||||
expr = getParser().parseExpression(expression);
|
expr = parseExpression(expression);
|
||||||
cache.put(expressionKey, expr);
|
cache.put(expressionKey, expr);
|
||||||
}
|
}
|
||||||
return expr;
|
return expr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Parse the specified {@code expression}.
|
||||||
|
* @param expression the expression to parse
|
||||||
|
* @since 5.3.13
|
||||||
|
*/
|
||||||
|
protected Expression parseExpression(String expression) {
|
||||||
|
return getParser().parseExpression(expression);
|
||||||
|
}
|
||||||
|
|
||||||
private ExpressionKey createKey(AnnotatedElementKey elementKey, String expression) {
|
private ExpressionKey createKey(AnnotatedElementKey elementKey, String expression) {
|
||||||
return new ExpressionKey(elementKey, expression);
|
return new ExpressionKey(elementKey, expression);
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2002-2019 the original author or authors.
|
* Copyright 2002-2021 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|||||||
Reference in New Issue
Block a user