org.activemath.util
Class XStreamBackupFileStrategy

java.lang.Object
  extended by org.activemath.util.XStreamBackupFileStrategy
All Implemented Interfaces:
com.thoughtworks.xstream.persistence.PersistenceStrategy

public class XStreamBackupFileStrategy
extends Object
implements com.thoughtworks.xstream.persistence.PersistenceStrategy

FileStreamStrategy which performs automatic backup operations on the streams it handles (as well as restores in failure cases)


Field Summary
protected static Category log
           
 
Constructor Summary
XStreamBackupFileStrategy(File origDirectory, File backupDirectory, com.thoughtworks.xstream.XStream xstream)
           
 
Method Summary
 Object get(Object key)
          Load an object from the file system.
 Iterator iterator()
           
 Object put(Object key, Object value)
          Will store the file twice: once in origDir, once in backup dir.
 Object remove(Object key)
           
 void setMaxSize(long maxSize)
          Set a hard limit for XStream's file size as safety net for infinite loop due to concurrency issue (AMATH-1906).
 int size()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

protected static Category log
Constructor Detail

XStreamBackupFileStrategy

public XStreamBackupFileStrategy(File origDirectory,
                                 File backupDirectory,
                                 com.thoughtworks.xstream.XStream xstream)
Method Detail

setMaxSize

public void setMaxSize(long maxSize)
Set a hard limit for XStream's file size as safety net for infinite loop due to concurrency issue (AMATH-1906).


get

public Object get(Object key)
Load an object from the file system. Here is where the main action takes place: Always try to make sure that the correct data is loaded, and that backups are in place.

Specified by:
get in interface com.thoughtworks.xstream.persistence.PersistenceStrategy
See Also:
PersistenceStrategy.get(java.lang.Object)

put

public Object put(Object key,
                  Object value)
Will store the file twice: once in origDir, once in backup dir.

Specified by:
put in interface com.thoughtworks.xstream.persistence.PersistenceStrategy
See Also:
PersistenceStrategy.put(java.lang.Object, java.lang.Object)

remove

public Object remove(Object key)
Specified by:
remove in interface com.thoughtworks.xstream.persistence.PersistenceStrategy
See Also:
PersistenceStrategy.remove(java.lang.Object)

iterator

public Iterator iterator()
Specified by:
iterator in interface com.thoughtworks.xstream.persistence.PersistenceStrategy
See Also:
PersistenceStrategy.iterator()

size

public int size()
Specified by:
size in interface com.thoughtworks.xstream.persistence.PersistenceStrategy
See Also:
PersistenceStrategy.size()