com.framework.jdto.transaction
Class TransactionContext

java.lang.Object
  extended bycom.framework.jdto.transaction.TransactionContext
All Implemented Interfaces:
Transaction

public class TransactionContext
extends Object
implements Transaction

This class is associated with the Current Thread whenever a transaction is started.

Author:
msatish

Constructor Summary
TransactionContext()
           
 
Method Summary
 void commit()
          Commits the Transaction if the current Transaction Status is STATUS_MARKED_COMMIT.
 Connection getConnection()
          Returns the connection that is held by the current Transaction.
 int getStatus()
          Gets the current Transaction Status.
 int getTransactionOwner()
          Returns the current Transaction Owner
 void releaseConnection()
          Releases the Connection that is held by the Current Transaction Context once the transaction is either comitted or rolled back.
 void rollback()
          RollBack the Transaction if the current Transaction Status is STATUS_MARKED_ROLLBACK.
 void setConnection(Connection con)
          Sets the connection to the current Transaction context.
 void setRollbackOnly()
          Sets the current Transaction to STATUS_MARKED_ROLLBACK if any failure occurs.
 void setStatus(int statusFlag)
          Sets the status of the Current Transaction.
 void setTransactionOwner(int transactionOwner)
          Sets the Tranasaction Owner.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TransactionContext

public TransactionContext()
Method Detail

getTransactionOwner

public int getTransactionOwner()
Returns the current Transaction Owner

Returns:
transactionOwner.

setTransactionOwner

public void setTransactionOwner(int transactionOwner)
Sets the Tranasaction Owner. This sets the transaction owner as CONTEXT_MANAGER, if the transaction is started by the TransactionContextManager class. otherwise it sets as JDBC_WRAPPER, if the current transaction is started by either PreparedStatementWrapper or StatementWrapper classes.

Parameters:
transactionOwner -

getConnection

public Connection getConnection()
Returns the connection that is held by the current Transaction.

Returns:
connection.

setConnection

public void setConnection(Connection con)
Sets the connection to the current Transaction context.

Parameters:
con - java.sql.Connection type of object.

setStatus

public void setStatus(int statusFlag)
Sets the status of the Current Transaction.

Parameters:
statusFlag - status of the Transaction as int.

releaseConnection

public void releaseConnection()
Releases the Connection that is held by the Current Transaction Context once the transaction is either comitted or rolled back.


commit

public void commit()
            throws SQLException
Commits the Transaction if the current Transaction Status is STATUS_MARKED_COMMIT.

Specified by:
commit in interface Transaction
Throws:
SQLException

getStatus

public int getStatus()
Gets the current Transaction Status.

Specified by:
getStatus in interface Transaction
Returns:
the current Transaction Status as int.

rollback

public void rollback()
              throws SQLException
RollBack the Transaction if the current Transaction Status is STATUS_MARKED_ROLLBACK.

Specified by:
rollback in interface Transaction
Throws:
SQLException

setRollbackOnly

public void setRollbackOnly()
Sets the current Transaction to STATUS_MARKED_ROLLBACK if any failure occurs.

Specified by:
setRollbackOnly in interface Transaction