fr.dyade.aaa.util
Class DBTransaction

java.lang.Object
  extended by fr.dyade.aaa.util.AbstractTransaction
      extended by fr.dyade.aaa.util.DBTransaction
All Implemented Interfaces:
DBTransactionMBean, Transaction, TransactionMBean
Direct Known Subclasses:
DerbyDBTransaction, MySQLDBTransaction

public abstract class DBTransaction
extends AbstractTransaction
implements DBTransactionMBean

The DBTransaction class implements a transactionnal storage through a JDBC interface. This class is designed to be specialized for different database implementation.

Be Careful, the configuration properties don't work for the transaction component: these properties are saved in the transaction repository so they can not be used to configure it.

See Also:
Transaction, MySQLDBTransaction, DerbyDBTransaction

Nested Class Summary
 
Nested classes/interfaces inherited from class fr.dyade.aaa.util.AbstractTransaction
AbstractTransaction.Context
 
Field Summary
protected  java.sql.Connection conn
           
private  java.sql.PreparedStatement deleteStmt
           
(package private)  java.io.File dir
           
private  java.sql.PreparedStatement insertStmt
           
protected static org.objectweb.util.monolog.api.Logger logmon
           
(package private) static int LogThresholdOperation
          Number of pooled operation, by default 1000.
(package private)  long startTime
           
private  java.sql.PreparedStatement updateStmt
           
 
Fields inherited from class fr.dyade.aaa.util.AbstractTransaction
OOS_STREAM_HEADER, perThreadContext, phase
 
Fields inherited from interface fr.dyade.aaa.util.Transaction
COMMIT, FINALIZE, FREE, GARBAGE, INIT, Kb, Mb, PhaseInfo, ROLLBACK, RUN
 
Constructor Summary
DBTransaction()
           
 
Method Summary
 void close()
          Close the transaction module.
 void commit(boolean release)
          Commit the current transaction.
 void delete(java.lang.String dirName, java.lang.String name)
          Deletes the specified object.
(package private)  java.lang.String fname(java.lang.String dirName, java.lang.String name)
           
 java.lang.String[] getList(java.lang.String prefix)
          Returns an array of strings naming the persistent objects denoted by a name that satisfy the specified prefix.
 int getLogThresholdOperation()
          Returns the pool size for operation objects, by default 1000.
 java.lang.String getPersistenceDir()
          Returns the path of persistence directory.
 long getStartTime()
          Returns the starting time.
 void init(java.lang.String path)
          Initializes the atomic storage component.
protected abstract  void initDB()
          Instantiates the database driver and creates the table if necessary
 boolean isPersistent()
          Tests if the Transaction component is persistent.
 byte[] loadByteArray(java.lang.String dirName, java.lang.String name)
          Load the specified byte array.
protected  void saveInLog(byte[] buf, java.lang.String dirName, java.lang.String name, java.util.Hashtable log, boolean copy, boolean first)
          Register the specified object in transaction log.
protected  void setPhase(int newPhase)
          Changes the transaction state.
 void stop()
          Stops the transaction module.
 
Methods inherited from class fr.dyade.aaa.util.AbstractTransaction
begin, create, create, createByteArray, createByteArray, delete, getPhase, getPhaseInfo, load, load, loadByteArray, release, save, save, save, saveByteArray, saveByteArray, saveByteArray
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface fr.dyade.aaa.util.DBTransactionMBean
getPhase, getPhaseInfo
 

Field Detail

logmon

protected static org.objectweb.util.monolog.api.Logger logmon

dir

java.io.File dir

LogThresholdOperation

static int LogThresholdOperation
Number of pooled operation, by default 1000. This value can be adjusted for a particular server by setting DBLogThresholdOperation specific property.

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


startTime

long startTime

conn

protected java.sql.Connection conn

insertStmt

private java.sql.PreparedStatement insertStmt

updateStmt

private java.sql.PreparedStatement updateStmt

deleteStmt

private java.sql.PreparedStatement deleteStmt
Constructor Detail

DBTransaction

public DBTransaction()
Method Detail

getLogThresholdOperation

public int getLogThresholdOperation()
Returns the pool size for operation objects, by default 1000.

Specified by:
getLogThresholdOperation in interface DBTransactionMBean
Returns:
The pool size for operation objects.

getStartTime

public long getStartTime()
Returns the starting time.

Specified by:
getStartTime in interface DBTransactionMBean
Returns:
The starting time.

init

public void init(java.lang.String path)
          throws java.io.IOException
Description copied from interface: Transaction
Initializes the atomic storage component.

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

initDB

protected abstract void initDB()
                        throws java.io.IOException
Instantiates the database driver and creates the table if necessary

Throws:
java.io.IOException

getPersistenceDir

public java.lang.String getPersistenceDir()
Returns the path of persistence directory.

Returns:
The path of persistence directory.

setPhase

protected final void setPhase(int newPhase)
Description copied from class: AbstractTransaction
Changes the transaction state.

Specified by:
setPhase in class AbstractTransaction
Parameters:
newPhase - the new transaction state.

getList

public final java.lang.String[] getList(java.lang.String prefix)
Returns an array of strings naming the persistent objects denoted by a name that satisfy the specified prefix. Each string is an object name.

Specified by:
getList in interface Transaction
Parameters:
prefix - the prefix
Returns:
An array of strings naming the persistent objects denoted by a name that satisfy the specified prefix. The array will be empty if no names match.

isPersistent

public boolean isPersistent()
Tests if the Transaction component is persistent.

Specified by:
isPersistent in interface Transaction
Specified by:
isPersistent in interface TransactionMBean
Returns:
true.

fname

final java.lang.String fname(java.lang.String dirName,
                             java.lang.String name)

saveInLog

protected final void saveInLog(byte[] buf,
                               java.lang.String dirName,
                               java.lang.String name,
                               java.util.Hashtable log,
                               boolean copy,
                               boolean first)
                        throws java.io.IOException
Description copied from class: AbstractTransaction
Register the specified object in transaction log.

Specified by:
saveInLog in class AbstractTransaction
Parameters:
buf - the byte array containing the state of the object.
dirName - the directory name of the object.
name - the name of the object.
log - the log to use.
copy - the byte array can be modified, copy it.
first - the object is a new one.
Throws:
java.io.IOException

loadByteArray

public byte[] loadByteArray(java.lang.String dirName,
                            java.lang.String name)
                     throws java.io.IOException
Description copied from interface: Transaction
Load the specified byte array.

Specified by:
loadByteArray in interface Transaction
Parameters:
dirName - the directory name of the object.
name - the name of the object.
Returns:
the loaded byte array.
Throws:
java.io.IOException

delete

public void delete(java.lang.String dirName,
                   java.lang.String name)
Description copied from interface: Transaction
Deletes the specified object.

Specified by:
delete in interface Transaction
Parameters:
dirName - the directory name of the object.
name - the name of the object.

commit

public final void commit(boolean release)
                  throws java.io.IOException
Description copied from interface: Transaction
Commit the current transaction.

Specified by:
commit in interface Transaction
Parameters:
release - if true releases the transaction at the end of the commit.
Throws:
java.io.IOException

stop

public void stop()
Stops the transaction module. It waits all transactions termination, then the module is kept in a FREE 'ready to use' state.

Specified by:
stop in interface Transaction

close

public void close()
Close the transaction module. It waits all transactions termination, the module will be initialized anew before reusing it.

Specified by:
close in interface Transaction


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