Skip to content

Commit 585f92a

Browse files
committed
* Fix AbstractExpressionEvaluator
* Add JavaDocs for the `IntegrationEvaluationContextAware`
1 parent 9499ae2 commit 585f92a

File tree

2 files changed

+14
-6
lines changed

2 files changed

+14
-6
lines changed

spring-integration-core/src/main/java/org/springframework/integration/expression/IntegrationEvaluationContextAware.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,21 @@
1919
import org.springframework.expression.EvaluationContext;
2020

2121
/**
22+
* Interface to be implemented by beans that wish to be aware of their
23+
* owning integration {@link EvaluationContext}, which is the result of
24+
* {@link org.springframework.integration.config.IntegrationEvaluationContextFactoryBean}
25+
* <p>
26+
* The {@link #setIntegrationEvaluationContext} is invoked from
27+
* the {@link IntegrationEvaluationContextAwareBeanPostProcessor#afterSingletonsInstantiated()},
28+
* not during standard {@code postProcessBefore(After)Initialization} to avoid any
29+
* {@code BeanFactory} early access during integration {@link EvaluationContext} retrieval.
30+
* Therefore, if it is necessary to use {@link EvaluationContext} in the {@code afterPropertiesSet()},
31+
* the {@code IntegrationContextUtils.getEvaluationContext(this.beanFactory)} should be used instead
32+
* of this interface implementation.
33+
*
2234
* @author Artem Bilan
2335
* @since 3.0
36+
* @see IntegrationEvaluationContextAwareBeanPostProcessor
2437
*/
2538
public interface IntegrationEvaluationContextAware {
2639

spring-integration-core/src/main/java/org/springframework/integration/util/AbstractExpressionEvaluator.java

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,6 @@ public abstract class AbstractExpressionEvaluator implements BeanFactoryAware, I
5656

5757
private volatile MessageBuilderFactory messageBuilderFactory = new DefaultMessageBuilderFactory();
5858

59-
private volatile boolean messageBuilderFactorySet;
60-
6159
/**
6260
* Specify a BeanFactory in order to enable resolution via <code>@beanName</code> in the expression.
6361
*/
@@ -83,16 +81,13 @@ public void setConversionService(ConversionService conversionService) {
8381
}
8482

8583
protected MessageBuilderFactory getMessageBuilderFactory() {
86-
if (this.messageBuilderFactory == null) {
87-
this.messageBuilderFactory = new DefaultMessageBuilderFactory();
88-
}
8984
return this.messageBuilderFactory;
9085
}
9186

9287
@Override
9388
public void afterPropertiesSet() throws Exception {
9489
getEvaluationContext();
95-
if (this.messageBuilderFactory == null) {
90+
if (this.beanFactory != null) {
9691
this.messageBuilderFactory = IntegrationUtils.getMessageBuilderFactory(this.beanFactory);
9792
}
9893
}

0 commit comments

Comments
 (0)