diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/reactive/context/AnnotationConfigReactiveWebServerApplicationContext.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/reactive/context/AnnotationConfigReactiveWebServerApplicationContext.java index 5d52691266..51c7c1464f 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/reactive/context/AnnotationConfigReactiveWebServerApplicationContext.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/reactive/context/AnnotationConfigReactiveWebServerApplicationContext.java @@ -18,6 +18,7 @@ package org.springframework.boot.web.reactive.context; import org.springframework.beans.factory.config.ConfigurableListableBeanFactory; import org.springframework.beans.factory.support.BeanNameGenerator; +import org.springframework.beans.factory.support.DefaultListableBeanFactory; import org.springframework.context.annotation.AnnotatedBeanDefinitionReader; import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.context.annotation.AnnotationConfigUtils; @@ -69,6 +70,19 @@ public class AnnotationConfigReactiveWebServerApplicationContext this.scanner = new ClassPathBeanDefinitionScanner(this); } + /** + * Create a new {@link AnnotationConfigReactiveWebServerApplicationContext} with the + * given {@code DefaultListableBeanFactory}. The context needs to be populated through + * {@link #register} calls and then manually {@linkplain #refresh refreshed}. + * @param beanFactory the DefaultListableBeanFactory instance to use for this context + */ + public AnnotationConfigReactiveWebServerApplicationContext( + DefaultListableBeanFactory beanFactory) { + super(beanFactory); + this.reader = new AnnotatedBeanDefinitionReader(this); + this.scanner = new ClassPathBeanDefinitionScanner(this); + } + /** * Create a new {@link AnnotationConfigReactiveWebServerApplicationContext}, deriving * bean definitions from the given annotated classes and automatically refreshing the diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/reactive/context/ReactiveWebServerApplicationContext.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/reactive/context/ReactiveWebServerApplicationContext.java index aff7446dbe..390390f117 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/reactive/context/ReactiveWebServerApplicationContext.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/reactive/context/ReactiveWebServerApplicationContext.java @@ -17,6 +17,7 @@ package org.springframework.boot.web.reactive.context; import org.springframework.beans.BeansException; +import org.springframework.beans.factory.support.DefaultListableBeanFactory; import org.springframework.boot.web.reactive.server.ReactiveWebServerFactory; import org.springframework.boot.web.server.WebServer; import org.springframework.context.ApplicationContextException; @@ -35,9 +36,21 @@ public class ReactiveWebServerApplicationContext private volatile WebServer webServer; + /** + * Create a new {@link ReactiveWebServerApplicationContext}. + */ public ReactiveWebServerApplicationContext() { } + /** + * Create a new {@link ReactiveWebServerApplicationContext} with the given + * {@code DefaultListableBeanFactory}. + * @param beanFactory the DefaultListableBeanFactory instance to use for this context + */ + public ReactiveWebServerApplicationContext(DefaultListableBeanFactory beanFactory) { + super(beanFactory); + } + @Override public final void refresh() throws BeansException, IllegalStateException { try { diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/servlet/context/AnnotationConfigServletWebServerApplicationContext.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/servlet/context/AnnotationConfigServletWebServerApplicationContext.java index 9174db756e..fa0a0cb871 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/servlet/context/AnnotationConfigServletWebServerApplicationContext.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/servlet/context/AnnotationConfigServletWebServerApplicationContext.java @@ -18,6 +18,7 @@ package org.springframework.boot.web.servlet.context; import org.springframework.beans.factory.config.ConfigurableListableBeanFactory; import org.springframework.beans.factory.support.BeanNameGenerator; +import org.springframework.beans.factory.support.DefaultListableBeanFactory; import org.springframework.context.annotation.AnnotatedBeanDefinitionReader; import org.springframework.context.annotation.AnnotationConfigUtils; import org.springframework.context.annotation.AnnotationScopeMetadataResolver; @@ -67,6 +68,19 @@ public class AnnotationConfigServletWebServerApplicationContext this.scanner = new ClassPathBeanDefinitionScanner(this); } + /** + * Create a new {@link AnnotationConfigServletWebServerApplicationContext} with the + * given {@code DefaultListableBeanFactory}. The context needs to be populated through + * {@link #register} calls and then manually {@linkplain #refresh refreshed}. + * @param beanFactory the DefaultListableBeanFactory instance to use for this context + */ + public AnnotationConfigServletWebServerApplicationContext( + DefaultListableBeanFactory beanFactory) { + super(beanFactory); + this.reader = new AnnotatedBeanDefinitionReader(this); + this.scanner = new ClassPathBeanDefinitionScanner(this); + } + /** * Create a new {@link AnnotationConfigServletWebServerApplicationContext}, deriving * bean definitions from the given annotated classes and automatically refreshing the diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/servlet/context/ServletWebServerApplicationContext.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/servlet/context/ServletWebServerApplicationContext.java index 6f7202eee7..1ddd830efa 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/servlet/context/ServletWebServerApplicationContext.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/servlet/context/ServletWebServerApplicationContext.java @@ -36,6 +36,7 @@ import org.apache.commons.logging.LogFactory; import org.springframework.beans.BeansException; import org.springframework.beans.factory.config.ConfigurableListableBeanFactory; import org.springframework.beans.factory.config.Scope; +import org.springframework.beans.factory.support.DefaultListableBeanFactory; import org.springframework.boot.web.server.WebServer; import org.springframework.boot.web.servlet.FilterRegistrationBean; import org.springframework.boot.web.servlet.ServletContextInitializer; @@ -105,6 +106,21 @@ public class ServletWebServerApplicationContext extends GenericWebApplicationCon private String namespace; + /** + * Create a new {@link ServletWebServerApplicationContext}. + */ + public ServletWebServerApplicationContext() { + } + + /** + * Create a new {@link ServletWebServerApplicationContext} with the given + * {@code DefaultListableBeanFactory}. + * @param beanFactory the DefaultListableBeanFactory instance to use for this context + */ + public ServletWebServerApplicationContext(DefaultListableBeanFactory beanFactory) { + super(beanFactory); + } + /** * Register ServletContextAwareProcessor. * @see ServletContextAwareProcessor