Package org.springframework.web.reactive
Interface HandlerAdapter
- All Known Implementing Classes:
HandlerFunctionAdapter,RequestMappingHandlerAdapter,SimpleHandlerAdapter,WebSocketHandlerAdapter
public interface HandlerAdapter
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(org.springframework.web.server.ServerWebExchange, java.lang.Object) handles the onNext signal, while
DispatchExceptionHandler.handleError(org.springframework.web.server.ServerWebExchange, java.lang.Throwable) handles the onError signal
from the dispatch processing chain.
- Since:
- 5.0
- Author:
- Rossen Stoyanchev, Sebastien Deleuze
-
Method Summary
Modifier and TypeMethodDescriptionreactor.core.publisher.Mono<HandlerResult>handle(ServerWebExchange exchange, Object handler) Handle the request with the given handler, previously checked viasupports(Object).booleanWhether thisHandlerAdaptersupports the givenhandler.
-
Method Details
-
supports
Whether thisHandlerAdaptersupports the givenhandler.- Parameters:
handler- the handler object to check- Returns:
- whether the handler is supported
-
handle
Handle the request with the given handler, previously checked viasupports(Object).Implementations should consider the following for exception handling:
- Handle invocation exceptions within this method.
Set an exception handleron the returnedHandlerResultto handle deferred exceptions from asynchronous return values, and to handle exceptions from response rendering.- Implement
DispatchExceptionHandlerto extend exception handling to exceptions that occur before a handler is selected.
- Parameters:
exchange- current server exchangehandler- the selected handler which must have been previously checked viasupports(Object)- Returns:
Monothat emits aHandlerResult, or completes empty if the request is fully handled; any error signal would not be handled within theDispatcherHandler, and would instead be processed by the chain of registeredWebExceptionHandlers at the end of theWebFilterchain
-