org.apache.ace.repository.ext.impl
Class FilebasedBackupRepository

java.lang.Object
  extended by org.apache.ace.repository.ext.impl.FilebasedBackupRepository
All Implemented Interfaces:
BackupRepository

public class FilebasedBackupRepository
extends Object
implements BackupRepository

A file-based implementation of the Backup Repository, using two files to store the current and backup version.


Constructor Summary
FilebasedBackupRepository(File current, File backup)
          Creates a FilebasedBackupRepository.
 
Method Summary
 boolean backup()
          Backs up the current version of the object, overwriting a previous backup, if any.
 InputStream read()
          Reads the input stream from the current object.
 boolean restore()
          Restores a previously backuped version of the object.
 String toString()
           
 void write(InputStream data)
          Writes the input stream to the current object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

FilebasedBackupRepository

public FilebasedBackupRepository(File current,
                                 File backup)
Creates a FilebasedBackupRepository. The file objects should point to a correct file, but the files will be created when necessary.

Parameters:
current - A file to store the current revision in.
backup - A file to store a backup version in.
Method Detail

read

public InputStream read()
                 throws IOException
Description copied from interface: BackupRepository
Reads the input stream from the current object. If there is no current version, an empty stream will be returned.

Specified by:
read in interface BackupRepository
Returns:
An input stream, from which can be read. Remember to close it.
Throws:
IOException - Will be thrown when there is a problem storing the data.

write

public void write(InputStream data)
           throws IOException
Description copied from interface: BackupRepository
Writes the input stream to the current object.

Specified by:
write in interface BackupRepository
Parameters:
data - The data to be written. Remember to close this stream, if necessary.
Throws:
IOException - Will be thrown when (a) the input stream gets closed unexpectedly, or (b) there is an error writing the data.

backup

public boolean backup()
               throws IOException
Description copied from interface: BackupRepository
Backs up the current version of the object, overwriting a previous backup, if any.

Specified by:
backup in interface BackupRepository
Returns:
True when there was a current version to be backed up, false otherwise.
Throws:
IOException - Thrown when the restore process goes bad.

restore

public boolean restore()
                throws IOException
Description copied from interface: BackupRepository
Restores a previously backuped version of the object.

Specified by:
restore in interface BackupRepository
Returns:
True when there was a previously backup version which has now been restored, false otherwise.
Throws:
IOException - Thrown when the restore process goes bad.

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2009-2011 The Apache Software Foundation. All Rights Reserved.