Align ReactiveWebApplicationContext with framework

Refactor `ReactiveWebApplicationContext` implementations to align closer
with the `WebApplicationContext` implementations defined in
Spring Framework.

The following classes are now provided:

  - `AnnotationConfigReactiveWebApplicationContext` -- A refreshable
    reactive web context with support for `@Configuration` classes.

  - `GenericReactiveWebApplicationContext` -- A non-refreshable reactive
    GenericApplicationContext.

  - `ReactiveWebServerApplicationContext` --  A non-refreshable reactive
    GenericApplicationContext with support for server discovery.

  - `AnnotationConfigReactiveWebServerApplicationContext` -- A
    non-refreshable reactive `GenericApplicationContext` with support
    for `@Configuration` classes and server discovery.

These classes roughly align to the following Servlet equivalents:

  - `AnnotationConfigWebApplicationContext` (Spring Framework)
  - `GenericWebApplicationContext` (Spring Framework)
  - `ServletWebServerApplicationContext` (Spring Boot)
  - `AnnotationConfigServletWebServerApplicationContext` (Spring Boot)

An additional `ConfigurableReactiveWebEnvironment` interface as also
been introduced, primarily for `@ConditionalOnWebApplication` to use.

Fixes gh-10852
This commit is contained in:
Phillip Webb
2017-11-03 15:56:34 -07:00
parent b6166dc12a
commit fa191d8c73
24 changed files with 968 additions and 111 deletions

View File

@@ -25,6 +25,7 @@ import org.springframework.boot.actuate.endpoint.web.EndpointMediaTypes;
import org.springframework.boot.actuate.endpoint.web.annotation.WebAnnotationEndpointDiscoverer;
import org.springframework.boot.endpoint.web.EndpointMapping;
import org.springframework.boot.web.embedded.netty.NettyReactiveWebServerFactory;
import org.springframework.boot.web.reactive.context.AnnotationConfigReactiveWebServerApplicationContext;
import org.springframework.boot.web.reactive.context.ReactiveWebServerApplicationContext;
import org.springframework.boot.web.reactive.context.ReactiveWebServerInitializedEvent;
import org.springframework.context.ApplicationContext;
@@ -80,9 +81,9 @@ public class WebFluxEndpointIntegrationTests
}
@Override
protected ReactiveWebServerApplicationContext createApplicationContext(
protected AnnotationConfigReactiveWebServerApplicationContext createApplicationContext(
Class<?>... config) {
ReactiveWebServerApplicationContext context = new ReactiveWebServerApplicationContext();
AnnotationConfigReactiveWebServerApplicationContext context = new AnnotationConfigReactiveWebServerApplicationContext();
context.register(config);
return context;
}

View File

@@ -34,7 +34,7 @@ import org.springframework.boot.autoconfigure.web.reactive.WebFluxAutoConfigurat
import org.springframework.boot.endpoint.web.EndpointMapping;
import org.springframework.boot.web.context.WebServerInitializedEvent;
import org.springframework.boot.web.embedded.netty.NettyReactiveWebServerFactory;
import org.springframework.boot.web.reactive.context.ReactiveWebServerApplicationContext;
import org.springframework.boot.web.reactive.context.AnnotationConfigReactiveWebServerApplicationContext;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationListener;
import org.springframework.context.ConfigurableApplicationContext;
@@ -58,7 +58,7 @@ class WebFluxEndpointsRunner extends AbstractWebEndpointRunner {
}
private static ConfigurableApplicationContext createContext(List<Class<?>> classes) {
ReactiveWebServerApplicationContext context = new ReactiveWebServerApplicationContext();
AnnotationConfigReactiveWebServerApplicationContext context = new AnnotationConfigReactiveWebServerApplicationContext();
classes.add(WebFluxEndpointConfiguration.class);
context.register(classes.toArray(new Class<?>[classes.size()]));
context.refresh();