spring-framework / org.springframework.messaging.handler.invocation / HandlerMethodArgumentResolver

HandlerMethodArgumentResolver

interface HandlerMethodArgumentResolver

Strategy interface for resolving method parameters into argument values in the context of a given Message.

Author
Rossen Stoyanchev

Since
4.0

Functions

resolveArgument

abstract fun resolveArgument(parameter: MethodParameter, message: Message<*>): Any

Resolves a method parameter into an argument value from a given message.

supportsParameter

abstract fun supportsParameter(parameter: MethodParameter): Boolean

Whether the given MethodParameter is supported by this resolver.

Inheritors

AbstractNamedValueMethodArgumentResolver

abstract class AbstractNamedValueMethodArgumentResolver : HandlerMethodArgumentResolver

Abstract base class for resolving method arguments from a named value. Message headers, and path variables are examples of named values. Each may have a name, a required flag, and a default value.

Subclasses define how to do the following:

  • Obtain named value information for a method parameter
  • Resolve names into argument values
  • Handle missing argument values when argument values are required
  • Optionally handle a resolved value

A default value string can contain ${...} placeholders and Spring Expression Language #{...} expressions. For this to work a ConfigurableBeanFactory must be supplied to the class constructor.

A ConversionService may be used to apply type conversion to the resolved argument value if it doesn't match the method parameter type.

HeadersMethodArgumentResolver

open class HeadersMethodArgumentResolver : HandlerMethodArgumentResolver

Resolves the following method parameters:

  • Parameters assignable to Map annotated with Headers
  • Parameters of type MessageHeaders
  • Parameters assignable to MessageHeaderAccessor

MessageMethodArgumentResolver

open class MessageMethodArgumentResolver : HandlerMethodArgumentResolver

HandlerMethodArgumentResolver for Message method arguments. Validates that the generic type of the payload matches to the message value or otherwise applies MessageConverter to convert to the expected payload type.

PayloadArgumentResolver

open class PayloadArgumentResolver : HandlerMethodArgumentResolver

A resolver to extract and convert the payload of a message using a MessageConverter. It also validates the payload using a Validator if the argument is annotated with a Validation annotation.

This HandlerMethodArgumentResolver should be ordered last as it supports all types and does not require the Payload annotation.

PrincipalMethodArgumentResolver

open class PrincipalMethodArgumentResolver : HandlerMethodArgumentResolver