Top Description Methods
org.springframework.web.reactive

public Interface HandlerAdapter

Known Direct Implementers
org.springframework.web.reactive.function.server.support.HandlerFunctionAdapter, org.springframework.web.reactive.result.SimpleHandlerAdapter, org.springframework.web.reactive.result.method.annotation.RequestMappingHandlerAdapter, org.springframework.web.reactive.socket.server.support.WebSocketHandlerAdapter
Imports
reactor.core.publisher.Mono, org.springframework.web.server.ServerWebExchange

Contract to abstract the details of invoking a handler of a given type.

An implementation can also choose to be an instance of DispatchExceptionHandler if it wants to handle exceptions that occur before the request is successfully mapped to a handler. This allows a HandlerAdapter to expose the same exception handling both for handler invocation errors and for errors before a handler is selected. In Reactive Streams terms, handle handles the onNext signal, while DispatchExceptionHandler#handleError handles the onError signal from the dispatch processing chain.

Authors
Rossen Stoyanchev, Sebastien Deleuze
Since
5.0

Method Summary

Modifier and TypeMethod and Description
public Mono<HandlerResult>

Returns:

Mono that emits a HandlerResult, or completes empty if the request is fully handled; any error signal would not be handled within the DispatcherHandler, and would instead be processed by the chain of registered org.springframework.web.server.WebExceptionHandlers at the end of the org.springframework.web.server.WebFilter chain
handle
(ServerWebExchange
current server exchange
exchange
,
Object
the selected handler which must have been previously checked via supports(Object)
handler
)

Handle the request with the given handler, previously checked via supports(Object).

public boolean

Returns:

whether the handler is supported
supports
(Object
the handler object to check
handler
)

Whether this HandlerAdapter supports the given handler.

Method Detail

handleback to summary
public Mono<HandlerResult> handle(ServerWebExchange exchange, Object handler)

Handle the request with the given handler, previously checked via supports(Object).

Implementations should consider the following for exception handling:

  • Handle invocation exceptions within this method.
  • Set an exception handler on the returned HandlerResult to handle deferred exceptions from asynchronous return values, and to handle exceptions from response rendering.
  • Implement DispatchExceptionHandler to extend exception handling to exceptions that occur before a handler is selected.
Parameters
exchange:ServerWebExchange

current server exchange

handler:Object

the selected handler which must have been previously checked via supports(Object)

Returns:Mono<HandlerResult>

Mono that emits a HandlerResult, or completes empty if the request is fully handled; any error signal would not be handled within the DispatcherHandler, and would instead be processed by the chain of registered org.springframework.web.server.WebExceptionHandlers at the end of the org.springframework.web.server.WebFilter chain

supportsback to summary
public boolean supports(Object handler)

Whether this HandlerAdapter supports the given handler.

Parameters
handler:Object

the handler object to check

Returns:boolean

whether the handler is supported