Class RequestMappingHandlerAdapter
java.lang.Object
org.springframework.web.reactive.result.method.annotation.RequestMappingHandlerAdapter
- All Implemented Interfaces:
org.springframework.beans.factory.Aware,org.springframework.beans.factory.InitializingBean,org.springframework.context.ApplicationContextAware,DispatchExceptionHandler,HandlerAdapter
public class RequestMappingHandlerAdapter
extends Object
implements HandlerAdapter, DispatchExceptionHandler, org.springframework.context.ApplicationContextAware, org.springframework.beans.factory.InitializingBean
Supports the invocation of
@RequestMapping
handler methods.- Since:
- 5.0
- Author:
- Rossen Stoyanchev
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidReturn the configured resolvers for controller method arguments.List<org.springframework.http.codec.HttpMessageReader<?>>Return the configurer for HTTP message readers.org.springframework.core.ReactiveAdapterRegistryReturn the configured registry for adapting reactive types.org.springframework.web.bind.support.WebBindingInitializerReturn the configured WebBindingInitializer, ornullif none.reactor.core.publisher.Mono<HandlerResult>Handle the request with the given handler, previously checked viaHandlerAdapter.supports(Object).reactor.core.publisher.Mono<HandlerResult>handleError(org.springframework.web.server.ServerWebExchange exchange, Throwable ex) Handle the given exception, mapping it to aHandlerResultthat can then be used to render an HTTP response.voidsetApplicationContext(org.springframework.context.ApplicationContext applicationContext) AConfigurableApplicationContextis expected for resolving expressions in method argument default values as well as for detecting@ControllerAdvicebeans.voidConfigure resolvers for controller method arguments.voidsetMessageReaders(List<org.springframework.http.codec.HttpMessageReader<?>> messageReaders) Configure HTTP message readers to de-serialize the request body with.voidsetReactiveAdapterRegistry(org.springframework.core.ReactiveAdapterRegistry registry) Configure the registry for adapting various reactive types.voidsetWebBindingInitializer(org.springframework.web.bind.support.WebBindingInitializer webBindingInitializer) Provide a WebBindingInitializer with "global" initialization to apply to every DataBinder instance.booleanWhether thisHandlerAdaptersupports the givenhandler.
-
Constructor Details
-
RequestMappingHandlerAdapter
public RequestMappingHandlerAdapter()
-
-
Method Details
-
setMessageReaders
public void setMessageReaders(List<org.springframework.http.codec.HttpMessageReader<?>> messageReaders) 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
public void setWebBindingInitializer(@Nullable org.springframework.web.bind.support.WebBindingInitializer webBindingInitializer) Provide a WebBindingInitializer with "global" initialization to apply to every DataBinder instance. -
getWebBindingInitializer
@Nullable public org.springframework.web.bind.support.WebBindingInitializer getWebBindingInitializer()Return the configured WebBindingInitializer, ornullif none. -
setArgumentResolverConfigurer
Configure resolvers for controller method arguments. -
getArgumentResolverConfigurer
Return the configured resolvers for controller method arguments. -
setReactiveAdapterRegistry
public void setReactiveAdapterRegistry(@Nullable org.springframework.core.ReactiveAdapterRegistry registry) Configure the registry for adapting various reactive types.By default this is an instance of
ReactiveAdapterRegistrywith default settings. -
getReactiveAdapterRegistry
@Nullable public org.springframework.core.ReactiveAdapterRegistry getReactiveAdapterRegistry()Return the configured registry for adapting reactive types. -
setApplicationContext
public void setApplicationContext(org.springframework.context.ApplicationContext applicationContext) AConfigurableApplicationContextis expected for resolving expressions in method argument default values as well as for detecting@ControllerAdvicebeans.- Specified by:
setApplicationContextin interfaceorg.springframework.context.ApplicationContextAware
-
afterPropertiesSet
- Specified by:
afterPropertiesSetin interfaceorg.springframework.beans.factory.InitializingBean- Throws:
Exception
-
supports
Description copied from interface:HandlerAdapterWhether thisHandlerAdaptersupports the givenhandler.- Specified by:
supportsin interfaceHandlerAdapter- Parameters:
handler- the handler object to check- Returns:
- whether the handler is supported
-
handle
public reactor.core.publisher.Mono<HandlerResult> handle(org.springframework.web.server.ServerWebExchange exchange, Object handler) Description copied from interface:HandlerAdapterHandle 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 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.
- Specified by:
handlein interfaceHandlerAdapter- Parameters:
exchange- current server exchangehandler- the selected handler which must have been previously checked viaHandlerAdapter.supports(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
-
handleError
public reactor.core.publisher.Mono<HandlerResult> handleError(org.springframework.web.server.ServerWebExchange exchange, Throwable ex) Description copied from interface:DispatchExceptionHandlerHandle the given exception, mapping it to aHandlerResultthat can then be used to render an HTTP response.- Specified by:
handleErrorin interfaceDispatchExceptionHandler- Parameters:
exchange- the current exchangeex- the exception to handle- Returns:
- a
Monothat emits aHandlerResultor an error signal with the original exception if it remains not handled
-