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, @Nullable Object conversionHint) A variant ofMessageConverter.fromMessage(Message, Class)which takes an extra conversion context as an argument, allowing to take, for example, annotations on a payload parameter into account.A variant ofMessageConverter.toMessage(Object, MessageHeaders)which takes an extra conversion context as an argument, allowing to take, for example, annotations on a return type into account.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, for example, annotations on a payload parameter into account.- Parameters:
message- the input messagetargetClass- the target class for the conversionconversionHint- an extra object passed to theMessageConverter, for example, the associatedMethodParameter(may benull}- Returns:
- the result of the conversion, or
nullif 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, for example, 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, for example, the associatedMethodParameter(may benull}- Returns:
- the new message, or
nullif the converter does not support the Object type or the target media type - See Also:
-