org.openejb.core
Class TransactionManagerWrapper

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

public class TransactionManagerWrapper
extends java.lang.Object
implements javax.transaction.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(javax.transaction.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 java.lang.String getStatus(int status)
          Returns the readable name for the specified status.
 javax.transaction.Transaction getTransaction()
          Delegates the call to the Transaction Manager passed into the constructor.
 javax.transaction.TransactionManager getTxManager()
           
 void resume(javax.transaction.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.
 javax.transaction.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(javax.transaction.TransactionManager txMngr)
Constructor

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

getTxManager

public javax.transaction.TransactionManager getTxManager()

begin

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

Specified by:
begin in interface javax.transaction.TransactionManager
Throws:
javax.transaction.SystemException
javax.transaction.NotSupportedException

commit

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

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

getStatus

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

Specified by:
getStatus in interface javax.transaction.TransactionManager
Returns:
int
Throws:
javax.transaction.SystemException

getTransaction

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

Specified by:
getTransaction in interface javax.transaction.TransactionManager
Returns:
Transaction
Throws:
javax.transaction.SystemException

resume

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

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

suspend

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

Specified by:
suspend in interface javax.transaction.TransactionManager
Returns:
Transaction
Throws:
javax.transaction.SystemException

rollback

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

Specified by:
rollback in interface javax.transaction.TransactionManager
Throws:
javax.transaction.SystemException

setRollbackOnly

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

Specified by:
setRollbackOnly in interface javax.transaction.TransactionManager
Throws:
javax.transaction.SystemException

setTransactionTimeout

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

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

getStatus

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

Parameters:
status - The status
Returns:
The status


Copyright © 1999-2011 OpenEJB. All Rights Reserved.