fr.dyade.aaa.util
Class DBRepository

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

final class DBRepository
extends java.lang.Object
implements Repository

This class allows to use a database through JDBC as repository with the NTransaction module.

See Also:
NTransaction, Repository

Field Summary
private  int baddeleted
           
(package private)  java.sql.Connection conn
           
(package private)  java.lang.String connurl
           
(package private)  java.sql.PreparedStatement deleteStmt
           
(package private)  java.io.File dir
           
(package private)  java.lang.String driver
           
(package private)  java.sql.PreparedStatement insertStmt
           
private  int nbdeleted
           
private  int nbloaded
           
private  int nbsaved
           
(package private)  java.sql.PreparedStatement updateStmt
           
 
Constructor Summary
DBRepository()
           
 
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.
 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

driver

java.lang.String driver

connurl

java.lang.String connurl

dir

java.io.File dir

nbsaved

private int nbsaved

nbdeleted

private int nbdeleted

baddeleted

private int baddeleted

nbloaded

private int nbloaded

conn

java.sql.Connection conn

insertStmt

java.sql.PreparedStatement insertStmt

updateStmt

java.sql.PreparedStatement updateStmt

deleteStmt

java.sql.PreparedStatement deleteStmt
Constructor Detail

DBRepository

DBRepository()
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. Opens the connection, evntually creates the database and tables.

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

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.