Class GenericMessageConverter
- java.lang.Object
- org.springframework.messaging.converter.SimpleMessageConverter
- org.springframework.messaging.converter.GenericMessageConverter
- All Implemented Interfaces:
MessageConverter
public class GenericMessageConverter extends SimpleMessageConverter
An extension of theSimpleMessageConverterthat uses aConversionServiceto convert the payload of the message to the requested type.Return
nullif the conversion service cannot convert from the payload type to the requested type.- Since:
- 4.1
- Author:
- Stephane Nicoll
- See Also:
ConversionService
Constructor Summary
Constructors Constructor Description GenericMessageConverter()Create a new instance with a defaultConversionService.GenericMessageConverter(ConversionService conversionService)Create a new instance with the givenConversionService.
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ObjectfromMessage(Message<?> message, Class<?> targetClass)Convert the payload of aMessagefrom a serialized form to a typed Object of the specified target class.Methods inherited from class org.springframework.messaging.converter.SimpleMessageConverter
toMessage
Constructor Detail
GenericMessageConverter
public GenericMessageConverter()
Create a new instance with a defaultConversionService.
GenericMessageConverter
public GenericMessageConverter(ConversionService conversionService)
Create a new instance with the givenConversionService.
Method Detail
fromMessage
public Object fromMessage(Message<?> message, Class<?> targetClass)
Description copied from interface:MessageConverterConvert the payload of aMessagefrom a serialized form to a typed Object of the specified target class. TheMessageHeaders.CONTENT_TYPEheader 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.- Specified by:
fromMessagein interfaceMessageConverter- Overrides:
fromMessagein classSimpleMessageConverter- Parameters:
message- the input messagetargetClass- the target class for the conversion- Returns:
- the result of the conversion, or
nullif the converter cannot perform the conversion