Top Description Fields Constructors Methods
org.springframework.messaging.handler.annotation.support

public Class MessageMethodArgumentResolver

extends Object
implements HandlerMethodArgumentResolver
Class Inheritance
All Implemented Interfaces
org.springframework.messaging.handler.invocation.HandlerMethodArgumentResolver
Imports
java.lang.reflect.Type, org.springframework.core.MethodParameter, .ResolvableType, org.springframework.lang.Nullable, org.springframework.messaging.Message, org.springframework.messaging.converter.MessageConversionException, .MessageConverter, .SmartMessageConverter, org.springframework.messaging.handler.invocation.HandlerMethodArgumentResolver, org.springframework.messaging.support.MessageBuilder, org.springframework.util.ClassUtils, .StringUtils

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.
Authors
Rossen Stoyanchev, Stephane Nicoll, Juergen Hoeller
Since
4.0

Field Summary

Modifier and TypeField and Description
private final MessageConverter

Constructor Summary

AccessConstructor and Description
public
MessageMethodArgumentResolver()

Create a default resolver instance without message conversion.

public
MessageMethodArgumentResolver(MessageConverter
the MessageConverter to use (may be null)
converter
)

Create a resolver instance with the given MessageConverter.

Method Summary

Modifier and TypeMethod and Description
private Object
convertPayload(Message<?> message, MethodParameter parameter, Class<?> targetPayloadType)

protected Class<?>

Returns:

the target type to use
getPayloadType
(MethodParameter
the target method parameter
parameter
,
Message<?>
the message being processed
message
)

Resolve the target class to convert the payload to.

protected boolean
isEmptyPayload(Object
the payload to check (can be null)
payload
)

Check if the given payload is empty.

public Object
resolveArgument(MethodParameter
the method parameter to resolve. This parameter must have previously been passed to supportsParameter(org.springframework.core.MethodParameter) which must have returned true.
parameter
,
Message<?>
the currently processed message
message
)

Implements org.springframework.messaging.handler.invocation.HandlerMethodArgumentResolver.resolveArgument.

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

public boolean
supportsParameter(MethodParameter
the method parameter to check
parameter
)

Implements org.springframework.messaging.handler.invocation.HandlerMethodArgumentResolver.supportsParameter.

Whether the given method parameter is supported by this resolver.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

converterback to summary
private final MessageConverter converter
Annotations
@Nullable

Constructor Detail

MessageMethodArgumentResolverback to summary
public MessageMethodArgumentResolver()

Create a default resolver instance without message conversion.

MessageMethodArgumentResolverback to summary
public MessageMethodArgumentResolver(MessageConverter converter)

Create a resolver instance with the given MessageConverter.

Parameters
converter:MessageConverter

the MessageConverter to use (may be null)

Since
4.3

Method Detail

convertPayloadback to summary
private Object convertPayload(Message<?> message, MethodParameter parameter, Class<?> targetPayloadType)
getPayloadTypeback to summary
protected Class<?> getPayloadType(MethodParameter parameter, Message<?> message)

Resolve the target class to convert the payload to.

By default this is the generic type declared in the Message method parameter but that can be overridden to select a more specific target type after also taking into account the "Content-Type", e.g. return String if target type is Object and "Content-Type:text/**".

Parameters
parameter:MethodParameter

the target method parameter

message:Message<?>

the message being processed

Returns:Class<?>

the target type to use

Since
5.2
isEmptyPayloadback to summary
protected boolean isEmptyPayload(Object payload)

Check if the given payload is empty.

Parameters
payload:Object

the payload to check (can be null)

resolveArgumentback to summary
public Object resolveArgument(MethodParameter parameter, Message<?> message) throws Exception

Implements org.springframework.messaging.handler.invocation.HandlerMethodArgumentResolver.resolveArgument.

Doc from org.springframework.messaging.handler.invocation.HandlerMethodArgumentResolver.resolveArgument.

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

Parameters
parameter:MethodParameter

the method parameter to resolve. This parameter must have previously been passed to supportsParameter(org.springframework.core.MethodParameter) which must have returned true.

message:Message<?>

the currently processed message

Returns:Object

the resolved argument value, or null

Annotations
@Override
Exceptions
Exception:
in case of errors with the preparation of argument values
supportsParameterback to summary
public boolean supportsParameter(MethodParameter parameter)

Implements org.springframework.messaging.handler.invocation.HandlerMethodArgumentResolver.supportsParameter.

Doc from org.springframework.messaging.handler.invocation.HandlerMethodArgumentResolver.supportsParameter.

Whether the given method parameter is supported by this resolver.

Parameters
parameter:MethodParameter

the method parameter to check

Returns:boolean

true if this resolver supports the supplied parameter; false otherwise

Annotations
@Override