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:
@@ -93,7 +93,7 @@ public class IntegrationFlowBeanPostProcessor
|
|||||||
|
|
||||||
private ConfigurableListableBeanFactory beanFactory;
|
private ConfigurableListableBeanFactory beanFactory;
|
||||||
|
|
||||||
private IntegrationFlowContext flowContext;
|
private volatile IntegrationFlowContext flowContext;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
|
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
|
||||||
@@ -105,8 +105,6 @@ public class IntegrationFlowBeanPostProcessor
|
|||||||
this.applicationContext = (ConfigurableApplicationContext) applicationContext;
|
this.applicationContext = (ConfigurableApplicationContext) applicationContext;
|
||||||
this.beanFactory = this.applicationContext.getBeanFactory();
|
this.beanFactory = this.applicationContext.getBeanFactory();
|
||||||
this.embeddedValueResolver = new EmbeddedValueResolver(this.beanFactory);
|
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
|
@Override
|
||||||
@@ -140,6 +138,9 @@ public class IntegrationFlowBeanPostProcessor
|
|||||||
|
|
||||||
private Object processStandardIntegrationFlow(StandardIntegrationFlow flow, String flowBeanName) {
|
private Object processStandardIntegrationFlow(StandardIntegrationFlow flow, String flowBeanName) {
|
||||||
String flowNamePrefix = flowBeanName + ".";
|
String flowNamePrefix = flowBeanName + ".";
|
||||||
|
if (this.flowContext == null) {
|
||||||
|
this.flowContext = this.beanFactory.getBean(IntegrationFlowContext.class);
|
||||||
|
}
|
||||||
boolean useFlowIdAsPrefix = this.flowContext.isUseIdAsPrefix(flowBeanName);
|
boolean useFlowIdAsPrefix = this.flowContext.isUseIdAsPrefix(flowBeanName);
|
||||||
int subFlowNameIndex = 0;
|
int subFlowNameIndex = 0;
|
||||||
int channelNameIndex = 0;
|
int channelNameIndex = 0;
|
||||||
|
|||||||
Reference in New Issue
Block a user