public class DispatcherHandler extends Object implements org.springframework.web.server.WebHandler, org.springframework.web.cors.reactive.PreFlightRequestHandler, org.springframework.context.ApplicationContextAware
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.
WebHttpHandlerBuilder.applicationContext(ApplicationContext)| Constructor and Description |
|---|
DispatcherHandler()
Create a new
DispatcherHandler which needs to be configured with
an ApplicationContext through setApplicationContext(org.springframework.context.ApplicationContext). |
DispatcherHandler(org.springframework.context.ApplicationContext applicationContext)
Create a new
DispatcherHandler for the given ApplicationContext. |
| Modifier and Type | Method and Description |
|---|---|
List<HandlerMapping> |
getHandlerMappings()
|
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) |
public DispatcherHandler()
DispatcherHandler which needs to be configured with
an ApplicationContext through setApplicationContext(org.springframework.context.ApplicationContext).public DispatcherHandler(org.springframework.context.ApplicationContext applicationContext)
DispatcherHandler for the given ApplicationContext.applicationContext - the application context to find the handler beans in@Nullable public final List<HandlerMapping> getHandlerMappings()
HandlerMapping beans detected by type in the
injected context and also
sorted.
Note: This method may return null if invoked
prior to setApplicationContext(ApplicationContext).
nullpublic void setApplicationContext(org.springframework.context.ApplicationContext applicationContext)
setApplicationContext in interface org.springframework.context.ApplicationContextAwareprotected void initStrategies(org.springframework.context.ApplicationContext context)
public reactor.core.publisher.Mono<Void> handle(org.springframework.web.server.ServerWebExchange exchange)
handle in interface org.springframework.web.server.WebHandlerpublic reactor.core.publisher.Mono<Void> handlePreFlight(org.springframework.web.server.ServerWebExchange exchange)
handlePreFlight in interface org.springframework.web.cors.reactive.PreFlightRequestHandler