org.dellroad.stuff.pobj
Class SpringDelegate<T>

java.lang.Object
  extended by org.dellroad.stuff.pobj.AbstractDelegate<T>
      extended by org.dellroad.stuff.pobj.SpringDelegate<T>
Type Parameters:
T - type of the root persistent object
All Implemented Interfaces:
PersistentObjectDelegate<T>, InitializingBean

public class SpringDelegate<T>
extends AbstractDelegate<T>
implements InitializingBean

PersistentObjectDelegate that uses Spring's Marshaller and Unmarshaller interfaces for XML conversion.


Field Summary
 
Fields inherited from class org.dellroad.stuff.pobj.AbstractDelegate
log
 
Constructor Summary
SpringDelegate()
           
 
Method Summary
 void afterPropertiesSet()
           
 T deserialize(Source source)
          Deserialize a root object from XML.
 void serialize(T obj, Result result)
          Serialize a root object into XML.
 void setMarshaller(Marshaller marshaller)
          Set the Marshaller used to convert instances to XML.
 void setUnmarshaller(Unmarshaller unmarshaller)
          Set the Marshaller used to convert instances to XML.
 
Methods inherited from class org.dellroad.stuff.pobj.AbstractDelegate
copy, handleWritebackException, isSameGraph, validate
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SpringDelegate

public SpringDelegate()
Method Detail

setMarshaller

public void setMarshaller(Marshaller marshaller)
Set the Marshaller used to convert instances to XML. Required property.


setUnmarshaller

public void setUnmarshaller(Unmarshaller unmarshaller)
Set the Marshaller used to convert instances to XML. Required property.


afterPropertiesSet

public void afterPropertiesSet()
                        throws Exception
Specified by:
afterPropertiesSet in interface InitializingBean
Throws:
Exception

serialize

public void serialize(T obj,
                      Result result)
               throws IOException
Description copied from interface: PersistentObjectDelegate
Serialize a root object into XML.

Note that this method effectively defines what is contained in the object graph rooted at obj.

This method must not modify obj or any other object in its object graph.

Specified by:
serialize in interface PersistentObjectDelegate<T>
Parameters:
obj - object to serialize; must not be modified
result - XML destination
Throws:
IOException

deserialize

public T deserialize(Source source)
              throws IOException
Description copied from interface: PersistentObjectDelegate
Deserialize a root object from XML.

Specified by:
deserialize in interface PersistentObjectDelegate<T>
Parameters:
source - XML source
Returns:
deserialized object
Throws:
IOException