Class RequestMappingHandlerAdapter
java.lang.Object
org.springframework.web.reactive.result.method.annotation.RequestMappingHandlerAdapter
- All Implemented Interfaces:
Aware
,InitializingBean
,ApplicationContextAware
,DispatchExceptionHandler
,HandlerAdapter
public class RequestMappingHandlerAdapter
extends Object
implements HandlerAdapter, DispatchExceptionHandler, ApplicationContextAware, InitializingBean
Supports the invocation of
@RequestMapping
handler methods.- Since:
- 5.0
- Author:
- Rossen Stoyanchev
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Invoked by the containingBeanFactory
after it has set all bean properties and satisfiedBeanFactoryAware
,ApplicationContextAware
etc.Return the configured resolvers for controller method arguments.Return the configurer for HTTP message readers.Return the configured registry for adapting reactive types.Return the configured WebBindingInitializer, ornull
if none.reactor.core.publisher.Mono<HandlerResult>
handle
(ServerWebExchange exchange, Object handler) Handle the request with the given handler, previously checked viaHandlerAdapter.supports(Object)
.reactor.core.publisher.Mono<HandlerResult>
handleError
(ServerWebExchange exchange, Throwable ex) Handle the given exception, mapping it to aHandlerResult
that can then be used to render an HTTP response.void
setApplicationContext
(ApplicationContext applicationContext) AConfigurableApplicationContext
is expected for resolving expressions in method argument default values as well as for detecting@ControllerAdvice
beans.void
Configure resolvers for controller method arguments.void
setMessageReaders
(List<HttpMessageReader<?>> messageReaders) Configure HTTP message readers to de-serialize the request body with.void
Configure the registry for adapting various reactive types.void
setWebBindingInitializer
(WebBindingInitializer webBindingInitializer) Provide a WebBindingInitializer with "global" initialization to apply to every DataBinder instance.boolean
Whether thisHandlerAdapter
supports the givenhandler
.
-
Constructor Details
-
RequestMappingHandlerAdapter
public RequestMappingHandlerAdapter()
-
-
Method Details
-
setMessageReaders
Configure HTTP message readers to de-serialize the request body with.By default this is set to
ServerCodecConfigurer
's readers with defaults. -
getMessageReaders
Return the configurer for HTTP message readers. -
setWebBindingInitializer
Provide a WebBindingInitializer with "global" initialization to apply to every DataBinder instance. -
getWebBindingInitializer
Return the configured WebBindingInitializer, ornull
if none. -
setArgumentResolverConfigurer
Configure resolvers for controller method arguments. -
getArgumentResolverConfigurer
Return the configured resolvers for controller method arguments. -
setReactiveAdapterRegistry
Configure the registry for adapting various reactive types.By default this is an instance of
ReactiveAdapterRegistry
with default settings. -
getReactiveAdapterRegistry
Return the configured registry for adapting reactive types. -
setApplicationContext
AConfigurableApplicationContext
is expected for resolving expressions in method argument default values as well as for detecting@ControllerAdvice
beans.- Specified by:
setApplicationContext
in interfaceApplicationContextAware
- Parameters:
applicationContext
- the ApplicationContext object to be used by this object- See Also:
-
afterPropertiesSet
Description copied from interface:InitializingBean
Invoked by the containingBeanFactory
after it has set all bean properties and satisfiedBeanFactoryAware
,ApplicationContextAware
etc.This method allows the bean instance to perform validation of its overall configuration and final initialization when all bean properties have been set.
- Specified by:
afterPropertiesSet
in interfaceInitializingBean
- Throws:
Exception
- in the event of misconfiguration (such as failure to set an essential property) or if initialization fails for any other reason
-
supports
Description copied from interface:HandlerAdapter
Whether thisHandlerAdapter
supports the givenhandler
.- Specified by:
supports
in interfaceHandlerAdapter
- Parameters:
handler
- the handler object to check- Returns:
- whether the handler is supported
-
handle
public reactor.core.publisher.Mono<HandlerResult> handle(ServerWebExchange exchange, Object handler) Description copied from interface:HandlerAdapter
Handle the request with the given handler, previously checked viaHandlerAdapter.supports(Object)
.Implementations should consider the following for exception handling:
- Handle invocation exceptions within this method.
Set an exception handler
on the returnedHandlerResult
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.
- Specified by:
handle
in interfaceHandlerAdapter
- Parameters:
exchange
- current server exchangehandler
- the selected handler which must have been previously checked viaHandlerAdapter.supports(Object)
- Returns:
Mono
that 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 registeredWebExceptionHandler
s at the end of theWebFilter
chain
-
handleError
public reactor.core.publisher.Mono<HandlerResult> handleError(ServerWebExchange exchange, Throwable ex) Description copied from interface:DispatchExceptionHandler
Handle the given exception, mapping it to aHandlerResult
that can then be used to render an HTTP response.- Specified by:
handleError
in interfaceDispatchExceptionHandler
- Parameters:
exchange
- the current exchangeex
- the exception to handle- Returns:
- a
Mono
that emits aHandlerResult
or an error signal with the original exception if it remains not handled
-