fr.dyade.aaa.util
Class FileRepository

java.lang.Object
  extended by fr.dyade.aaa.util.FileRepository
All Implemented Interfaces:
Repository

final class FileRepository
extends java.lang.Object
implements Repository

This class allows to use a filesystem directory as repository with the NTransaction module.

See Also:
NTransaction, Repository

Field Summary
private  int baddeleted
          The number of useless delete operation on repository.
(package private)  java.io.File dir
           
private  int nbdeleted
          The number of delete operation on repository.
private  int nbloaded
          The number of load operation from repository.
private  int nbsaved
          The number of save operation to repository.
private  boolean useFileOutputStream
          Boolean value to force the use of FileOutputStream rather than RandomAccessFile.
 
Constructor Summary
FileRepository()
           
 
Method Summary
 void close()
          Closes the repository.
 void commit()
          Commits all changes to the repository.
 void delete(java.lang.String dirName, java.lang.String name)
          Deletes the corresponding objects in repository.
private  void deleteDir(java.io.File dir)
          Delete the specified directory if it is empty.
 int getNbBadDeletedObjects()
          Returns the number of useless delete operation on repository.
 int getNbDeletedObjects()
          Returns the number of delete operation on repository.
 int getNbLoadedObjects()
          Returns the number of load operation from repository.
 int getNbSavedObjects()
          Returns the number of save operation to repository.
 void init(java.io.File dir)
          Initializes the repository.
 java.lang.String[] list(java.lang.String prefix)
          Gets a list of persistent objects that name corresponds to prefix.
 byte[] load(java.lang.String dirName, java.lang.String name)
          Loads the byte array.
 void save(java.lang.String dirName, java.lang.String name, byte[] content)
          Save the corresponding bytes array.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

dir

java.io.File dir

nbsaved

private int nbsaved
The number of save operation to repository.


nbdeleted

private int nbdeleted
The number of delete operation on repository.


baddeleted

private int baddeleted
The number of useless delete operation on repository.


nbloaded

private int nbloaded
The number of load operation from repository.


useFileOutputStream

private boolean useFileOutputStream
Boolean value to force the use of FileOutputStream rather than RandomAccessFile. By default this value is false, it can be set to true using the FileRepository.useRandomAccessFile java property.

This property can be fixed only from java launching command, or through System.property method.

Constructor Detail

FileRepository

FileRepository()
Method Detail

getNbSavedObjects

public int getNbSavedObjects()
Returns the number of save operation to repository.

Specified by:
getNbSavedObjects in interface Repository
Returns:
The number of save operation to repository.

getNbDeletedObjects

public int getNbDeletedObjects()
Returns the number of delete operation on repository.

Specified by:
getNbDeletedObjects in interface Repository
Returns:
The number of delete operation on repository.

getNbBadDeletedObjects

public int getNbBadDeletedObjects()
Returns the number of useless delete operation on repository.

Specified by:
getNbBadDeletedObjects in interface Repository
Returns:
The number of useless delete operation on repository.

getNbLoadedObjects

public int getNbLoadedObjects()
Returns the number of load operation from repository.

Specified by:
getNbLoadedObjects in interface Repository
Returns:
The number of load operation from repository.

init

public void init(java.io.File dir)
          throws java.io.IOException
Initializes the repository. Nothing to do.

Specified by:
init in interface Repository
Throws:
java.io.IOException

list

public java.lang.String[] list(java.lang.String prefix)
                        throws java.io.IOException
Gets a list of persistent objects that name corresponds to prefix.

Specified by:
list in interface Repository
Returns:
The list of corresponding names.
Throws:
java.io.IOException

save

public void save(java.lang.String dirName,
                 java.lang.String name,
                 byte[] content)
          throws java.io.IOException
Save the corresponding bytes array.

Specified by:
save in interface Repository
Throws:
java.io.IOException

load

public byte[] load(java.lang.String dirName,
                   java.lang.String name)
            throws java.io.IOException
Loads the byte array.

Specified by:
load in interface Repository
Returns:
The loaded bytes array.
Throws:
java.io.IOException

delete

public void delete(java.lang.String dirName,
                   java.lang.String name)
            throws java.io.IOException
Deletes the corresponding objects in repository.

Specified by:
delete in interface Repository
Throws:
java.io.IOException

deleteDir

private final void deleteDir(java.io.File dir)
Delete the specified directory if it is empty. Also recursively delete the parent directories if they are empty.


commit

public void commit()
            throws java.io.IOException
Commits all changes to the repository.

Specified by:
commit in interface Repository
Throws:
java.io.IOException

close

public void close()
           throws java.io.IOException
Closes the repository.

Specified by:
close in interface Repository
Throws:
java.io.IOException


Copyright © 2010 ScalAgent D.T.. All Rights Reserved.