Top Description Inners Fields Constructors Methods
org.springframework.web.reactive.result.method.annotation

public Class RequestMappingHandlerAdapter

extends Object
implements HandlerAdapter, DispatchExceptionHandler, ApplicationContextAware, InitializingBean
Class Inheritance
All Implemented Interfaces
org.springframework.beans.factory.InitializingBean, org.springframework.context.ApplicationContextAware, org.springframework.beans.factory.Aware, org.springframework.web.reactive.DispatchExceptionHandler, org.springframework.web.reactive.HandlerAdapter
Imports
java.util.ArrayList, .Collections, .List, java.util.concurrent.Executor, java.util.function.Predicate, org.apache.commons.logging.Log, .LogFactory, reactor.core.publisher.Mono, reactor.core.scheduler.Scheduler, .Schedulers, org.springframework.beans.factory.InitializingBean, org.springframework.context.ApplicationContext, .ApplicationContextAware, .ConfigurableApplicationContext, org.springframework.core.KotlinDetector, .ReactiveAdapterRegistry, org.springframework.http.codec.HttpMessageReader, .ServerCodecConfigurer, org.springframework.lang.Nullable, org.springframework.util.Assert, .CollectionUtils, org.springframework.web.bind.support.WebBindingInitializer, org.springframework.web.method.HandlerMethod, org.springframework.web.reactive.BindingContext, .DispatchExceptionHandler, .HandlerAdapter, .HandlerMapping, .HandlerResult, org.springframework.web.reactive.result.method.InvocableHandlerMethod, org.springframework.web.server.ServerWebExchange, org.springframework.web.util.DisconnectedClientHelper

Supports the invocation of @RequestMapping handler methods.
Author
Rossen Stoyanchev
Since
5.0

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static record
RequestMappingHandlerAdapter.NonReactiveHandlerMethodPredicate

Match methods with a return type without an adapter in ReactiveAdapterRegistry which are not suspending functions.

Field Summary

Modifier and TypeField and Description
private ConfigurableApplicationContext
private ArgumentResolverConfigurer
private Predicate<HandlerMethod>
private static final String
DISCONNECTED_CLIENT_LOG_CATEGORY

Log category to use for network failure after a client has gone away.

private static final DisconnectedClientHelper
private static final Log
private List<HttpMessageReader<?>>
private ControllerMethodResolver
private ModelInitializer
private ReactiveAdapterRegistry
private Scheduler
private WebBindingInitializer

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public void
afterPropertiesSet()

Implements org.springframework.beans.factory.InitializingBean.afterPropertiesSet.

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.

public ArgumentResolverConfigurer
getArgumentResolverConfigurer()

Return the configured resolvers for controller method arguments.

public List<HttpMessageReader<?>>
getMessageReaders()

Return the configurer for HTTP message readers.

public ReactiveAdapterRegistry
getReactiveAdapterRegistry()

Return the configured registry for adapting reactive types.

public WebBindingInitializer
getWebBindingInitializer()

Return the configured WebBindingInitializer, or null if none.

public Mono<HandlerResult>
handle(ServerWebExchange
current server exchange
exchange
,
Object
the selected handler which must have been previously checked via supports(Object)
handler
)

Implements org.springframework.web.reactive.HandlerAdapter.handle.

Handle the request with the given handler, previously checked via supports(Object).

public Mono<HandlerResult>
handleError(ServerWebExchange
the current exchange
exchange
,
Throwable
the exception to handle
ex
)

Implements org.springframework.web.reactive.DispatchExceptionHandler.handleError.

Handle the given exception, mapping it to a HandlerResult that can then be used to render an HTTP response.

private Mono<HandlerResult>
handleException(ServerWebExchange exchange, Throwable exception, HandlerMethod handlerMethod, BindingContext bindingContext)

public void
setApplicationContext(ApplicationContext
the ApplicationContext object to be used by this object
applicationContext
)

Implements org.springframework.context.ApplicationContextAware.setApplicationContext.

A ConfigurableApplicationContext is expected for resolving expressions in method argument default values as well as for detecting @ControllerAdvice beans.

public void
setArgumentResolverConfigurer(ArgumentResolverConfigurer configurer)

Configure resolvers for controller method arguments.

public void
setBlockingExecutor(Executor
the task executor to use
executor
)

Configure an executor to invoke blocking controller methods with.

public void
setBlockingMethodPredicate(Predicate<HandlerMethod>
the predicate to use
predicate
)

Provide a predicate to decide which controller methods to invoke through the configured blockingExecutor.

public void
setMessageReaders(List<HttpMessageReader<?>> messageReaders)

Configure HTTP message readers to de-serialize the request body with.

public void
setReactiveAdapterRegistry(ReactiveAdapterRegistry registry)

Configure the registry for adapting various reactive types.

public void
setWebBindingInitializer(WebBindingInitializer webBindingInitializer)

Provide a WebBindingInitializer with "global" initialization to apply to every DataBinder instance.

public boolean
supports(Object
the handler object to check
handler
)

Implements org.springframework.web.reactive.HandlerAdapter.supports.

Whether this HandlerAdapter supports the given handler.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

applicationContextback to summary
private ConfigurableApplicationContext applicationContext
Annotations
@Nullable
argumentResolverConfigurerback to summary
private ArgumentResolverConfigurer argumentResolverConfigurer
Annotations
@Nullable
blockingMethodPredicateback to summary
private Predicate<HandlerMethod> blockingMethodPredicate
Annotations
@Nullable
DISCONNECTED_CLIENT_LOG_CATEGORYback to summary
private static final String DISCONNECTED_CLIENT_LOG_CATEGORY

Log category to use for network failure after a client has gone away.

See Also
DisconnectedClientHelper
disconnectedClientHelperback to summary
private static final DisconnectedClientHelper disconnectedClientHelper
loggerback to summary
private static final Log logger
messageReadersback to summary
private List<HttpMessageReader<?>> messageReaders
methodResolverback to summary
private ControllerMethodResolver methodResolver
Annotations
@Nullable
modelInitializerback to summary
private ModelInitializer modelInitializer
Annotations
@Nullable
reactiveAdapterRegistryback to summary
private ReactiveAdapterRegistry reactiveAdapterRegistry
Annotations
@Nullable
schedulerback to summary
private Scheduler scheduler
Annotations
@Nullable
webBindingInitializerback to summary
private WebBindingInitializer webBindingInitializer
Annotations
@Nullable

Constructor Detail

RequestMappingHandlerAdapterback to summary
public RequestMappingHandlerAdapter()

Method Detail

afterPropertiesSetback to summary
public void afterPropertiesSet() throws Exception

Implements org.springframework.beans.factory.InitializingBean.afterPropertiesSet.

Doc from org.springframework.beans.factory.InitializingBean.afterPropertiesSet.

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.

Annotations
@Override
Exceptions
Exception:
in the event of misconfiguration (such as failure to set an essential property) or if initialization fails for any other reason
getArgumentResolverConfigurerback to summary
public ArgumentResolverConfigurer getArgumentResolverConfigurer()

Return the configured resolvers for controller method arguments.

Annotations
@Nullable
getMessageReadersback to summary
public List<HttpMessageReader<?>> getMessageReaders()

Return the configurer for HTTP message readers.

getReactiveAdapterRegistryback to summary
public ReactiveAdapterRegistry getReactiveAdapterRegistry()

Return the configured registry for adapting reactive types.

Annotations
@Nullable
getWebBindingInitializerback to summary
public WebBindingInitializer getWebBindingInitializer()

Return the configured WebBindingInitializer, or null if none.

Annotations
@Nullable
handleback to summary
public Mono<HandlerResult> handle(ServerWebExchange exchange, Object handler)

Implements org.springframework.web.reactive.HandlerAdapter.handle.

Doc from org.springframework.web.reactive.HandlerAdapter.handle.

Handle the request with the given handler, previously checked via 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.
Parameters
exchange:ServerWebExchange

current server exchange

handler:Object

the selected handler which must have been previously checked via supports(Object)

Returns:Mono<HandlerResult>

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 org.springframework.web.server.WebExceptionHandlers at the end of the org.springframework.web.server.WebFilter chain

Annotations
@Override
handleErrorback to summary
public Mono<HandlerResult> handleError(ServerWebExchange exchange, Throwable ex)

Implements org.springframework.web.reactive.DispatchExceptionHandler.handleError.

Doc from org.springframework.web.reactive.DispatchExceptionHandler.handleError.

Handle the given exception, mapping it to a HandlerResult that can then be used to render an HTTP response.

Parameters
exchange:ServerWebExchange

the current exchange

ex:Throwable

the exception to handle

Returns:Mono<HandlerResult>

a Mono that emits a HandlerResult or an error signal with the original exception if it remains not handled

Annotations
@Override
handleExceptionback to summary
private Mono<HandlerResult> handleException(ServerWebExchange exchange, Throwable exception, HandlerMethod handlerMethod, BindingContext bindingContext)
setApplicationContextback to summary
public void setApplicationContext(ApplicationContext applicationContext)

Implements org.springframework.context.ApplicationContextAware.setApplicationContext.

A ConfigurableApplicationContext is expected for resolving expressions in method argument default values as well as for detecting @ControllerAdvice beans.

Parameters
applicationContext:ApplicationContext

Doc from org.springframework.context.ApplicationContextAware.setApplicationContext.

the ApplicationContext object to be used by this object

Annotations
@Override
setArgumentResolverConfigurerback to summary
public void setArgumentResolverConfigurer(ArgumentResolverConfigurer configurer)

Configure resolvers for controller method arguments.

setBlockingExecutorback to summary
public void setBlockingExecutor(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.

Parameters
executor:Executor

the task executor to use

Since
6.1
setBlockingMethodPredicateback to summary
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 org.springframework.core.ReactiveAdapterRegistry.

Parameters
predicate:Predicate<HandlerMethod>

the predicate to use

Since
6.1
setMessageReadersback to summary
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.

setReactiveAdapterRegistryback to summary
public void setReactiveAdapterRegistry(ReactiveAdapterRegistry registry)

Configure the registry for adapting various reactive types.

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

setWebBindingInitializerback to summary
public void setWebBindingInitializer(WebBindingInitializer webBindingInitializer)

Provide a WebBindingInitializer with "global" initialization to apply to every DataBinder instance.

supportsback to summary
public boolean supports(Object handler)

Implements org.springframework.web.reactive.HandlerAdapter.supports.

Doc from org.springframework.web.reactive.HandlerAdapter.supports.

Whether this HandlerAdapter supports the given handler.

Parameters
handler:Object

the handler object to check

Returns:boolean

whether the handler is supported

Annotations
@Override
org.springframework.web.reactive.result.method.annotation back to summary

private final Record RequestMappingHandlerAdapter.NonReactiveHandlerMethodPredicate

extends Record
implements Predicate<HandlerMethod>
Class Inheritance
All Implemented Interfaces
java.util.function.Predicate
Record Components
adapterRegistry:ReactiveAdapterRegistry 

Match methods with a return type without an adapter in ReactiveAdapterRegistry which are not suspending functions.

Field Summary

Modifier and TypeField and Description
private final ReactiveAdapterRegistry
adapterRegistry

Record Component accessed by adapterRegistry().

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public ReactiveAdapterRegistry
adapterRegistry()

Record Component getter of adapterRegistry.

public final boolean
equals(Object
the reference object with which to compare.
o
)

Implements abstract java.lang.Record.equals.

Indicates whether some other object is "equal to" this one.

public final int
hashCode()

Implements abstract java.lang.Record.hashCode.

Returns a hash code value for the record.

public boolean
test(HandlerMethod
the input argument
handlerMethod
)

Implements java.util.function.Predicate.test.

Evaluates this predicate on the given argument.

public final String
toString()

Implements abstract java.lang.Record.toString.

Returns a string representation of the record.

Field Detail

adapterRegistryback to summary
private final ReactiveAdapterRegistry adapterRegistry

Record Component accessed by adapterRegistry().

Constructor Detail

NonReactiveHandlerMethodPredicateback to summary
private NonReactiveHandlerMethodPredicate(ReactiveAdapterRegistry adapterRegistry)

Method Detail

adapterRegistryback to summary
public ReactiveAdapterRegistry adapterRegistry()

Record Component getter of adapterRegistry.

equalsback to summary
public final boolean equals(Object o)

Implements abstract java.lang.Record.equals.

Doc from java.lang.Record.equals.

Indicates whether some other object is "equal to" this one. In addition to the general contract of Object.equals, record classes must further obey the invariant that when a record instance is "copied" by passing the result of the record component accessor methods to the canonical constructor, as follows:

    R copy = new R(r.c1(), r.c2(), ..., r.cn());
then it must be the case that r.equals(copy).
Parameters
o:Object

the reference object with which to compare.

Returns:boolean

true if this record is equal to the argument; false otherwise.

hashCodeback to summary
public final int hashCode()

Implements abstract java.lang.Record.hashCode.

Doc from java.lang.Record.hashCode.

Returns a hash code value for the record. Obeys the general contract of Object.hashCode. For records, hashing behavior is constrained by the refined contract of Record.equals, so that any two records created from the same components must have the same hash code.

Returns:int

a hash code value for this record.

testback to summary
public boolean test(HandlerMethod handlerMethod)

Implements java.util.function.Predicate.test.

Doc from java.util.function.Predicate.test.

Evaluates this predicate on the given argument.

Parameters
handlerMethod:HandlerMethod

the input argument

Returns:boolean

true if the input argument matches the predicate, otherwise false

Annotations
@Override
toStringback to summary
public final String toString()

Implements abstract java.lang.Record.toString.

Doc from java.lang.Record.toString.

Returns a string representation of the record. In accordance with the general contract of Object#toString(), the toString method returns a string that "textually represents" this record. The result should be a concise but informative representation that is easy for a person to read.

In addition to this general contract, record classes must further participate in the invariant that any two records which are equal must produce equal strings. This invariant is necessarily relaxed in the rare case where corresponding equal component values might fail to produce equal strings for themselves.

Returns:String

a string representation of the object.