mirror of
https://github.com/spring-projects/spring-boot.git
synced 2024-09-03 04:26:12 +08:00
Merge branch '1.4.x' into 1.5.x
This commit is contained in:
commit
a3d5101369
@ -134,25 +134,21 @@ public class EmbeddedServletContainerAutoConfiguration {
|
||||
if (this.beanFactory == null) {
|
||||
return;
|
||||
}
|
||||
if (ObjectUtils.isEmpty(this.beanFactory.getBeanNamesForType(
|
||||
EmbeddedServletContainerCustomizerBeanPostProcessor.class, true,
|
||||
false))) {
|
||||
RootBeanDefinition beanDefinition = new RootBeanDefinition(
|
||||
EmbeddedServletContainerCustomizerBeanPostProcessor.class);
|
||||
beanDefinition.setSynthetic(true);
|
||||
registry.registerBeanDefinition(
|
||||
"embeddedServletContainerCustomizerBeanPostProcessor",
|
||||
beanDefinition);
|
||||
registerSyntheticBeanIfMissing(registry,
|
||||
"embeddedServletContainerCustomizerBeanPostProcessor",
|
||||
EmbeddedServletContainerCustomizerBeanPostProcessor.class);
|
||||
registerSyntheticBeanIfMissing(registry,
|
||||
"errorPageRegistrarBeanPostProcessor",
|
||||
ErrorPageRegistrarBeanPostProcessor.class);
|
||||
}
|
||||
|
||||
}
|
||||
if (ObjectUtils.isEmpty(this.beanFactory.getBeanNamesForType(
|
||||
ErrorPageRegistrarBeanPostProcessor.class, true, false))) {
|
||||
RootBeanDefinition beanDefinition = new RootBeanDefinition(
|
||||
ErrorPageRegistrarBeanPostProcessor.class);
|
||||
private void registerSyntheticBeanIfMissing(BeanDefinitionRegistry registry,
|
||||
String name, Class<?> beanClass) {
|
||||
if (ObjectUtils.isEmpty(
|
||||
this.beanFactory.getBeanNamesForType(beanClass, true, false))) {
|
||||
RootBeanDefinition beanDefinition = new RootBeanDefinition(beanClass);
|
||||
beanDefinition.setSynthetic(true);
|
||||
registry.registerBeanDefinition("errorPageRegistrarBeanPostProcessor",
|
||||
beanDefinition);
|
||||
|
||||
registry.registerBeanDefinition(name, beanDefinition);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -27,6 +27,7 @@ import org.springframework.beans.factory.BeanFactoryAware;
|
||||
import org.springframework.beans.factory.ListableBeanFactory;
|
||||
import org.springframework.beans.factory.config.BeanPostProcessor;
|
||||
import org.springframework.core.annotation.AnnotationAwareOrderComparator;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
* {@link BeanPostProcessor} that applies all {@link EmbeddedServletContainerCustomizer}s
|
||||
@ -45,6 +46,9 @@ public class EmbeddedServletContainerCustomizerBeanPostProcessor
|
||||
|
||||
@Override
|
||||
public void setBeanFactory(BeanFactory beanFactory) {
|
||||
Assert.isInstanceOf(ListableBeanFactory.class, beanFactory,
|
||||
"EmbeddedServletContainerCustomizerBeanPostProcessor can only be used "
|
||||
+ "with a ListableBeanFactory");
|
||||
this.beanFactory = (ListableBeanFactory) beanFactory;
|
||||
}
|
||||
|
||||
|
@ -27,6 +27,7 @@ import org.springframework.beans.factory.BeanFactoryAware;
|
||||
import org.springframework.beans.factory.ListableBeanFactory;
|
||||
import org.springframework.beans.factory.config.BeanPostProcessor;
|
||||
import org.springframework.core.annotation.AnnotationAwareOrderComparator;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
* {@link BeanPostProcessor} that applies all {@link ErrorPageRegistrar}s from the bean
|
||||
@ -45,6 +46,9 @@ public class ErrorPageRegistrarBeanPostProcessor
|
||||
|
||||
@Override
|
||||
public void setBeanFactory(BeanFactory beanFactory) {
|
||||
Assert.isInstanceOf(ListableBeanFactory.class, beanFactory,
|
||||
"ErrorPageRegistrarBeanPostProcessor can only be used "
|
||||
+ "with a ListableBeanFactory");
|
||||
this.beanFactory = (ListableBeanFactory) beanFactory;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user