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.server.WebHandler

    public class DispatcherHandler
    extends Object
    implements org.springframework.web.server.WebHandler, 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 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 with the bean name "webHandler" it is discovered by `WebHttpHandlerBuilder.applicationContext` which creates 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

Constructors
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`.

### Method Summary

All Methods Instance Methods Concrete Methods
`List<HandlerMapping>` `getHandlerMappings()` Return all `HandlerMapping` beans detected by type in the `injected context` and also `sorted`.
`reactor.core.publisher.Mono<Void>` `handle(org.springframework.web.server.ServerWebExchange exchange)`
`protected void` `initStrategies(org.springframework.context.ApplicationContext context)`
`void` `setApplicationContext(org.springframework.context.ApplicationContext applicationContext)`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Constructor Detail

#### DispatcherHandler

    public DispatcherHandler()

Create a new `DispatcherHandler` which needs to be configured with an `ApplicationContext` through `setApplicationContext(org.springframework.context.ApplicationContext)`.

#### DispatcherHandler

    public DispatcherHandler(org.springframework.context.ApplicationContext applicationContext)

Create a new `DispatcherHandler` for the given `ApplicationContext`.

Parameters:
  `applicationContext` - the application context to find the handler beans in

### Method Detail

#### getHandlerMappings

    @Nullable
    public final List<HandlerMapping> getHandlerMappings()

Return all `HandlerMapping` beans detected by type in the `injected context` and also `sorted`.

Note: This method may return `null` if invoked prior to `setApplicationContext(ApplicationContext)`.

Returns:
  immutable list with the configured mappings or `null`

#### setApplicationContext

    public void setApplicationContext(org.springframework.context.ApplicationContext applicationContext)

Specified by:
  `setApplicationContext` in interface `org.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 interface `org.springframework.web.server.WebHandler`