[jboss-svn-commits] JBL Code SVN: r23896 - in labs/jbosstm/trunk/XTS: WS-T/dev/src10/com/arjuna/wst and 16 other directories.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Mon Nov 17 13:35:05 EST 2008


Author: adinn
Date: 2008-11-17 13:35:05 -0500 (Mon, 17 Nov 2008)
New Revision: 23896

Removed:
   labs/jbosstm/trunk/XTS/WS-T/dev/src10/com/arjuna/wst/RecoverableBusinessAgreementWithCoordinatorCompletionParticipant.java
   labs/jbosstm/trunk/XTS/WS-T/dev/src10/com/arjuna/wst/RecoverableBusinessAgreementWithParticipantCompletionParticipant.java
   labs/jbosstm/trunk/XTS/WS-T/dev/src11/com/arjuna/wst11/RecoverableBusinessAgreementWithCoordinatorCompletionParticipant.java
   labs/jbosstm/trunk/XTS/WS-T/dev/src11/com/arjuna/wst11/RecoverableBusinessAgreementWithParticipantCompletionParticipant.java
   labs/jbosstm/trunk/XTS/WSCF/classes/com/arjuna/mw/wscf/model/sagas/participants/RecoverableParticipant.java
   labs/jbosstm/trunk/XTS/WSCF/classes/com/arjuna/mw/wscf/model/sagas/participants/RecoverableParticipantWithComplete.java
Modified:
   labs/jbosstm/trunk/XTS/WS-T/dev/src10/com/arjuna/webservices/wsba/processors/CoordinatorCompletionCoordinatorProcessor.java
   labs/jbosstm/trunk/XTS/WS-T/dev/src10/com/arjuna/webservices/wsba/processors/ParticipantCompletionCoordinatorProcessor.java
   labs/jbosstm/trunk/XTS/WS-T/dev/src10/com/arjuna/wst/messaging/CoordinatorCompletionCoordinatorProcessorImpl.java
   labs/jbosstm/trunk/XTS/WS-T/dev/src10/com/arjuna/wst/messaging/ParticipantCompletionCoordinatorProcessorImpl.java
   labs/jbosstm/trunk/XTS/WS-T/dev/src10/com/arjuna/wst/messaging/engines/CoordinatorCompletionCoordinatorEngine.java
   labs/jbosstm/trunk/XTS/WS-T/dev/src10/com/arjuna/wst/messaging/engines/ParticipantCompletionCoordinatorEngine.java
   labs/jbosstm/trunk/XTS/WS-T/dev/src10/com/arjuna/wst/stub/BusinessAgreementWithCoordinatorCompletionStub.java
   labs/jbosstm/trunk/XTS/WS-T/dev/src10/com/arjuna/wst/stub/BusinessAgreementWithParticipantCompletionStub.java
   labs/jbosstm/trunk/XTS/WS-T/dev/src10/com/arjuna/wst/stub/LocalCoordinatorCompletionParticipantStub.java
   labs/jbosstm/trunk/XTS/WS-T/dev/src10/com/arjuna/wst/stub/LocalParticipantCompletionParticipantStub.java
   labs/jbosstm/trunk/XTS/WS-T/dev/src11/com/arjuna/webservices11/wsba/processors/CoordinatorCompletionCoordinatorProcessor.java
   labs/jbosstm/trunk/XTS/WS-T/dev/src11/com/arjuna/webservices11/wsba/processors/ParticipantCompletionCoordinatorProcessor.java
   labs/jbosstm/trunk/XTS/WS-T/dev/src11/com/arjuna/wst11/messaging/CoordinatorCompletionCoordinatorProcessorImpl.java
   labs/jbosstm/trunk/XTS/WS-T/dev/src11/com/arjuna/wst11/messaging/ParticipantCompletionCoordinatorProcessorImpl.java
   labs/jbosstm/trunk/XTS/WS-T/dev/src11/com/arjuna/wst11/messaging/engines/CoordinatorCompletionCoordinatorEngine.java
   labs/jbosstm/trunk/XTS/WS-T/dev/src11/com/arjuna/wst11/messaging/engines/ParticipantCompletionCoordinatorEngine.java
   labs/jbosstm/trunk/XTS/WS-T/dev/src11/com/arjuna/wst11/stub/BusinessAgreementWithCoordinatorCompletionStub.java
   labs/jbosstm/trunk/XTS/WS-T/dev/src11/com/arjuna/wst11/stub/BusinessAgreementWithParticipantCompletionStub.java
   labs/jbosstm/trunk/XTS/WS-T/tests/src/com/arjuna/wst/tests/junit/TestCoordinatorCompletionCoordinatorProcessor.java
   labs/jbosstm/trunk/XTS/WS-T/tests/src/com/arjuna/wst/tests/junit/TestParticipantCompletionCoordinatorProcessor.java
   labs/jbosstm/trunk/XTS/WS-T/tests/src/com/arjuna/wst11/tests/junit/TestCoordinatorCompletionCoordinatorProcessor.java
   labs/jbosstm/trunk/XTS/WS-T/tests/src/com/arjuna/wst11/tests/junit/TestParticipantCompletionCoordinatorProcessor.java
   labs/jbosstm/trunk/XTS/WSCF/classes/com/arjuna/mw/wscf/model/sagas/api/CoordinatorManager.java
   labs/jbosstm/trunk/XTS/WSCF/classes/com/arjuna/mwlabs/wscf/model/sagas/arjunacore/ACCoordinator.java
   labs/jbosstm/trunk/XTS/WSCF/classes/com/arjuna/mwlabs/wscf/model/sagas/arjunacore/CoordinatorControl.java
   labs/jbosstm/trunk/XTS/WSCF/classes/com/arjuna/mwlabs/wscf/model/sagas/arjunacore/CoordinatorServiceImple.java
   labs/jbosstm/trunk/XTS/WSCF/classes/com/arjuna/mwlabs/wscf/model/sagas/arjunacore/ParticipantRecord.java
   labs/jbosstm/trunk/XTS/WSTX/classes10/com/arjuna/mwlabs/wst/ba/participants/BusinessAgreementWithCoordinatorCompletionImple.java
   labs/jbosstm/trunk/XTS/WSTX/classes10/com/arjuna/mwlabs/wst/ba/participants/BusinessAgreementWithParticipantCompletionImple.java
   labs/jbosstm/trunk/XTS/WSTX/classes11/com/arjuna/mwlabs/wst11/ba/participants/BusinessAgreementWithCoordinatorCompletionImple.java
   labs/jbosstm/trunk/XTS/WSTX/classes11/com/arjuna/mwlabs/wst11/ba/participants/BusinessAgreementWithParticipantCompletionImple.java
   labs/jbosstm/trunk/XTS/sar/src/org/jboss/jbossts/xts/recovery/coordinator/ba/RecoverACCoordinator.java
Log:
version of BA code with recovery which passes unit tests and TX11 interop test

Modified: labs/jbosstm/trunk/XTS/WS-T/dev/src10/com/arjuna/webservices/wsba/processors/CoordinatorCompletionCoordinatorProcessor.java
===================================================================
--- labs/jbosstm/trunk/XTS/WS-T/dev/src10/com/arjuna/webservices/wsba/processors/CoordinatorCompletionCoordinatorProcessor.java	2008-11-17 15:07:59 UTC (rev 23895)
+++ labs/jbosstm/trunk/XTS/WS-T/dev/src10/com/arjuna/webservices/wsba/processors/CoordinatorCompletionCoordinatorProcessor.java	2008-11-17 18:35:05 UTC (rev 23896)
@@ -64,7 +64,7 @@
     
     /**
      * Activate the coordinator.
-     * @param coordinatorState The coordinator.
+     * @param coordinator The coordinator.
      * @param identifier The identifier.
      */
     public abstract void activateCoordinator(final CoordinatorCompletionCoordinatorInboundEvents coordinator, final String identifier) ;
@@ -76,6 +76,12 @@
     public abstract void deactivateCoordinator(final CoordinatorCompletionCoordinatorInboundEvents coordinator) ;
     
     /**
+     * Locate a coordinator by name.
+     * @param identifier The name of the coordinator.
+     */
+    public abstract CoordinatorCompletionCoordinatorInboundEvents getCoordinator(final String  identifier) ;
+
+    /**
      * Cancelled.
      * @param cancelled The cancelled notification.
      * @param addressingContext The addressing context.

Modified: labs/jbosstm/trunk/XTS/WS-T/dev/src10/com/arjuna/webservices/wsba/processors/ParticipantCompletionCoordinatorProcessor.java
===================================================================
--- labs/jbosstm/trunk/XTS/WS-T/dev/src10/com/arjuna/webservices/wsba/processors/ParticipantCompletionCoordinatorProcessor.java	2008-11-17 15:07:59 UTC (rev 23895)
+++ labs/jbosstm/trunk/XTS/WS-T/dev/src10/com/arjuna/webservices/wsba/processors/ParticipantCompletionCoordinatorProcessor.java	2008-11-17 18:35:05 UTC (rev 23896)
@@ -63,7 +63,7 @@
     
     /**
      * Activate the coordinator.
-     * @param coordinatorState The coordinator.
+     * @param coordinator The coordinator.
      * @param identifier The identifier.
      */
     public abstract void activateCoordinator(final ParticipantCompletionCoordinatorInboundEvents coordinator, final String identifier) ;
@@ -75,6 +75,12 @@
     public abstract void deactivateCoordinator(final ParticipantCompletionCoordinatorInboundEvents coordinator) ;
     
     /**
+     * Locate a coordinator by name.
+     * @param identifier The name of the coordinator.
+     */
+    public abstract ParticipantCompletionCoordinatorInboundEvents getCoordinator(final String  identifier) ;
+
+    /**
      * Cancelled.
      * @param cancelled The cancelled notification.
      * @param addressingContext The addressing context.

Deleted: labs/jbosstm/trunk/XTS/WS-T/dev/src10/com/arjuna/wst/RecoverableBusinessAgreementWithCoordinatorCompletionParticipant.java
===================================================================
--- labs/jbosstm/trunk/XTS/WS-T/dev/src10/com/arjuna/wst/RecoverableBusinessAgreementWithCoordinatorCompletionParticipant.java	2008-11-17 15:07:59 UTC (rev 23895)
+++ labs/jbosstm/trunk/XTS/WS-T/dev/src10/com/arjuna/wst/RecoverableBusinessAgreementWithCoordinatorCompletionParticipant.java	2008-11-17 18:35:05 UTC (rev 23896)
@@ -1,41 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2006, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. 
- * See the copyright.txt in the distribution for a full listing 
- * of individual contributors.
- * This copyrighted material is made available to anyone wishing to use,
- * modify, copy, or redistribute it subject to the terms and conditions
- * of the GNU Lesser General Public License, v. 2.1.
- * This program is distributed in the hope that it will be useful, but WITHOUT A
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
- * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
- * You should have received a copy of the GNU Lesser General Public License,
- * v.2.1 along with this distribution; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
- * MA  02110-1301, USA.
- * 
- * (C) 2005-2006,
- * @author JBoss Inc.
- */
-/*
- * Copyright (C) 2002, 2003, 2004,
- *
- * Arjuna Technologies Limited,
- * Newcastle upon Tyne,
- * Tyne and Wear,
- * UK.
- *
- * $Id: BusinessAgreementWithCoordinatorCompletionParticipant.java,v 1.1.2.1 2004/05/26 10:02:33 nmcl Exp $
- */
-
-package com.arjuna.wst;
-
-/**
- * extension of BusinessAgreementWithCoordinatorCompletionParticipant API which allows establishment of a
- * back channel from the coordinator side protocol engine to the coordinator.
- */
-
-public interface RecoverableBusinessAgreementWithCoordinatorCompletionParticipant extends RecoverableBusinessAgreementWithParticipantCompletionParticipant, BusinessAgreementWithCoordinatorCompletionParticipant
-{
-}
\ No newline at end of file

Deleted: labs/jbosstm/trunk/XTS/WS-T/dev/src10/com/arjuna/wst/RecoverableBusinessAgreementWithParticipantCompletionParticipant.java
===================================================================
--- labs/jbosstm/trunk/XTS/WS-T/dev/src10/com/arjuna/wst/RecoverableBusinessAgreementWithParticipantCompletionParticipant.java	2008-11-17 15:07:59 UTC (rev 23895)
+++ labs/jbosstm/trunk/XTS/WS-T/dev/src10/com/arjuna/wst/RecoverableBusinessAgreementWithParticipantCompletionParticipant.java	2008-11-17 18:35:05 UTC (rev 23896)
@@ -1,47 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2006, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. 
- * See the copyright.txt in the distribution for a full listing 
- * of individual contributors.
- * This copyrighted material is made available to anyone wishing to use,
- * modify, copy, or redistribute it subject to the terms and conditions
- * of the GNU Lesser General Public License, v. 2.1.
- * This program is distributed in the hope that it will be useful, but WITHOUT A
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
- * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
- * You should have received a copy of the GNU Lesser General Public License,
- * v.2.1 along with this distribution; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
- * MA  02110-1301, USA.
- * 
- * (C) 2005-2006,
- * @author JBoss Inc.
- */
-/*
- * Copyright (C) 2002, 2003, 2004,
- *
- * Arjuna Technologies Limited,
- * Newcastle upon Tyne,
- * Tyne and Wear,
- * UK.
- *
- * $Id: BusinessAgreementWithParticipantCompletionParticipant.java,v 1.1.2.1 2004/05/26 10:02:33 nmcl Exp $
- */
-
-package com.arjuna.wst;
-
-/**
- * extension of BusinessAgreementWithCoordinatorCompletionParticipant API which allows establishment of a
- * back channel from the coordinator side protocol engine to the coordinator.
- */
-
-public interface RecoverableBusinessAgreementWithParticipantCompletionParticipant extends BusinessAgreementWithParticipantCompletionParticipant
-{
-    /**
-     * establish  a back channel from the coordinator side protocol engine to the coordinator.
-     *
-     * @param participantManager a manager which will forward incoming remote participant requests to the coordinator
-     */
-    public void setParticipantManager(BAParticipantManager participantManager);
-}
\ No newline at end of file

Modified: labs/jbosstm/trunk/XTS/WS-T/dev/src10/com/arjuna/wst/messaging/CoordinatorCompletionCoordinatorProcessorImpl.java
===================================================================
--- labs/jbosstm/trunk/XTS/WS-T/dev/src10/com/arjuna/wst/messaging/CoordinatorCompletionCoordinatorProcessorImpl.java	2008-11-17 15:07:59 UTC (rev 23895)
+++ labs/jbosstm/trunk/XTS/WS-T/dev/src10/com/arjuna/wst/messaging/CoordinatorCompletionCoordinatorProcessorImpl.java	2008-11-17 18:35:05 UTC (rev 23896)
@@ -67,6 +67,15 @@
     }
     
     /**
+     * Locate a coordinator by name.
+     * @param identifier The name of the coordinator.
+     */
+    public CoordinatorCompletionCoordinatorInboundEvents getCoordinator(final String  identifier)
+    {
+        return (CoordinatorCompletionCoordinatorInboundEvents)activatedObjectProcessor.getObject(identifier);
+    }
+
+    /**
      * Get the coordinator associated with the specified identifier.
      * @param instanceIdentifier The coordinator identifier.
      * @return The coordinator or null if not known.

Modified: labs/jbosstm/trunk/XTS/WS-T/dev/src10/com/arjuna/wst/messaging/ParticipantCompletionCoordinatorProcessorImpl.java
===================================================================
--- labs/jbosstm/trunk/XTS/WS-T/dev/src10/com/arjuna/wst/messaging/ParticipantCompletionCoordinatorProcessorImpl.java	2008-11-17 15:07:59 UTC (rev 23895)
+++ labs/jbosstm/trunk/XTS/WS-T/dev/src10/com/arjuna/wst/messaging/ParticipantCompletionCoordinatorProcessorImpl.java	2008-11-17 18:35:05 UTC (rev 23896)
@@ -67,6 +67,15 @@
     }
     
     /**
+     * Locate a coordinator by name.
+     * @param identifier The name of the coordinator.
+     */
+    public ParticipantCompletionCoordinatorInboundEvents getCoordinator(final String  identifier)
+    {
+        return (ParticipantCompletionCoordinatorInboundEvents)activatedObjectProcessor.getObject(identifier);
+    }
+
+    /**
      * Get the coordinator with the specified identifier.
      * @param instanceIdentifier The coordinator identifier.
      * @return The coordinator or null if not known.

Modified: labs/jbosstm/trunk/XTS/WS-T/dev/src10/com/arjuna/wst/messaging/engines/CoordinatorCompletionCoordinatorEngine.java
===================================================================
--- labs/jbosstm/trunk/XTS/WS-T/dev/src10/com/arjuna/wst/messaging/engines/CoordinatorCompletionCoordinatorEngine.java	2008-11-17 15:07:59 UTC (rev 23895)
+++ labs/jbosstm/trunk/XTS/WS-T/dev/src10/com/arjuna/wst/messaging/engines/CoordinatorCompletionCoordinatorEngine.java	2008-11-17 18:35:05 UTC (rev 23896)
@@ -67,6 +67,10 @@
      */
     private State state ;
     /**
+     * The failure state which preceded state ended during close/cancel or null if no failure occurred.
+     */
+    private State failureState;
+    /**
      * The flag indicating that this coordinator has been recovered from the log.
      */
     private boolean recovered ;
@@ -82,7 +86,7 @@
     }
     
     /**
-     * Construct the engine for the coordinator in a specified state.
+     * Construct the engine for the coordinator in a specified state and register it.
      * @param id The coordinator id.
      * @param participant The participant endpoint reference.
      * @param state The initial state.
@@ -94,23 +98,24 @@
         this.instanceIdentifier = new InstanceIdentifier(id) ;
         this.participant = participant ;
         this.state = state ;
+        this.failureState = null;
         this.recovered = recovered;
+        // unrecovered participants are always activated
+        // we only need to reactivate recovered participants which were successfully COMPLETED or which began
+        // CLOSING. any others will only have been saved because of a heuristic outcome. we can safely drop
+        // it since we implement presumed abort.
+        if (!recovered || state == State.STATE_COMPLETED || state == State.STATE_CLOSING) {
+            CoordinatorCompletionCoordinatorProcessor.getProcessor().activateCoordinator(this, id) ;
+        }
     }
     
     /**
-     * Set the coordinator and register
+     * Set the coordinator
      * @param coordinator
      */
     public void setCoordinator(final BAParticipantManager coordinator)
     {
         this.coordinator = coordinator ;
-        // unrecovered participants are always activated
-        // we only need to reactivate recovered participants which were successfully COMPLETED or which began
-        // CLOSING. any others will only have been saved because of a heuristic outcome. we can safely drop
-        // it since we implement presumed abort.
-        if (!recovered || state == State.STATE_COMPLETED || state == State.STATE_CLOSING) {
-            CoordinatorCompletionCoordinatorProcessor.getProcessor().activateCoordinator(this, id) ;
-        }
     }
     
     /**

Modified: labs/jbosstm/trunk/XTS/WS-T/dev/src10/com/arjuna/wst/messaging/engines/ParticipantCompletionCoordinatorEngine.java
===================================================================
--- labs/jbosstm/trunk/XTS/WS-T/dev/src10/com/arjuna/wst/messaging/engines/ParticipantCompletionCoordinatorEngine.java	2008-11-17 15:07:59 UTC (rev 23895)
+++ labs/jbosstm/trunk/XTS/WS-T/dev/src10/com/arjuna/wst/messaging/engines/ParticipantCompletionCoordinatorEngine.java	2008-11-17 18:35:05 UTC (rev 23896)
@@ -66,6 +66,10 @@
      */
     private State state ;
     /**
+     * The failure state which preceded state ended during close/cancel or null if no failure occurred.
+     */
+    private State failureState;
+    /**
      * The flag indicating that this coordinator has been recovered from the log.
      */
     private boolean recovered ;
@@ -81,7 +85,7 @@
     }
     
     /**
-     * Construct the engine for the coordinator in a specified state.
+     * Construct the engine for the coordinator in a specified state and register it.
      * @param id The coordinator id.
      * @param participant The participant endpoint reference.
      * @param state The initial state.
@@ -93,23 +97,24 @@
         this.instanceIdentifier = new InstanceIdentifier(id) ;
         this.participant = participant ;
         this.state = state ;
+        this.failureState = null;
         this.recovered = recovered;
+        // unrecovered participants are always activated
+        // we only need to reactivate recovered participants which were successfully COMPLETED or which began
+        // CLOSING. any others will only have been saved because of a heuristic outcome. we can safely drop
+        // it since we implement presumed abort.
+        if (!recovered || state == State.STATE_COMPLETED || state == State.STATE_CLOSING) {
+            ParticipantCompletionCoordinatorProcessor.getProcessor().activateCoordinator(this, id) ;
+        }
     }
     
     /**
-     * Set the coordinator and register
+     * Set the coordinator
      * @param coordinator
      */
     public void setCoordinator(final BAParticipantManager coordinator)
     {
         this.coordinator = coordinator ;
-        // unrecovered participants are always activated
-        // we only need to reactivate recovered participants which were successfully COMPLETED or which began
-        // CLOSING. any others will only have been saved because of a heuristic outcome. we can safely drop
-        // it since we implement presumed abort.
-        if (!recovered || state == State.STATE_COMPLETED || state == State.STATE_CLOSING) {
-            ParticipantCompletionCoordinatorProcessor.getProcessor().activateCoordinator(this, id) ;
-        }
     }
     
     /**

Modified: labs/jbosstm/trunk/XTS/WS-T/dev/src10/com/arjuna/wst/stub/BusinessAgreementWithCoordinatorCompletionStub.java
===================================================================
--- labs/jbosstm/trunk/XTS/WS-T/dev/src10/com/arjuna/wst/stub/BusinessAgreementWithCoordinatorCompletionStub.java	2008-11-17 15:07:59 UTC (rev 23895)
+++ labs/jbosstm/trunk/XTS/WS-T/dev/src10/com/arjuna/wst/stub/BusinessAgreementWithCoordinatorCompletionStub.java	2008-11-17 18:35:05 UTC (rev 23896)
@@ -39,11 +39,13 @@
 import com.arjuna.webservices.soap.SoapUtils;
 import com.arjuna.webservices.util.StreamHelper;
 import com.arjuna.webservices.wsba.State;
+import com.arjuna.webservices.wsba.processors.CoordinatorCompletionCoordinatorProcessor;
 import com.arjuna.webservices.wsaddr.EndpointReferenceType;
 import com.arjuna.wst.*;
 import com.arjuna.wst.messaging.engines.CoordinatorCompletionCoordinatorEngine;
+import com.arjuna.wst.messaging.CoordinatorCompletionCoordinatorProcessorImpl;
 
-public class BusinessAgreementWithCoordinatorCompletionStub implements RecoverableBusinessAgreementWithCoordinatorCompletionParticipant, PersistableParticipant
+public class BusinessAgreementWithCoordinatorCompletionStub implements BusinessAgreementWithCoordinatorCompletionParticipant, PersistableParticipant
 {
     private static final QName QNAME_BACC_PARTICIPANT = new QName("baccParticipant") ;
     private CoordinatorCompletionCoordinatorEngine participant ;
@@ -267,20 +269,19 @@
             QName statename = new QName(ns, localPart, prefix);
             State state = State.toState(statename);
 
-            participant = new CoordinatorCompletionCoordinatorEngine(id, endpointReferenceType, state, true);
+            // if we already have an engine from a previous recovery scan or because
+            // we had a heuristic outcome then reuse it with luck it will have been committed
+            // or aborted between the last scan and this one
+            // note that whatever happens it will not have been removed from the table
+            // because it is marked as recovered
+            participant = (CoordinatorCompletionCoordinatorEngine) CoordinatorCompletionCoordinatorProcessor.getProcessor().getCoordinator(id);
+            if (participant == null) {
+                participant = new CoordinatorCompletionCoordinatorEngine(id, endpointReferenceType, state, true);
+            }
             return true ;
         } catch (final Throwable th) {
             WSTLogger.arjLoggerI18N.error("com.arjuna.wst.stub.BusinessAgreementWithCoordinatorCompletionStub_3", th) ;
             return false ;
         }
     }
-
-    /**
-     * establish  a back channel from the coordinator side protocol engine to the coordinator.
-     *
-     * @param participantManager a manager which will forward incoming remote participant requests to the coordinator
-     */
-    public void setParticipantManager(BAParticipantManager participantManager) {
-        participant.setCoordinator(participantManager);
-    }
 }

Modified: labs/jbosstm/trunk/XTS/WS-T/dev/src10/com/arjuna/wst/stub/BusinessAgreementWithParticipantCompletionStub.java
===================================================================
--- labs/jbosstm/trunk/XTS/WS-T/dev/src10/com/arjuna/wst/stub/BusinessAgreementWithParticipantCompletionStub.java	2008-11-17 15:07:59 UTC (rev 23895)
+++ labs/jbosstm/trunk/XTS/WS-T/dev/src10/com/arjuna/wst/stub/BusinessAgreementWithParticipantCompletionStub.java	2008-11-17 18:35:05 UTC (rev 23896)
@@ -39,11 +39,13 @@
 import com.arjuna.webservices.soap.SoapUtils;
 import com.arjuna.webservices.util.StreamHelper;
 import com.arjuna.webservices.wsba.State;
+import com.arjuna.webservices.wsba.processors.ParticipantCompletionCoordinatorProcessor;
 import com.arjuna.webservices.wsaddr.EndpointReferenceType;
 import com.arjuna.wst.*;
 import com.arjuna.wst.messaging.engines.ParticipantCompletionCoordinatorEngine;
+import com.arjuna.wst.messaging.ParticipantCompletionCoordinatorProcessorImpl;
 
-public class BusinessAgreementWithParticipantCompletionStub implements RecoverableBusinessAgreementWithParticipantCompletionParticipant, PersistableParticipant
+public class BusinessAgreementWithParticipantCompletionStub implements BusinessAgreementWithParticipantCompletionParticipant, PersistableParticipant
 {
     private static final QName QNAME_BAPC_PARTICIPANT = new QName("bapcParticipant") ;
     
@@ -228,7 +230,15 @@
             QName statename = new QName(ns, localPart, prefix);
             State state = State.toState(statename);
 
-            participant = new ParticipantCompletionCoordinatorEngine(id, endpointReferenceType, state, true);
+            // if we already have an engine from a previous recovery scan or because
+            // we had a heuristic outcome then reuse it with luck it will have been committed
+            // or aborted between the last scan and this one
+            // note that whatever happens it will not have been removed from the table
+            // because it is marked as recovered
+            participant = (ParticipantCompletionCoordinatorEngine) ParticipantCompletionCoordinatorProcessor.getProcessor().getCoordinator(id);
+            if (participant == null) {
+                participant = new ParticipantCompletionCoordinatorEngine(id, endpointReferenceType, state, true);
+            }
             return true ;
         }
         catch (final Throwable th)
@@ -237,13 +247,4 @@
             return false ;
         }
     }
-
-    /**
-     * establish  a back channel from the coordinator side protocol engine to the coordinator.
-     *
-     * @param participantManager a manager which will forward incoming remote participant requests to the coordinator
-     */
-    public void setParticipantManager(BAParticipantManager participantManager) {
-        participant.setCoordinator(participantManager);
-    }
 }

Modified: labs/jbosstm/trunk/XTS/WS-T/dev/src10/com/arjuna/wst/stub/LocalCoordinatorCompletionParticipantStub.java
===================================================================
--- labs/jbosstm/trunk/XTS/WS-T/dev/src10/com/arjuna/wst/stub/LocalCoordinatorCompletionParticipantStub.java	2008-11-17 15:07:59 UTC (rev 23895)
+++ labs/jbosstm/trunk/XTS/WS-T/dev/src10/com/arjuna/wst/stub/LocalCoordinatorCompletionParticipantStub.java	2008-11-17 18:35:05 UTC (rev 23896)
@@ -10,7 +10,7 @@
  */
 public class LocalCoordinatorCompletionParticipantStub
         extends LocalParticipantCompletionParticipantStub
-        implements RecoverableBusinessAgreementWithCoordinatorCompletionParticipant, PersistableParticipant {
+        implements BusinessAgreementWithCoordinatorCompletionParticipant, PersistableParticipant {
 
     public LocalCoordinatorCompletionParticipantStub(BusinessAgreementWithCoordinatorCompletionParticipant participant, String id) {
         super(participant, id);

Modified: labs/jbosstm/trunk/XTS/WS-T/dev/src10/com/arjuna/wst/stub/LocalParticipantCompletionParticipantStub.java
===================================================================
--- labs/jbosstm/trunk/XTS/WS-T/dev/src10/com/arjuna/wst/stub/LocalParticipantCompletionParticipantStub.java	2008-11-17 15:07:59 UTC (rev 23895)
+++ labs/jbosstm/trunk/XTS/WS-T/dev/src10/com/arjuna/wst/stub/LocalParticipantCompletionParticipantStub.java	2008-11-17 18:35:05 UTC (rev 23896)
@@ -14,7 +14,7 @@
  * to the underlying participant.
  */
 public class LocalParticipantCompletionParticipantStub
-        implements RecoverableBusinessAgreementWithParticipantCompletionParticipant, PersistableParticipant
+        implements BusinessAgreementWithParticipantCompletionParticipant, PersistableParticipant
 {
     public LocalParticipantCompletionParticipantStub(BusinessAgreementWithParticipantCompletionParticipant participant, String id)
     {
@@ -31,15 +31,6 @@
     }
 
     /**
-     * establish  a back channel from the coordinator side protocol engine to the coordinator.
-     *
-     * @param participantManager a manager which will forward incoming remote participant requests to the coordinator
-     */
-    public void setParticipantManager(BAParticipantManager participantManager) {
-        // currently unimplemented this really needs help from the applicaton helper
-    }
-
-    /**
      * The transaction has completed successfully. The participant previously
      * informed the coordinator that it was ready to complete.
      */

Modified: labs/jbosstm/trunk/XTS/WS-T/dev/src11/com/arjuna/webservices11/wsba/processors/CoordinatorCompletionCoordinatorProcessor.java
===================================================================
--- labs/jbosstm/trunk/XTS/WS-T/dev/src11/com/arjuna/webservices11/wsba/processors/CoordinatorCompletionCoordinatorProcessor.java	2008-11-17 15:07:59 UTC (rev 23895)
+++ labs/jbosstm/trunk/XTS/WS-T/dev/src11/com/arjuna/webservices11/wsba/processors/CoordinatorCompletionCoordinatorProcessor.java	2008-11-17 18:35:05 UTC (rev 23896)
@@ -76,6 +76,12 @@
     public abstract void deactivateCoordinator(final CoordinatorCompletionCoordinatorInboundEvents coordinator) ;
 
     /**
+     * Locate a coordinator by name.
+     * @param identifier The name of the coordinator.
+     */
+    public abstract CoordinatorCompletionCoordinatorInboundEvents getCoordinator(final String  identifier) ;
+
+    /**
      * Cancelled.
      * @param cancelled The cancelled notification.
      * @param addressingProperties The addressing context.

Modified: labs/jbosstm/trunk/XTS/WS-T/dev/src11/com/arjuna/webservices11/wsba/processors/ParticipantCompletionCoordinatorProcessor.java
===================================================================
--- labs/jbosstm/trunk/XTS/WS-T/dev/src11/com/arjuna/webservices11/wsba/processors/ParticipantCompletionCoordinatorProcessor.java	2008-11-17 15:07:59 UTC (rev 23895)
+++ labs/jbosstm/trunk/XTS/WS-T/dev/src11/com/arjuna/webservices11/wsba/processors/ParticipantCompletionCoordinatorProcessor.java	2008-11-17 18:35:05 UTC (rev 23896)
@@ -76,6 +76,12 @@
     public abstract void deactivateCoordinator(final ParticipantCompletionCoordinatorInboundEvents coordinator) ;
 
     /**
+     * Locate a coordinator by name.
+     * @param identifier The name of the coordinator.
+     */
+    public abstract ParticipantCompletionCoordinatorInboundEvents getCoordinator(final String  identifier) ;
+
+    /**
      * Cancelled.
      * @param cancelled The cancelled notification.
      * @param addressingProperties The addressing context.

Deleted: labs/jbosstm/trunk/XTS/WS-T/dev/src11/com/arjuna/wst11/RecoverableBusinessAgreementWithCoordinatorCompletionParticipant.java
===================================================================
--- labs/jbosstm/trunk/XTS/WS-T/dev/src11/com/arjuna/wst11/RecoverableBusinessAgreementWithCoordinatorCompletionParticipant.java	2008-11-17 15:07:59 UTC (rev 23895)
+++ labs/jbosstm/trunk/XTS/WS-T/dev/src11/com/arjuna/wst11/RecoverableBusinessAgreementWithCoordinatorCompletionParticipant.java	2008-11-17 18:35:05 UTC (rev 23896)
@@ -1,45 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2006, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. 
- * See the copyright.txt in the distribution for a full listing 
- * of individual contributors.
- * This copyrighted material is made available to anyone wishing to use,
- * modify, copy, or redistribute it subject to the terms and conditions
- * of the GNU Lesser General Public License, v. 2.1.
- * This program is distributed in the hope that it will be useful, but WITHOUT A
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
- * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
- * You should have received a copy of the GNU Lesser General Public License,
- * v.2.1 along with this distribution; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
- * MA  02110-1301, USA.
- * 
- * (C) 2005-2006,
- * @author JBoss Inc.
- */
-/*
- * Copyright (C) 2002, 2003, 2004,
- *
- * Arjuna Technologies Limited,
- * Newcastle upon Tyne,
- * Tyne and Wear,
- * UK.
- *
- * $Id: BusinessAgreementWithCoordinatorCompletionParticipant.java,v 1.1.2.1 2004/05/26 10:02:33 nmcl Exp $
- */
-
-package com.arjuna.wst11;
-
-import com.arjuna.wst.WrongStateException;
-import com.arjuna.wst.SystemException;
-import com.arjuna.wst.BusinessAgreementWithCoordinatorCompletionParticipant;
-
-/**
- * extension of BusinessAgreementWithCoordinatorCompletionParticipant API which allows establishment of a
- * back channel from the coordinator side protocol engine to the coordinator.
- */
-
-public interface RecoverableBusinessAgreementWithCoordinatorCompletionParticipant extends RecoverableBusinessAgreementWithParticipantCompletionParticipant, BusinessAgreementWithCoordinatorCompletionParticipant
-{
-}
\ No newline at end of file

Deleted: labs/jbosstm/trunk/XTS/WS-T/dev/src11/com/arjuna/wst11/RecoverableBusinessAgreementWithParticipantCompletionParticipant.java
===================================================================
--- labs/jbosstm/trunk/XTS/WS-T/dev/src11/com/arjuna/wst11/RecoverableBusinessAgreementWithParticipantCompletionParticipant.java	2008-11-17 15:07:59 UTC (rev 23895)
+++ labs/jbosstm/trunk/XTS/WS-T/dev/src11/com/arjuna/wst11/RecoverableBusinessAgreementWithParticipantCompletionParticipant.java	2008-11-17 18:35:05 UTC (rev 23896)
@@ -1,51 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2006, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. 
- * See the copyright.txt in the distribution for a full listing 
- * of individual contributors.
- * This copyrighted material is made available to anyone wishing to use,
- * modify, copy, or redistribute it subject to the terms and conditions
- * of the GNU Lesser General Public License, v. 2.1.
- * This program is distributed in the hope that it will be useful, but WITHOUT A
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
- * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
- * You should have received a copy of the GNU Lesser General Public License,
- * v.2.1 along with this distribution; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
- * MA  02110-1301, USA.
- * 
- * (C) 2005-2006,
- * @author JBoss Inc.
- */
-/*
- * Copyright (C) 2002, 2003, 2004,
- *
- * Arjuna Technologies Limited,
- * Newcastle upon Tyne,
- * Tyne and Wear,
- * UK.
- *
- * $Id: BusinessAgreementWithParticipantCompletionParticipant.java,v 1.1.2.1 2004/05/26 10:02:33 nmcl Exp $
- */
-
-package com.arjuna.wst11;
-
-import com.arjuna.wst.WrongStateException;
-import com.arjuna.wst.SystemException;
-import com.arjuna.wst.FaultedException;
-import com.arjuna.wst.BusinessAgreementWithParticipantCompletionParticipant;
-
-/**
- * extension of BusinessAgreementWithParticipantCompletionParticipant API which allows establishment of a
- * back channel from the coordinator side protocol engine to the coordinator.
- */
-public interface RecoverableBusinessAgreementWithParticipantCompletionParticipant extends BusinessAgreementWithParticipantCompletionParticipant
-{
-    /**
-     * establish  a back channel from the coordinator side protocol engine to the coordinator.
-     *
-     * @param participantManager a manager which will forward incoming remote participant requests to the coordinator
-     */
-    public void setParticipantManager(BAParticipantManager participantManager);
-}
\ No newline at end of file

Modified: labs/jbosstm/trunk/XTS/WS-T/dev/src11/com/arjuna/wst11/messaging/CoordinatorCompletionCoordinatorProcessorImpl.java
===================================================================
--- labs/jbosstm/trunk/XTS/WS-T/dev/src11/com/arjuna/wst11/messaging/CoordinatorCompletionCoordinatorProcessorImpl.java	2008-11-17 15:07:59 UTC (rev 23895)
+++ labs/jbosstm/trunk/XTS/WS-T/dev/src11/com/arjuna/wst11/messaging/CoordinatorCompletionCoordinatorProcessorImpl.java	2008-11-17 18:35:05 UTC (rev 23896)
@@ -71,6 +71,15 @@
     }
 
     /**
+     * Locate a coordinator by name.
+     * @param identifier The name of the coordinator.
+     */
+    public CoordinatorCompletionCoordinatorInboundEvents getCoordinator(final String  identifier)
+    {
+        return (CoordinatorCompletionCoordinatorInboundEvents)activatedObjectProcessor.getObject(identifier);
+    }
+
+    /**
      * Get the coordinator associated with the specified identifier.
      * @param instanceIdentifier The coordinator identifier.
      * @return The coordinator or null if not known.

Modified: labs/jbosstm/trunk/XTS/WS-T/dev/src11/com/arjuna/wst11/messaging/ParticipantCompletionCoordinatorProcessorImpl.java
===================================================================
--- labs/jbosstm/trunk/XTS/WS-T/dev/src11/com/arjuna/wst11/messaging/ParticipantCompletionCoordinatorProcessorImpl.java	2008-11-17 15:07:59 UTC (rev 23895)
+++ labs/jbosstm/trunk/XTS/WS-T/dev/src11/com/arjuna/wst11/messaging/ParticipantCompletionCoordinatorProcessorImpl.java	2008-11-17 18:35:05 UTC (rev 23896)
@@ -69,6 +69,15 @@
     }
 
     /**
+     * Locate a coordinator by name.
+     * @param identifier The name of the coordinator.
+     */
+    public ParticipantCompletionCoordinatorInboundEvents getCoordinator(final String  identifier)
+    {
+        return (ParticipantCompletionCoordinatorInboundEvents)activatedObjectProcessor.getObject(identifier);
+    }
+
+    /**
      * Get the coordinator with the specified identifier.
      * @param instanceIdentifier The coordinator identifier.
      * @return The coordinator or null if not known.

Modified: labs/jbosstm/trunk/XTS/WS-T/dev/src11/com/arjuna/wst11/messaging/engines/CoordinatorCompletionCoordinatorEngine.java
===================================================================
--- labs/jbosstm/trunk/XTS/WS-T/dev/src11/com/arjuna/wst11/messaging/engines/CoordinatorCompletionCoordinatorEngine.java	2008-11-17 15:07:59 UTC (rev 23895)
+++ labs/jbosstm/trunk/XTS/WS-T/dev/src11/com/arjuna/wst11/messaging/engines/CoordinatorCompletionCoordinatorEngine.java	2008-11-17 18:35:05 UTC (rev 23896)
@@ -30,10 +30,8 @@
 import com.arjuna.webservices11.wsarj.InstanceIdentifier;
 import com.arjuna.webservices11.wsba.CoordinatorCompletionCoordinatorInboundEvents;
 import com.arjuna.webservices11.wsba.State;
-import com.arjuna.webservices11.wsba.BusinessActivityConstants;
 import com.arjuna.webservices11.wsba.processors.CoordinatorCompletionCoordinatorProcessor;
 import com.arjuna.webservices11.wsba.client.CoordinatorCompletionParticipantClient;
-import com.arjuna.webservices11.ServiceRegistry;
 import com.arjuna.webservices11.SoapFault11;
 import com.arjuna.webservices11.wscoor.CoordinationConstants;
 import com.arjuna.wsc11.messaging.MessageId;
@@ -76,6 +74,10 @@
      */
     private State state;
     /**
+     * The failure state which preceded state ended during close/cancel or null if no failure occurred.
+     */
+    private State failureState;
+    /**
      * The flag indicating that this coordinator has been recovered from the log.
      */
     private boolean recovered ;
@@ -91,7 +93,7 @@
     }
 
     /**
-     * Construct the engine for the coordinator in a specified state.
+     * Construct the engine for the coordinator in a specified state and register it.
      * @param id The coordinator id.
      * @param participant The participant endpoint reference.
      * @param state The initial state.
@@ -103,23 +105,24 @@
         this.instanceIdentifier = new InstanceIdentifier(id) ;
         this.participant = participant ;
         this.state = state ;
+        this.failureState = null;
         this.recovered = recovered;
+        // unrecovered participants are always activated
+        // we only need to reactivate recovered participants which were successfully COMPLETED or which began
+        // CLOSING. any others will only have been saved because of a heuristic outcome. we can safely drop
+        // them since we implement presumed abort.
+        if (!recovered || state == State.STATE_COMPLETED || state == State.STATE_CLOSING) {
+            CoordinatorCompletionCoordinatorProcessor.getProcessor().activateCoordinator(this, id) ;
+        }
     }
 
     /**
-     * Set the coordinator and register
+     * Set the coordinator
      * @param coordinator
      */
     public void setCoordinator(final BAParticipantManager coordinator)
     {
         this.coordinator = coordinator ;
-        // unrecovered participants are always activated
-        // we only need to reactivate recovered participants which were successfully COMPLETED or which began
-        // CLOSING. any others will only have been saved because of a heuristic outcome. we can safely drop
-        // them since we implement presumed abort.
-        if (!recovered || state == State.STATE_COMPLETED || state == State.STATE_CLOSING) {
-            CoordinatorCompletionCoordinatorProcessor.getProcessor().activateCoordinator(this, id) ;
-        }
     }
 
     /**
@@ -341,6 +344,35 @@
      * NotCompleting -> NotCompleting (invalid state)
      * Exiting -> Exiting (invalid state)
      * Ended -> Ended (resend Failed)
+     *
+     * In fact we only execute the transition to FAILING_ACTIVE and in this case we send a message to the
+     * coordinator by calling executeFail. This propagates the failure back thorugh the activityy hierarchy
+     * to the relevant participant and also marks the acivity as ABORT_ONLY.
+     *
+     * In the other failure cases we do not change to a FAILING_XXX state but instead go straight to ENDED
+     * and save the failing state in a field failureState. In these cases there will be a coordinator
+     * close/cancel/compensate thread waiting on the change to state FAILING_XXX. The change to FAILING_XXX
+     * will wake it up and, if the state is still FAILING_XXX, return a fault to the coordinator, However,
+     * the failing thread also sends a failed response and then call ended. This means the state might be
+     * transitioned to ENDED before the coordinator thread is scheduled. So, we have to avoid this race by
+     * going straight to ENDED and saving a failureState which the coordinator thread can check.
+     *
+     * The failureState also avoids another race condition for these (non-ACTIVE) cases. It means we don't have
+     * to send a message to the coordinator to notify the failure. We would need to do this after the state
+     * change as we need to exclude threads handling resent messages. However, the waiting coordinator thread
+     * is woken by the state change and so it might complete and remove the activity before the message is sent
+     * causing a NoSuchActivity exception in this thread. Settign the  failureState ensures that the failure is
+     * detected cleanly by any waiting coordinator thread.
+     *
+     * Fortuitously, this also avoids problems during recovery. During recovery we have no link to our
+     * coordinator available since there is no activity hierarchy in the current context. So, communicating
+     * failures via the failureState is the only way to ensure that the recovreed coordinator sees a failure.
+     * There is a further wrinkle here too. If a recovered coordinator times out waiting for a response we need
+     * to leave the engine in place when we ditch the recovered coordinator and then reestablish a link to it
+     * next time we recreate the coordinator. We cannot afford to miss a failure during this interval but the]
+     * engine must transition to ENDED after handling the failure. Saving the failure state ensures that the
+     * next time the coordinator calls cancel, compensate or close it receives a fault indicating a failure
+     * rather than just detecting that the pariticpant  has ended.
      */
     public void fail(final ExceptionType fail, final AddressingProperties addressingProperties,
         final ArjunaContext arjunaContext)
@@ -355,15 +387,18 @@
             }
             else if ((current == State.STATE_CANCELING_ACTIVE) || (current == State.STATE_CANCELING_COMPLETING))
             {
-                changeState(State.STATE_FAILING_CANCELING) ;
+                failureState = State.STATE_FAILING_CANCELING;
+                ended();
             }
             else if (current == State.STATE_COMPLETING)
             {
-                changeState(State.STATE_FAILING_COMPLETING) ;
+                failureState = State.STATE_FAILING_COMPLETING;
+                ended();
             }
             else if (current == State.STATE_COMPENSATING)
             {
-                changeState(State.STATE_FAILING_COMPENSATING) ;
+                failureState = State.STATE_FAILING_COMPENSATING;
+                ended();
             }
         }
 
@@ -372,15 +407,11 @@
             executeFail(fail.getExceptionIdentifier()) ;
         }
         else if ((current == State.STATE_CANCELING_ACTIVE) || (current == State.STATE_CANCELING_COMPLETING) ||
-        	 (current == State.STATE_COMPLETING) || (current == State.STATE_COMPENSATING))
+                (current == State.STATE_COMPLETING) || (current == State.STATE_COMPENSATING) ||
+                (current == State.STATE_ENDED))
         {
             sendFailed() ;
-            ended() ;
         }
-        else if (current == State.STATE_ENDED)
-        {
-            sendFailed() ;
-        }
     }
 
     /**
@@ -486,7 +517,7 @@
      */
     public State cancel()
     {
-        final State current ;
+        State current ;
         synchronized(this)
         {
             current = state ;
@@ -503,13 +534,21 @@
         if (current == State.STATE_ACTIVE)
         {
             sendCancel() ;
-            return waitForState(State.STATE_CANCELING_ACTIVE, TransportTimer.getTransportTimeout()) ;
+            current = waitForState(State.STATE_CANCELING_ACTIVE, TransportTimer.getTransportTimeout()) ;
         }
         else if (current == State.STATE_COMPLETING)
         {
             sendCancel() ;
-            return waitForState(State.STATE_CANCELING_COMPLETING, TransportTimer.getTransportTimeout()) ;
+            current = waitForState(State.STATE_CANCELING_COMPLETING, TransportTimer.getTransportTimeout()) ;
         }
+
+        // if we reached ended via a failure then make sure we return the failure state so that
+        // the coordinator sees the failure
+
+        if (current == State.STATE_ENDED && failureState != null) {
+            return failureState;
+        }
+
         return current ;
     }
 
@@ -534,7 +573,7 @@
      */
     public State compensate()
     {
-        final State current ;
+        State current ;
         synchronized(this)
         {
             current = state ;
@@ -547,10 +586,30 @@
         if (current == State.STATE_COMPLETED)
         {
             sendCompensate() ;
-            return waitForState(State.STATE_COMPENSATING, TransportTimer.getTransportTimeout()) ;
+            waitForState(State.STATE_COMPENSATING, TransportTimer.getTransportTimeout()) ;
         }
 
-        return current ;
+        synchronized(this) {
+            if (state != State.STATE_COMPENSATING) {
+                // if this is a recovered participant then ended will not have
+                // deactivated the entry so that this (recovery) thread can
+                // detect it and update its log entry. so we need to deactivate
+                // the entry here.
+
+                if (recovered) {
+                    CoordinatorCompletionCoordinatorProcessor.getProcessor().deactivateCoordinator(this) ;
+                }
+
+                if (state == State.STATE_ENDED && failureState != null) {
+                    return failureState;
+                }
+
+                return state;
+            }  else {
+                // timeout -- leave participant in place as this TX will get retried later
+                return State.STATE_COMPENSATING;
+            }
+        }
     }
 
     /**
@@ -613,7 +672,7 @@
      */
     public State close()
     {
-        final State current ;
+        State current ;
         synchronized(this)
         {
             current = state ;
@@ -626,9 +685,30 @@
         if (current == State.STATE_COMPLETED)
         {
             sendClose() ;
-            return waitForState(State.STATE_CLOSING, TransportTimer.getTransportTimeout()) ;
+            waitForState(State.STATE_CLOSING, TransportTimer.getTransportTimeout()) ;
         }
-        return current ;
+
+        synchronized(this) {
+            if (state != State.STATE_CLOSING) {
+                // if this is a recovered participant then ended will not have
+                // deactivated the entry so that this (recovery) thread can
+                // detect it and update its log entry. so we need to deactivate
+                // the entry here.
+
+                if (recovered) {
+                    CoordinatorCompletionCoordinatorProcessor.getProcessor().deactivateCoordinator(this) ;
+                }
+
+                if (state == State.STATE_ENDED && failureState != null) {
+                    return failureState;
+                }
+
+                return state;
+            }  else {
+                // timeout -- leave participant in place as this TX will get retried later
+                return State.STATE_CLOSING;
+            }
+        }
     }
 
     /**
@@ -642,7 +722,9 @@
         ended() ;
         try
         {
-            coordinator.fail(soapFault.getSubcode()) ;
+            if (coordinator != null) {
+                coordinator.fail(soapFault.getSubcode()) ;
+            }
         }
         catch (final Throwable th) {} // ignore
     }
@@ -1009,7 +1091,18 @@
     private void ended()
     {
         changeState(State.STATE_ENDED) ;
-        CoordinatorCompletionCoordinatorProcessor.getProcessor().deactivateCoordinator(this) ;
+        // participants which have not been recovered from the log can be deactivated now.
+
+        // participants which have been recovered are left for the recovery thread to deactivate.
+        // this is because the recovery thread may have timed out waiting for a response to
+        // a close/cancel message and gone on to complete its scan and suspend. the next scan
+        // will detect this activated participant and note that it has completed. if a crash
+        // happens in between the recovery thread can safely recreate and reactivate the
+        // participant and resend the commit since the commit/committed exchange is idempotent.
+
+        if (!recovered) {
+            CoordinatorCompletionCoordinatorProcessor.getProcessor().deactivateCoordinator(this) ;
+        }
     }
 
     /**

Modified: labs/jbosstm/trunk/XTS/WS-T/dev/src11/com/arjuna/wst11/messaging/engines/ParticipantCompletionCoordinatorEngine.java
===================================================================
--- labs/jbosstm/trunk/XTS/WS-T/dev/src11/com/arjuna/wst11/messaging/engines/ParticipantCompletionCoordinatorEngine.java	2008-11-17 15:07:59 UTC (rev 23895)
+++ labs/jbosstm/trunk/XTS/WS-T/dev/src11/com/arjuna/wst11/messaging/engines/ParticipantCompletionCoordinatorEngine.java	2008-11-17 18:35:05 UTC (rev 23896)
@@ -28,10 +28,8 @@
 import com.arjuna.webservices11.wsarj.InstanceIdentifier;
 import com.arjuna.webservices11.wsba.ParticipantCompletionCoordinatorInboundEvents;
 import com.arjuna.webservices11.wsba.State;
-import com.arjuna.webservices11.wsba.BusinessActivityConstants;
 import com.arjuna.webservices11.wsba.processors.ParticipantCompletionCoordinatorProcessor;
 import com.arjuna.webservices11.wsba.client.ParticipantCompletionParticipantClient;
-import com.arjuna.webservices11.ServiceRegistry;
 import com.arjuna.wsc11.messaging.MessageId;
 import com.arjuna.wst11.BAParticipantManager;
 import org.oasis_open.docs.ws_tx.wsba._2006._06.ExceptionType;
@@ -44,7 +42,7 @@
 
 /**
  * The participant completion coordinator state engine
- * @author kevin                     cannot
+ * @author kevin
  */
 public class ParticipantCompletionCoordinatorEngine implements ParticipantCompletionCoordinatorInboundEvents
 {
@@ -69,6 +67,10 @@
      */
     private State state ;
     /**
+     * The failure state which preceded state ended during close/cancel or null if no failure occurred.
+     */
+    private State failureState;
+    /**
      * The flag indicating that this coordinator has been recovered from the log.
      */
     private boolean recovered ;
@@ -84,7 +86,7 @@
     }
 
     /**
-     * Construct the engine for the coordinator in a specified state.
+     * Construct the engine for the coordinator in a specified state and register it.
      * @param id The coordinator id.
      * @param participant The participant endpoint reference.
      * @param state The initial state.
@@ -96,23 +98,24 @@
         this.instanceIdentifier = new InstanceIdentifier(id) ;
         this.participant = participant ;
         this.state = state ;
+        this.failureState = null;
         this.recovered = recovered;
+        // unrecovered participants are always activated
+        // we only need to reactivate recovered participants which were successfully COMPLETED or which began
+        // CLOSING. any others will only have been saved because of a heuristic outcome. we can safely drop
+        // them since we implement presumed abort.
+        if (!recovered || state == State.STATE_COMPLETED || state == State.STATE_CLOSING) {
+            ParticipantCompletionCoordinatorProcessor.getProcessor().activateCoordinator(this, id) ;
+        }
     }
 
     /**
-     * Set the coordinator and register
+     * Set the coordinator
      * @param coordinator
      */
     public void setCoordinator(final BAParticipantManager coordinator)
     {
         this.coordinator = coordinator ;
-        // unrecovered participants are always activated
-        // we only need to reactivate recovered participants which were successfully COMPLETED or which began
-        // CLOSING. any others will only have been saved because of a heuristic outcome. we can safely drop
-        // them since we implement presumed abort.
-        if (!recovered || state == State.STATE_COMPLETED || state == State.STATE_CLOSING) {
-            ParticipantCompletionCoordinatorProcessor.getProcessor().activateCoordinator(this, id) ;
-        }
     }
 
     /**
@@ -310,6 +313,35 @@
      * NotCompleting -> NotCompleting (invalid state)
      * Exiting -> Exiting (invalid state)
      * Ended -> Ended (resend Failed)
+     *
+     * In fact we only execute the transition to FAILING_ACTIVE and in this case we send a message to the
+     * coordinator by calling executeFail. This propagates the failure back thorugh the activityy hierarchy
+     * to the relevant participant and also marks the acivity as ABORT_ONLY.
+     *
+     * In the other failure cases we do not change to a FAILING_XXX state but instead go straight to ENDED
+     * and save the failing state in a field failureState. In these cases there will be a coordinator
+     * close/cancel/compensate thread waiting on the change to state FAILING_XXX. The change to FAILING_XXX
+     * will wake it up and, if the state is still FAILING_XXX, return a fault to the coordinator, However,
+     * the failing thread also sends a failed response and then call ended. This means the state might be
+     * transitioned to ENDED before the coordinator thread is scheduled. So, we have to avoid this race by
+     * going straight to ENDED and saving a failureState which the coordinator thread can check.
+     *
+     * The failureState also avoids another race condition for these (non-ACTIVE) cases. It means we don't have
+     * to send a message to the coordinator to notify the failure. We would need to do this after the state
+     * change as we need to exclude threads handling resent messages. However, the waiting coordinator thread
+     * is woken by the state change and so it might complete and remove the activity before the message is sent
+     * causing a NoSuchActivity exception in this thread. Settign the  failureState ensures that the failure is
+     * detected cleanly by any waiting coordinator thread.
+     *
+     * Fortuitously, this also avoids problems during recovery. During recovery we have no link to our
+     * coordinator available since there is no activity hierarchy in the current context. So, communicating
+     * failures via the failureState is the only way to ensure that the recovreed coordinator sees a failure.
+     * There is a further wrinkle here too. If a recovered coordinator times out waiting for a response we need
+     * to leave the engine in place when we ditch the recovered coordinator and then reestablish a link to it
+     * next time we recreate the coordinator. We cannot afford to miss a failure during this interval but the]
+     * engine must transition to ENDED after handling the failure. Saving the failure state ensures that the
+     * next time the coordinator calls cancel, compensate or close it receives a fault indicating a failure
+     * rather than just detecting that the pariticpant  has ended.
      */
     public void fail(final ExceptionType fail, final AddressingProperties addressingProperties,
         final ArjunaContext arjunaContext)
@@ -324,11 +356,13 @@
             }
             else if (current == State.STATE_CANCELING)
             {
-                changeState(State.STATE_FAILING_CANCELING) ;
+                failureState = State.STATE_FAILING_CANCELING;
+                ended();
             }
             else if (current == State.STATE_COMPENSATING)
             {
-                changeState(State.STATE_FAILING_COMPENSATING) ;
+                failureState = State.STATE_FAILING_COMPENSATING;
+                ended();
             }
         }
 
@@ -336,12 +370,9 @@
         {
             executeFail(fail.getExceptionIdentifier()) ;
         }
-        else if ((current == State.STATE_CANCELING) || (current == State.STATE_COMPENSATING))
+        else if ((current == State.STATE_CANCELING) || (current == State.STATE_COMPENSATING) ||
+                (current == State.STATE_ENDED))
         {
-            executeFail(fail.getExceptionIdentifier()) ;
-        }
-        else if (current == State.STATE_ENDED)
-        {
             sendFailed() ;
         }
     }
@@ -447,7 +478,7 @@
      */
     public State cancel()
     {
-        final State current ;
+        State current ;
         synchronized(this)
         {
             current = state ;
@@ -460,8 +491,16 @@
         if ((current == State.STATE_ACTIVE) || (current == State.STATE_CANCELING))
         {
             sendCancel() ;
-            return waitForState(State.STATE_CANCELING, TransportTimer.getTransportTimeout()) ;
+            current = waitForState(State.STATE_CANCELING, TransportTimer.getTransportTimeout()) ;
         }
+
+        // if we reached ended via a failure then make sure we return the failure state so that the coordinator
+        // sees the failure
+
+        if (current == State.STATE_ENDED && failureState != null) {
+            return failureState;
+        }
+        
         return current ;
     }
 
@@ -483,7 +522,7 @@
      */
     public State compensate()
     {
-        final State current ;
+        State current ;
         synchronized(this)
         {
             current = state ;
@@ -496,9 +535,30 @@
         if ((current == State.STATE_COMPLETED) || (current == State.STATE_COMPENSATING))
         {
             sendCompensate() ;
-            return waitForState(State.STATE_COMPENSATING, TransportTimer.getTransportTimeout()) ;
+            waitForState(State.STATE_COMPENSATING, TransportTimer.getTransportTimeout()) ;
         }
-        return current ;
+
+        synchronized(this) {
+            if (state != State.STATE_COMPENSATING) {
+                // if this is a recovered participant then ended will not have
+                // deactivated the entry so that this (recovery) thread can
+                // detect it and update its log entry. so we need to deactivate
+                // the entry here.
+
+                if (recovered) {
+                    ParticipantCompletionCoordinatorProcessor.getProcessor().deactivateCoordinator(this) ;
+                }
+
+                if (state == State.STATE_ENDED && failureState != null) {
+                    return failureState;
+                }
+
+                return state;
+            }  else {
+                // timeout -- leave participant in place as this TX will get retried later
+                return State.STATE_COMPENSATING;
+            }
+        }
     }
 
     /**
@@ -519,7 +579,7 @@
      */
     public State close()
     {
-        final State current ;
+        State current ;
         synchronized(this)
         {
             current = state ;
@@ -532,9 +592,30 @@
         if ((current == State.STATE_COMPLETED) || (current == State.STATE_CLOSING))
         {
             sendClose() ;
-            return waitForState(State.STATE_CLOSING, TransportTimer.getTransportTimeout()) ;
+            waitForState(State.STATE_CLOSING, TransportTimer.getTransportTimeout()) ;
         }
-        return current ;
+
+        synchronized(this) {
+            if (state != State.STATE_CLOSING) {
+                // if this is a recovered participant then ended will not have
+                // deactivated the entry so that this (recovery) thread can
+                // detect it and update its log entry. so we need to deactivate
+                // the entry here.
+
+                if (recovered) {
+                    ParticipantCompletionCoordinatorProcessor.getProcessor().deactivateCoordinator(this) ;
+                }
+
+                if (state == State.STATE_ENDED && failureState != null) {
+                    return failureState;
+                }
+
+                return state;
+            }  else {
+                // timeout -- leave participant in place as this TX will get retried later
+                return State.STATE_CLOSING;
+            }
+        }
     }
 
     /**
@@ -868,7 +949,18 @@
     private void ended()
     {
         changeState(State.STATE_ENDED) ;
-        ParticipantCompletionCoordinatorProcessor.getProcessor().deactivateCoordinator(this) ;
+        // participants which have not been recovered from the log can be deactivated now.
+
+        // participants which have been recovered are left for the recovery thread to deactivate.
+        // this is because the recovery thread may have timed out waiting for a response to
+        // a close/cancel message and gone on to complete its scan and suspend. the next scan
+        // will detect this activated participant and note that it has completed. if a crash
+        // happens in between the recovery thread can safely recreate and reactivate the
+        // participant and resend the commit since the commit/committed exchange is idempotent.
+        
+        if (!recovered) {
+            ParticipantCompletionCoordinatorProcessor.getProcessor().deactivateCoordinator(this) ;
+        }
     }
 
     /**

Modified: labs/jbosstm/trunk/XTS/WS-T/dev/src11/com/arjuna/wst11/stub/BusinessAgreementWithCoordinatorCompletionStub.java
===================================================================
--- labs/jbosstm/trunk/XTS/WS-T/dev/src11/com/arjuna/wst11/stub/BusinessAgreementWithCoordinatorCompletionStub.java	2008-11-17 15:07:59 UTC (rev 23895)
+++ labs/jbosstm/trunk/XTS/WS-T/dev/src11/com/arjuna/wst11/stub/BusinessAgreementWithCoordinatorCompletionStub.java	2008-11-17 18:35:05 UTC (rev 23896)
@@ -40,6 +40,7 @@
 import com.arjuna.webservices.logging.WSTLogger;
 import com.arjuna.webservices.soap.SoapUtils;
 import com.arjuna.webservices11.wsba.State;
+import com.arjuna.webservices11.wsba.processors.CoordinatorCompletionCoordinatorProcessor;
 import com.arjuna.webservices11.util.StreamHelper;
 import com.arjuna.wst.BusinessAgreementWithCoordinatorCompletionParticipant;
 import com.arjuna.wst.FaultedException;
@@ -47,10 +48,9 @@
 import com.arjuna.wst.SystemException;
 import com.arjuna.wst.WrongStateException;
 import com.arjuna.wst11.messaging.engines.CoordinatorCompletionCoordinatorEngine;
-import com.arjuna.wst11.RecoverableBusinessAgreementWithCoordinatorCompletionParticipant;
-import com.arjuna.wst11.BAParticipantManager;
+import com.arjuna.wst11.messaging.CoordinatorCompletionCoordinatorProcessorImpl;
 
-public class BusinessAgreementWithCoordinatorCompletionStub implements RecoverableBusinessAgreementWithCoordinatorCompletionParticipant, PersistableParticipant
+public class BusinessAgreementWithCoordinatorCompletionStub implements BusinessAgreementWithCoordinatorCompletionParticipant, PersistableParticipant
 {
     private static final QName QNAME_BACCWS_PARTICIPANT = new QName("baccwsParticipant") ;
     private CoordinatorCompletionCoordinatorEngine participant ;
@@ -284,15 +284,15 @@
             QName statename = new QName(ns, localPart, prefix);
             State state = State.toState11(statename);
 
-            participant = new CoordinatorCompletionCoordinatorEngine(id, endpointReference, state, true);
-            /*
-             * this hppens when the registrar first creates an engine -- we need to do something similar
-            BusinessAgreementWithParticipantCompletionImple participant = new BusinessAgreementWithParticipantCompletionImple(
-                    new BusinessAgreementWithParticipantCompletionStub(engine), id);
-            engine.setCoordinator(participant.participantManager()) ;
-
-            _coordManager.enlistParticipant(participant);
-            */
+            // if we already have an engine from a previous recovery scan or because
+            // we had a heuristic outcome then reuse it with luck it will have been committed
+            // or aborted between the last scan and this one
+            // note that whatever happens it will not have been removed from the table
+            // because it is marked as recovered
+            participant = (CoordinatorCompletionCoordinatorEngine) CoordinatorCompletionCoordinatorProcessor.getProcessor().getCoordinator(id);
+            if (participant == null) {
+                participant = new CoordinatorCompletionCoordinatorEngine(id, endpointReference, state, true);
+            }
             return true ;
         }
         catch (final Throwable th)
@@ -301,13 +301,4 @@
             return false ;
         }
     }
-
-    /**
-     * establish  a back channel from the coordinator side protocol engine to the coordinator.
-     *
-     * @param participantManager a manager which will forward incoming remote participant requests to the coordinator
-     */
-    public void setParticipantManager(BAParticipantManager participantManager) {
-        participant.setCoordinator(participantManager);
-    }
 }

Modified: labs/jbosstm/trunk/XTS/WS-T/dev/src11/com/arjuna/wst11/stub/BusinessAgreementWithParticipantCompletionStub.java
===================================================================
--- labs/jbosstm/trunk/XTS/WS-T/dev/src11/com/arjuna/wst11/stub/BusinessAgreementWithParticipantCompletionStub.java	2008-11-17 15:07:59 UTC (rev 23895)
+++ labs/jbosstm/trunk/XTS/WS-T/dev/src11/com/arjuna/wst11/stub/BusinessAgreementWithParticipantCompletionStub.java	2008-11-17 18:35:05 UTC (rev 23896)
@@ -40,6 +40,7 @@
 import com.arjuna.webservices.logging.WSTLogger;
 import com.arjuna.webservices.soap.SoapUtils;
 import com.arjuna.webservices11.wsba.State;
+import com.arjuna.webservices11.wsba.processors.ParticipantCompletionCoordinatorProcessor;
 import com.arjuna.webservices11.util.StreamHelper;
 import com.arjuna.wst.BusinessAgreementWithParticipantCompletionParticipant;
 import com.arjuna.wst.FaultedException;
@@ -47,10 +48,9 @@
 import com.arjuna.wst.SystemException;
 import com.arjuna.wst.WrongStateException;
 import com.arjuna.wst11.messaging.engines.ParticipantCompletionCoordinatorEngine;
-import com.arjuna.wst11.RecoverableBusinessAgreementWithParticipantCompletionParticipant;
-import com.arjuna.wst11.BAParticipantManager;
+import com.arjuna.wst11.messaging.ParticipantCompletionCoordinatorProcessorImpl;
 
-public class BusinessAgreementWithParticipantCompletionStub implements RecoverableBusinessAgreementWithParticipantCompletionParticipant, PersistableParticipant
+public class BusinessAgreementWithParticipantCompletionStub implements BusinessAgreementWithParticipantCompletionParticipant, PersistableParticipant
 {
     private static final QName QNAME_BAPCWS_PARTICIPANT = new QName("bapcwsParticipant") ;
 
@@ -246,25 +246,15 @@
             QName statename = new QName(ns, localPart, prefix);
             State state = State.toState11(statename);
 
-            participant = new ParticipantCompletionCoordinatorEngine(id, endpointReference, state, true);
-            // TODO -- work out how to fix this
-            // we need to obtain a participant manager allowing the engine to post events to the coordinator
-            // the normal one is obtained from the BusinessAgreementWithParticipantCompletionImple which wraps
-            // this stub. the registrar normally creates an engine, a stub and a BAWCPImple. it asks the BAWPCImple
-            // for a participant manager and passes it to the engine. to make things worse, the BAWPCImple relies
-            // upon being created inside an activity which identifies the relevant coordinator. this is because
-            // the manager it creates needs to access the coordinator and it uses the current activity to provide
-            // an access path. we cannot do this here because 1) the restore_state protocol is a simple top-down
-            // recursive model so does not give us a handle on either the enclosing BAWCImple or the ACCoordinator
-            // and 2) the BAWCImple does not know about the implementation of this stub so cannot access the engine
-            // it wraps and 3) we cannot install an activity at this point during recovery as we are still creating
-            // the coordinator which will coordinate it.
-            //
-            // if we obtain a handle on the current coordinator we can just create an alternative proxy to route
-            // messages directly, avoiding the activity hierarchy.
-            //
-            //participantManager = ???;
-            // participant.setCoordinator(participantManager) ;
+            // if we already have an engine from a previous recovery scan or because
+            // we had a heuristic outcome then reuse it with luck it will have been committed
+            // or aborted between the last scan and this one
+            // note that whatever happens it will not have been removed from the table
+            // because it is marked as recovered
+            participant = (ParticipantCompletionCoordinatorEngine) ParticipantCompletionCoordinatorProcessor.getProcessor().getCoordinator(id);
+            if (participant == null) {
+                participant = new ParticipantCompletionCoordinatorEngine(id, endpointReference, state, true);
+            }
             return true ;
         }
         catch (final Throwable th)
@@ -273,13 +263,4 @@
             return false ;
         }
     }
-
-    /**
-     * establish  a back channel from the coordinator side protocol engine to the coordinator.
-     *
-     * @param participantManager a manager which will forward incoming remote participant requests to the coordinator
-     */
-    public void setParticipantManager(BAParticipantManager participantManager) {
-        participant.setCoordinator(participantManager);
-    }
 }
\ No newline at end of file

Modified: labs/jbosstm/trunk/XTS/WS-T/tests/src/com/arjuna/wst/tests/junit/TestCoordinatorCompletionCoordinatorProcessor.java
===================================================================
--- labs/jbosstm/trunk/XTS/WS-T/tests/src/com/arjuna/wst/tests/junit/TestCoordinatorCompletionCoordinatorProcessor.java	2008-11-17 15:07:59 UTC (rev 23895)
+++ labs/jbosstm/trunk/XTS/WS-T/tests/src/com/arjuna/wst/tests/junit/TestCoordinatorCompletionCoordinatorProcessor.java	2008-11-17 18:35:05 UTC (rev 23896)
@@ -83,6 +83,10 @@
     public void deactivateCoordinator(CoordinatorCompletionCoordinatorInboundEvents coordinator) {
     }
 
+    public CoordinatorCompletionCoordinatorInboundEvents getCoordinator(String identifier) {
+        return null;  //To change body of implemented methods use File | Settings | File Templates.
+    }
+
     /**
      * Cancelled.
      *

Modified: labs/jbosstm/trunk/XTS/WS-T/tests/src/com/arjuna/wst/tests/junit/TestParticipantCompletionCoordinatorProcessor.java
===================================================================
--- labs/jbosstm/trunk/XTS/WS-T/tests/src/com/arjuna/wst/tests/junit/TestParticipantCompletionCoordinatorProcessor.java	2008-11-17 15:07:59 UTC (rev 23895)
+++ labs/jbosstm/trunk/XTS/WS-T/tests/src/com/arjuna/wst/tests/junit/TestParticipantCompletionCoordinatorProcessor.java	2008-11-17 18:35:05 UTC (rev 23896)
@@ -83,6 +83,10 @@
     public void deactivateCoordinator(ParticipantCompletionCoordinatorInboundEvents coordinator) {
     }
 
+    public ParticipantCompletionCoordinatorInboundEvents getCoordinator(String identifier) {
+        return null;  //To change body of implemented methods use File | Settings | File Templates.
+    }
+
     /**
      * Cancelled.
      *

Modified: labs/jbosstm/trunk/XTS/WS-T/tests/src/com/arjuna/wst11/tests/junit/TestCoordinatorCompletionCoordinatorProcessor.java
===================================================================
--- labs/jbosstm/trunk/XTS/WS-T/tests/src/com/arjuna/wst11/tests/junit/TestCoordinatorCompletionCoordinatorProcessor.java	2008-11-17 15:07:59 UTC (rev 23895)
+++ labs/jbosstm/trunk/XTS/WS-T/tests/src/com/arjuna/wst11/tests/junit/TestCoordinatorCompletionCoordinatorProcessor.java	2008-11-17 18:35:05 UTC (rev 23896)
@@ -84,6 +84,10 @@
     public void deactivateCoordinator(CoordinatorCompletionCoordinatorInboundEvents coordinator) {
     }
 
+    public CoordinatorCompletionCoordinatorInboundEvents getCoordinator(String identifier) {
+        return null;  //To change body of implemented methods use File | Settings | File Templates.
+    }
+
     /**
      * Cancelled.
      *

Modified: labs/jbosstm/trunk/XTS/WS-T/tests/src/com/arjuna/wst11/tests/junit/TestParticipantCompletionCoordinatorProcessor.java
===================================================================
--- labs/jbosstm/trunk/XTS/WS-T/tests/src/com/arjuna/wst11/tests/junit/TestParticipantCompletionCoordinatorProcessor.java	2008-11-17 15:07:59 UTC (rev 23895)
+++ labs/jbosstm/trunk/XTS/WS-T/tests/src/com/arjuna/wst11/tests/junit/TestParticipantCompletionCoordinatorProcessor.java	2008-11-17 18:35:05 UTC (rev 23896)
@@ -84,6 +84,10 @@
     public void deactivateCoordinator(ParticipantCompletionCoordinatorInboundEvents coordinator) {
     }
 
+    public ParticipantCompletionCoordinatorInboundEvents getCoordinator(String identifier) {
+        return null;  //To change body of implemented methods use File | Settings | File Templates.
+    }
+
     /**
      * Cancelled.
      *

Modified: labs/jbosstm/trunk/XTS/WSCF/classes/com/arjuna/mw/wscf/model/sagas/api/CoordinatorManager.java
===================================================================
--- labs/jbosstm/trunk/XTS/WSCF/classes/com/arjuna/mw/wscf/model/sagas/api/CoordinatorManager.java	2008-11-17 15:07:59 UTC (rev 23895)
+++ labs/jbosstm/trunk/XTS/WSCF/classes/com/arjuna/mw/wscf/model/sagas/api/CoordinatorManager.java	2008-11-17 18:35:05 UTC (rev 23896)
@@ -68,7 +68,7 @@
      * @exception SystemException Thrown if any other error occurs.
      */
 
-    public void enlistParticipant (RecoverableParticipant act) throws NoActivityException, WrongStateException, DuplicateParticipantException, InvalidParticipantException, SystemException;
+    public void enlistParticipant (Participant act) throws NoActivityException, WrongStateException, DuplicateParticipantException, InvalidParticipantException, SystemException;
 
     /**
      * Remove the specified participant from the coordinator associated with

Deleted: labs/jbosstm/trunk/XTS/WSCF/classes/com/arjuna/mw/wscf/model/sagas/participants/RecoverableParticipant.java
===================================================================
--- labs/jbosstm/trunk/XTS/WSCF/classes/com/arjuna/mw/wscf/model/sagas/participants/RecoverableParticipant.java	2008-11-17 15:07:59 UTC (rev 23895)
+++ labs/jbosstm/trunk/XTS/WSCF/classes/com/arjuna/mw/wscf/model/sagas/participants/RecoverableParticipant.java	2008-11-17 18:35:05 UTC (rev 23896)
@@ -1,16 +0,0 @@
-package com.arjuna.mw.wscf.model.sagas.participants;
-
-import com.arjuna.mwlabs.wscf.model.sagas.arjunacore.ACCoordinator;
-
-/**
- * extension of the Participant API implemented by BA Participant Stubs which allows the coordinator
- * to establish a back channel from the participant engine to the corodinator during recovery processing.
- * the back channel is necessary so that remote participant requests can flow via the protocol engine to
- * to the coordinator. the back channel is normally established using the activivty mechanism but this
- * is not possible when recreating participant stubs and their engines during recovery as there is no thread
- * association in place.
- */
-public interface RecoverableParticipant extends Participant
-{
-    public void setCoordinator(ACCoordinator coordinator);
-}

Deleted: labs/jbosstm/trunk/XTS/WSCF/classes/com/arjuna/mw/wscf/model/sagas/participants/RecoverableParticipantWithComplete.java
===================================================================
--- labs/jbosstm/trunk/XTS/WSCF/classes/com/arjuna/mw/wscf/model/sagas/participants/RecoverableParticipantWithComplete.java	2008-11-17 15:07:59 UTC (rev 23895)
+++ labs/jbosstm/trunk/XTS/WSCF/classes/com/arjuna/mw/wscf/model/sagas/participants/RecoverableParticipantWithComplete.java	2008-11-17 18:35:05 UTC (rev 23896)
@@ -1,13 +0,0 @@
-package com.arjuna.mw.wscf.model.sagas.participants;
-
-/**
- * extension of the ParticipantWithComplete API implemented by BA Participant Records which allows the coordinator
- * to establish a back channel form the participant engine to the corodinator during recovery processing.
- * the back channel is necessary so that remote participant requests can flow via the protocol engine to
- * to the coordinator. the back channel is normally established using the activivty mechanism but this
- * is not possible when recreating participants and their engines during recovery as there is no thread
- * association in place.
- */
-public interface RecoverableParticipantWithComplete extends RecoverableParticipant, ParticipantWithComplete
-{
-}

Modified: labs/jbosstm/trunk/XTS/WSCF/classes/com/arjuna/mwlabs/wscf/model/sagas/arjunacore/ACCoordinator.java
===================================================================
--- labs/jbosstm/trunk/XTS/WSCF/classes/com/arjuna/mwlabs/wscf/model/sagas/arjunacore/ACCoordinator.java	2008-11-17 15:07:59 UTC (rev 23895)
+++ labs/jbosstm/trunk/XTS/WSCF/classes/com/arjuna/mwlabs/wscf/model/sagas/arjunacore/ACCoordinator.java	2008-11-17 18:35:05 UTC (rev 23896)
@@ -388,13 +388,13 @@
 	 *                Thrown if any other error occurs.
 	 */
 
-	public void enlistParticipant (RecoverableParticipant act) throws WrongStateException,
+	public void enlistParticipant (Participant act) throws WrongStateException,
 			DuplicateParticipantException, InvalidParticipantException,
 			SystemException
 	{
 		if (act == null) throw new InvalidParticipantException();
 
-		AbstractRecord rec = new ParticipantRecord((RecoverableParticipant)act, new Uid());
+		AbstractRecord rec = new ParticipantRecord((Participant)act, new Uid());
 
 		if (add(rec) != AddOutcome.AR_ADDED) throw new WrongStateException();
 		else

Modified: labs/jbosstm/trunk/XTS/WSCF/classes/com/arjuna/mwlabs/wscf/model/sagas/arjunacore/CoordinatorControl.java
===================================================================
--- labs/jbosstm/trunk/XTS/WSCF/classes/com/arjuna/mwlabs/wscf/model/sagas/arjunacore/CoordinatorControl.java	2008-11-17 15:07:59 UTC (rev 23895)
+++ labs/jbosstm/trunk/XTS/WSCF/classes/com/arjuna/mwlabs/wscf/model/sagas/arjunacore/CoordinatorControl.java	2008-11-17 18:35:05 UTC (rev 23896)
@@ -213,7 +213,7 @@
      * This implementation only supports coordination at the end of the
      * activity.
      *
-     * @param CompletionStatus cs The completion status to use when determining
+     * @param cs The completion status to use when determining
      * how to execute the protocol.
      *
      * @exception WrongStateException Thrown if the coordinator is in a state
@@ -304,7 +304,7 @@
      * Enrol the specified participant with the coordinator associated with
      * the current thread.
      *
-     * @param Participant act The participant.
+     * @param act The participant.
      *
      * @exception WrongStateException Thrown if the coordinator is not in a
      * state that allows participants to be enrolled.
@@ -315,7 +315,7 @@
      * @exception SystemException Thrown if any other error occurs.
      */
 
-    public void enlistParticipant (RecoverableParticipant act) throws WrongStateException, DuplicateParticipantException, InvalidParticipantException, NoCoordinatorException, SystemException
+    public void enlistParticipant (Participant act) throws WrongStateException, DuplicateParticipantException, InvalidParticipantException, NoCoordinatorException, SystemException
     {
 	currentCoordinator().enlistParticipant(act);
     }

Modified: labs/jbosstm/trunk/XTS/WSCF/classes/com/arjuna/mwlabs/wscf/model/sagas/arjunacore/CoordinatorServiceImple.java
===================================================================
--- labs/jbosstm/trunk/XTS/WSCF/classes/com/arjuna/mwlabs/wscf/model/sagas/arjunacore/CoordinatorServiceImple.java	2008-11-17 15:07:59 UTC (rev 23895)
+++ labs/jbosstm/trunk/XTS/WSCF/classes/com/arjuna/mwlabs/wscf/model/sagas/arjunacore/CoordinatorServiceImple.java	2008-11-17 18:35:05 UTC (rev 23896)
@@ -398,7 +398,7 @@
      * @exception SystemException Thrown if any other error occurs.
      */
 
-    public void enlistParticipant (RecoverableParticipant act) throws WrongStateException, DuplicateParticipantException, InvalidParticipantException, NoCoordinatorException, SystemException
+    public void enlistParticipant (Participant act) throws WrongStateException, DuplicateParticipantException, InvalidParticipantException, NoCoordinatorException, SystemException
     {
 	_coordManager.enlistParticipant(act);
     }

Modified: labs/jbosstm/trunk/XTS/WSCF/classes/com/arjuna/mwlabs/wscf/model/sagas/arjunacore/ParticipantRecord.java
===================================================================
--- labs/jbosstm/trunk/XTS/WSCF/classes/com/arjuna/mwlabs/wscf/model/sagas/arjunacore/ParticipantRecord.java	2008-11-17 15:07:59 UTC (rev 23895)
+++ labs/jbosstm/trunk/XTS/WSCF/classes/com/arjuna/mwlabs/wscf/model/sagas/arjunacore/ParticipantRecord.java	2008-11-17 18:35:05 UTC (rev 23896)
@@ -41,7 +41,6 @@
 
 import com.arjuna.mw.wscf.model.sagas.participants.Participant;
 import com.arjuna.mw.wscf.model.sagas.participants.ParticipantWithComplete;
-import com.arjuna.mw.wscf.model.sagas.participants.RecoverableParticipant;
 import com.arjuna.mw.wscf.model.sagas.exceptions.CompensateFailedException;
 import com.arjuna.mw.wscf.model.sagas.exceptions.CancelFailedException;
 
@@ -74,7 +73,7 @@
 	 *          ParticipantRecord {0} - null participant provided!
 	 */
 
-	public ParticipantRecord (RecoverableParticipant theResource, Uid id)
+	public ParticipantRecord (Participant theResource, Uid id)
 	{
 		super(id, null, ObjectType.ANDPERSISTENT);
 
@@ -669,7 +668,7 @@
 			{
                 String resourcehandleImplClassName = os.unpackString();
                 Class clazz = ClassLoaderHelper.forName(ParticipantRecord.class, resourcehandleImplClassName);
-                _resourceHandle = (RecoverableParticipant)clazz.newInstance();
+                _resourceHandle = (Participant)clazz.newInstance();
 
                 result = _resourceHandle.restore_state(os);
 
@@ -737,26 +736,6 @@
 		return result;
 	}
 
-    /**
-     * called during recovery activation to propagate the coordinator to the underlying stubs and their protocol
-     * engines allowing the engines to establish a back channel to the cooridnator for flow of remote participant
-     * requests.
-     */
-    
-    public void setRecoveryCoordinator(ACCoordinator coordinator)
-    {
-        try {
-            // try to propagate setCoordinator to the resource
-
-            RecoverableParticipant recoverableParticipant = (RecoverableParticipant) _resourceHandle;
-            recoverableParticipant.setCoordinator(coordinator);
-        } catch (ClassCastException e) {
-            // ignore as this is obviously not an instance of RecoverableParticipant
-            // it must be a participant registered via the local API which means there is
-            // no BAParticipantManager instance around to drive messages to the coordinator
-        }
-    }
-
     public String type ()
 	{
 		return "/StateManager/AbstractRecord/WSCF/ArjunaCore/ParticipantRecord";
@@ -854,7 +833,7 @@
 		_coordId = null;
 	}
 
-	private RecoverableParticipant _resourceHandle;
+	private Participant _resourceHandle;
 
 	private long _timeout;
 

Modified: labs/jbosstm/trunk/XTS/WSTX/classes10/com/arjuna/mwlabs/wst/ba/participants/BusinessAgreementWithCoordinatorCompletionImple.java
===================================================================
--- labs/jbosstm/trunk/XTS/WSTX/classes10/com/arjuna/mwlabs/wst/ba/participants/BusinessAgreementWithCoordinatorCompletionImple.java	2008-11-17 15:07:59 UTC (rev 23895)
+++ labs/jbosstm/trunk/XTS/WSTX/classes10/com/arjuna/mwlabs/wst/ba/participants/BusinessAgreementWithCoordinatorCompletionImple.java	2008-11-17 18:35:05 UTC (rev 23896)
@@ -35,7 +35,6 @@
 import com.arjuna.mw.wsas.exceptions.WrongStateException;
 import com.arjuna.mw.wscf.exceptions.InvalidParticipantException;
 import com.arjuna.wst.BusinessAgreementWithCoordinatorCompletionParticipant;
-import com.arjuna.wst.RecoverableBusinessAgreementWithCoordinatorCompletionParticipant;
 
 /**
  * @author Mark Little (mark.little at arjuna.com)
@@ -46,11 +45,11 @@
 
 public class BusinessAgreementWithCoordinatorCompletionImple extends
 		BusinessAgreementWithParticipantCompletionImple implements
-		com.arjuna.mw.wscf.model.sagas.participants.RecoverableParticipantWithComplete
+		com.arjuna.mw.wscf.model.sagas.participants.ParticipantWithComplete
 {
 
 	public BusinessAgreementWithCoordinatorCompletionImple (
-			RecoverableBusinessAgreementWithCoordinatorCompletionParticipant participant,
+			BusinessAgreementWithCoordinatorCompletionParticipant participant,
 			String identifier)
 	{
 		super(participant, identifier);

Modified: labs/jbosstm/trunk/XTS/WSTX/classes10/com/arjuna/mwlabs/wst/ba/participants/BusinessAgreementWithParticipantCompletionImple.java
===================================================================
--- labs/jbosstm/trunk/XTS/WSTX/classes10/com/arjuna/mwlabs/wst/ba/participants/BusinessAgreementWithParticipantCompletionImple.java	2008-11-17 15:07:59 UTC (rev 23895)
+++ labs/jbosstm/trunk/XTS/WSTX/classes10/com/arjuna/mwlabs/wst/ba/participants/BusinessAgreementWithParticipantCompletionImple.java	2008-11-17 18:35:05 UTC (rev 23896)
@@ -43,7 +43,6 @@
 import com.arjuna.mwlabs.wst.ba.remote.BARecoveryParticipantManagerImple;
 import com.arjuna.mwlabs.wscf.model.sagas.arjunacore.ACCoordinator;
 import com.arjuna.wst.BusinessAgreementWithParticipantCompletionParticipant;
-import com.arjuna.wst.RecoverableBusinessAgreementWithParticipantCompletionParticipant;
 
 // TODO crash recovery (for EVERYTHING!!)
 
@@ -57,11 +56,11 @@
  */
 
 public class BusinessAgreementWithParticipantCompletionImple implements
-		com.arjuna.mw.wscf.model.sagas.participants.RecoverableParticipant
+		com.arjuna.mw.wscf.model.sagas.participants.Participant
 {
 //
 	public BusinessAgreementWithParticipantCompletionImple (
-			RecoverableBusinessAgreementWithParticipantCompletionParticipant resource,
+			BusinessAgreementWithParticipantCompletionParticipant resource,
 			String id)
 	{
 		_resource = resource;
@@ -226,7 +225,7 @@
         final Object resource = PersistableParticipantHelper.restore_state(is) ;
         if (resource != null)
         {
-            _resource = (RecoverableBusinessAgreementWithParticipantCompletionParticipant)resource ;
+            _resource = (BusinessAgreementWithParticipantCompletionParticipant)resource ;
             return true ;
         }
         else
@@ -235,20 +234,8 @@
         }
 	}
 
-    /**
-     * establish a back channel from the underlying stub to the coordinator by creating a participant manager which
-     * will forward messages to the coordinator. this is only called during recovery processing
-     *
-     * @param coordinator
-     */
-    public void setCoordinator(ACCoordinator coordinator)
-    {
-        _baParticipantManager = new BARecoveryParticipantManagerImple(coordinator, _identifier);
-        _resource.setParticipantManager(_baParticipantManager);
-    }
+	protected BusinessAgreementWithParticipantCompletionParticipant _resource;
 
-	protected RecoverableBusinessAgreementWithParticipantCompletionParticipant _resource;
-
 	private String _identifier = null;
 
 	private com.arjuna.wst.BAParticipantManager _baParticipantManager = null;

Modified: labs/jbosstm/trunk/XTS/WSTX/classes11/com/arjuna/mwlabs/wst11/ba/participants/BusinessAgreementWithCoordinatorCompletionImple.java
===================================================================
--- labs/jbosstm/trunk/XTS/WSTX/classes11/com/arjuna/mwlabs/wst11/ba/participants/BusinessAgreementWithCoordinatorCompletionImple.java	2008-11-17 15:07:59 UTC (rev 23895)
+++ labs/jbosstm/trunk/XTS/WSTX/classes11/com/arjuna/mwlabs/wst11/ba/participants/BusinessAgreementWithCoordinatorCompletionImple.java	2008-11-17 18:35:05 UTC (rev 23896)
@@ -35,8 +35,6 @@
 import com.arjuna.mw.wsas.exceptions.WrongStateException;
 import com.arjuna.mw.wscf.exceptions.InvalidParticipantException;
 import com.arjuna.wst.BusinessAgreementWithCoordinatorCompletionParticipant;
-import com.arjuna.mwlabs.wst11.ba.participants.BusinessAgreementWithParticipantCompletionImple;
-import com.arjuna.wst11.RecoverableBusinessAgreementWithCoordinatorCompletionParticipant;
 
 /**
  * @author Mark Little (mark.little at arjuna.com)
@@ -47,11 +45,11 @@
 
 public class BusinessAgreementWithCoordinatorCompletionImple extends
         BusinessAgreementWithParticipantCompletionImple implements
-		com.arjuna.mw.wscf.model.sagas.participants.RecoverableParticipantWithComplete
+		com.arjuna.mw.wscf.model.sagas.participants.ParticipantWithComplete
 {
 
 	public BusinessAgreementWithCoordinatorCompletionImple(
-			RecoverableBusinessAgreementWithCoordinatorCompletionParticipant participant,
+			BusinessAgreementWithCoordinatorCompletionParticipant participant,
 			String identifier)
 	{
 		super(participant, identifier);

Modified: labs/jbosstm/trunk/XTS/WSTX/classes11/com/arjuna/mwlabs/wst11/ba/participants/BusinessAgreementWithParticipantCompletionImple.java
===================================================================
--- labs/jbosstm/trunk/XTS/WSTX/classes11/com/arjuna/mwlabs/wst11/ba/participants/BusinessAgreementWithParticipantCompletionImple.java	2008-11-17 15:07:59 UTC (rev 23895)
+++ labs/jbosstm/trunk/XTS/WSTX/classes11/com/arjuna/mwlabs/wst11/ba/participants/BusinessAgreementWithParticipantCompletionImple.java	2008-11-17 18:35:05 UTC (rev 23896)
@@ -42,14 +42,8 @@
 import com.arjuna.mw.wscf.model.sagas.exceptions.CancelFailedException;
 import com.arjuna.mwlabs.wst.util.PersistableParticipantHelper;
 import com.arjuna.mwlabs.wst11.ba.remote.BAParticipantManagerImple;
-import com.arjuna.mwlabs.wst11.ba.remote.BARecoveryParticipantManagerImple;
-import com.arjuna.mwlabs.wscf.model.sagas.arjunacore.ACCoordinator;
 import com.arjuna.wst.BusinessAgreementWithParticipantCompletionParticipant;
-import com.arjuna.wst.stub.SystemCommunicationException;
 import com.arjuna.wst11.BAParticipantManager;
-import com.arjuna.wst11.RecoverableBusinessAgreementWithParticipantCompletionParticipant;
-import com.arjuna.wst11.messaging.engines.ParticipantCompletionCoordinatorEngine;
-import com.arjuna.wst11.stub.BusinessAgreementWithParticipantCompletionStub;
 
 import java.io.IOException;
 
@@ -65,11 +59,11 @@
  */
 
 public class BusinessAgreementWithParticipantCompletionImple implements
-		com.arjuna.mw.wscf.model.sagas.participants.RecoverableParticipant
+		com.arjuna.mw.wscf.model.sagas.participants.Participant
 {
 //
 public BusinessAgreementWithParticipantCompletionImple(
-        RecoverableBusinessAgreementWithParticipantCompletionParticipant resource,
+        BusinessAgreementWithParticipantCompletionParticipant resource,
         String id)
 {
     _resource = resource;
@@ -243,7 +237,7 @@
         final Object resource = PersistableParticipantHelper.restore_state(is) ;
         if (resource != null)
         {
-            _resource = (RecoverableBusinessAgreementWithParticipantCompletionParticipant)resource ;
+            _resource = (BusinessAgreementWithParticipantCompletionParticipant)resource ;
             return true ;
         }
         else
@@ -252,20 +246,8 @@
         }
 	}
 
-    /**
-     * establish a back channel from the underlying stub to the coordinator by creating a participant manager which
-     * will forward messages to the coordinator. thisis oly called during recovery processing
-     *
-     * @param coordinator
-     */
-    public void setCoordinator(ACCoordinator coordinator)
-    {
-        _baParticipantManager = new BARecoveryParticipantManagerImple(coordinator, _identifier);
-        _resource.setParticipantManager(_baParticipantManager);
-    }
+	protected BusinessAgreementWithParticipantCompletionParticipant _resource;
 
-	protected RecoverableBusinessAgreementWithParticipantCompletionParticipant _resource;
-
 	private String _identifier = null;
 
 	private BAParticipantManager _baParticipantManager = null;

Modified: labs/jbosstm/trunk/XTS/sar/src/org/jboss/jbossts/xts/recovery/coordinator/ba/RecoverACCoordinator.java
===================================================================
--- labs/jbosstm/trunk/XTS/sar/src/org/jboss/jbossts/xts/recovery/coordinator/ba/RecoverACCoordinator.java	2008-11-17 15:07:59 UTC (rev 23895)
+++ labs/jbosstm/trunk/XTS/sar/src/org/jboss/jbossts/xts/recovery/coordinator/ba/RecoverACCoordinator.java	2008-11-17 18:35:05 UTC (rev 23896)
@@ -56,7 +56,6 @@
                 if (absRec instanceof ParticipantRecord)
                 {
                     ParticipantRecord pr = (ParticipantRecord) absRec;
-                    pr.setRecoveryCoordinator(this);
                 }
 
                 absRec = iter.iterate();




More information about the jboss-svn-commits mailing list