tyrex.tm.impl
Class TransactionManagerImpl

java.lang.Object
  extended bytyrex.tm.impl.TransactionManagerImpl
All Implemented Interfaces:
javax.transaction.Status, javax.transaction.TransactionManager, TyrexTransactionManager

final class TransactionManagerImpl
extends java.lang.Object
implements javax.transaction.TransactionManager, javax.transaction.Status, TyrexTransactionManager

Implements a local transaction manager. The transaction manager allows the application server to manage transactions on the local thread through the TransactionManager interface.

Nested transactions are supported if the server configuration indicates so, but all nested transactions appear as flat transactions to the resources and are not registered with the transaction server.

Version:
$Revision: 1.19 $ $Date: 2001/10/05 22:15:34 $
Author:
Assaf Arkin
See Also:
Tyrex#recycleThread, TransactionDomain, TransactionImpl

Field Summary
 
Fields inherited from interface javax.transaction.Status
STATUS_ACTIVE, STATUS_COMMITTED, STATUS_COMMITTING, STATUS_MARKED_ROLLBACK, STATUS_NO_TRANSACTION, STATUS_PREPARED, STATUS_PREPARING, STATUS_ROLLEDBACK, STATUS_ROLLING_BACK, STATUS_UNKNOWN
 
Constructor Summary
(package private) TransactionManagerImpl(TransactionDomainImpl txDomain)
           
 
Method Summary
 void begin()
           
 void commit()
           
 void delistResource(javax.transaction.xa.XAResource xaResource, int flag)
          Called to delist a resource from the current thread.
 void dumpCurrentTransaction(java.io.PrintWriter writer)
          Convenience method.
 void dumpTransactionList(java.io.PrintWriter writer)
          Convenience method.
 void enlistResource(javax.transaction.xa.XAResource xaResource)
          Called to enlist a resource with the current thread.
 void enlistResource(javax.transaction.xa.XAResource xaResource, XAResourceCallback callback)
          Called to enlist a resource with the current thread.
 int getStatus()
           
 javax.transaction.Transaction getTransaction()
           
 javax.transaction.Transaction getTransaction(java.lang.String xid)
          Returns a transaction based on the transaction identifier.
 javax.transaction.Transaction getTransaction(java.lang.Thread thread)
          Returns the transaction currently associated with the given thread, or null if the thread is not associated with any transaction.
 javax.transaction.Transaction getTransaction(javax.transaction.xa.Xid xid)
          Returns a transaction based on the transaction identifier.
protected  void internalResume(TransactionImpl tx)
          Called to resume the current transaction, but does not attempt to associate the resources with this transaction.
 void resume(javax.transaction.Transaction tx)
           
 void rollback()
           
 void setRollbackOnly()
           
 void setTransactionTimeout(int seconds)
           
 javax.transaction.Transaction suspend()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TransactionManagerImpl

TransactionManagerImpl(TransactionDomainImpl txDomain)
Method Detail

begin

public void begin()
           throws javax.transaction.NotSupportedException,
                  javax.transaction.SystemException
Specified by:
begin in interface javax.transaction.TransactionManager
Throws:
javax.transaction.NotSupportedException
javax.transaction.SystemException

commit

public void commit()
            throws javax.transaction.RollbackException,
                   javax.transaction.HeuristicMixedException,
                   javax.transaction.HeuristicRollbackException,
                   java.lang.SecurityException,
                   java.lang.IllegalStateException,
                   javax.transaction.SystemException
Specified by:
commit in interface javax.transaction.TransactionManager
Throws:
javax.transaction.RollbackException
javax.transaction.HeuristicMixedException
javax.transaction.HeuristicRollbackException
java.lang.SecurityException
java.lang.IllegalStateException
javax.transaction.SystemException

rollback

public void rollback()
              throws java.lang.IllegalStateException,
                     java.lang.SecurityException,
                     javax.transaction.SystemException
Specified by:
rollback in interface javax.transaction.TransactionManager
Throws:
java.lang.IllegalStateException
java.lang.SecurityException
javax.transaction.SystemException

getStatus

public int getStatus()
Specified by:
getStatus in interface javax.transaction.TransactionManager

getTransaction

public javax.transaction.Transaction getTransaction()
Specified by:
getTransaction in interface javax.transaction.TransactionManager

resume

public void resume(javax.transaction.Transaction tx)
            throws javax.transaction.InvalidTransactionException,
                   java.lang.IllegalStateException,
                   javax.transaction.SystemException
Specified by:
resume in interface javax.transaction.TransactionManager
Throws:
javax.transaction.InvalidTransactionException
java.lang.IllegalStateException
javax.transaction.SystemException

suspend

public javax.transaction.Transaction suspend()
Specified by:
suspend in interface javax.transaction.TransactionManager

setRollbackOnly

public void setRollbackOnly()
                     throws java.lang.IllegalStateException,
                            javax.transaction.SystemException
Specified by:
setRollbackOnly in interface javax.transaction.TransactionManager
Throws:
java.lang.IllegalStateException
javax.transaction.SystemException

setTransactionTimeout

public void setTransactionTimeout(int seconds)
Specified by:
setTransactionTimeout in interface javax.transaction.TransactionManager

getTransaction

public javax.transaction.Transaction getTransaction(javax.transaction.xa.Xid xid)
Description copied from interface: TyrexTransactionManager
Returns a transaction based on the transaction identifier.

Specified by:
getTransaction in interface TyrexTransactionManager
Parameters:
xid - The transaction identifier
Returns:
The transaction, or null if no such transaction exists

getTransaction

public javax.transaction.Transaction getTransaction(java.lang.String xid)
Description copied from interface: TyrexTransactionManager
Returns a transaction based on the transaction identifier.

Specified by:
getTransaction in interface TyrexTransactionManager
Parameters:
xid - The transaction identifier
Returns:
The transaction, or null if no such transaction exists

dumpTransactionList

public void dumpTransactionList(java.io.PrintWriter writer)
Description copied from interface: TyrexTransactionManager
Convenience method. Dumps information about all active transactions created by this transaction manager.

Specified by:
dumpTransactionList in interface TyrexTransactionManager
Parameters:
writer - The writer to use

dumpCurrentTransaction

public void dumpCurrentTransaction(java.io.PrintWriter writer)
Description copied from interface: TyrexTransactionManager
Convenience method. Dumps information about the transaction associated with the current thread.

Specified by:
dumpCurrentTransaction in interface TyrexTransactionManager
Parameters:
writer - The writer to use

getTransaction

public javax.transaction.Transaction getTransaction(java.lang.Thread thread)
Returns the transaction currently associated with the given thread, or null if the thread is not associated with any transaction. This method is equivalent to calling TransactionManager.getTransaction() from within the thread.

Parameters:
thread - The thread to lookup
Returns:
The transaction currently associated with that thread

enlistResource

public void enlistResource(javax.transaction.xa.XAResource xaResource)
                    throws javax.transaction.SystemException
Description copied from interface: TyrexTransactionManager
Called to enlist a resource with the current thread. If this method is called within an active transaction, the connection will be enlisted in that transaction. The connection will be enlisted in any future transaction associated with the same thread context.

Specified by:
enlistResource in interface TyrexTransactionManager
Throws:
javax.transaction.SystemException - The resource cannot be enlisted with the current transaction

enlistResource

public void enlistResource(javax.transaction.xa.XAResource xaResource,
                           XAResourceCallback callback)
                    throws javax.transaction.SystemException
Description copied from interface: TyrexTransactionManager
Called to enlist a resource with the current thread. If this method is called within an active transaction, the connection will be enlisted in that transaction. The connection will be enlisted in any future transaction associated with the same thread context.

Specified by:
enlistResource in interface TyrexTransactionManager
Parameters:
callback - The callback (optional)
Throws:
javax.transaction.SystemException - The resource cannot be enlisted with the current transaction
See Also:
XAResourceCallback

delistResource

public void delistResource(javax.transaction.xa.XAResource xaResource,
                           int flag)
Description copied from interface: TyrexTransactionManager
Called to delist a resource from the current thread. If this method is called within an active transaction, the connection will be delisted using the success flag. The connection will not be enlisted in any future transaction associated with the same thread context.

Specified by:
delistResource in interface TyrexTransactionManager
Parameters:
flag - The delist flag

internalResume

protected void internalResume(TransactionImpl tx)
                       throws java.lang.IllegalStateException,
                              javax.transaction.SystemException
Called to resume the current transaction, but does not attempt to associate the resources with this transaction. This method is used during the synchronization.

Throws:
java.lang.IllegalStateException
javax.transaction.SystemException


Original code is Copyright (c) 1999-2001, Intalio, Inc. All Rights Reserved. Contributions by MetaBoss team are Copyright (c) 2003-2005, Softaris Pty. Ltd. All Rights Reserved.