Class DispatcherHandler
- All Implemented Interfaces:
- Aware, ApplicationContextAware, PreFlightRequestHandler, WebHandler
DispatcherHandler discovers the delegate components it needs from
Spring configuration. It detects the following in the application context:
- HandlerMapping-- map requests to handler objects
- HandlerAdapter-- for using any handler interface
- HandlerResultHandler-- process handler return values
DispatcherHandler is also designed to be a Spring bean itself and
implements ApplicationContextAware for access to the context it runs
in. If DispatcherHandler is declared as a bean with the name
"webHandler", it is discovered by
WebHttpHandlerBuilder.applicationContext(ApplicationContext) which
puts together a processing chain together with WebFilter,
WebExceptionHandler and others.
A DispatcherHandler bean declaration is included in
@EnableWebFlux
configuration.
- Since:
- 5.0
- Author:
- Rossen Stoyanchev, Sebastien Deleuze, Juergen Hoeller
- See Also:
- 
Constructor SummaryConstructorsConstructorDescriptionCreate a newDispatcherHandlerwhich needs to be configured with anApplicationContextthroughsetApplicationContext(ApplicationContext).DispatcherHandler(ApplicationContext applicationContext) Create a newDispatcherHandlerfor the givenApplicationContext.
- 
Method SummaryModifier and TypeMethodDescriptionfinal @Nullable List<HandlerMapping> reactor.core.publisher.Mono<Void> handle(ServerWebExchange exchange) Handle the web server exchange.reactor.core.publisher.Mono<Void> handlePreFlight(ServerWebExchange exchange) Handle a pre-flight request by finding and applying the CORS configuration that matches the expected actual request.protected voidinitStrategies(ApplicationContext context) voidsetApplicationContext(ApplicationContext applicationContext) Set the ApplicationContext that this object runs in.
- 
Constructor Details- 
DispatcherHandlerpublic DispatcherHandler()Create a newDispatcherHandlerwhich needs to be configured with anApplicationContextthroughsetApplicationContext(ApplicationContext).
- 
DispatcherHandlerCreate a newDispatcherHandlerfor the givenApplicationContext.- Parameters:
- applicationContext- the application context to find the handler beans in
 
 
- 
- 
Method Details- 
getHandlerMappingsReturn allHandlerMappingbeans detected by type in theinjected contextand alsosorted.Note: This method may return nullif invoked prior tosetApplicationContext(ApplicationContext).- Returns:
- immutable list with the configured mappings or null
 
- 
setApplicationContextDescription copied from interface:ApplicationContextAwareSet the ApplicationContext that this object runs in. Normally this call will be used to initialize the object.Invoked after population of normal bean properties but before an init callback such as InitializingBean.afterPropertiesSet()or a custom init-method. Invoked afterResourceLoaderAware.setResourceLoader(ResourceLoader),ApplicationEventPublisherAware.setApplicationEventPublisher(ApplicationEventPublisher)andMessageSourceAware, if applicable.- Specified by:
- setApplicationContextin interface- ApplicationContextAware
- Parameters:
- applicationContext- the ApplicationContext object to be used by this object
- See Also:
 
- 
initStrategies
- 
handleDescription copied from interface:WebHandlerHandle the web server exchange.- Specified by:
- handlein interface- WebHandler
- Parameters:
- exchange- the current server exchange
- Returns:
- Mono<Void>to indicate when request handling is complete
 
- 
handlePreFlightDescription copied from interface:PreFlightRequestHandlerHandle a pre-flight request by finding and applying the CORS configuration that matches the expected actual request. As a result of handling, the response should be updated with CORS headers or rejected withHttpStatus.FORBIDDEN.- Specified by:
- handlePreFlightin interface- PreFlightRequestHandler
- Parameters:
- exchange- the exchange for the request
- Returns:
- a completion handle
 
 
-