public class MessageMethodArgumentResolver extends Object implements 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.Constructor and Description |
---|
MessageMethodArgumentResolver()
Create a default resolver instance without message conversion.
|
MessageMethodArgumentResolver(MessageConverter converter)
Create a resolver instance with the given
MessageConverter . |
Modifier and Type | Method and Description |
---|---|
protected Class<?> |
getPayloadType(MethodParameter parameter,
Message<?> message)
Resolve the target class to convert the payload to.
|
protected boolean |
isEmptyPayload(Object payload)
Check if the given
payload is empty. |
Object |
resolveArgument(MethodParameter parameter,
Message<?> message)
Resolves a method parameter into an argument value from a given message.
|
boolean |
supportsParameter(MethodParameter parameter)
Whether the given method parameter is
supported by this resolver.
|
public MessageMethodArgumentResolver()
public MessageMethodArgumentResolver(@Nullable MessageConverter converter)
MessageConverter
.converter
- the MessageConverter to use (may be null
)public boolean supportsParameter(MethodParameter parameter)
HandlerMethodArgumentResolver
supportsParameter
in interface HandlerMethodArgumentResolver
parameter
- the method parameter to checktrue
if this resolver supports the supplied parameter;
false
otherwisepublic Object resolveArgument(MethodParameter parameter, Message<?> message) throws Exception
HandlerMethodArgumentResolver
resolveArgument
in interface HandlerMethodArgumentResolver
parameter
- the method parameter to resolve.
This parameter must have previously been passed to
HandlerMethodArgumentResolver.supportsParameter(org.springframework.core.MethodParameter)
which must have returned true
.message
- the currently processed messagenull
Exception
- in case of errors with the preparation of argument valuesprotected Class<?> getPayloadType(MethodParameter parameter, Message<?> message)
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/**"
.
parameter
- the target method parametermessage
- the message being processed