public class

MarshallingHttpMessageConverter

extends AbstractXmlHttpMessageConverter<T>
java.lang.Object
   ↳ org.springframework.http.converter.AbstractHttpMessageConverter<T>
     ↳ org.springframework.http.converter.xml.AbstractXmlHttpMessageConverter<T>
       ↳ org.springframework.http.converter.xml.MarshallingHttpMessageConverter

Class Overview

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.

Summary

[Expand]
Inherited Fields
From class org.springframework.http.converter.AbstractHttpMessageConverter
Public Constructors
MarshallingHttpMessageConverter()
Construct a new MarshallingHttpMessageConverter with no Marshaller or Unmarshaller set.
MarshallingHttpMessageConverter(Marshaller marshaller)
Construct a new MarshallingMessageConverter with the given Marshaller set.
MarshallingHttpMessageConverter(Marshaller marshaller, Unmarshaller unmarshaller)
Construct a new MarshallingMessageConverter with the given Marshaller and Unmarshaller.
Public Methods
void setMarshaller(Marshaller marshaller)
Set the Marshaller to be used by this message converter.
void setUnmarshaller(Unmarshaller unmarshaller)
Set the Unmarshaller to be used by this message converter.
boolean supports(Class<?> clazz)
Indicates whether the given class is supported by this converter.
Protected Methods
Object readFromSource(Class<?> clazz, HttpHeaders headers, Source source)
Abstract template method called from read(Class, HttpInputMessage).
void writeToResult(Object o, HttpHeaders headers, Result result)
Abstract template method called from writeInternal(Object, HttpOutputMessage).
[Expand]
Inherited Methods
From class org.springframework.http.converter.xml.AbstractXmlHttpMessageConverter
From class org.springframework.http.converter.AbstractHttpMessageConverter
From class java.lang.Object
From interface org.springframework.http.converter.HttpMessageConverter

Public Constructors

public MarshallingHttpMessageConverter ()

Construct a new MarshallingHttpMessageConverter with no Marshaller or Unmarshaller set. The Marshaller and Unmarshaller must be set after construction by invoking setMarshaller(Marshaller) and setUnmarshaller(Unmarshaller) .

public MarshallingHttpMessageConverter (Marshaller marshaller)

Construct a new MarshallingMessageConverter with the given Marshaller set.

If the given Marshaller also implements the Unmarshaller interface, it is used for both marshalling and unmarshalling. Otherwise, an exception is thrown.

Note that all Marshaller implementations in Spring also implement the Unmarshaller interface, so that you can safely use this constructor.

Parameters
marshaller object used as marshaller and unmarshaller

public MarshallingHttpMessageConverter (Marshaller marshaller, Unmarshaller unmarshaller)

Construct a new MarshallingMessageConverter with the given Marshaller and Unmarshaller.

Parameters
marshaller the Marshaller to use
unmarshaller the Unmarshaller to use

Public Methods

public void setMarshaller (Marshaller marshaller)

Set the Marshaller to be used by this message converter.

public void setUnmarshaller (Unmarshaller unmarshaller)

Set the Unmarshaller to be used by this message converter.

public boolean supports (Class<?> clazz)

Indicates whether the given class is supported by this converter.

Parameters
clazz the class to test for support
Returns
  • true if supported; false otherwise

Protected Methods

protected Object readFromSource (Class<?> clazz, HttpHeaders headers, Source source)

Abstract template method called from read(Class, HttpInputMessage).

Parameters
clazz the type of object to return
headers the HTTP input headers
source the HTTP input body
Returns
  • the converted object
Throws
IOException

protected void writeToResult (Object o, HttpHeaders headers, Result result)

Abstract template method called from writeInternal(Object, HttpOutputMessage).

Parameters
o the object to write to the output message
headers the HTTP output headers
result the HTTP output body
Throws
IOException