Package org.springframework.web.reactive
Class DispatcherHandler
java.lang.Object
org.springframework.web.reactive.DispatcherHandler
- All Implemented Interfaces:
org.springframework.beans.factory.Aware
,org.springframework.context.ApplicationContextAware
,org.springframework.web.cors.reactive.PreFlightRequestHandler
,org.springframework.web.server.WebHandler
public class DispatcherHandler
extends Object
implements org.springframework.web.server.WebHandler, org.springframework.web.cors.reactive.PreFlightRequestHandler, org.springframework.context.ApplicationContextAware
Central dispatcher for HTTP request handlers/controllers. Dispatches to
registered handlers for processing a request, providing convenient mapping
facilities.
DispatcherHandler
discovers the delegate components it needs from
Spring configuration. It detects the following in the application context:
HandlerMapping
-- map requests to handler objectsHandlerAdapter
-- for using any handler interfaceHandlerResultHandler
-- 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:
-
WebHttpHandlerBuilder.applicationContext(ApplicationContext)
-
Constructor Summary
ConstructorDescriptionCreate a newDispatcherHandler
which needs to be configured with anApplicationContext
throughsetApplicationContext(org.springframework.context.ApplicationContext)
.DispatcherHandler
(org.springframework.context.ApplicationContext applicationContext) Create a newDispatcherHandler
for the givenApplicationContext
. -
Method Summary
Modifier and TypeMethodDescriptionfinal List<HandlerMapping>
reactor.core.publisher.Mono<Void>
handle
(org.springframework.web.server.ServerWebExchange exchange) reactor.core.publisher.Mono<Void>
handlePreFlight
(org.springframework.web.server.ServerWebExchange exchange) protected void
initStrategies
(org.springframework.context.ApplicationContext context) void
setApplicationContext
(org.springframework.context.ApplicationContext applicationContext)
-
Constructor Details
-
DispatcherHandler
public DispatcherHandler()Create a newDispatcherHandler
which needs to be configured with anApplicationContext
throughsetApplicationContext(org.springframework.context.ApplicationContext)
. -
DispatcherHandler
public DispatcherHandler(org.springframework.context.ApplicationContext applicationContext) Create a newDispatcherHandler
for the givenApplicationContext
.- Parameters:
applicationContext
- the application context to find the handler beans in
-
-
Method Details
-
getHandlerMappings
Return allHandlerMapping
beans detected by type in theinjected context
and alsosorted
.Note: This method may return
null
if invoked prior tosetApplicationContext(ApplicationContext)
.- Returns:
- immutable list with the configured mappings or
null
-
setApplicationContext
public void setApplicationContext(org.springframework.context.ApplicationContext applicationContext) - Specified by:
setApplicationContext
in interfaceorg.springframework.context.ApplicationContextAware
-
initStrategies
protected void initStrategies(org.springframework.context.ApplicationContext context) -
handle
public reactor.core.publisher.Mono<Void> handle(org.springframework.web.server.ServerWebExchange exchange) - Specified by:
handle
in interfaceorg.springframework.web.server.WebHandler
-
handlePreFlight
public reactor.core.publisher.Mono<Void> handlePreFlight(org.springframework.web.server.ServerWebExchange exchange) - Specified by:
handlePreFlight
in interfaceorg.springframework.web.cors.reactive.PreFlightRequestHandler
-