Top Description Fields Constructors Methods
org.springframework.messaging.converter

public Class GenericMessageConverter

extends SimpleMessageConverter
Class Inheritance
Imports
org.springframework.core.convert.ConversionException, .ConversionService, org.springframework.core.convert.support.DefaultConversionService, org.springframework.lang.Nullable, org.springframework.messaging.Message, org.springframework.util.Assert, .ClassUtils

An extension of the 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.

Author
Stephane Nicoll
Since
4.1
See Also
ConversionService

Field Summary

Modifier and TypeField and Description
private final ConversionService

Constructor Summary

AccessConstructor and Description
public
GenericMessageConverter()

Create a new instance with a default ConversionService.

public
GenericMessageConverter(ConversionService conversionService)

Create a new instance with the given ConversionService.

Method Summary

Modifier and TypeMethod and Description
public Object
fromMessage(Message<?>
the input message
message
,
Class<?>
the target class for the conversion
targetClass
)

Overrides org.springframework.messaging.converter.SimpleMessageConverter.fromMessage.

Implements org.springframework.messaging.converter.MessageConverter.fromMessage.

Convert the payload of a Message from a serialized form to a typed Object of the specified target class.

Inherited from org.springframework.messaging.converter.SimpleMessageConverter:
toMessage

Field Detail

conversionServiceback to summary
private final ConversionService conversionService

Constructor Detail

GenericMessageConverterback to summary
public GenericMessageConverter()

Create a new instance with a default ConversionService.

GenericMessageConverterback to summary
public GenericMessageConverter(ConversionService conversionService)

Create a new instance with the given ConversionService.

Method Detail

fromMessageback to summary
public Object fromMessage(Message<?> message, Class<?> targetClass)

Overrides org.springframework.messaging.converter.SimpleMessageConverter.fromMessage.

Implements org.springframework.messaging.converter.MessageConverter.fromMessage.

Doc from org.springframework.messaging.converter.MessageConverter.fromMessage.

Convert the payload of a 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.

Parameters
message:Message<?>

the input message

targetClass:Class<?>

the target class for the conversion

Returns:Object

the result of the conversion, or null if the converter cannot perform the conversion

Annotations
@Override
@Nullable