Skip to content

Commit 8fc744f

Browse files
committed
Improve Javadoc for BeanExpressionResolver
1 parent 9a5891e commit 8fc744f

File tree

2 files changed

+14
-13
lines changed

2 files changed

+14
-13
lines changed

spring-beans/src/main/java/org/springframework/beans/factory/config/BeanExpressionResolver.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2017 the original author or authors.
2+
* Copyright 2002-2022 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -20,8 +20,8 @@
2020
import org.springframework.lang.Nullable;
2121

2222
/**
23-
* Strategy interface for resolving a value through evaluating it
24-
* as an expression, if applicable.
23+
* Strategy interface for resolving a value by evaluating it as an expression,
24+
* if applicable.
2525
*
2626
* <p>A raw {@link org.springframework.beans.factory.BeanFactory} does not
2727
* contain a default implementation of this strategy. However,
@@ -36,12 +36,13 @@ public interface BeanExpressionResolver {
3636
/**
3737
* Evaluate the given value as an expression, if applicable;
3838
* return the value as-is otherwise.
39-
* @param value the value to check
40-
* @param evalContext the evaluation context
39+
* @param value the value to evaluate as an expression
40+
* @param beanExpressionContext the bean expression context to use when
41+
* evaluating the expression
4142
* @return the resolved value (potentially the given value as-is)
4243
* @throws BeansException if evaluation failed
4344
*/
4445
@Nullable
45-
Object evaluate(@Nullable String value, BeanExpressionContext evalContext) throws BeansException;
46+
Object evaluate(@Nullable String value, BeanExpressionContext beanExpressionContext) throws BeansException;
4647

4748
}

spring-context/src/main/java/org/springframework/context/expression/StandardBeanExpressionResolver.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ public void setExpressionParser(ExpressionParser expressionParser) {
138138

139139
@Override
140140
@Nullable
141-
public Object evaluate(@Nullable String value, BeanExpressionContext evalContext) throws BeansException {
141+
public Object evaluate(@Nullable String value, BeanExpressionContext beanExpressionContext) throws BeansException {
142142
if (!StringUtils.hasLength(value)) {
143143
return value;
144144
}
@@ -148,21 +148,21 @@ public Object evaluate(@Nullable String value, BeanExpressionContext evalContext
148148
expr = this.expressionParser.parseExpression(value, this.beanExpressionParserContext);
149149
this.expressionCache.put(value, expr);
150150
}
151-
StandardEvaluationContext sec = this.evaluationCache.get(evalContext);
151+
StandardEvaluationContext sec = this.evaluationCache.get(beanExpressionContext);
152152
if (sec == null) {
153-
sec = new StandardEvaluationContext(evalContext);
153+
sec = new StandardEvaluationContext(beanExpressionContext);
154154
sec.addPropertyAccessor(new BeanExpressionContextAccessor());
155155
sec.addPropertyAccessor(new BeanFactoryAccessor());
156156
sec.addPropertyAccessor(new MapAccessor());
157157
sec.addPropertyAccessor(new EnvironmentAccessor());
158-
sec.setBeanResolver(new BeanFactoryResolver(evalContext.getBeanFactory()));
159-
sec.setTypeLocator(new StandardTypeLocator(evalContext.getBeanFactory().getBeanClassLoader()));
158+
sec.setBeanResolver(new BeanFactoryResolver(beanExpressionContext.getBeanFactory()));
159+
sec.setTypeLocator(new StandardTypeLocator(beanExpressionContext.getBeanFactory().getBeanClassLoader()));
160160
sec.setTypeConverter(new StandardTypeConverter(() -> {
161-
ConversionService cs = evalContext.getBeanFactory().getConversionService();
161+
ConversionService cs = beanExpressionContext.getBeanFactory().getConversionService();
162162
return (cs != null ? cs : DefaultConversionService.getSharedInstance());
163163
}));
164164
customizeEvaluationContext(sec);
165-
this.evaluationCache.put(evalContext, sec);
165+
this.evaluationCache.put(beanExpressionContext, sec);
166166
}
167167
return expr.getValue(sec);
168168
}

0 commit comments

Comments
 (0)