org.openejb.core
Class TransactionManagerWrapper

java.lang.Object
  extended by org.openejb.core.TransactionManagerWrapper
All Implemented Interfaces:
TransactionManager

public class TransactionManagerWrapper
extends Object
implements TransactionManager

This class intercepts requests to the TransactonManager so that it can provide wrappers for javax.transaction.Transaction objects. The Transaction wrappers allow Synchronization objects can be more finely managed. This allows, for example, enterprise beans to have their synchronization callback methods executed before synchronization objects registered by the Persistence Manager instances or Connectors.

Synchronized objects can be registered in groups organized by priority. The Synchronization group with the highest priority, priority = 1, is handled first, so that all of 1st (priority=1) synchronization group beforeCompletion() and afterCompletion( ) methods are executed first. The synchronization group with the second highest priority (priority = 2) is handled second and so on.

Their are 3 priorities (1, 2, and 3). Synchronization objects may be added with any one of these priorities. If a Synchronization object is added with a priority higher then 3, its added to the third priority group. If a Synchronization object is added with a priority lower then 1, its added to the first priority group.

Within a synchronization group, Synchronization objects are handled in the order they were registered. The first Synchronization object added to the group is handled first.

All the beforeCompletion() methods on all the Synchronization objects will be executed before any of the afterCompletion() methods are executed. Both are executed according to priority and order registered.


Field Summary
protected static org.apache.log4j.Category logger
           
 
Constructor Summary
TransactionManagerWrapper(TransactionManager txMngr)
          Constructor
 
Method Summary
 void begin()
          Delegates the call to the Transaction Manager passed into the constructor.
 void commit()
          Delegates the call to the Transaction Manager passed into the constructor.
 int getStatus()
          Delegates the call to the Transaction Manager passed into the constructor.
static String getStatus(int status)
          Returns the readable name for the specified status.
 Transaction getTransaction()
          Delegates the call to the Transaction Manager passed into the constructor.
 TransactionManager getTxManager()
           
 void resume(Transaction tx)
          Delegates the call to the Transaction Manager passed into the constructor.
 void rollback()
          Delegates the call to the Transaction Manager passed into the constructor.
 void setRollbackOnly()
          Delegates the call to the Transaction Manager passed into the constructor.
 void setTransactionTimeout(int x)
          Delegates the call to the Transaction Manager passed into the constructor.
 Transaction suspend()
          Delegates the call to the Transaction Manager passed into the constructor.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

protected static final org.apache.log4j.Category logger
Constructor Detail

TransactionManagerWrapper

public TransactionManagerWrapper(TransactionManager txMngr)
Constructor

Parameters:
txMngr - The Transaction Manager plugged into OpenEJB
Method Detail

getTxManager

public TransactionManager getTxManager()

begin

public void begin()
           throws SystemException,
                  NotSupportedException
Delegates the call to the Transaction Manager passed into the constructor.

Specified by:
begin in interface TransactionManager
Throws:
SystemException
NotSupportedException

commit

public void commit()
            throws SystemException,
                   RollbackException,
                   HeuristicRollbackException,
                   HeuristicMixedException
Delegates the call to the Transaction Manager passed into the constructor.

Specified by:
commit in interface TransactionManager
Throws:
SystemException
RollbackException
HeuristicRollbackException
HeuristicMixedException

getStatus

public int getStatus()
              throws SystemException
Delegates the call to the Transaction Manager passed into the constructor.

Specified by:
getStatus in interface TransactionManager
Returns:
int
Throws:
SystemException

getTransaction

public Transaction getTransaction()
                           throws SystemException
Delegates the call to the Transaction Manager passed into the constructor.

Specified by:
getTransaction in interface TransactionManager
Returns:
Transaction
Throws:
SystemException

resume

public void resume(Transaction tx)
            throws SystemException,
                   InvalidTransactionException
Delegates the call to the Transaction Manager passed into the constructor.

Specified by:
resume in interface TransactionManager
Parameters:
tx -
Throws:
SystemException
InvalidTransactionException

suspend

public Transaction suspend()
                    throws SystemException
Delegates the call to the Transaction Manager passed into the constructor.

Specified by:
suspend in interface TransactionManager
Returns:
Transaction
Throws:
SystemException

rollback

public void rollback()
              throws SystemException
Delegates the call to the Transaction Manager passed into the constructor.

Specified by:
rollback in interface TransactionManager
Throws:
SystemException

setRollbackOnly

public void setRollbackOnly()
                     throws SystemException
Delegates the call to the Transaction Manager passed into the constructor.

Specified by:
setRollbackOnly in interface TransactionManager
Throws:
SystemException

setTransactionTimeout

public void setTransactionTimeout(int x)
                           throws SystemException
Delegates the call to the Transaction Manager passed into the constructor.

Specified by:
setTransactionTimeout in interface TransactionManager
Parameters:
x -
Throws:
SystemException

getStatus

public static String getStatus(int status)
Returns the readable name for the specified status.

Parameters:
status - The status
Returns:
The status


Copyright © 1999-2008 OpenEJB. All Rights Reserved.