Class CompositeMessageConverter
java.lang.Object
org.springframework.messaging.converter.CompositeMessageConverter
- All Implemented Interfaces:
- MessageConverter,- SmartMessageConverter
A 
MessageConverter that delegates to a list of registered converters
 to be invoked until one of them returns a non-null result.
 As of 4.2.1, this composite converter implements SmartMessageConverter
 in order to support the delegation of conversion hints.
- Since:
- 4.0
- Author:
- Rossen Stoyanchev, Juergen Hoeller
- 
Constructor SummaryConstructorsConstructorDescriptionCompositeMessageConverter(Collection<MessageConverter> converters) Create an instance with the given converters.
- 
Method SummaryModifier and TypeMethodDescriptionfromMessage(Message<?> message, Class<?> targetClass) Convert the payload of aMessagefrom a serialized form to a typed Object of the specified target class.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.Return the underlying list of delegate converters.toMessage(Object payload, @Nullable MessageHeaders headers) Create aMessagewhose payload is the result of converting the given payload Object to serialized form.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.toString()
- 
Constructor Details- 
CompositeMessageConverterCreate an instance with the given converters.
 
- 
- 
Method Details- 
fromMessageDescription 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 interface- MessageConverter
- Parameters:
- message- the input message
- targetClass- the target class for the conversion
- Returns:
- the result of the conversion, or nullif the converter cannot perform the conversion
 
- 
fromMessagepublic @Nullable Object fromMessage(Message<?> message, Class<?> targetClass, @Nullable Object conversionHint) Description copied from interface:SmartMessageConverterA 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.- Specified by:
- fromMessagein interface- SmartMessageConverter
- Parameters:
- message- the input message
- targetClass- the target class for the conversion
- conversionHint- an extra object passed to the- MessageConverter, for example, the associated- MethodParameter(may be- null}
- Returns:
- the result of the conversion, or nullif the converter cannot perform the conversion
- See Also:
 
- 
toMessageDescription copied from interface:MessageConverterCreate aMessagewhose payload is the result of converting the given payload Object to serialized form. The optionalMessageHeadersparameter may contain aMessageHeaders.CONTENT_TYPEheader to specify the target media type for the conversion and it may contain additional headers to be added to the message.If the converter does not support the specified media type or cannot perform the conversion, it should return null.- Specified by:
- toMessagein interface- MessageConverter
- Parameters:
- payload- the Object to convert
- headers- optional headers for the message (may be- null)
- Returns:
- the new message, or nullif the converter does not support the Object type or the target media type
 
- 
toMessagepublic @Nullable Message<?> toMessage(Object payload, @Nullable MessageHeaders headers, @Nullable Object conversionHint) Description copied from interface:SmartMessageConverterA 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.- Specified by:
- toMessagein interface- SmartMessageConverter
- Parameters:
- payload- the Object to convert
- headers- optional headers for the message (may be- null)
- conversionHint- an extra object passed to the- MessageConverter, for example, the associated- MethodParameter(may be- null}
- Returns:
- the new message, or nullif the converter does not support the Object type or the target media type
- See Also:
 
- 
getConvertersReturn the underlying list of delegate converters.
- 
toString
 
-