Package com.tangosol.coherence.rest.io
Class JaxbXmlMarshaller<T>
- java.lang.Object
-
- com.tangosol.coherence.rest.io.AbstractMarshaller<T>
-
- com.tangosol.coherence.rest.io.JaxbXmlMarshaller<T>
-
- All Implemented Interfaces:
Marshaller<T>
- Direct Known Subclasses:
XmlJaxbMarshaller
public class JaxbXmlMarshaller<T> extends AbstractMarshaller<T>
JAXB-based marshaller that marshals object to/from XML.- Author:
- as 2011.07.10
-
-
Field Summary
-
Fields inherited from interface com.tangosol.coherence.rest.io.Marshaller
FORMAT_OUTPUT
-
-
Constructor Summary
Constructors Constructor Description JaxbXmlMarshaller(Class<T> clzRoot)
Construct an JaxbXmlMarshaller instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
configureJaxbMarshaller(javax.xml.bind.Marshaller marshaller)
Configure a JAXB marshaller.protected void
configureJaxbUnmarshaller(javax.xml.bind.Unmarshaller unmarshaller)
Configure a JAXB unmarshaller.void
marshal(T value, OutputStream out, javax.ws.rs.core.MultivaluedMap<String,Object> httpHeaders)
Write the specified object into the given stream.void
marshalAsFragment(T value, OutputStream out, javax.ws.rs.core.MultivaluedMap<String,Object> httpHeaders)
Write the specified object into the given stream as a fragment.T
unmarshal(InputStream in, javax.ws.rs.core.MediaType mediaType)
Read an object from the specified stream.-
Methods inherited from class com.tangosol.coherence.rest.io.AbstractMarshaller
getRootClass
-
-
-
-
Method Detail
-
marshal
public void marshal(T value, OutputStream out, javax.ws.rs.core.MultivaluedMap<String,Object> httpHeaders) throws IOException
Description copied from interface:Marshaller
Write the specified object into the given stream.- Parameters:
value
- object to marshallout
- theOutputStream
for the HTTP entity. The implementation should not close the output stream.httpHeaders
- a mutable map of the HTTP message headers.- Throws:
IOException
- if an error occurs during marshalling
-
marshalAsFragment
public void marshalAsFragment(T value, OutputStream out, javax.ws.rs.core.MultivaluedMap<String,Object> httpHeaders) throws IOException
Description copied from interface:Marshaller
Write the specified object into the given stream as a fragment.This method is called when marshalling collections of objects, as marshalling behavior might differ when an object is serialized directly or as element of a collection.
For example, when marshalling a collection of objects into XML, you need to ensure that the XML declaration is emmitted only once, not for each object in the collection.
In cases where there is no difference in output between fragments and full objects (JSON, for example), this method could simply delegate to
Marshaller.marshal(Object, OutputStream, MultivaluedMap)
.- Parameters:
value
- object to marshallout
- theOutputStream
for the HTTP entity. The implementation should not close the output stream.httpHeaders
- a mutable map of the HTTP message headers.- Throws:
IOException
- if an error occurs during marshalling
-
unmarshal
public T unmarshal(InputStream in, javax.ws.rs.core.MediaType mediaType) throws IOException
Description copied from interface:Marshaller
Read an object from the specified stream.- Parameters:
in
- stream to read frommediaType
- the media type of the object to read- Returns:
- unmarshalled object instance
- Throws:
IOException
- if an error occurs during unmarshalling
-
configureJaxbMarshaller
protected void configureJaxbMarshaller(javax.xml.bind.Marshaller marshaller) throws javax.xml.bind.PropertyException
Configure a JAXB marshaller.- Parameters:
marshaller
- marshaller to configure- Throws:
javax.xml.bind.PropertyException
- when there is an error processing a property or value
-
configureJaxbUnmarshaller
protected void configureJaxbUnmarshaller(javax.xml.bind.Unmarshaller unmarshaller) throws javax.xml.bind.PropertyException
Configure a JAXB unmarshaller.- Parameters:
unmarshaller
- unmarshaller to configure- Throws:
javax.xml.bind.PropertyException
- when there is an error processing a property or value
-
-