org.wso2.carbon.registry.core.jdbc.utils
Class Transaction

java.lang.Object
  extended by org.wso2.carbon.registry.core.jdbc.utils.Transaction

public class Transaction
extends Object

This is the base class that manages the transactional database operations of the Registry. The transactions API of the Registry is capable of handling nested transactions. If a nested transaction is rollbacked, the whole outer transaction would also be rollbacked, so that the database will not be in an inconsistent state.

The transaction API also supports transactions across multiple databases. This allows various portions of the Registry to be mounted from various databases and work as a part of a single tree.

The transaction is session scoped, and therefore, is available only on a single running thread. Multiple threads would have its own transaction and thereby make it possible to manage concurrency at a much lower level.


Constructor Summary
Transaction()
           
 
Method Summary
static void decNestedDepth()
          This method will decrement the nested depth of the transaction on the current session.
static Connection getConnection()
          Method to get connection.
static Connection getManagedRegistryConnection(Connection conn)
          Method to obtain a connection that is managed by the registry transactions implementation.
static int getNestedDepth()
          Method to obtain the depth of nesting of this transaction at a given point in time.
static void incNestedDepth()
          This method will increment the nested depth of the transaction on the current session.
static boolean isRollbacked()
          Method to determine whether this transaction has been rollbacked at least once.
static boolean isStarted()
          Method to determine whether a transaction is started or not.
static void popTransaction()
          Pop stacked transaction and replace the existing one with that.
static void pushTransaction()
          Push current transaction to a stack and make room for a new one.
static void removeConnection()
          Method to remove the connection from the transaction.
static void setConnection(Connection connection)
          Method to set connection.
static void setRollbacked(boolean rollbacked)
          Method to set whether this transaction has been rollbacked or not.
static void setStarted(boolean started)
          Method to set whether a transaction is started or not.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Transaction

public Transaction()
Method Detail

pushTransaction

public static void pushTransaction()
Push current transaction to a stack and make room for a new one.


popTransaction

public static void popTransaction()
Pop stacked transaction and replace the existing one with that.


isStarted

public static boolean isStarted()
Method to determine whether a transaction is started or not.

Returns:
whether a transaction is started or not.

setStarted

public static void setStarted(boolean started)
Method to set whether a transaction is started or not.

Parameters:
started - whether a transaction is started or not.

getConnection

public static Connection getConnection()
Method to get connection.

Returns:
the connection.

setConnection

public static void setConnection(Connection connection)
Method to set connection.

Parameters:
connection - the connection.

removeConnection

public static void removeConnection()
Method to remove the connection from the transaction.


incNestedDepth

public static void incNestedDepth()
This method will increment the nested depth of the transaction on the current session.


decNestedDepth

public static void decNestedDepth()
This method will decrement the nested depth of the transaction on the current session.


getNestedDepth

public static int getNestedDepth()
Method to obtain the depth of nesting of this transaction at a given point in time.

Returns:
the nested depth.

isRollbacked

public static boolean isRollbacked()
Method to determine whether this transaction has been rollbacked at least once. This applies to the out as well as inner transactions as a whole.

Returns:
whether this transaction has been rollbacked.

setRollbacked

public static void setRollbacked(boolean rollbacked)
Method to set whether this transaction has been rollbacked or not.

Parameters:
rollbacked - whether this transaction has been rollbacked or not.

getManagedRegistryConnection

public static Connection getManagedRegistryConnection(Connection conn)
Method to obtain a connection that is managed by the registry transactions implementation. If the managed transaction is already closed, committed or rollbacked, this method will reinstate it.

Parameters:
conn - un-managed connection.
Returns:
managed connection.


Copyright © 2010. All Rights Reserved.