wt.pom
Class Transaction

java.lang.Object
  extended bywt.pom.Transaction

public class Transaction
extends Object

Transaction provides interfaces to create transaction blocks. This class supports transaction block nesting. A new database level transaction is not started for nested transaction blocks. Internal state is maintained so that only a commit at the outer most transaction block will cause a database level commit. A rollback at any level will cause the entire transaction to be rolled back immediately.

TransactionListeners can be added within a global or local scope. For global listeners, callback methods will be executed when the outer-most Transaction either commits or rolls back. For the local listeners, the methods will be called when this Transaction instance either commits or rolls back. The overall transactional behavior is not affected.

Supported API: true
Extendable: false

See Also:
TransactionListener

Field Summary
static Object BEFORE_COMPLETION_MANIFEST_KEY
          Key used for accessing a Manifest associated with the TransactionCommitListener.beforeCompletion() processing.
private  int id
           
private  ArrayList listeners
           
private  Map map
           
(package private)  PersistentObjectManager pom
           
private static String RESOURCE
           
private  Savepoint savepoint
           
 
Constructor Summary
Transaction()
           
 
Method Summary
 void addLocalTransactionListener(TransactionListener a_listener)
          Add a listener for local Transaction events.
static void addTransactionListener(TransactionListener listener)
          Add a listener for Transaction events.
 void commit()
          Commit a transaction block.
static boolean containsKeyInContext(Object a_key, boolean a_includeGlobalMap, boolean a_includeMethodContext)
          Indicates if the key exists in the current context of the Transaction.
static List findAllInContext(Object a_key)
          Returns List of Transactions that contains the specified key.
static Transaction findInContext(Object a_key)
          Returns the inner-most Transaction in the current Transaction stack that contains the specified key.
static Transaction getCurrentTransaction()
          Returns the current Transaction.
static Map getGlobalMap()
          Returns the global transaction map.
static Object getInContext(Object a_key, boolean a_includeGlobalMap, boolean a_includeMethodContext)
          Returns the values associated with the specified key exists in the current context of the Transaction.
 Map getLocalMap()
          Returns the local transaction map.
 Savepoint getSavepoint()
          Get current transaction savepoint.
 boolean hasLocalMap()
          Indicates if the Transaction has a local map.
 void removeLocalTransactionListener(TransactionListener listener)
          Remove a listener for Transaction events.
static void removeTransactionListener(TransactionListener listener)
          Remove a listener for Transaction events.
 void rollback()
          Rollback a transaction block.
 void setSavepoint()
          Set a transaction savepoint.
 void start()
          Start a transaction block.
 String toString()
          Return a String representation of the Transaction.
static String toStringInContext()
          Return a String representation of the Transaction context.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

BEFORE_COMPLETION_MANIFEST_KEY

public static final Object BEFORE_COMPLETION_MANIFEST_KEY
Key used for accessing a Manifest associated with the TransactionCommitListener.beforeCompletion() processing.

Supported API: false


pom

PersistentObjectManager pom

id

private int id

listeners

private ArrayList listeners

map

private Map map

savepoint

private Savepoint savepoint

RESOURCE

private static final String RESOURCE
Constructor Detail

Transaction

public Transaction()
Method Detail

containsKeyInContext

public static boolean containsKeyInContext(Object a_key,
                                           boolean a_includeGlobalMap,
                                           boolean a_includeMethodContext)
                                    throws WTException
Indicates if the key exists in the current context of the Transaction. The context includes the Transaction stack local Maps and optionally the global Transaction Map and MethodContext.

Supported API: true

Throws:
WTException

getInContext

public static Object getInContext(Object a_key,
                                  boolean a_includeGlobalMap,
                                  boolean a_includeMethodContext)
                           throws WTException
Returns the values associated with the specified key exists in the current context of the Transaction. The context includes the Transaction stack local Maps and optionally the global Transaction Map and MethodContext. The key is searched in the current Transaction context local Maps from inner (most recently created) to outer (first created) Transaction blocks. If the key is not found in the Transaction context and a_includeGlobalMap is true, then the Transaction global map is searched. If still not found and a_includeMethodContext is true, then the MethodContext is searched.

Returns:
the value associated with the key, null if not found

Supported API: true
Throws:
WTException

findInContext

public static Transaction findInContext(Object a_key)
                                 throws WTException
Returns the inner-most Transaction in the current Transaction stack that contains the specified key.

Returns:
current local Transaction that contains the key or null if no Transaction exists or the key is not found.

Supported API: true
Throws:
WTException

findAllInContext

public static List findAllInContext(Object a_key)
                             throws WTException
Returns List of Transactions that contains the specified key. The List is ordered from inner-most (index=0) to outer-most (index=size() - 1).

Returns:
List of local Transactions that contain the key or null if no Transaction exists or the key is not found.

Supported API: true
Throws:
WTException

getCurrentTransaction

public static Transaction getCurrentTransaction()
                                         throws WTException
Returns the current Transaction.

Returns:
current local Transaction or null if no Transaction exists.

Supported API: true
Throws:
WTException

getGlobalMap

public static Map getGlobalMap()
                        throws WTException
Returns the global transaction map. If a global Map does not currently exist, then one is created.

Returns:
global Transaction Map

Supported API: true
Throws:
WTException

addTransactionListener

public static void addTransactionListener(TransactionListener listener)
                                   throws PersistenceException
Add a listener for Transaction events.

Supported API: true

Throws:
PersistenceException

removeTransactionListener

public static void removeTransactionListener(TransactionListener listener)
                                      throws PersistenceException
Remove a listener for Transaction events.

Supported API: true

Throws:
PersistenceException

hasLocalMap

public boolean hasLocalMap()
Indicates if the Transaction has a local map.

Supported API: true


getLocalMap

public Map getLocalMap()
Returns the local transaction map. If a local Map does not currently exist, then one is created.

Supported API: true


setSavepoint

public void setSavepoint()
                  throws WTException
Set a transaction savepoint.

Supported API: false

Throws:
WTException

getSavepoint

public Savepoint getSavepoint()
Get current transaction savepoint.

Supported API: false


start

public void start()
           throws PersistenceException
Start a transaction block.

Supported API: true

Throws:
PersistenceException

commit

public void commit()
            throws PersistenceException
Commit a transaction block. An acutal database commit is only performed when the outer-most transaction block is committed.

Supported API: true

Throws:
PersistenceException

rollback

public void rollback()
Rollback a transaction block.

Supported API: true


addLocalTransactionListener

public void addLocalTransactionListener(TransactionListener a_listener)
                                 throws PersistenceException
Add a listener for local Transaction events.

Supported API: true

Throws:
PersistenceException

removeLocalTransactionListener

public void removeLocalTransactionListener(TransactionListener listener)
                                    throws PersistenceException
Remove a listener for Transaction events.

Supported API: true

Throws:
PersistenceException

toString

public String toString()
Return a String representation of the Transaction. The local map string representation is returned.


toStringInContext

public static String toStringInContext()
                                throws WTException
Return a String representation of the Transaction context. The Transaction string representation of each Transaction from outermost to innermost is returned.

Throws:
WTException