Class SpringDelegate<T>

java.lang.Object
org.dellroad.stuff.pobj.AbstractDelegate<T>
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.
  • Constructor Details

    • SpringDelegate

      public SpringDelegate()
  • Method Details

    • setMarshaller

      public void setMarshaller(Marshaller marshaller)
      Set the Marshaller used to convert instances to XML. Required property.
      Parameters:
      marshaller - XML marshaller
    • setUnmarshaller

      public void setUnmarshaller(Unmarshaller unmarshaller)
      Set the Marshaller used to convert instances to XML. Required property.
      Parameters:
      unmarshaller - XML unmarshaller
    • 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 graph 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 - if an I/O error occurs
    • deserialize

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

      This method also presents an opportunity to (re)construct any indexes used for optimizing queries into the root object graph.

      Specified by:
      deserialize in interface PersistentObjectDelegate<T>
      Parameters:
      source - XML source
      Returns:
      deserialized object
      Throws:
      IOException - if an I/O error occurs