Prevayler™
The Free Software
Prevalence Layer

org.prevayler.implementation.snapshot
Class SnapshotManager

java.lang.Object
  extended byorg.prevayler.implementation.snapshot.SnapshotManager
Direct Known Subclasses:
NullSnapshotManager, XmlSnapshotManager

public class SnapshotManager
extends java.lang.Object

Writes and reads snapshots to/from files. You can extend this class to use a serialization mechanism other than Java's. E.g: XML.


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

Constructor Detail

SnapshotManager

public SnapshotManager(java.lang.Object newPrevalentSystem,
                       java.lang.String snapshotDirectoryName)
                throws java.lang.ClassNotFoundException,
                       java.io.IOException
Parameters:
snapshotDirectoryName - The path of the directory where the last snapshot file will be read and where the new snapshot files will be created.
Method Detail

recoveredPrevalentSystem

public java.lang.Object recoveredPrevalentSystem()

recoveredVersion

public long recoveredVersion()

writeSnapshot

public void writeSnapshot(java.lang.Object prevalentSystem,
                          long version)
                   throws java.io.IOException
Throws:
java.io.IOException

writeSnapshot

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

Throws:
java.io.IOException

suffix

protected java.lang.String suffix()
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"


readSnapshot

public java.lang.Object readSnapshot(java.io.InputStream in)
                              throws java.io.IOException,
                                     java.lang.ClassNotFoundException
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.

Throws:
java.io.IOException
java.lang.ClassNotFoundException

deepCopy

public java.lang.Object deepCopy(java.lang.Object original,
                                 java.lang.String errorMessage)


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