Add beanFactory context constructors
Align `WebServer` application contexts with Spring Framework by allowing a custom beanFactory to be used on construction. Fixes gh-8547
This commit is contained in:
parent
99afc4bc1f
commit
74c48767a1
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in New Issue