INT-4501: Don't call getBean from BPP.setBFactory

JIRA: https://jira.spring.io/browse/INT-4501

The call to the `IntegrationFlowBeanPostProcessor#setBeanFactory`
happens during BPP creation.
The introduced call to `beanFactory#getBean` triggers a lot of bean
creations.
For those beans not all `BPP`s are applied.

* Obtain a `flowContext` bean in lazy-load manner

**Cherry-pick to 5.0.x**
This commit is contained in:
Artem Bilan
2018-07-16 19:40:06 -04:00
parent aac4051d68
commit de9f8d7ccd

View File

@@ -93,7 +93,7 @@ public class IntegrationFlowBeanPostProcessor
private ConfigurableListableBeanFactory beanFactory;
private IntegrationFlowContext flowContext;
private volatile IntegrationFlowContext flowContext;
@Override
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
@@ -105,8 +105,6 @@ public class IntegrationFlowBeanPostProcessor
this.applicationContext = (ConfigurableApplicationContext) applicationContext;
this.beanFactory = this.applicationContext.getBeanFactory();
this.embeddedValueResolver = new EmbeddedValueResolver(this.beanFactory);
this.flowContext = this.beanFactory.getBean(IntegrationFlowContext.class);
Assert.notNull(this.flowContext, "There must be an IntegrationFlowContext in the application context");
}
@Override
@@ -140,6 +138,9 @@ public class IntegrationFlowBeanPostProcessor
private Object processStandardIntegrationFlow(StandardIntegrationFlow flow, String flowBeanName) {
String flowNamePrefix = flowBeanName + ".";
if (this.flowContext == null) {
this.flowContext = this.beanFactory.getBean(IntegrationFlowContext.class);
}
boolean useFlowIdAsPrefix = this.flowContext.isUseIdAsPrefix(flowBeanName);
int subFlowNameIndex = 0;
int channelNameIndex = 0;