Class 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.
Rossen Stoyanchev
  • Constructor Details

    • RequestMappingHandlerAdapter

      public RequestMappingHandlerAdapter()
  • Method Details

    • 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, or null if 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.
    • setBlockingExecutor

      public void setBlockingExecutor(@Nullable Executor executor)
      Configure 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.

      executor - the task executor to use
    • setBlockingMethodPredicate

      public void setBlockingMethodPredicate(Predicate<HandlerMethod> predicate)
      Provide a predicate to decide which controller methods to invoke through the configured blockingExecutor.

      If an executor is configured, the default predicate matches controller methods whose return type is not recognized by the configured ReactiveAdapterRegistry.

      predicate - the predicate to use
    • setReactiveAdapterRegistry

      public void setReactiveAdapterRegistry(@Nullable ReactiveAdapterRegistry registry)
      Configure the registry for adapting various reactive types.

      By default this is an instance of ReactiveAdapterRegistry with default settings.

    • getReactiveAdapterRegistry

      @Nullable public ReactiveAdapterRegistry getReactiveAdapterRegistry()
      Return the configured registry for adapting reactive types.
    • setApplicationContext

      public void setApplicationContext(ApplicationContext applicationContext)
      A ConfigurableApplicationContext is expected for resolving expressions in method argument default values as well as for detecting @ControllerAdvice beans.
      Specified by:
      setApplicationContext in interface ApplicationContextAware
      applicationContext - the ApplicationContext object to be used by this object
      See Also:
    • afterPropertiesSet

      public void afterPropertiesSet() throws Exception
      Description copied from interface: InitializingBean
      Invoked by the containing BeanFactory after it has set all bean properties and satisfied BeanFactoryAware, 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 interface InitializingBean
      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: HandlerAdapter
      Whether this HandlerAdapter supports the given handler.
      Specified by:
      supports in interface HandlerAdapter
      handler - the handler object to check
      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 via HandlerAdapter.supports(Object).

      Implementations should consider the following for exception handling:

      • Handle invocation exceptions within this method.
      • Set an exception handler on the returned HandlerResult 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 interface HandlerAdapter
      exchange - current server exchange
      handler - the selected handler which must have been previously checked via HandlerAdapter.supports(Object)
      Mono that 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 WebFilter 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 a HandlerResult that can then be used to render an HTTP response.
      Specified by:
      handleError in interface DispatchExceptionHandler
      exchange - the current exchange
      ex - the exception to handle
      a Mono that emits a HandlerResult or an error signal with the original exception if it remains not handled