|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectwt.pom.TransactionManager
TransactionManager manages nested transactions for a user thread.
An instance of TransactionManager is held by each user connection.
The TransactionManager handles nested transaction blocks and
only forwards the actual datastore commit when a commit which matchs
an outer level start is received. If a commit is received which does
not match a corresponding start, an exception is thrown.
A rollback is invoked immediately and if the rollback occurs at a
nested level, a "rollback in process" state is triggered. In this case,
further start or commit actions will throw an exception until a rollback
matching the outer block is received.
The interface to transaction blocks is through wt.pom.Transaction.
Example 1 - normal commit
Transaction trx1 = new Transaction();
trx1.start();
anObj1.insert();
Transaction trx2 = new Transaction();
trx2.start();
anObj2.delete();
trx2.commit(); // commit is pending
trx1.commit(); // commit happens
Example 2 - rollback
Transaction trx1 = new Transaction();
trx1.start();
anObj1.insert();
Transaction trx2 = new Transaction();
trx2.start();
anObj2.delete();
trx2.rollback(); // rollback happens
trx1.rollback(); // transaction is cleared (commit not allowed)
WTConnection
,
Transaction
Nested Class Summary | |
(package private) static class |
TransactionManager.BeforeCompletionTransactionListener
|
(package private) static class |
TransactionManager.FinishTransactionListener
|
(package private) static interface |
TransactionManager.FireTransactionListener
|
(package private) static class |
TransactionManager.NotifyCommitTransactionListener
|
(package private) static class |
TransactionManager.NotifyRollbackTransactionListener
|
Field Summary | |
(package private) static TransactionManager.BeforeCompletionTransactionListener |
BEFORE_COMPLETION
|
(package private) static BeforeCompletionValidationListener |
BEFORE_COMPLETION_VALIDATION_LISTENER
|
private RefreshCache |
cache
|
private static String |
CLASSNAME
|
private HashMap |
classoidmap
|
private int |
count
|
static boolean |
DEBUG
|
(package private) static TransactionManager.FinishTransactionListener |
FINISH
|
private static DebugWriter |
LOG
|
private HashMap |
map
|
(package private) static TransactionManager.NotifyCommitTransactionListener |
NOTIFY_COMMIT
|
(package private) static TransactionManager.NotifyRollbackTransactionListener |
NOTIFY_ROLLBACK
|
private ArrayList |
pomOperationListeners
|
private static String |
RESOURCE
|
private boolean |
rollbackInProgress
|
private int |
transactionLevel
|
private ArrayList |
transactionListeners
|
private int |
transactionMode
|
private ArrayList |
transactionStack
|
Constructor Summary | |
TransactionManager()
|
Method Summary | |
protected void |
addEntryInCache(ObjectIdentifier a_oid)
|
void |
addEntryInCache(Persistable a_obj)
Adds the specified Persistable to the RefreshCache. |
protected void |
addPOMOperationListener(POMOperationListener listener)
|
protected void |
addTransactionListener(TransactionListener listener)
|
protected void |
commitTransaction(int aHandle)
Commit a transaction flushing changes to the datastore. |
protected boolean |
containOidInCache(ObjectIdentifier a_oid)
|
private void |
executeCommitTransaction(Savepoint a_savepoint)
|
private void |
executeRollbackTransaction(Savepoint a_savepoint)
|
private void |
executeTransactionOperation(boolean a_commit,
Savepoint a_savepoint,
String a_traceTimingName)
|
protected List |
findAll(Object a_key)
Returns a List of Transactions with a local Map that contains the specified key. |
protected Transaction |
findFirst(Object a_key)
Returns the first Transaction with a local Map that contains the specified key. |
protected void |
fireTransactionListener(boolean callCommit)
|
(package private) static void |
fireTransactionListener(List a_listeners,
TransactionManager.FireTransactionListener a_fireListener)
|
protected List |
getContext()
Returns Transactions context. |
protected Transaction |
getCurrentTransaction()
Returns the current Transaction. |
Persistable |
getEntryFromCache(ObjectIdentifier a_oid,
Persistable a_target)
Returns a Persistable from the RefreshCache, if it exists. |
protected Map |
getGlobalTransactionMap()
Returns the global Transaction Map. |
protected List |
getLocalPOMOperationListeners()
|
protected boolean |
getrollbackInProgress()
|
private Savepoint |
getSavepoint()
|
private Savepoint |
getSavepoint(int a_level)
|
protected int |
getTransactionId()
|
protected int |
getTransactionLevel()
|
protected boolean |
hasGlobalTransactionMap()
Indicates if a global transaction Map exists. |
protected boolean |
isTransactionActive()
|
protected void |
releaseSavepoint(Connection a_connection,
Savepoint a_savepoint)
|
protected void |
removeEntriesFromCache(String a_className)
|
protected void |
removeEntryFromCache(ObjectIdentifier a_oid)
|
protected void |
removeEntryFromCache(Persistable a_obj)
|
protected void |
removePOMOperationListener(POMOperationListener listener)
|
protected void |
removeTransactionListener(TransactionListener listener)
|
protected void |
rollbackTransaction()
|
protected void |
rollbackTransaction(int aHandle)
Rollback a transaction cancelling pending changes to the datastore. |
protected void |
setrollbackInProgress(boolean state)
|
protected void |
setTransactionIsolation(int a_mode)
|
protected void |
setTransactionLevel(int level)
|
protected int |
startTransaction(Transaction a_transaction)
Start a transaction. |
private void |
validateCommit(int aHandle)
|
private void |
validateStart()
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
private static final String CLASSNAME
public static final boolean DEBUG
private static final DebugWriter LOG
private int transactionLevel
private int transactionMode
private boolean rollbackInProgress
private ArrayList transactionListeners
private ArrayList pomOperationListeners
private RefreshCache cache
private int count
private ArrayList transactionStack
private HashMap map
private HashMap classoidmap
private static final String RESOURCE
static final TransactionManager.FinishTransactionListener FINISH
static final TransactionManager.BeforeCompletionTransactionListener BEFORE_COMPLETION
static final TransactionManager.NotifyCommitTransactionListener NOTIFY_COMMIT
static final TransactionManager.NotifyRollbackTransactionListener NOTIFY_ROLLBACK
static final BeforeCompletionValidationListener BEFORE_COMPLETION_VALIDATION_LISTENER
Constructor Detail |
public TransactionManager()
Method Detail |
protected boolean hasGlobalTransactionMap()
protected Map getGlobalTransactionMap()
protected Transaction getCurrentTransaction()
protected Transaction findFirst(Object a_key)
protected List findAll(Object a_key)
protected List getContext()
protected int startTransaction(Transaction a_transaction) throws PersistenceException
PersistenceException
- Occurs if the persistent object manager cannot
start the transaction.protected void commitTransaction(int aHandle) throws PersistenceException
PersistenceException
- Occurs if the persistent object manager cannot
end the transaction.protected void rollbackTransaction(int aHandle) throws PersistenceException
PersistenceException
- Occurs if the persistent object manager cannot
drop the transaction.protected void rollbackTransaction() throws PersistenceException
PersistenceException
public void addEntryInCache(Persistable a_obj)
a_obj
- Persistable object to addprotected void addEntryInCache(ObjectIdentifier a_oid)
protected void removeEntryFromCache(ObjectIdentifier a_oid)
protected void removeEntryFromCache(Persistable a_obj)
protected void removeEntriesFromCache(String a_className)
protected boolean containOidInCache(ObjectIdentifier a_oid)
public Persistable getEntryFromCache(ObjectIdentifier a_oid, Persistable a_target)
a_oid
- ObjectIdentifier that specifies the Persistablea_target
- Persistable to use for in-place refresh (optional)protected void addPOMOperationListener(POMOperationListener listener) throws PersistenceException
PersistenceException
protected void removePOMOperationListener(POMOperationListener listener) throws PersistenceException
PersistenceException
protected List getLocalPOMOperationListeners()
protected void addTransactionListener(TransactionListener listener) throws PersistenceException
PersistenceException
protected void removeTransactionListener(TransactionListener listener) throws PersistenceException
PersistenceException
protected void fireTransactionListener(boolean callCommit) throws PersistenceException
PersistenceException
private Savepoint getSavepoint(int a_level)
private Savepoint getSavepoint()
private void executeCommitTransaction(Savepoint a_savepoint) throws PersistenceException
PersistenceException
private void executeRollbackTransaction(Savepoint a_savepoint) throws PersistenceException
PersistenceException
private void executeTransactionOperation(boolean a_commit, Savepoint a_savepoint, String a_traceTimingName) throws PersistenceException
PersistenceException
protected void releaseSavepoint(Connection a_connection, Savepoint a_savepoint) throws SQLException
SQLException
private void validateStart() throws PersistenceException
PersistenceException
private void validateCommit(int aHandle) throws PersistenceException
PersistenceException
protected boolean isTransactionActive()
protected int getTransactionId()
protected int getTransactionLevel()
protected void setTransactionLevel(int level)
protected boolean getrollbackInProgress()
protected void setrollbackInProgress(boolean state)
protected void setTransactionIsolation(int a_mode) throws PersistenceException
PersistenceException
static void fireTransactionListener(List a_listeners, TransactionManager.FireTransactionListener a_fireListener) throws PersistenceException
PersistenceException
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |