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, Brian Clozel
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionvoidInvoked by the containingBeanFactoryafter it has set all bean properties and satisfiedBeanFactoryAware,ApplicationContextAwareetc.Return the configured resolvers for controller method arguments.Return the configuredRequestedContentTypeResolver.Return the configurer for HTTP message readers.Return the configured registry for adapting reactive types.Return the configured WebBindingInitializer, ornullif 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 aHandlerResultthat can then be used to render an HTTP response.voidsetApplicationContext(ApplicationContext applicationContext) AConfigurableApplicationContextis expected for resolving expressions in method argument default values as well as for detecting@ControllerAdvicebeans.voidConfigure resolvers for controller method arguments.voidsetBlockingExecutor(Executor executor) Configure an executor to invoke blocking controller methods with.voidsetBlockingMethodPredicate(Predicate<HandlerMethod> predicate) Provide a predicate to decide which controller methods to invoke through the configuredblockingExecutor.voidsetContentTypeResolver(RequestedContentTypeResolver contentTypeResolver) Set theRequestedContentTypeResolverto use to determine requested media types.voidsetMessageReaders(List<HttpMessageReader<?>> messageReaders) Configure HTTP message readers to de-serialize the request body with.voidConfigure the registry for adapting various reactive types.voidsetWebBindingInitializer(WebBindingInitializer webBindingInitializer) Provide a WebBindingInitializer with "global" initialization to apply to every DataBinder instance.booleanWhether thisHandlerAdaptersupports the givenhandler.
- 
Constructor Details- 
RequestMappingHandlerAdapterpublic RequestMappingHandlerAdapter()
 
- 
- 
Method Details- 
setMessageReadersConfigure HTTP message readers to de-serialize the request body with.By default this is set to ServerCodecConfigurer's readers with defaults.
- 
getMessageReadersReturn the configurer for HTTP message readers.
- 
setWebBindingInitializerProvide a WebBindingInitializer with "global" initialization to apply to every DataBinder instance.
- 
getWebBindingInitializerReturn the configured WebBindingInitializer, ornullif none.
- 
setArgumentResolverConfigurerConfigure resolvers for controller method arguments.
- 
getArgumentResolverConfigurerReturn the configured resolvers for controller method arguments.
- 
setContentTypeResolverSet theRequestedContentTypeResolverto use to determine requested media types. If not set, the default constructor is used.- Since:
- 6.2
 
- 
getContentTypeResolverReturn the configuredRequestedContentTypeResolver.- Since:
- 6.2
 
- 
setBlockingExecutorConfigure an executor to invoke blocking controller methods with.By default, this is not set in which case controller methods are invoked without the use of an Executor. - Parameters:
- executor- the task executor to use
- Since:
- 6.1
 
- 
setBlockingMethodPredicateProvide a predicate to decide which controller methods to invoke through the configuredblockingExecutor.If an executor is configured, the default predicate matches controller methods whose return type is not recognized by the configured ReactiveAdapterRegistry.- Parameters:
- predicate- the predicate to use
- Since:
- 6.1
 
- 
setReactiveAdapterRegistryConfigure the registry for adapting various reactive types.By default this is an instance of ReactiveAdapterRegistrywith default settings.
- 
getReactiveAdapterRegistryReturn the configured registry for adapting reactive types.
- 
setApplicationContextAConfigurableApplicationContextis expected for resolving expressions in method argument default values as well as for detecting@ControllerAdvicebeans.- Specified by:
- setApplicationContextin interface- ApplicationContextAware
- Parameters:
- applicationContext- the ApplicationContext object to be used by this object
- See Also:
 
- 
afterPropertiesSetDescription copied from interface:InitializingBeanInvoked by the containingBeanFactoryafter it has set all bean properties and satisfiedBeanFactoryAware,ApplicationContextAwareetc.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:
- afterPropertiesSetin interface- InitializingBean
- Throws:
- Exception- in the event of misconfiguration (such as failure to set an essential property) or if initialization fails for any other reason
 
- 
supportsDescription copied from interface:HandlerAdapterWhether thisHandlerAdaptersupports the givenhandler.- Specified by:
- supportsin interface- HandlerAdapter
- Parameters:
- handler- the handler object to check
- Returns:
- whether the handler is supported
 
- 
handlepublic reactor.core.publisher.Mono<HandlerResult> handle(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 returned- HandlerResultto 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 interface- HandlerAdapter
- Parameters:
- exchange- current server exchange
- handler- the selected handler which must have been previously checked via- HandlerAdapter.supports(Object)
- Returns:
- Monothat 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- WebExceptionHandlers at the end of the- WebFilterchain
 
- 
handleErrorpublic reactor.core.publisher.Mono<HandlerResult> handleError(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 interface- DispatchExceptionHandler
- Parameters:
- exchange- the current exchange
- ex- the exception to handle
- Returns:
- a Monothat emits aHandlerResultor an error signal with the original exception if it remains not handled
 
 
-