Interface SmartMessageConverter
- All Superinterfaces:
MessageConverter
- All Known Implementing Classes:
AbstractJsonMessageConverter
,AbstractMessageConverter
,ByteArrayMessageConverter
,CompositeMessageConverter
,GsonMessageConverter
,JsonbMessageConverter
,KotlinSerializationJsonMessageConverter
,MappingJackson2MessageConverter
,MarshallingMessageConverter
,ProtobufJsonFormatMessageConverter
,ProtobufMessageConverter
,StringMessageConverter
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.
- Since:
- 4.2.1
- Author:
- Juergen Hoeller
-
Method Summary
Modifier and TypeMethodDescriptionfromMessage
(Message<?> message, Class<?> targetClass, Object conversionHint) A variant ofMessageConverter.fromMessage(Message, Class)
which takes an extra conversion context as an argument, allowing to take e.g.Message<?>
toMessage
(Object payload, MessageHeaders headers, Object conversionHint) A variant ofMessageConverter.toMessage(Object, MessageHeaders)
which takes an extra conversion context as an argument, allowing to take e.g.Methods inherited from interface org.springframework.messaging.converter.MessageConverter
fromMessage, toMessage
-
Method Details
-
fromMessage
@Nullable Object fromMessage(Message<?> message, Class<?> targetClass, @Nullable Object conversionHint) A variant ofMessageConverter.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
- the input messagetargetClass
- the target class for the conversionconversionHint
- an extra object passed to theMessageConverter
, e.g. the associatedMethodParameter
(may benull
}- Returns:
- the result of the conversion, or
null
if the converter cannot perform the conversion - See Also:
-
toMessage
@Nullable Message<?> toMessage(Object payload, @Nullable MessageHeaders headers, @Nullable Object conversionHint) A variant ofMessageConverter.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
- the Object to convertheaders
- optional headers for the message (may benull
)conversionHint
- an extra object passed to theMessageConverter
, e.g. the associatedMethodParameter
(may benull
}- Returns:
- the new message, or
null
if the converter does not support the Object type or the target media type - See Also:
-