[jboss-svn-commits] JBL Code SVN: r35003 - in labs/jbosstm/trunk: ArjunaJTS/jtax/classes/com/arjuna/ats/internal/jta/resources/jts and 2 other directories.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Sat Sep 4 14:19:51 EDT 2010


Author: mark.little at jboss.com
Date: 2010-09-04 14:19:51 -0400 (Sat, 04 Sep 2010)
New Revision: 35003

Modified:
   labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/coordinator/TwoPhaseCoordinator.java
   labs/jbosstm/trunk/ArjunaJTS/jtax/classes/com/arjuna/ats/internal/jta/resources/jts/CleanupSynchronization.java
   labs/jbosstm/trunk/ArjunaJTS/jtax/classes/com/arjuna/ats/internal/jta/transaction/jts/TransactionImple.java
   labs/jbosstm/trunk/ArjunaJTS/jts/classes/com/arjuna/ats/internal/jts/orbspecific/coordinator/ArjunaTransactionImple.java
Log:
https://jira.jboss.org/browse/JBTM-770

Modified: labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/coordinator/TwoPhaseCoordinator.java
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/coordinator/TwoPhaseCoordinator.java	2010-09-03 15:46:07 UTC (rev 35002)
+++ labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/coordinator/TwoPhaseCoordinator.java	2010-09-04 18:19:51 UTC (rev 35003)
@@ -213,109 +213,123 @@
 		super(u, at);
 	}
 
+	/**
+	 * Drive beforeCompletion participants.
+	 * 
+	 * @return true if successful, false otherwise.
+	 */
+	
 	protected boolean beforeCompletion ()
 	{
-		boolean problem = false;
+	    boolean problem = false;
 
-		synchronized (_syncLock)
-		{
-		    if (!_beforeCalled)
-		    {
-		        _beforeCalled = true;
+	    synchronized (_syncLock)
+	    {
+	        if (!_beforeCalled)
+	        {
+	            _beforeCalled = true;
 
-		        /*
-		         * If we have a synchronization list then we must be top-level.
-		         */
+	            /*
+	             * If we have a synchronization list then we must be top-level.
+	             */
 
-		        if (_synchs != null)
-		        {
-		            /*
-		             * We must always call afterCompletion() methods, so just catch (and
-		             * log) any exceptions/errors from beforeCompletion() methods.
-		             *
-		             * If one of the Syncs throws an error the Record wrapper returns false
-		             * and we will rollback. Hence we don't then bother to call beforeCompletion
-		             * on the remaining records (it's not done for rollabcks anyhow).
-		             *
-		             * Since Synchronizations may add register other Synchronizations, we can't simply
-		             * iterate the collection. Instead we work from an ordered copy, which we periodically
-		             * check for freshness. The addSynchronization method uses _currentRecord to disallow
-		             * adding records in the part of the array we have already traversed, thus all
-		             * Synchronization will be called and the (jta only) rules on ordering of interposed
-		             * Synchronization will be respected.
-		             */
+	            if (_synchs != null)
+	            {
+	                /*
+	                 * We must always call afterCompletion() methods, so just catch (and
+	                 * log) any exceptions/errors from beforeCompletion() methods.
+	                 *
+	                 * If one of the Syncs throws an error the Record wrapper returns false
+	                 * and we will rollback. Hence we don't then bother to call beforeCompletion
+	                 * on the remaining records (it's not done for rollabcks anyhow).
+	                 *
+	                 * Since Synchronizations may register other Synchronizations, we can't simply
+	                 * iterate the collection. Instead we work from an ordered copy, which we periodically
+	                 * check for freshness. The addSynchronization method uses _currentRecord to disallow
+	                 * adding records in the part of the array we have already traversed, thus all
+	                 * Synchronization will be called and the (jta only) rules on ordering of interposed
+	                 * Synchronization will be respected.
+	                 */
 
-		            int lastIndexProcessed = -1;
-		            SynchronizationRecord[] copiedSynchs;
-		            // need to guard against synchs being added while we are performing beforeCompletion processing
-		            synchronized (_synchs) {
-		                copiedSynchs = (SynchronizationRecord[])_synchs.toArray(new SynchronizationRecord[] {});
-		            }
-		            while( (lastIndexProcessed < _synchs.size()-1) && !problem) {
+	                int lastIndexProcessed = -1;
+	                SynchronizationRecord[] copiedSynchs;
+	                // need to guard against synchs being added while we are performing beforeCompletion processing
+	                synchronized (_synchs) {
+	                    copiedSynchs = (SynchronizationRecord[])_synchs.toArray(new SynchronizationRecord[] {});
+	                }
+	                while( (lastIndexProcessed < _synchs.size()-1) && !problem) {
 
-		                synchronized (_synchs) {
-		                    // if new Synchronization have been registered, refresh our copy of the collection:
-		                    if(copiedSynchs.length != _synchs.size()) {
-		                        copiedSynchs = (SynchronizationRecord[])_synchs.toArray(new SynchronizationRecord[] {});
-		                    }
-		                }
+	                    synchronized (_synchs) {
+	                        // if new Synchronization have been registered, refresh our copy of the collection:
+	                        if(copiedSynchs.length != _synchs.size()) {
+	                            copiedSynchs = (SynchronizationRecord[])_synchs.toArray(new SynchronizationRecord[] {});
+	                        }
+	                    }
 
-		                lastIndexProcessed = lastIndexProcessed+1;
-		                _currentRecord = copiedSynchs[lastIndexProcessed];
+	                    lastIndexProcessed = lastIndexProcessed+1;
+	                    _currentRecord = copiedSynchs[lastIndexProcessed];
 
-		                try
-		                {
-		                    problem = !_currentRecord.beforeCompletion();
+	                    try
+	                    {
+	                        problem = !_currentRecord.beforeCompletion();
 
-		                    // if something goes wrong, we can't just throw the exception, we need to continue to
-		                    // complete the transaction. However, the exception may have interesting information that
-		                    // we want later, so we keep a reference to it as well as logging it.
+	                        // if something goes wrong, we can't just throw the exception, we need to continue to
+	                        // complete the transaction. However, the exception may have interesting information that
+	                        // we want later, so we keep a reference to it as well as logging it.
 
-		                }
-		                catch (Exception ex) {
-                            tsLogger.i18NLogger.warn_coordinator_TwoPhaseCoordinator_2(_currentRecord.toString(), ex);
-                            if (_deferredThrowable == null) {
-                                _deferredThrowable = ex;
-                            }
-                            problem = true;
-                        }
-		                catch (Error er) {
-                            tsLogger.i18NLogger.warn_coordinator_TwoPhaseCoordinator_2(_currentRecord.toString(), er);
-                            if (_deferredThrowable == null) {
-                                _deferredThrowable = er;
-                            }
-                            problem = true;
-                        }
-		            }
+	                    }
+	                    catch (Exception ex) {
+	                        tsLogger.i18NLogger.warn_coordinator_TwoPhaseCoordinator_2(_currentRecord.toString(), ex);
+	                        if (_deferredThrowable == null) {
+	                            _deferredThrowable = ex;
+	                        }
+	                        problem = true;
+	                    }
+	                    catch (Error er) {
+	                        tsLogger.i18NLogger.warn_coordinator_TwoPhaseCoordinator_2(_currentRecord.toString(), er);
+	                        if (_deferredThrowable == null) {
+	                            _deferredThrowable = er;
+	                        }
+	                        problem = true;
+	                    }
+	                }
 
-		            if (problem)
-		            {
-		                if (!preventCommit()) {
-                            /*
-                                    * This should not happen. If it does, continue with commit
-                                    * to tidy-up.
-                                    */
+	                if (problem)
+	                {
+	                    if (!preventCommit()) {
+	                        /*
+	                         * This should not happen. If it does, continue with commit
+	                         * to tidy-up.
+	                         */
 
-                            tsLogger.i18NLogger.warn_coordinator_TwoPhaseCoordinator_1();
-                        }
-		            }
-		        }
-		    }
-		    else
-		    {
-		        /*
-		         * beforeCompletions already called. Assume everything is alright
-		         * to proceed to commit. The TM instance will flag the outcome. If
-		         * it's rolling back, then we'll get an exception. If it's committing
-		         * then we'll be blocked until the commit (assuming we're still the
-		         * slower thread).
-		         */
-		    }
-		}
+	                        tsLogger.i18NLogger.warn_coordinator_TwoPhaseCoordinator_1();
+	                    }
+	                }
+	            }
+	        }
+	        else
+	        {
+	            /*
+	             * beforeCompletions already called. Assume everything is alright
+	             * to proceed to commit. The TM instance will flag the outcome. If
+	             * it's rolling back, then we'll get an exception. If it's committing
+	             * then we'll be blocked until the commit (assuming we're still the
+	             * slower thread).
+	             */
+	        }
+	    }
 
-		return !problem;
+	    return !problem;
 	}
 
+	/**
+	 * Drive afterCompletion participants.
+	 * 
+	 * @param myStatus the outcome of the transaction (ActionStatus.COMMITTED or ActionStatus.ABORTED).
+	 * 
+	 * @return true if successful, false otherwise.
+	 */
+	
 	protected boolean afterCompletion (int myStatus)
 	{
 		if (myStatus == ActionStatus.RUNNING) {

Modified: labs/jbosstm/trunk/ArjunaJTS/jtax/classes/com/arjuna/ats/internal/jta/resources/jts/CleanupSynchronization.java
===================================================================
--- labs/jbosstm/trunk/ArjunaJTS/jtax/classes/com/arjuna/ats/internal/jta/resources/jts/CleanupSynchronization.java	2010-09-03 15:46:07 UTC (rev 35002)
+++ labs/jbosstm/trunk/ArjunaJTS/jtax/classes/com/arjuna/ats/internal/jta/resources/jts/CleanupSynchronization.java	2010-09-04 18:19:51 UTC (rev 35003)
@@ -33,10 +33,6 @@
 
 import com.arjuna.ats.internal.jta.transaction.jts.TransactionImple;
 
-import com.arjuna.ats.jta.utils.JTAHelper;
-
-import javax.transaction.xa.*;
-
 /**
  * This synchronization is responsible for removing the JTA transaction
  * from the internal table. We don't need one for the purely local JTA

Modified: labs/jbosstm/trunk/ArjunaJTS/jtax/classes/com/arjuna/ats/internal/jta/transaction/jts/TransactionImple.java
===================================================================
--- labs/jbosstm/trunk/ArjunaJTS/jtax/classes/com/arjuna/ats/internal/jta/transaction/jts/TransactionImple.java	2010-09-03 15:46:07 UTC (rev 35002)
+++ labs/jbosstm/trunk/ArjunaJTS/jtax/classes/com/arjuna/ats/internal/jta/transaction/jts/TransactionImple.java	2010-09-04 18:19:51 UTC (rev 35003)
@@ -59,6 +59,7 @@
 
 import com.arjuna.ats.internal.jts.OTSImpleManager;
 import com.arjuna.ats.internal.jts.ControlWrapper;
+import com.arjuna.ats.internal.jts.orbspecific.coordinator.ArjunaTransactionImple;
 
 import javax.transaction.xa.*;
 

Modified: labs/jbosstm/trunk/ArjunaJTS/jts/classes/com/arjuna/ats/internal/jts/orbspecific/coordinator/ArjunaTransactionImple.java
===================================================================
--- labs/jbosstm/trunk/ArjunaJTS/jts/classes/com/arjuna/ats/internal/jts/orbspecific/coordinator/ArjunaTransactionImple.java	2010-09-03 15:46:07 UTC (rev 35002)
+++ labs/jbosstm/trunk/ArjunaJTS/jts/classes/com/arjuna/ats/internal/jts/orbspecific/coordinator/ArjunaTransactionImple.java	2010-09-04 18:19:51 UTC (rev 35003)
@@ -1373,272 +1373,286 @@
 
 	protected void doBeforeCompletion () throws SystemException
 	{
-		if (jtsLogger.logger.isTraceEnabled()) {
-            jtsLogger.logger.trace("ArjunaTransactionImple::doBeforeCompletion for "
-                    + get_uid());
-        }
+	    if (jtsLogger.logger.isTraceEnabled()) {
+	        jtsLogger.logger.trace("ArjunaTransactionImple::doBeforeCompletion for "
+	                + get_uid());
+	    }
 
-		boolean problem = false;
-		SystemException exp = null;
+	    boolean problem = false;
+	    SystemException exp = null;
 
-		/*
-		 * If we have a synchronization list then we must be top-level.
-		 */
-        if (_synchs != null)
-		{
-			boolean doSuspend = false;
-			ControlWrapper cw = null;
+	    /*
+	     * If we have a synchronization list then we must be top-level.
+	     */
+	    if (_synchs != null)
+	    {
+	        boolean doSuspend = false;
+	        ControlWrapper cw = null;
 
-			try
-			{
-				/*
-				 * Make sure that this transaction is active on the thread
-				 * before we invoke any Synchronizations. They are
-				 * TransactionalObjects and must have the context flowed to
-				 * them.
-				 */
+	        try
+	        {
+	            /*
+	             * Make sure that this transaction is active on the thread
+	             * before we invoke any Synchronizations. They are
+	             * TransactionalObjects and must have the context flowed to
+	             * them.
+	             */
 
-				try
-				{
-					//		    cw = OTSImpleManager.systemCurrent().getControlWrapper();
+	            try
+	            {
+	                //		    cw = OTSImpleManager.systemCurrent().getControlWrapper();
 
-					cw = OTSImpleManager.current().getControlWrapper();
+	                cw = OTSImpleManager.current().getControlWrapper();
 
-					/*
-					 * If there's no transaction incoming, then use the one that
-					 * we got at creation time.
-					 */
+	                /*
+	                 * If there's no transaction incoming, then use the one that
+	                 * we got at creation time.
+	                 */
 
-					if ((cw == null) || (!controlHandle.equals(cw.getImple())))
-					{
-						//			OTSImpleManager.systemCurrent().resumeImple(controlHandle);
+	                if ((cw == null) || (!controlHandle.equals(cw.getImple())))
+	                {
+	                    //			OTSImpleManager.systemCurrent().resumeImple(controlHandle);
 
-						OTSImpleManager.current().resumeImple(controlHandle);
+	                    OTSImpleManager.current().resumeImple(controlHandle);
 
-						doSuspend = true;
-					}
-				}
-				catch (Exception ex)
-				{
-					/*
-					 * It should be OK to continue with the invocations even if
-					 * we couldn't resume, because a Synchronization is only
-					 * supposed to be associated with a single transaction. So,
-					 * it should be able to infer the transaction.
-					 */
-				}
+	                    doSuspend = true;
+	                }
+	            }
+	            catch (Exception ex)
+	            {
+	                /*
+	                 * It should be OK to continue with the invocations even if
+	                 * we couldn't resume, because a Synchronization is only
+	                 * supposed to be associated with a single transaction. So,
+	                 * it should be able to infer the transaction.
+	                 */
+	            }
 
-               /*
-                * Since Synchronizations may add register other Synchronizations, we can't simply
-                * iterate the collection. Instead we work from an ordered copy, which we periodically
-                * check for freshness. The addSynchronization method uses _currentRecord to disallow
-                * adding records in the part of the array we have already traversed, thus all
-                * Synchronization will be called and the (jta only) rules on ordering of interposed
-                * Synchronization will be respected.
-                */
-               int lastIndexProcessed = -1;
-               SynchronizationRecord[] copiedSynchs = (SynchronizationRecord[])_synchs.toArray(new SynchronizationRecord[] {});
+	            /*
+	             * Since Synchronizations may add register other Synchronizations, we can't simply
+	             * iterate the collection. Instead we work from an ordered copy, which we periodically
+	             * check for freshness. The addSynchronization method uses _currentRecord to disallow
+	             * adding records in the part of the array we have already traversed, thus all
+	             * Synchronization will be called and the (jta only) rules on ordering of interposed
+	             * Synchronization will be respected.
+	             */
+	            int lastIndexProcessed = -1;
+	            SynchronizationRecord[] copiedSynchs = (SynchronizationRecord[])_synchs.toArray(new SynchronizationRecord[] {});
 
-               while( (lastIndexProcessed < _synchs.size()-1) && !problem) {
+	            while( (lastIndexProcessed < _synchs.size()-1) && !problem) {
 
-                   // if new Synchronization have been registered, refresh our copy of the collection:
-                   if(copiedSynchs.length != _synchs.size()) {
-                       copiedSynchs = (SynchronizationRecord[])_synchs.toArray(new SynchronizationRecord[] {});
-                   }
+	                // if new Synchronization have been registered, refresh our copy of the collection:
+	                if(copiedSynchs.length != _synchs.size()) {
+	                    copiedSynchs = (SynchronizationRecord[])_synchs.toArray(new SynchronizationRecord[] {});
+	                }
 
-                   lastIndexProcessed = lastIndexProcessed+1;
-                   _currentRecord = copiedSynchs[lastIndexProcessed];
+	                lastIndexProcessed = lastIndexProcessed+1;
+	                _currentRecord = copiedSynchs[lastIndexProcessed];
 
-					Synchronization c = _currentRecord.contents();
-					c.before_completion();
-				}
-			}
-			catch (SystemException e) {
-                jtsLogger.i18NLogger.warn_orbspecific_coordinator_generror("ArjunaTransactionImple.doBeforeCompletion", e);
+	                Synchronization c = _currentRecord.contents();
+	                c.before_completion();
+	            }
+	        }
+	        catch (SystemException e) {
+	            jtsLogger.i18NLogger.warn_orbspecific_coordinator_generror("ArjunaTransactionImple.doBeforeCompletion", e);
 
-                if (!problem) {
-                    exp = e;
+	            if (!problem) {
+	                exp = e;
 
-                    problem = true;
+	                problem = true;
 
-                    /*
-                          * Mark as rollback_only, so when we try to commit it will
-                          * fail.
-                          */
+	                /*
+	                 * Mark as rollback_only, so when we try to commit it will
+	                 * fail.
+	                 */
 
-                    try {
-                        rollback_only();
-                    }
-                    catch (Inactive ex) {
-                        /*
-                               * This should not happen. If it does, continue with
-                               * commit to tidy-up.
-                               */
+	                try {
+	                    rollback_only();
+	                }
+	                catch (Inactive ex) {
+	                    /*
+	                     * This should not happen. If it does, continue with
+	                     * commit to tidy-up.
+	                     */
 
-                        jtsLogger.i18NLogger.warn_orbspecific_coordinator_rbofail(
-                                "ArjunaTransactionImple.doBeforeCompletion", get_uid(), ex);
-                    }
-                }
-            }
-			finally
-			{
-				if (doSuspend)
-				{
-					try
-					{
-						//			OTSImpleManager.systemCurrent().resumeWrapper(cw);
+	                    jtsLogger.i18NLogger.warn_orbspecific_coordinator_rbofail(
+	                            "ArjunaTransactionImple.doBeforeCompletion", get_uid(), ex);
+	                }
+	            }
+	        }
+	        finally
+	        {
+	            if (doSuspend)
+	            {
+	                try
+	                {
+	                    //			OTSImpleManager.systemCurrent().resumeWrapper(cw);
 
-						if (cw != null)
-							OTSImpleManager.current().resumeWrapper(cw);
-						else
-							OTSImpleManager.current().suspend();
-					}
-					catch (Exception ex)
-					{
-					}
+	                    if (cw != null)
+	                        OTSImpleManager.current().resumeWrapper(cw);
+	                    else
+	                        OTSImpleManager.current().suspend();
+	                }
+	                catch (Exception ex)
+	                {
+	                }
 
-					//		    OTSImpleManager.systemCurrent().suspend();
-				}
-			}
-		}
+	                //		    OTSImpleManager.systemCurrent().suspend();
+	            }
+	        }
+	    }
+	    
+	    /*
+	     * If there's no problem so far then call beforeCompletion on the underlying TwoPhaseCoordinator.
+	     */
 
-		if (problem)
-		{
-			if (exp != null)
-				throw exp;
-			else
-				throw new UNKNOWN(ExceptionCodes.SYNCHRONIZATION_EXCEPTION,
-						CompletionStatus.COMPLETED_NO);
-		}
+	    if (!problem)
+	        problem = !super.beforeCompletion();
+	    
+	    if (problem)
+	    {
+	        if (exp != null)
+	            throw exp;
+	        else
+	            throw new UNKNOWN(ExceptionCodes.SYNCHRONIZATION_EXCEPTION,
+	                    CompletionStatus.COMPLETED_NO);
+	    }
 	}
 
 	protected void doAfterCompletion (org.omg.CosTransactions.Status myStatus)
 			throws SystemException
 	{
-		if (jtsLogger.logger.isTraceEnabled()) {
-            jtsLogger.logger.trace("ArjunaTransactionImple::doAfterCompletion for "
-                    + get_uid());
-        }
+	    if (jtsLogger.logger.isTraceEnabled()) {
+	        jtsLogger.logger.trace("ArjunaTransactionImple::doAfterCompletion for "
+	                + get_uid());
+	    }
 
-		if (myStatus == Status.StatusActive) {
-            jtsLogger.i18NLogger.warn_orbspecific_coordinator_txrun("ArjunaTransactionImple.doAfterCompletion");
+	    if (myStatus == Status.StatusActive) {
+	        jtsLogger.i18NLogger.warn_orbspecific_coordinator_txrun("ArjunaTransactionImple.doAfterCompletion");
 
-            return;
-        }
+	        return;
+	    }
 
-		boolean problem = false;
-		SystemException exp = null;
+	    boolean problem = false;
+	    SystemException exp = null;
 
-		if (_synchs != null)
-		{
-			ControlWrapper cw = null;
-			boolean doSuspend = false;
+	    if (_synchs != null)
+	    {
+	        ControlWrapper cw = null;
+	        boolean doSuspend = false;
 
-			try
-			{
-				//		cw = OTSImpleManager.systemCurrent().getControlWrapper();
+	        try
+	        {
+	            //		cw = OTSImpleManager.systemCurrent().getControlWrapper();
 
-				cw = OTSImpleManager.current().getControlWrapper();
+	            cw = OTSImpleManager.current().getControlWrapper();
 
-				/*
-				 * If there isn't a transaction context shipped, then use the
-				 * one we had during creation.
-				 */
+	            /*
+	             * If there isn't a transaction context shipped, then use the
+	             * one we had during creation.
+	             */
 
-				if ((cw == null) || (!controlHandle.equals(cw.getImple())))
-				{
-					//		    OTSImpleManager.systemCurrent().resumeImple(controlHandle);
+	            if ((cw == null) || (!controlHandle.equals(cw.getImple())))
+	            {
+	                //		    OTSImpleManager.systemCurrent().resumeImple(controlHandle);
 
-					OTSImpleManager.current().resumeImple(controlHandle);
+	                OTSImpleManager.current().resumeImple(controlHandle);
 
-					doSuspend = true;
-				}
-			}
-			catch (Exception ex)
-			{
-				/*
-				 * It should still be OK to make the call without a context
-				 * because a Synchronization can only be associated with a
-				 * single transaction.
-				 */
+	                doSuspend = true;
+	            }
+	        }
+	        catch (Exception ex)
+	        {
+	            /*
+	             * It should still be OK to make the call without a context
+	             * because a Synchronization can only be associated with a
+	             * single transaction.
+	             */
 
-				problem = true;
-			}
+	            problem = true;
+	        }
 
-			/*
-			 * Regardless of failures, we must tell all synchronizations what
-			 * happened.
-			 */
+	        /*
+	         * Regardless of failures, we must tell all synchronizations what
+	         * happened.
+	         */
 
-			// afterCompletions should run in reverse order compared to beforeCompletions
-			Stack stack = new Stack();
-			Iterator iterator = _synchs.iterator();
-			while(iterator.hasNext()) {
-				stack.push(iterator.next());
-			}
+	        // afterCompletions should run in reverse order compared to beforeCompletions
+	        Stack stack = new Stack();
+	        Iterator iterator = _synchs.iterator();
+	        while(iterator.hasNext()) {
+	            stack.push(iterator.next());
+	        }
 
-			iterator = stack.iterator();
+	        iterator = stack.iterator();
 
-			/*
-			 * Regardless of failures, we must tell all synchronizations what
-			 * happened.
-			 */
-			while(!stack.isEmpty())
-			{
-				SynchronizationRecord value = (SynchronizationRecord)stack.pop();
-				Synchronization c = value.contents();
+	        /*
+	         * Regardless of failures, we must tell all synchronizations what
+	         * happened.
+	         */
+	        while(!stack.isEmpty())
+	        {
+	            SynchronizationRecord value = (SynchronizationRecord)stack.pop();
+	            Synchronization c = value.contents();
 
-				try
-				{
-					c.after_completion(myStatus);
-				}
-				catch (SystemException e)
-				{
-					if (jtsLogger.logger.isTraceEnabled()) {
-                        jtsLogger.logger.trace("ArjunaTransactionImple.doAfterCompletion - caught exception "
-                                + e);
-                    }
+	            try
+	            {
+	                c.after_completion(myStatus);
+	            }
+	            catch (SystemException e)
+	            {
+	                if (jtsLogger.logger.isTraceEnabled()) {
+	                    jtsLogger.logger.trace("ArjunaTransactionImple.doAfterCompletion - caught exception "
+	                            + e);
+	                }
 
-					problem = true;
+	                problem = true;
 
-					/*
-					 * Remember the first exception we get, because it may well
-					 * be the only one. In which case we can return it, rather
-					 * than UNKNOWN.
-					 */
+	                /*
+	                 * Remember the first exception we get, because it may well
+	                 * be the only one. In which case we can return it, rather
+	                 * than UNKNOWN.
+	                 */
 
-					if (exp == null)
-						exp = e;
-				}
-			}
+	                if (exp == null)
+	                    exp = e;
+	            }
+	        }
 
-			if (doSuspend)
-			{
-				try
-				{
-					//		    OTSImpleManager.systemCurrent().resumeWrapper(cw);
+	        if (doSuspend)
+	        {
+	            try
+	            {
+	                //		    OTSImpleManager.systemCurrent().resumeWrapper(cw);
 
-					if (cw != null)
-						OTSImpleManager.current().resumeWrapper(cw);
-					else
-						OTSImpleManager.current().suspend();
-				}
-				catch (Exception ex)
-				{
-				}
-			}
+	                if (cw != null)
+	                    OTSImpleManager.current().resumeWrapper(cw);
+	                else
+	                    OTSImpleManager.current().suspend();
+	            }
+	            catch (Exception ex)
+	            {
+	            }
+	        }
 
-			_synchs = null;
-		}
+	        _synchs = null;
+	    }
 
-		if (problem)
-		{
-			if (exp != null)
-				throw exp;
-			else
-				throw new UNKNOWN(ExceptionCodes.SYNCHRONIZATION_EXCEPTION,
-						CompletionStatus.COMPLETED_NO);
-		}
+	    /*
+             * If there's no problem so far then call afterCompletion on the underlying TwoPhaseCoordinator.
+             */
+
+            if (!problem)
+                problem = !super.afterCompletion(myStatus == Status.StatusCommitted ? ActionStatus.COMMITTED : ActionStatus.ABORTED);
+            
+	    if (problem)
+	    {
+	        if (exp != null)
+	            throw exp;
+	        else
+	            throw new UNKNOWN(ExceptionCodes.SYNCHRONIZATION_EXCEPTION,
+	                    CompletionStatus.COMPLETED_NO);
+	    }
 	}
 
 	/**



More information about the jboss-svn-commits mailing list