Class MarshallingHttpMessageConverter
java.lang.Object
org.springframework.http.converter.AbstractHttpMessageConverter<T>
org.springframework.http.converter.xml.AbstractXmlHttpMessageConverter<Object>
org.springframework.http.converter.xml.MarshallingHttpMessageConverter
- All Implemented Interfaces:
- HttpMessageConverter<Object>
Implementation of 
HttpMessageConverter
 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.
 
By default, this converter supports text/xml and application/xml. This can be
 overridden by setting the supportedMediaTypes property.
- Since:
- 3.0
- Author:
- Arjen Poutsma
- 
Field SummaryFields inherited from class org.springframework.http.converter.AbstractHttpMessageConverterlogger
- 
Constructor SummaryConstructorsConstructorDescriptionMarshallingHttpMessageConverter(Marshaller marshaller) Construct a newMarshallingMessageConverterwith the givenMarshallerset.MarshallingHttpMessageConverter(Marshaller marshaller, Unmarshaller unmarshaller) Construct a newMarshallingMessageConverterwith the givenMarshallerandUnmarshaller.
- 
Method SummaryModifier and TypeMethodDescriptionbooleanThis implementation checks if the given class is supported, and if the supported media types include the given media type.booleanprotected ObjectreadFromSource(Class<?> clazz, HttpHeaders headers, Source source) Abstract template method called fromAbstractHttpMessageConverter.read(Class, HttpInputMessage).voidsetMarshaller(Marshaller marshaller) Set theMarshallerto be used by this message converter.voidsetUnmarshaller(Unmarshaller unmarshaller) Set theUnmarshallerto be used by this message converter.protected booleanIndicates whether the given class is supported by this converter.protected booleanIndicates whether this message converter can write the given object multiple times.protected voidwriteToResult(Object o, HttpHeaders headers, Result result) Abstract template method called fromAbstractXmlHttpMessageConverter.writeInternal(Object, HttpOutputMessage).Methods inherited from class org.springframework.http.converter.xml.AbstractXmlHttpMessageConverterreadInternal, transform, writeInternalMethods inherited from class org.springframework.http.converter.AbstractHttpMessageConverteraddDefaultHeaders, canRead, canWrite, getContentLength, getDefaultCharset, getDefaultContentType, getSupportedMediaTypes, read, setDefaultCharset, setSupportedMediaTypes, writeMethods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.springframework.http.converter.HttpMessageConvertergetSupportedMediaTypes
- 
Constructor Details- 
MarshallingHttpMessageConverterpublic MarshallingHttpMessageConverter()Construct a newMarshallingHttpMessageConverterwith noMarshallerorUnmarshallerset. The Marshaller and Unmarshaller must be set after construction by invokingsetMarshaller(Marshaller)andsetUnmarshaller(Unmarshaller).
- 
MarshallingHttpMessageConverterConstruct a newMarshallingMessageConverterwith the givenMarshallerset.If the given Marshalleralso implements theUnmarshallerinterface, it is used for both marshalling and unmarshalling. Otherwise, an exception is thrown.Note that all Marshallerimplementations in Spring also implement theUnmarshallerinterface, so that you can safely use this constructor.- Parameters:
- marshaller- object used as marshaller and unmarshaller
 
- 
MarshallingHttpMessageConverterConstruct a newMarshallingMessageConverterwith the givenMarshallerandUnmarshaller.- Parameters:
- marshaller- the Marshaller to use
- unmarshaller- the Unmarshaller to use
 
 
- 
- 
Method Details- 
setMarshallerSet theMarshallerto be used by this message converter.
- 
setUnmarshallerSet theUnmarshallerto be used by this message converter.
- 
canReadDescription copied from class:AbstractHttpMessageConverterThis implementation checks if the given class is supported, and if the supported media types include the given media type.- Specified by:
- canReadin interface- HttpMessageConverter<Object>
- Overrides:
- canReadin class- AbstractHttpMessageConverter<Object>
- Parameters:
- clazz- the class to test for readability
- mediaType- the media type to read (can be- nullif not specified); typically the value of a- Content-Typeheader.
- Returns:
- trueif readable;- falseotherwise
 
- 
canWriteDescription copied from class:AbstractHttpMessageConverterThis implementation checks if the given class is supported, and if the supported media types include the given media type.- Specified by:
- canWritein interface- HttpMessageConverter<Object>
- Overrides:
- canWritein class- AbstractHttpMessageConverter<Object>
- Parameters:
- clazz- the class to test for writability
- mediaType- the media type to write (can be- nullif not specified); typically the value of an- Acceptheader.
- Returns:
- trueif writable;- falseotherwise
 
- 
supportsDescription copied from class:AbstractHttpMessageConverterIndicates whether the given class is supported by this converter.- Specified by:
- supportsin class- AbstractHttpMessageConverter<Object>
- Parameters:
- clazz- the class to test for support
- Returns:
- trueif supported;- falseotherwise
 
- 
readFromSourceprotected Object readFromSource(Class<?> clazz, HttpHeaders headers, Source source) throws Exception Description copied from class:AbstractXmlHttpMessageConverterAbstract template method called fromAbstractHttpMessageConverter.read(Class, HttpInputMessage).- Specified by:
- readFromSourcein class- AbstractXmlHttpMessageConverter<Object>
- Parameters:
- clazz- the type of object to return
- headers- the HTTP input headers
- source- the HTTP input body
- Returns:
- the converted object
- Throws:
- Exception- in case of I/O or conversion errors
 
- 
writeToResultDescription copied from class:AbstractXmlHttpMessageConverterAbstract template method called fromAbstractXmlHttpMessageConverter.writeInternal(Object, HttpOutputMessage).- Specified by:
- writeToResultin class- AbstractXmlHttpMessageConverter<Object>
- Parameters:
- o- the object to write to the output message
- headers- the HTTP output headers
- result- the HTTP output body
- Throws:
- Exception- in case of I/O or conversion errors
 
- 
supportsRepeatableWritesDescription copied from class:AbstractHttpMessageConverterIndicates whether this message converter can write the given object multiple times.The default implementation returns false.- Overrides:
- supportsRepeatableWritesin class- AbstractHttpMessageConverter<Object>
- Parameters:
- o- the object t
- Returns:
- trueif- tcan be written repeatedly;- falseotherwise
 
 
-