Top Description Methods
org.springframework.messaging.converter

public Interface SmartMessageConverter

extends MessageConverter
Known Direct Implementers
org.springframework.messaging.converter.AbstractMessageConverter, org.springframework.messaging.converter.CompositeMessageConverter
Imports
org.springframework.lang.Nullable, org.springframework.messaging.Message, .MessageHeaders

An extended MessageConverter SPI with conversion hint support.

In case of a conversion hint being provided, the framework will call these extended methods if a converter implements this interface, instead of calling the regular fromMessage / toMessage variants.

Author
Juergen Hoeller
Since
4.2.1

Method Summary

Modifier and TypeMethod and Description
public Object

Returns:

the result of the conversion, or null if the converter cannot perform the conversion
fromMessage
(Message<?>
the input message
message
,
Class<?>
the target class for the conversion
targetClass
,
Object
an extra object passed to the MessageConverter, e.g. the associated MethodParameter (may be null}
conversionHint
)

A variant of fromMessage(Message, Class) which takes an extra conversion context as an argument, allowing to take e.g. annotations on a payload parameter into account.

public Message<?>

Returns:

the new message, or null if the converter does not support the Object type or the target media type
toMessage
(Object
the Object to convert
payload
,
MessageHeaders
optional headers for the message (may be null)
headers
,
Object
an extra object passed to the MessageConverter, e.g. the associated MethodParameter (may be null}
conversionHint
)

A variant of toMessage(Object, MessageHeaders) which takes an extra conversion context as an argument, allowing to take e.g. annotations on a return type into account.

Inherited from org.springframework.messaging.converter.MessageConverter:
fromMessagetoMessage

Method Detail

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

A variant of fromMessage(Message, Class) which takes an extra conversion context as an argument, allowing to take e.g. annotations on a payload parameter into account.

Parameters
message:Message<?>

the input message

targetClass:Class<?>

the target class for the conversion

conversionHint:Object

an extra object passed to the MessageConverter, e.g. the associated MethodParameter (may be null}

Returns:Object

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

Annotations
@Nullable
See Also
fromMessage(Message, Class)
toMessageback to summary
public Message<?> toMessage(Object payload, MessageHeaders headers, Object conversionHint)

A variant of toMessage(Object, MessageHeaders) which takes an extra conversion context as an argument, allowing to take e.g. annotations on a return type into account.

Parameters
payload:Object

the Object to convert

headers:MessageHeaders

optional headers for the message (may be null)

conversionHint:Object

an extra object passed to the MessageConverter, e.g. the associated MethodParameter (may be null}

Returns:Message<?>

the new message, or null if the converter does not support the Object type or the target media type

Annotations
@Nullable
See Also
toMessage(Object, MessageHeaders)