Package wt.pom
Class Transaction
java.lang.Object
wt.pom.Transaction
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:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intThis constant specifies the default order used for TransactionListeners. -
Constructor Summary
ConstructorsConstructorDescriptionThis constructor initializes the instance.Transaction(LocalizableMessage a_description) This constructor initializes the instance. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddLocalTransactionListener(TransactionListener a_listener) Add a listener for local Transaction events.static voidaddTransactionListener(TransactionListener listener) Add a listener for Transaction events.static voidaddTransactionListener(TransactionListener listener, int order) Add a listener for Transaction events.voidcommit()Commit a transaction block.static booleancontainsKeyInContext(Object a_key, boolean a_includeGlobalMap, boolean a_includeMethodContext) Indicates if the key exists in the current context of the Transaction.static ListfindAllInContext(Object a_key) Returns List of Transactions that contains the specified key.static TransactionfindInContext(Object a_key) Returns the inner-most Transaction in the current Transaction stack that contains the specified key.static TransactionReturns the current Transaction.Returns the transaction description.static MapReturns the global transaction map.static ObjectgetInContext(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.Returns the local transaction map.static MapGet a Map associated with a shared transaction that may execute across several concurrent threads.static ListReturns the current Transaction stack.booleanIndicates if the Transaction has a local map.booleanisShared()This method indicates if the transaction is shared with other MethodContext threads.voidRemove a listener for Transaction events.static voidremoveTransactionListener(TransactionListener listener) Remove a listener for Transaction events.voidrollback()Rollback a transaction block.voidstart()Start a transaction block.booleanThis method indicates if Savepoints can be used for the transaction.
-
Field Details
-
DEFAULT_LISTENER_ORDER
public static final int DEFAULT_LISTENER_ORDERThis constant specifies the default order used for TransactionListeners.
Supported API: true- See Also:
-
-
Constructor Details
-
Transaction
public Transaction()This constructor initializes the instance.
Supported API: true -
Transaction
This constructor initializes the instance.- Parameters:
a_description- localizable message describing this transaction. The object must implement Evolvable.
Supported API: true- Throws:
PersistenceException- See Also:
-
-
Method Details
-
supportsSavepoints
This method indicates if Savepoints can be used for the transaction.- Returns:
- true, if savepoints can be used
Supported API: true - Throws:
WTException
-
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
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
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
-
getTransactionStack
Returns the current Transaction stack.- Returns:
- current Transaction stack or null if no Transaction exists.
Supported API: true - Throws:
WTException
-
getCurrentTransaction
Returns the current Transaction.- Returns:
- current local Transaction or null if no Transaction exists.
Supported API: true - Throws:
WTException
-
getGlobalMap
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
Add a listener for Transaction events. The listener is added with the default relative ordering. The listeners will be called in the relative order with other listeners from lowest to highest.- Parameters:
listener- to add
Supported API: true- Throws:
PersistenceException
-
addTransactionListener
public static void addTransactionListener(TransactionListener listener, int order) throws PersistenceException Add a listener for Transaction events. The listener is added with the specified relative ordering. The listeners will be called in the relative order with other listeners from lowest to highest.- Parameters:
listener- to addorder- relative to other listeners
Supported API: true- Throws:
PersistenceException
-
removeTransactionListener
public static void removeTransactionListener(TransactionListener listener) throws PersistenceException Remove a listener for Transaction events.- Parameters:
listener- to remove
Supported API: true- Throws:
PersistenceException
-
getDescription
Returns the transaction description.
Supported API: true -
hasLocalMap
public boolean hasLocalMap()Indicates if the Transaction has a local map.
Supported API: true -
getLocalMap
Returns the local transaction map. If a local Map does not currently exist, then one is created.
Supported API: true -
start
Start a transaction block.
Supported API: true- Throws:
PersistenceException
-
commit
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
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