ApplicationContext-based HttpHandler setup
This commit adds support for detecting the target WebHandler along with WebFilters, WebExceptionHandlers, and other spring-web reactive strategies in an ApplicationContext. WebReactiveConfigurationSupport has @Bean factory methods for DispatcherHandler and ResponseStatusExceptionHandler. WebHttpHandlerBuilder has a static factory method that initializes the builder from an ApplicationContext. This method is also used in the DispatcherHandler#toHttpHandler(ApplicationContext) shortcut method. Issue: SPR-14837
This commit is contained in:
@@ -29,9 +29,7 @@ import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.http.server.reactive.AbstractHttpHandlerIntegrationTests;
|
||||
import org.springframework.http.server.reactive.HttpHandler;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
import org.springframework.web.reactive.DispatcherHandler;
|
||||
import org.springframework.web.server.adapter.WebHttpHandlerBuilder;
|
||||
import org.springframework.web.server.handler.ResponseStatusExceptionHandler;
|
||||
|
||||
import static org.springframework.http.RequestEntity.get;
|
||||
import static org.springframework.http.RequestEntity.options;
|
||||
@@ -53,10 +51,7 @@ public abstract class AbstractRequestMappingIntegrationTests extends AbstractHtt
|
||||
protected HttpHandler createHttpHandler() {
|
||||
this.restTemplate = initRestTemplate();
|
||||
this.applicationContext = initApplicationContext();
|
||||
return WebHttpHandlerBuilder
|
||||
.webHandler(new DispatcherHandler(this.applicationContext))
|
||||
.exceptionHandlers(new ResponseStatusExceptionHandler())
|
||||
.build();
|
||||
return WebHttpHandlerBuilder.applicationContext(this.applicationContext).build();
|
||||
}
|
||||
|
||||
protected abstract ApplicationContext initApplicationContext();
|
||||
|
||||
Reference in New Issue
Block a user