public class ContentTypeDelegatingMessageConverter extends Object implements MessageConverter
MessageConverter that delegates to an actual MessageConverter
based on the contentType header. Supports a default converter when no content type matches.
Note: the MessageProperties requires a content type header to select a converter
when used for outbound conversion, but the converter will (generally) override it to match
the actual conversion.| Constructor and Description |
|---|
ContentTypeDelegatingMessageConverter()
Constructs an instance using a default
SimpleMessageConverter. |
ContentTypeDelegatingMessageConverter(MessageConverter defaultConverter)
Constructs an instance using a the supplied default converter.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addDelegate(String contentType,
MessageConverter messageConverter) |
void |
addDelgate(String contentType,
MessageConverter messageConverter)
Deprecated.
in favor of
addDelegate(String, MessageConverter) |
Object |
fromMessage(Message message)
Convert from a Message to a Java object.
|
protected MessageConverter |
getConverterForContentType(String contentType) |
Map<String,MessageConverter> |
getDelegates() |
MessageConverter |
removeDelegate(String contentType) |
MessageConverter |
removeDelgate(String contentType)
Deprecated.
in favor of
removeDelegate(String) |
void |
setDelegates(Map<String,MessageConverter> delegatesByContentType) |
Message |
toMessage(Object object,
MessageProperties messageProperties)
Convert a Java object to a Message.
|
public ContentTypeDelegatingMessageConverter()
SimpleMessageConverter.public ContentTypeDelegatingMessageConverter(MessageConverter defaultConverter)
defaultConverter - the converter.public void setDelegates(Map<String,MessageConverter> delegatesByContentType)
public Map<String,MessageConverter> getDelegates()
@Deprecated public void addDelgate(String contentType, MessageConverter messageConverter)
addDelegate(String, MessageConverter)contentType - the content type to check.messageConverter - the MessageConverter for the content type.public void addDelegate(String contentType, MessageConverter messageConverter)
contentType - the content type to check.messageConverter - the MessageConverter for the content type.@Deprecated public MessageConverter removeDelgate(String contentType)
removeDelegate(String)contentType - the content type key to remove MessageConverter from delegates.MessageConverter.public MessageConverter removeDelegate(String contentType)
contentType - the content type key to remove MessageConverter from delegates.MessageConverter.public Object fromMessage(Message message) throws MessageConversionException
MessageConverterfromMessage in interface MessageConvertermessage - the message to convertMessageConversionException - in case of conversion failurepublic Message toMessage(Object object, MessageProperties messageProperties)
MessageConvertertoMessage in interface MessageConverterobject - the object to convertmessageProperties - The message properties.protected MessageConverter getConverterForContentType(String contentType)