Class RequestMappingHandlerAdapter
- java.lang.Object
- org.springframework.web.reactive.result.method.annotation.RequestMappingHandlerAdapter
- All Implemented Interfaces:
Aware,InitializingBean,ApplicationContextAware,HandlerAdapter
public class RequestMappingHandlerAdapter extends Object implements HandlerAdapter, ApplicationContextAware, InitializingBean
Supports the invocation of@RequestMappinghandler methods.- Since:
- 5.0
- Author:
- Rossen Stoyanchev
Constructor Summary
Constructors Constructor Description RequestMappingHandlerAdapter()
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidafterPropertiesSet()Invoked by the containingBeanFactoryafter it has set all bean properties and satisfiedBeanFactoryAware,ApplicationContextAwareetc.ArgumentResolverConfigurergetArgumentResolverConfigurer()Return the configured resolvers for controller method arguments.List<HttpMessageReader<?>>getMessageReaders()Return the configurer for HTTP message readers.ReactiveAdapterRegistrygetReactiveAdapterRegistry()Return the configured registry for adapting reactive types.WebBindingInitializergetWebBindingInitializer()Return the configured WebBindingInitializer, ornullif none.reactor.core.publisher.Mono<HandlerResult>handle(ServerWebExchange exchange, Object handler)Handle the request with the given handler.voidsetApplicationContext(ApplicationContext applicationContext)AConfigurableApplicationContextis expected for resolving expressions in method argument default values as well as for detecting@ControllerAdvicebeans.voidsetArgumentResolverConfigurer(ArgumentResolverConfigurer configurer)Configure resolvers for controller method arguments.voidsetMessageReaders(List<HttpMessageReader<?>> messageReaders)Configure HTTP message readers to de-serialize the request body with.voidsetReactiveAdapterRegistry(ReactiveAdapterRegistry registry)Configure the registry for adapting various reactive types.voidsetWebBindingInitializer(WebBindingInitializer webBindingInitializer)Provide a WebBindingInitializer with "global" initialization to apply to every DataBinder instance.booleansupports(Object handler)Whether thisHandlerAdaptersupports the givenhandler.
Constructor Detail
RequestMappingHandlerAdapter
public RequestMappingHandlerAdapter()
Method Detail
setMessageReaders
public void setMessageReaders(List<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
public List<HttpMessageReader<?>> getMessageReaders()
Return the configurer for HTTP message readers.
setWebBindingInitializer
public void setWebBindingInitializer(@Nullable WebBindingInitializer webBindingInitializer)
Provide a WebBindingInitializer with "global" initialization to apply to every DataBinder instance.
getWebBindingInitializer
@Nullable public WebBindingInitializer getWebBindingInitializer()
Return the configured WebBindingInitializer, ornullif none.
setArgumentResolverConfigurer
public void setArgumentResolverConfigurer(@Nullable ArgumentResolverConfigurer configurer)
Configure resolvers for controller method arguments.
getArgumentResolverConfigurer
@Nullable public ArgumentResolverConfigurer getArgumentResolverConfigurer()
Return the configured resolvers for controller method arguments.
setReactiveAdapterRegistry
public void setReactiveAdapterRegistry(@Nullable ReactiveAdapterRegistry registry)
Configure the registry for adapting various reactive types.By default this is an instance of
ReactiveAdapterRegistrywith default settings.
getReactiveAdapterRegistry
@Nullable public ReactiveAdapterRegistry getReactiveAdapterRegistry()
Return the configured registry for adapting reactive types.
setApplicationContext
public void setApplicationContext(ApplicationContext applicationContext)
AConfigurableApplicationContextis expected for resolving expressions in method argument default values as well as for detecting@ControllerAdvicebeans.- Specified by:
setApplicationContextin interfaceApplicationContextAware- Parameters:
applicationContext- the ApplicationContext object to be used by this object- See Also:
BeanInitializationException
afterPropertiesSet
public void afterPropertiesSet() throws Exception
Description 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 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
public boolean supports(Object handler)
Description copied from interface:HandlerAdapterWhether thisHandlerAdaptersupports the givenhandler.- Specified by:
supportsin interfaceHandlerAdapter- Parameters:
handler- the handler object to check- Returns:
- whether or not the handler is supported
handle
public reactor.core.publisher.Mono<HandlerResult> handle(ServerWebExchange exchange, Object handler)
Description copied from interface:HandlerAdapterHandle the request with the given handler.Implementations are encouraged to handle exceptions resulting from the invocation of a handler in order and if necessary to return an alternate result that represents an error response.
Furthermore since an async
HandlerResultmay produce an error later during result handling implementations are also encouraged toset an exception handleron theHandlerResultso that may also be applied later after result handling.- Specified by:
handlein interfaceHandlerAdapter- Parameters:
exchange- current server exchangehandler- the selected handler which must have been previously checked viaHandlerAdapter.supports(Object)- Returns:
Monothat emits a singleHandlerResultor none if the request has been fully handled and doesn't require further handling.