User: azakkerman
  Date: 01/12/18 12:16:40

  Modified:    src/main/org/jboss/ejb/plugins TxInterceptorCMT.java
  Log:
  Fix small issues causing TyrexTM integration problems
  
  Revision  Changes    Path
  1.20      +25 -13    jboss/src/main/org/jboss/ejb/plugins/TxInterceptorCMT.java
  
  Index: TxInterceptorCMT.java
  ===================================================================
  RCS file: /cvsroot/jboss/jboss/src/main/org/jboss/ejb/plugins/TxInterceptorCMT.java,v
  retrieving revision 1.19
  retrieving revision 1.20
  diff -u -r1.19 -r1.20
  --- TxInterceptorCMT.java     2001/11/24 20:43:23     1.19
  +++ TxInterceptorCMT.java     2001/12/18 20:16:40     1.20
  @@ -30,7 +30,7 @@
    *  @author <a href="mailto:[EMAIL PROTECTED]";>Sebastien Alborini</a>
    *  @author <a href="mailto:[EMAIL PROTECTED]";>Anatoly Akkerman</a>
    *  @author <a href="mailto:[EMAIL PROTECTED]";>Ole Husgaard</a>
  - *  @version $Revision: 1.19 $
  + *  @version $Revision: 1.20 $
    */
   public class TxInterceptorCMT
       extends AbstractTxInterceptor
  @@ -118,16 +118,17 @@
           // New transaction is the new transaction this might start
           Transaction newTransaction = null;
   
  -        //DEBUG       Logger.debug("Current transaction in MI is 
"+mi.getTransaction());
  -        //DEBUG Logger.debug("Current method "+mi.getMethod());
  +        //DEBUG log.debug("Current transaction in MI is " + oldTransaction);
  +
           byte transType = getTransactionMethod(mi.getMethod(), remoteInvocation);
  -        // printMethod(mi.getMethod(), transType);
  +     //DEBUG printMethod(mi.getMethod(), transType);
   
           // Thread arriving must be clean (jboss doesn't set the thread
           // previously). However optimized calls come with associated
           // thread for example. We suspend the thread association here, and
           // resume in the finally block of the following try.
           Transaction threadTx = tm.suspend();
  +     //DEBUG log.debug("Thread came in with tx " + threadTx);
           try { // OSH FIXME: Indentation
   
           switch (transType) {
  @@ -142,6 +143,7 @@
   
                       // get the tx
                       newTransaction = tm.getTransaction();
  +                 //DEBUG log.debug("Starting new tx " + newTransaction);
   
                       // Let the method invocation know
                       mi.setTransaction(newTransaction);
  @@ -154,7 +156,7 @@
                   try {
                       return invokeNext(remoteInvocation, mi, newTransaction != null);
                   } finally {
  -//DEBUG                Logger.debug("TxInterceptorCMT: In finally");
  +                    //DEBUG                log.debug("TxInterceptorCMT: In 
finally");
   
                       // Only do something if we started the transaction
                       if (newTransaction != null) {
  @@ -166,23 +168,32 @@
                               // This will happen if
                               // a) everything goes well
                               // b) app. exception was thrown
  -//DEBUG                        Logger.debug("TxInterceptorCMT:before commit");
  +                            //DEBUG log.debug("TxInterceptorCMT:before commit of " 
+ newTransaction);
                               newTransaction.commit();
  -//DEBUG                        Logger.debug("TxInterceptorCMT:after commit");
  +                            //DEBUG log.debug("TxInterceptorCMT:after commit of " + 
newTransaction);
                           }
   
                           // reassociate the oldTransaction with the methodInvocation 
(even null)
                           mi.setTransaction(oldTransaction);
  -                    } else {
  -                        // Drop thread association
  -                        tm.suspend();
                       }
  +                    // Always drop thread association even if committing or
  +                    // rolling back the newTransaction because not all TMs
  +                    // will drop thread associations when commit() or rollback()
  +                    // are called through tx itself (see JTA spec that seems to
  +                    // indicate that thread assoc is required to be dropped only
  +                    // when commit() and rollback() are called through 
TransactionManager
  +                    // interface)
  +                    tm.suspend();
  +                    
                   }
   
               case MetaData.TX_SUPPORTS:
                   {
  -                    // Associate old transaction (may be null) with the thread
  -                    tm.resume(oldTransaction);
  +                    // Associate old transaction with the thread
  +                    // Some TMs cannot resume a null transaction and will throw
  +                    // an exception (e.g. Tyrex), so make sure it is not null
  +                    if (oldTransaction != null)
  +                        tm.resume(oldTransaction);
   
                       try {
                           return invokeNext(remoteInvocation, mi, false);
  @@ -221,6 +232,7 @@
   
                           // set the old transaction back on the method invocation
                           mi.setTransaction(oldTransaction);
  +                        tm.suspend();
                       }
                   }
               case MetaData.TX_MANDATORY:
  @@ -259,7 +271,7 @@
   
           BeanMetaData bmd = container.getBeanMetaData();
   
  -//DEBUG        Logger.debug("Found metadata for bean '"+bmd.getEjbName()+"'"+" 
method is "+m.getName());
  +//DEBUG        log.debug("Found metadata for bean '"+bmd.getEjbName()+"'"+" method 
is "+m.getName());
   
           byte result = bmd.getMethodTransactionType(m.getName(), 
m.getParameterTypes(), remoteInvocation);
   
  
  
  

_______________________________________________
Jboss-development mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-development

Reply via email to