Avoid early initializations for reactive support
This commit flags the `BeanPostProcessor` registered by the reactive embedded support as `synthetic` so that it doesn't trigger an early initialization of other components. See gh-8467
This commit is contained in:
parent
36d6ab41a2
commit
546338ac80
|
|
@ -84,9 +84,11 @@ public class ReactiveWebServerAutoConfiguration {
|
||||||
}
|
}
|
||||||
if (ObjectUtils.isEmpty(this.beanFactory.getBeanNamesForType(
|
if (ObjectUtils.isEmpty(this.beanFactory.getBeanNamesForType(
|
||||||
ReactiveWebServerCustomizerBeanPostProcessor.class, true, false))) {
|
ReactiveWebServerCustomizerBeanPostProcessor.class, true, false))) {
|
||||||
|
RootBeanDefinition beanDefinition = new RootBeanDefinition(
|
||||||
|
ReactiveWebServerCustomizerBeanPostProcessor.class);
|
||||||
|
beanDefinition.setSynthetic(true);
|
||||||
registry.registerBeanDefinition(
|
registry.registerBeanDefinition(
|
||||||
"reactiveWebServerCustomizerBeanPostProcessor",
|
"reactiveWebServerCustomizerBeanPostProcessor", beanDefinition);
|
||||||
new RootBeanDefinition(ReactiveWebServerCustomizerBeanPostProcessor.class));
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -22,29 +22,30 @@ import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.springframework.beans.BeansException;
|
import org.springframework.beans.BeansException;
|
||||||
|
import org.springframework.beans.factory.BeanFactory;
|
||||||
|
import org.springframework.beans.factory.BeanFactoryAware;
|
||||||
|
import org.springframework.beans.factory.ListableBeanFactory;
|
||||||
import org.springframework.beans.factory.config.BeanPostProcessor;
|
import org.springframework.beans.factory.config.BeanPostProcessor;
|
||||||
import org.springframework.context.ApplicationContext;
|
|
||||||
import org.springframework.context.ApplicationContextAware;
|
|
||||||
import org.springframework.core.annotation.AnnotationAwareOrderComparator;
|
import org.springframework.core.annotation.AnnotationAwareOrderComparator;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@link BeanPostProcessor} that applies all {@link ReactiveWebServerCustomizer}s
|
* {@link BeanPostProcessor} that applies all {@link ReactiveWebServerCustomizer}s
|
||||||
* from the bean factory to {@link ConfigurableReactiveWebServer} beans.
|
* from the bean factory to {@link ConfigurableReactiveWebServer} beans.
|
||||||
*
|
*
|
||||||
*
|
|
||||||
* @author Brian Clozel
|
* @author Brian Clozel
|
||||||
|
* @author Stephane Nicoll
|
||||||
|
* @since 2.0.0
|
||||||
*/
|
*/
|
||||||
public class ReactiveWebServerCustomizerBeanPostProcessor
|
public class ReactiveWebServerCustomizerBeanPostProcessor
|
||||||
implements BeanPostProcessor, ApplicationContextAware {
|
implements BeanPostProcessor, BeanFactoryAware {
|
||||||
|
|
||||||
private ApplicationContext applicationContext;
|
private ListableBeanFactory beanFactory;
|
||||||
|
|
||||||
private List<ReactiveWebServerCustomizer> customizers;
|
private List<ReactiveWebServerCustomizer> customizers;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setApplicationContext(ApplicationContext applicationContext)
|
public void setBeanFactory(BeanFactory beanFactory) throws BeansException {
|
||||||
throws BeansException {
|
this.beanFactory = (ListableBeanFactory) beanFactory;
|
||||||
this.applicationContext = applicationContext;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -73,7 +74,7 @@ public class ReactiveWebServerCustomizerBeanPostProcessor
|
||||||
if (this.customizers == null) {
|
if (this.customizers == null) {
|
||||||
// Look up does not include the parent context
|
// Look up does not include the parent context
|
||||||
this.customizers = new ArrayList<ReactiveWebServerCustomizer>(
|
this.customizers = new ArrayList<ReactiveWebServerCustomizer>(
|
||||||
this.applicationContext
|
this.beanFactory
|
||||||
.getBeansOfType(ReactiveWebServerCustomizer.class,
|
.getBeansOfType(ReactiveWebServerCustomizer.class,
|
||||||
false, false)
|
false, false)
|
||||||
.values());
|
.values());
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue