Prevayler™
The Free Software
Prevalence Layer

org.prevayler.implementation.snapshot
Class XmlSnapshotManager

java.lang.Object
  extended byorg.prevayler.implementation.snapshot.SnapshotManager
      extended byorg.prevayler.implementation.snapshot.XmlSnapshotManager

public class XmlSnapshotManager
extends SnapshotManager

Writes and reads snapshots to/from XML files.

This implementation requires the Skaringa Java and XML language binding framework which provides for Java object XML serialization.

Note that Skaringa has some dependencies of its own. It requires the standard XML API's (xml-apis.jar from the Apache Xerces-j project or j2sdk1.4.x), an XML Transformation engine (Apache Xalan-j), and a logging api (Apache Jakarta Commons Logging), and, if desired, a logging implementation (Apache Jakarta Log4j or j2sdk1.4.x logging).

One more quick note. j2sdk1.4.x comes with an old buggy version of Xalan which you should override using the endorsed package override mechanism. To do this, add your preferred version of xalan.jar to JAVA_HOME/jre/lib/endorsed. You will need to create the 'endorsed' directory if it doesn't already exist. That is the *only* way to override packages that the JDK already provides in j2sdk1.4.x and above. In JDK1.3.x, this isn't a problem, although you will need to supply everything mentioned above on the classpath.

See Also:
SnapshotManager

Constructor Summary
XmlSnapshotManager(java.lang.Object newPrevalentSystem, java.lang.String snapshotDirectoryName)
           
 
Method Summary
 java.lang.Object readSnapshot(java.io.InputStream in)
          Deserializes and returns the object contained in snapshotFile.
protected  java.lang.String suffix()
          Returns "snapshot", the default suffix/extension for snapshot files.
 void writeSnapshot(java.lang.Object prevalentSystem, java.io.OutputStream out)
          Serializes prevalentSystem and writes it to snapshotFile.
 
Methods inherited from class org.prevayler.implementation.snapshot.SnapshotManager
deepCopy, recoveredPrevalentSystem, recoveredVersion, writeSnapshot
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XmlSnapshotManager

public XmlSnapshotManager(java.lang.Object newPrevalentSystem,
                          java.lang.String snapshotDirectoryName)
                   throws java.lang.ClassNotFoundException,
                          java.io.IOException
Method Detail

readSnapshot

public java.lang.Object readSnapshot(java.io.InputStream in)
                              throws java.io.IOException
Description copied from class: SnapshotManager
Deserializes and returns the object contained in snapshotFile. You can overload this method to use a deserialization mechanism other than Java's. E.g: XML.

Overrides:
readSnapshot in class SnapshotManager
Throws:
java.io.IOException
See Also:
SnapshotManager.readSnapshot(InputStream)

suffix

protected java.lang.String suffix()
Description copied from class: SnapshotManager
Returns "snapshot", the default suffix/extension for snapshot files. You can overload this method and return a different suffix if you want. E.g: "XmlSnapshot"

Overrides:
suffix in class SnapshotManager
See Also:
SnapshotManager.suffix()

writeSnapshot

public void writeSnapshot(java.lang.Object prevalentSystem,
                          java.io.OutputStream out)
                   throws java.io.IOException
Description copied from class: SnapshotManager
Serializes prevalentSystem and writes it to snapshotFile. You can overload this method to use a serialization mechanism other than Java's. E.g: XML.

Overrides:
writeSnapshot in class SnapshotManager
Throws:
java.io.IOException
See Also:
SnapshotManager.writeSnapshot(Object, OutputStream)


'Prevayler' is a trademark of Klaus Wuestefeld.
Copyleft 2001-2004 Klaus Wuestefeld.