Class MarshallingMessageConverter
java.lang.Object
org.springframework.messaging.converter.AbstractMessageConverter
org.springframework.messaging.converter.MarshallingMessageConverter
- All Implemented Interfaces:
- MessageConverter,- SmartMessageConverter
Implementation of 
MessageConverter that can read and write XML using Spring's
 Marshaller and Unmarshaller abstractions.
 This converter requires a Marshaller and Unmarshaller before it can
 be used. These can be injected by the constructor or bean properties.
- Since:
- 4.2
- Author:
- Arjen Poutsma
- See Also:
- 
Field SummaryFields inherited from class org.springframework.messaging.converter.AbstractMessageConverterlogger
- 
Constructor SummaryConstructorsConstructorDescriptionDefault construct allowing forsetMarshaller(Marshaller)and/orsetUnmarshaller(Unmarshaller)to be invoked separately.MarshallingMessageConverter(Marshaller marshaller) Constructor withMarshaller.MarshallingMessageConverter(MimeType... supportedMimeTypes) Constructor with a given list of MIME types to support.
- 
Method SummaryModifier and TypeMethodDescriptionprotected booleancanConvertFrom(Message<?> message, Class<?> targetClass) protected booleancanConvertTo(Object payload, MessageHeaders headers) protected ObjectconvertFromInternal(Message<?> message, Class<?> targetClass, Object conversionHint) Convert the message payload from serialized form to an Object.protected ObjectconvertToInternal(Object payload, MessageHeaders headers, Object conversionHint) Convert the payload object to serialized form.Return the configured Marshaller.Return the configured unmarshaller.voidsetMarshaller(Marshaller marshaller) Set theMarshallerto be used by this message converter.voidsetUnmarshaller(Unmarshaller unmarshaller) Set theUnmarshallerto be used by this message converter.protected booleanWhether the given class is supported by this converter.Methods inherited from class org.springframework.messaging.converter.AbstractMessageConverteraddSupportedMimeTypes, fromMessage, fromMessage, getContentTypeResolver, getDefaultContentType, getMimeType, getSerializedPayloadClass, getSupportedMimeTypes, isStrictContentTypeMatch, setContentTypeResolver, setSerializedPayloadClass, setStrictContentTypeMatch, supportsMimeType, toMessage, toMessage
- 
Constructor Details- 
MarshallingMessageConverterpublic MarshallingMessageConverter()Default construct allowing forsetMarshaller(Marshaller)and/orsetUnmarshaller(Unmarshaller)to be invoked separately.
- 
MarshallingMessageConverterConstructor with a given list of MIME types to support.- Parameters:
- supportedMimeTypes- the MIME types
 
- 
MarshallingMessageConverterConstructor withMarshaller. If the givenMarshalleralso implementsUnmarshaller, it is also used for unmarshalling.Note that all Marshallerimplementations in Spring also implementUnmarshallerso that you can safely use this constructor.- Parameters:
- marshaller- object used as marshaller and unmarshaller
 
 
- 
- 
Method Details- 
setMarshallerSet theMarshallerto be used by this message converter.
- 
getMarshallerReturn the configured Marshaller.
- 
setUnmarshallerSet theUnmarshallerto be used by this message converter.
- 
getUnmarshallerReturn the configured unmarshaller.
- 
canConvertFrom- Overrides:
- canConvertFromin class- AbstractMessageConverter
 
- 
canConvertTo- Overrides:
- canConvertToin class- AbstractMessageConverter
 
- 
supportsDescription copied from class:AbstractMessageConverterWhether the given class is supported by this converter.- Specified by:
- supportsin class- AbstractMessageConverter
- Parameters:
- clazz- the class to test for support
- Returns:
- trueif supported;- falseotherwise
 
- 
convertFromInternal@Nullable protected Object convertFromInternal(Message<?> message, Class<?> targetClass, @Nullable Object conversionHint) Description copied from class:AbstractMessageConverterConvert the message payload from serialized form to an Object.- Overrides:
- convertFromInternalin class- AbstractMessageConverter
- Parameters:
- message- the input message
- targetClass- the target class for the conversion
- conversionHint- an extra object passed to the- MessageConverter, e.g. the associated- MethodParameter(may be- null}
- Returns:
- the result of the conversion, or nullif the converter cannot perform the conversion
 
- 
convertToInternal@Nullable protected Object convertToInternal(Object payload, @Nullable MessageHeaders headers, @Nullable Object conversionHint) Description copied from class:AbstractMessageConverterConvert the payload object to serialized form.- Overrides:
- convertToInternalin class- AbstractMessageConverter
- Parameters:
- payload- the Object to convert
- headers- optional headers for the message (may be- null)
- conversionHint- an extra object passed to the- MessageConverter, e.g. the associated- MethodParameter(may be- null}
- Returns:
- the resulting payload for the message, or nullif the converter cannot perform the conversion
 
 
-