public class GenericMessageConverter extends SimpleMessageConverter
SimpleMessageConverter
that uses a
ConversionService
to convert the payload of the message
to the requested type.
Return null
if the conversion service cannot convert
from the payload type to the requested type.
ConversionService
Constructor and Description |
---|
GenericMessageConverter()
Create a new instance with a default
ConversionService . |
GenericMessageConverter(ConversionService conversionService)
Create a new instance with the given
ConversionService . |
Modifier and Type | Method and Description |
---|---|
Object |
fromMessage(Message<?> message,
Class<?> targetClass)
Convert the payload of a
Message from a serialized form to a typed Object
of the specified target class. |
toMessage
public GenericMessageConverter()
ConversionService
.public GenericMessageConverter(ConversionService conversionService)
ConversionService
.@Nullable public Object fromMessage(Message<?> message, Class<?> targetClass)
MessageConverter
Message
from a serialized form to a typed Object
of the specified target class. The MessageHeaders.CONTENT_TYPE
header
should indicate the MIME type to convert from.
If the converter does not support the specified media type or cannot perform
the conversion, it should return null
.
fromMessage
in interface MessageConverter
fromMessage
in class SimpleMessageConverter
message
- the input messagetargetClass
- the target class for the conversionnull
if the converter cannot
perform the conversion