Tying together the stubs/skeletons with logic. Changed to handle wsa:submission reference parameters.
Refactored coordination/SimpleCoordinationContext.java and moved common code pieces to KandulaUtils.java

Few other changes due to Axis2 deployment changes
diff --git a/src/org/apache/kandula/Constants.java b/src/org/apache/kandula/Constants.java
index a90ea02..c8c4cb0 100644
--- a/src/org/apache/kandula/Constants.java
+++ b/src/org/apache/kandula/Constants.java
@@ -1,70 +1,90 @@
-/*
- * Copyright  2004 The Apache Software Foundation.
- *
- *  Licensed under the Apache License, Version 2.0 (the "License");
- *  you may not use this file except in compliance with the License.
- *  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing, software
- *  distributed under the License is distributed on an "AS IS" BASIS,
- *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *  See the License for the specific language governing permissions and
- *  limitations under the License.
- *
- */
-package org.apache.kandula;
-
-/**
- * @author <a href="mailto:thilina@opensource.lk"> Thilina Gunarathne </a>
- */
-abstract public interface Constants {
-
-    //WS-Coordination URI's
-
-    public static final String WS_COOR = "http://schemas.xmlsoap.org/ws/2004/10/wscoor";
-
-    public static final String WS_COOR_CREATE_COORDINATIONCONTEXT = "http://schemas.xmlsoap.org/ws/2004/10/wscoor/CreateCoordinationContext";
-
-    public static final String WS_COOR_CREATE_COORDINATIONCONTEXT_RESPONSE = "http://schemas.xmlsoap.org/ws/2004/10/wscoor/CreateCoordinationContextResponse";
-
-    public static final String WS_COOR_REGISTER = "http://schemas.xmlsoap.org/ws/2004/10/wscoor/Register";
-
-    public static final String WS_COOR_REGISTER_RESPONSE = "http://schemas.xmlsoap.org/ws/2004/10/wscoor/RegisterResponse";
-
-    //WS-AT URI's
-
-    public static final String WS_AT = "http://schemas.xmlsoap.org/ws/2004/10/wsat";
-
-    public static final String WS_AT_COMPLETION = "http://schemas.xmlsoap.org/ws/2004/10/wsat/Completion";
-
-    public static final String WS_AT_COMMIT = "http://schemas.xmlsoap.org/ws/2004/10/wsat/Commit";
-
-    public static final String WS_AT_COMMITTED = "http://schemas.xmlsoap.org/ws/2004/10/wsat/Committed";
-
-    public static final String WS_AT_ROLLBACK = "http://schemas.xmlsoap.org/ws/2004/10/wsat/Rollback";
-
-    public static final String WS_AT_ABORTED = "http://schemas.xmlsoap.org/ws/2004/10/wsat/Aborted";
-
-    public static final String WS_AT_DURABLE2PC = "http://schemas.xmlsoap.org/ws/2004/10/wsat/Durable2PC";
-
-    public static final String WS_AT_VOLATILE2PC = "http://schemas.xmlsoap.org/ws/2004/10/wsat/Volatile2PC";
-
-    public static final String WS_AT_PREPARE = "http://schemas.xmlsoap.org/ws/2004/10/wsat/Prepare";
-
-    public static final String WS_AT_PREPARED = "http://schemas.xmlsoap.org/ws/2004/10/wsat/Preapared";
-
-    public static final String WS_AT_REPLAY = "http://schemas.xmlsoap.org/ws/2004/10/wsat/Replay";
-
-    public static final String WS_AT_READONLY = "http://schemas.xmlsoap.org/ws/2004/10/wsat/ReadOnly";
-
-    public static final String SUB_VOLATILE_REGISTERED = "registered for volatile 2PC";
-
-    public static final String SUB_DURABLE_REGISTERED = "registered for durable 2PC";
-
-    //WS-BA URI's
-
-    public static final String WS_BA = "http://schemas.xmlsoap.org/ws/2004/10/wsba";
-
+/*

+ * Copyright  2004 The Apache Software Foundation.

+ *

+ *  Licensed under the Apache License, Version 2.0 (the "License");

+ *  you may not use this file except in compliance with the License.

+ *  You may obtain a copy of the License at

+ *

+ *      http://www.apache.org/licenses/LICENSE-2.0

+ *

+ *  Unless required by applicable law or agreed to in writing, software

+ *  distributed under the License is distributed on an "AS IS" BASIS,

+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

+ *  See the License for the specific language governing permissions and

+ *  limitations under the License.

+ *

+ */

+package org.apache.kandula;

+

+import javax.xml.namespace.QName;

+

+/**

+ * @author <a href="mailto:thilina@opensource.lk"> Thilina Gunarathne </a>

+ */

+abstract public interface Constants {

+

+    //WS-Coordination URI's

+

+    public static final String WS_COOR = "http://schemas.xmlsoap.org/ws/2004/10/wscoor";

+

+    public static final String WS_COOR_CREATE_COORDINATIONCONTEXT = "http://schemas.xmlsoap.org/ws/2004/10/wscoor/CreateCoordinationContext";

+

+    public static final String WS_COOR_CREATE_COORDINATIONCONTEXT_RESPONSE = "http://schemas.xmlsoap.org/ws/2004/10/wscoor/CreateCoordinationContextResponse";

+

+    public static final String WS_COOR_REGISTER = "http://schemas.xmlsoap.org/ws/2004/10/wscoor/Register";

+

+    public static final String WS_COOR_REGISTER_RESPONSE = "http://schemas.xmlsoap.org/ws/2004/10/wscoor/RegisterResponse";

+

+    //WS-AT URI's

+

+    public static final String WS_AT = "http://schemas.xmlsoap.org/ws/2004/10/wsat";

+

+    public static final String WS_AT_COMPLETION = "http://schemas.xmlsoap.org/ws/2004/10/wsat/Completion";

+

+    public static final String WS_AT_COMMIT = "http://schemas.xmlsoap.org/ws/2004/10/wsat/Commit";

+

+    public static final String WS_AT_COMMITTED = "http://schemas.xmlsoap.org/ws/2004/10/wsat/Committed";

+

+    public static final String WS_AT_ROLLBACK = "http://schemas.xmlsoap.org/ws/2004/10/wsat/Rollback";

+

+    public static final String WS_AT_ABORTED = "http://schemas.xmlsoap.org/ws/2004/10/wsat/Aborted";

+

+    public static final String WS_AT_DURABLE2PC = "http://schemas.xmlsoap.org/ws/2004/10/wsat/Durable2PC";

+

+    public static final String WS_AT_VOLATILE2PC = "http://schemas.xmlsoap.org/ws/2004/10/wsat/Volatile2PC";

+

+    public static final String WS_AT_PREPARE = "http://schemas.xmlsoap.org/ws/2004/10/wsat/Prepare";

+

+    public static final String WS_AT_PREPARED = "http://schemas.xmlsoap.org/ws/2004/10/wsat/Preapared";

+

+    public static final String WS_AT_REPLAY = "http://schemas.xmlsoap.org/ws/2004/10/wsat/Replay";

+

+    public static final String WS_AT_READONLY = "http://schemas.xmlsoap.org/ws/2004/10/wsat/ReadOnly";

+

+    public static final String SUB_VOLATILE_REGISTERED = "registered for volatile 2PC";

+

+    public static final String SUB_DURABLE_REGISTERED = "registered for durable 2PC";

+

+    //WS-BA URI's

+

+    public static final String WS_BA = "http://schemas.xmlsoap.org/ws/2004/10/wsba";

+    

+    //Kandula Specific Constants----------------------------------------------------------------------------------------------------

+    public static String KANDULA_URI = "http://ws.apache.org/kandula";

+

+    public static String KANDULA_RESOURCE = "KandulaResource";

+    

+    public static String KANDULA_PRE = "kand";

+    

+    public static final QName TRANSACTION_ID_PARAMETER = new QName(

+            KANDULA_URI, "TransactionID",KANDULA_PRE);

+    

+    public static final QName REQUESTER_ID_PARAMETER = new QName(

+           KANDULA_URI, "RequesterID",KANDULA_PRE);

+    

+    public static final QName ENLISTMENT_ID_PARAMETER = new QName(

+            KANDULA_URI, "EnlistmentID",KANDULA_PRE);

+

+

+

 }
\ No newline at end of file
diff --git a/src/org/apache/kandula/context/AbstractContext.java b/src/org/apache/kandula/context/AbstractContext.java
index 4d1500e..c72fc61 100644
--- a/src/org/apache/kandula/context/AbstractContext.java
+++ b/src/org/apache/kandula/context/AbstractContext.java
@@ -18,8 +18,6 @@
 
 import java.util.HashMap;
 
-import javax.xml.namespace.QName;
-
 import org.apache.axis2.addressing.AnyContentType;
 import org.apache.axis2.addressing.EndpointReference;
 import org.apache.kandula.Status.CoordinatorStatus;
@@ -42,6 +40,12 @@
 
     protected CoordinationContext coordinationContext = null;
 
+    public static String REQUESTER_ID = "requesterID";
+
+    public static String COORDINATION_EPR = "coordinationEPR";
+
+    public static String ACTIVATION_EPR = "activationEPR";
+
     protected AbstractContext() {
         propertyBag = new HashMap();
     }
@@ -52,9 +56,6 @@
         EndpointReference registrationEpr = EndpointReferenceFactory
                 .getInstance().getRegistrationEndpoint(activityID);
         AnyContentType referenceProp = new AnyContentType();
-        referenceProp.addReferenceValue(new QName(
-                "http://webservice.apache.org/~thilina", "myapp", "ID"),
-                activityID);
         registrationEpr.setReferenceProperties(referenceProp);
         coordinationContext = CoordinationContext.Factory.newContext(
                 activityID, coordinationType, registrationEpr);
diff --git a/src/org/apache/kandula/context/Participant.java b/src/org/apache/kandula/context/Participant.java
index ecba70d..42b3877 100644
--- a/src/org/apache/kandula/context/Participant.java
+++ b/src/org/apache/kandula/context/Participant.java
@@ -25,16 +25,15 @@
  */
 //TODO see whether we can avoid this class
 public class Participant {
-    
+
     private EndpointReference epr;
 
     private String protocol;
 
     private int status;
-    
+
     private String enlistmentId;
 
-    
     /**
      * @param epr
      * @param protocol
@@ -47,38 +46,44 @@
         this.protocol = protocol;
         this.enlistmentId = enlistmentId;
     }
-    
+
     /**
      * @return Returns the enlistmentId.
      */
     public String getEnlistmentId() {
         return enlistmentId;
     }
-    
+
     /**
      * @return Returns the epr.
      */
     public EndpointReference getEpr() {
         return epr;
     }
+
     /**
-     * @param epr The epr to set.
+     * @param epr
+     *            The epr to set.
      */
     public void setEpr(EndpointReference epr) {
         this.epr = epr;
     }
+
     /**
      * @return Returns the status.
      */
     public int getStatus() {
         return status;
     }
+
     /**
-     * @param status The status to set.
+     * @param status
+     *            The status to set.
      */
     public void setStatus(int status) {
         this.status = status;
     }
+
     /**
      * @return Returns the protocol.
      */
diff --git a/src/org/apache/kandula/context/at/ATActivityContext.java b/src/org/apache/kandula/context/at/ATActivityContext.java
index 7ffbd9c..ea92f8a 100644
--- a/src/org/apache/kandula/context/at/ATActivityContext.java
+++ b/src/org/apache/kandula/context/at/ATActivityContext.java
@@ -54,12 +54,6 @@
 
     private EndpointReference parentEPR;
 
-    public static String REQUESTER_ID = "requesterID";
-
-    public static String COORDINATION_EPR = "coordinationEPR";
-
-    public static String ACTIVATION_EPR = "activationEPR";
-
     /**
      * Used when creating new activities
      */
@@ -107,11 +101,11 @@
             String protocol) throws AbstractKandulaException {
         String enlistmentID = KandulaUtils.getRandomStringOf18Characters();
         if (Constants.WS_AT_VOLATILE2PC.equals(protocol)) {
-            addVolatileParticipant(participantEPR,enlistmentID);
+            addVolatileParticipant(participantEPR, enlistmentID);
             return EndpointReferenceFactory.getInstance().get2PCEndpoint(
                     this.activityID);
         } else if (Constants.WS_AT_DURABLE2PC.equals(protocol)) {
-            addDurableParticipant(participantEPR,enlistmentID);
+            addDurableParticipant(participantEPR, enlistmentID);
             return EndpointReferenceFactory.getInstance().get2PCEndpoint(
                     this.activityID);
         } else if (Constants.WS_AT_COMPLETION.equals(protocol)) {
@@ -123,19 +117,21 @@
         }
     }
 
-    public void addVolatileParticipant(EndpointReference participantEPR, String enlistmentID)
-            throws AbstractKandulaException {
+    public void addVolatileParticipant(EndpointReference participantEPR,
+            String enlistmentID) throws AbstractKandulaException {
         if (volatileParticipantsTable.contains(participantEPR))
             throw new AlreadyRegisteredException();
-        Participant participant = new Participant(participantEPR, Constants.WS_AT_VOLATILE2PC,enlistmentID);
+        Participant participant = new Participant(participantEPR,
+                Constants.WS_AT_VOLATILE2PC, enlistmentID);
         volatileParticipantsTable.put(enlistmentID, participant);
     }
 
-    public void addDurableParticipant(EndpointReference participantEPR, String enlistmentID)
-            throws AlreadyRegisteredException {
+    public void addDurableParticipant(EndpointReference participantEPR,
+            String enlistmentID) throws AlreadyRegisteredException {
         if (durableParticipantsTable.contains(participantEPR))
             throw new AlreadyRegisteredException();
-        Participant participant = new Participant(participantEPR, Constants.WS_AT_DURABLE2PC,enlistmentID);
+        Participant participant = new Participant(participantEPR,
+                Constants.WS_AT_DURABLE2PC, enlistmentID);
         durableParticipantsTable.put(enlistmentID, participant);
 
     }
@@ -154,19 +150,13 @@
         list.addAll(durableParticipantsTable.values());
         return list.iterator();
     }
-    
-    public Participant getParticipant(String enlistmentId)
-    {
-        if (volatileParticipantsTable.containsKey(enlistmentId))
-        {
-            return (Participant)volatileParticipantsTable.get(enlistmentId);
-        }
-        else if (durableParticipantsTable.containsKey(enlistmentId))
-        {
-            return (Participant)durableParticipantsTable.get(enlistmentId);
-        }
-        else
-        {
+
+    public Participant getParticipant(String enlistmentId) {
+        if (volatileParticipantsTable.containsKey(enlistmentId)) {
+            return (Participant) volatileParticipantsTable.get(enlistmentId);
+        } else if (durableParticipantsTable.containsKey(enlistmentId)) {
+            return (Participant) durableParticipantsTable.get(enlistmentId);
+        } else {
             return null;
         }
     }
@@ -182,9 +172,8 @@
         preparingParticipantsCount++;
 
     }
-    
-    public void decrementPreparing()
-    {
+
+    public void decrementPreparing() {
         preparingParticipantsCount--;
     }
 
diff --git a/src/org/apache/kandula/context/coordination/SimpleCoordinationContext.java b/src/org/apache/kandula/context/coordination/SimpleCoordinationContext.java
index a9ab027..6987c34 100644
--- a/src/org/apache/kandula/context/coordination/SimpleCoordinationContext.java
+++ b/src/org/apache/kandula/context/coordination/SimpleCoordinationContext.java
@@ -16,14 +16,9 @@
  */
 package org.apache.kandula.context.coordination;
 
-import java.util.Iterator;
-
 import javax.xml.namespace.QName;
 
-import org.apache.axis2.addressing.AddressingConstants;
-import org.apache.axis2.addressing.AnyContentType;
 import org.apache.axis2.addressing.EndpointReference;
-import org.apache.axis2.addressing.AddressingConstants.Final;
 import org.apache.axis2.om.OMAbstractFactory;
 import org.apache.axis2.om.OMElement;
 import org.apache.axis2.om.OMNamespace;
@@ -128,34 +123,8 @@
             contextElement.addChild(coorTypeElement);
             OMElement registrationServiceElement = factory.createOMElement(
                     "RegistrationService", wsCoor);
-            OMNamespace wsAddressing = factory.createOMNamespace(
-                    AddressingConstants.Submission.WSA_NAMESPACE,
-                    AddressingConstants.WSA_DEFAULT_PRFIX);
-            OMElement addressElement = factory.createOMElement("Address",
-                    wsAddressing);
-            addressElement.setText(registrationServiceEpr.getAddress());
-            registrationServiceElement.addChild(addressElement);
-            AnyContentType referenceValues = registrationServiceEpr
-                    .getReferenceProperties();
-            if (referenceValues != null) {
-                OMElement refPropertyElement = factory.createOMElement(
-                        "ReferenceProperties", wsAddressing);
-                registrationServiceElement.addChild(refPropertyElement);
-                Iterator iterator = referenceValues.getKeys();
-                while (iterator.hasNext()) {
-                    QName key = (QName) iterator.next();
-                    String value = referenceValues.getReferenceValue(key);
-                    OMElement omElement = factory.createOMElement(key,
-                            refPropertyElement);
-                    refPropertyElement.addChild(omElement);
-                    if (Final.WSA_NAMESPACE.equals(wsAddressing)) {
-                        omElement.addAttribute(
-                                Final.WSA_IS_REFERENCE_PARAMETER_ATTRIBUTE,
-                                Final.WSA_TYPE_ATTRIBUTE_VALUE, wsAddressing);
-                    }
-                    omElement.setText(value);
-                }
-            }
+            KandulaUtils.endpointToOM(registrationServiceEpr,
+                    registrationServiceElement, factory);
             contextElement.addChild(registrationServiceElement);
             return contextElement;
         }
diff --git a/src/org/apache/kandula/coordinator/at/ATCoordinator.java b/src/org/apache/kandula/coordinator/at/ATCoordinator.java
index 9fd7977..7183ad1 100644
--- a/src/org/apache/kandula/coordinator/at/ATCoordinator.java
+++ b/src/org/apache/kandula/coordinator/at/ATCoordinator.java
@@ -38,12 +38,14 @@
  * @author <a href="mailto:thilina@opensource.lk"> Thilina Gunarathne </a>
  */
 public class ATCoordinator implements Registerable {
-    
+
     private Store store;
+
     public ATCoordinator() {
         StorageFactory storageFactory = StorageFactory.getInstance();
         store = storageFactory.getStore();
     }
+
     public EndpointReference register(AbstractContext context, String protocol,
             EndpointReference participantEPR) throws AbstractKandulaException {
         ATActivityContext atContext = (ATActivityContext) context;
@@ -72,7 +74,7 @@
         case CoordinatorStatus.STATUS_ACTIVE:
         case CoordinatorStatus.STATUS_PREPARING_VOLATILE:
             atContext.unlock();
-            return atContext.addParticipant( participantEPR,protocol);
+            return atContext.addParticipant(participantEPR, protocol);
         case CoordinatorStatus.STATUS_NONE:
         default:
             atContext.unlock();
@@ -88,8 +90,8 @@
      */
     public void commitOperation(String id) throws AbstractKandulaException {
         CompletionInitiatorPortTypeRawXMLStub stub;
-        ATActivityContext atContext = (ATActivityContext)store.get(id);
-        
+        ATActivityContext atContext = (ATActivityContext) store.get(id);
+
         if (atContext == null) {
             throw new IllegalStateException(
                     "No Activity Found for this Activity ID");
@@ -125,13 +127,12 @@
             volatilePrepare(atContext);
             // wait till all the Volatile prepare()'s are done
             while (atContext.hasMorePreparing()) {
-                if (atContext.getStatus() == Status.CoordinatorStatus.STATUS_ABORTING)
-                {
+                if (atContext.getStatus() == Status.CoordinatorStatus.STATUS_ABORTING) {
                     abortActivity(atContext);
-                stub = new CompletionInitiatorPortTypeRawXMLStub(".", atContext
-                        .getCompletionParticipant());
-                stub.abortedOperation();
-                return;
+                    stub = new CompletionInitiatorPortTypeRawXMLStub(".",
+                            atContext.getCompletionParticipant());
+                    stub.abortedOperation();
+                    return;
                 }
             }
             durablePrepare(atContext);
@@ -153,7 +154,7 @@
 
     public void rollbackOperation(String id) throws Exception {
         CompletionInitiatorPortTypeRawXMLStub stub;
-        ATActivityContext atContext = (ATActivityContext)store.get(id);
+        ATActivityContext atContext = (ATActivityContext) store.get(id);
 
         // if store throws a Exception capture it
         if (atContext == null) {
@@ -223,21 +224,17 @@
             }
         }
     }
-    
-    public void countVote(String activityID, Vote vote,String enlistmentID) throws AbstractKandulaException
-    {
-        ATActivityContext context = (ATActivityContext)store.get(activityID);
+
+    public void countVote(String activityID, Vote vote, String enlistmentID)
+            throws AbstractKandulaException {
+        ATActivityContext context = (ATActivityContext) store.get(activityID);
         Participant participant = context.getParticipant(enlistmentID);
-        
-        if (Vote.PREPARED.equals(vote))
-        {
-           participant.setStatus(Status.CoordinatorStatus.STATUS_PREPARED);
-        }
-        else if (Vote.READ_ONLY.equals(vote))
-        {
-           participant.setStatus(Status.CoordinatorStatus.STATUS_READ_ONLY);
-        }else if(Vote.ABORT.equals(vote))
-        {
+
+        if (Vote.PREPARED.equals(vote)) {
+            participant.setStatus(Status.CoordinatorStatus.STATUS_PREPARED);
+        } else if (Vote.READ_ONLY.equals(vote)) {
+            participant.setStatus(Status.CoordinatorStatus.STATUS_READ_ONLY);
+        } else if (Vote.ABORT.equals(vote)) {
             participant.setStatus(Status.ParticipantStatus.STATUS_ABORTED);
             abortActivity(context);
         }
diff --git a/src/org/apache/kandula/participant/KandulaResource.java b/src/org/apache/kandula/participant/KandulaResource.java
index f20ff2f..6915519 100644
--- a/src/org/apache/kandula/participant/KandulaResource.java
+++ b/src/org/apache/kandula/participant/KandulaResource.java
@@ -25,4 +25,6 @@
     public void rollback();

 

     public Vote prepare();

+

+    public String getProtocol();

 }
\ No newline at end of file
diff --git a/src/org/apache/kandula/participant/ParticipantTransactionManager.java b/src/org/apache/kandula/participant/ParticipantTransactionManager.java
index 3c1ad50..1ad83fa 100644
--- a/src/org/apache/kandula/participant/ParticipantTransactionManager.java
+++ b/src/org/apache/kandula/participant/ParticipantTransactionManager.java
@@ -25,6 +25,7 @@
  * @author <a href="mailto:thilina@opensource.lk"> Thilina Gunarathne </a>
  */
 public class ParticipantTransactionManager {
+
     public Vote prepare(AbstractContext context) throws InvalidStateException {
         ATParticipantContext atContext = (ATParticipantContext) context;
         atContext.lock();
@@ -51,4 +52,31 @@
             throw new InvalidStateException();
         }
     }
+
+    public void commit(AbstractContext context) throws InvalidStateException {
+        //        ATParticipantContext atContext = (ATParticipantContext) context;
+        //        atContext.lock();
+        //        switch (context.getStatus()) {
+        //        case (Status.CoordinatorStatus.STATUS_NONE):
+        //            //TODO send aborted
+        //            atContext.unlock();
+        //            return Vote.ABORT;
+        //        case (Status.CoordinatorStatus.STATUS_PREPARING):
+        //        case (Status.CoordinatorStatus.STATUS_PREPARED):
+        //        case (Status.CoordinatorStatus.STATUS_COMMITTING):
+        //            //Ignore the message
+        //            atContext.unlock();
+        //            return Vote.NONE;
+        //        case (Status.CoordinatorStatus.STATUS_PREPARED_SUCCESS):
+        //            atContext.unlock();
+        //            return Vote.PREPARED;
+        //        case (Status.CoordinatorStatus.STATUS_ACTIVE):
+        //            atContext.setStatus(Status.CoordinatorStatus.STATUS_PREPARING);
+        //            KandulaResource resource = atContext.getResource();
+        //            return resource.prepare();
+        //        default:
+        //            context.unlock();
+        //            throw new InvalidStateException();
+        //        }
+    }
 }
\ No newline at end of file
diff --git a/src/org/apache/kandula/participant/TransactionInHandler.java b/src/org/apache/kandula/participant/TransactionInHandler.java
new file mode 100644
index 0000000..b313dc8
--- /dev/null
+++ b/src/org/apache/kandula/participant/TransactionInHandler.java
@@ -0,0 +1,92 @@
+/*

+ * Copyright 2004 The Apache Software Foundation.

+ * 

+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not

+ * use this file except in compliance with the License. You may obtain a copy of

+ * the License at

+ * 

+ * http://www.apache.org/licenses/LICENSE-2.0

+ * 

+ * Unless required by applicable law or agreed to in writing, software

+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT

+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the

+ * License for the specific language governing permissions and limitations under

+ * the License.

+ *  

+ */

+package org.apache.kandula.participant;

+

+import java.io.IOException;

+

+import javax.xml.namespace.QName;

+

+import org.apache.axis2.AxisFault;

+import org.apache.axis2.context.MessageContext;

+import org.apache.axis2.handlers.AbstractHandler;

+import org.apache.axis2.om.OMElement;

+import org.apache.axis2.soap.SOAPHeader;

+import org.apache.kandula.Constants;

+import org.apache.kandula.context.AbstractContext;

+import org.apache.kandula.context.at.ATParticipantContext;

+import org.apache.kandula.context.coordination.CoordinationContext;

+import org.apache.kandula.context.coordination.SimpleCoordinationContext;

+import org.apache.kandula.faults.AbstractKandulaException;

+import org.apache.kandula.storage.StorageFactory;

+import org.apache.kandula.storage.Store;

+import org.apache.kandula.utility.KandulaUtils;

+import org.apache.kandula.wscoor.RegistrationCoordinatorPortTypeRawXMLStub;

+

+public class TransactionInHandler extends AbstractHandler {

+    private ThreadLocal threadInfo = new ThreadLocal();

+

+    public void invoke(MessageContext msgContext) throws AxisFault {

+        KandulaResource resource;

+        ATParticipantContext context = new ATParticipantContext();

+        SOAPHeader header = msgContext.getEnvelope().getHeader();

+        OMElement coordinationElement = header.getFirstChildWithName(new QName(

+                Constants.WS_COOR, "CoordinationContext"));

+        if (coordinationElement == null) {

+            throw new AxisFault(

+                    "Transaction Handler engaged.. No Coordination Context found");

+        }

+        CoordinationContext coorContext = new SimpleCoordinationContext(

+                coordinationElement);

+        context.setCoordinationContext(coorContext);

+

+        // TODO  : See whether we can allow the user to set this when the business logiv receives the message

+        String resourceFile = (String) msgContext.getParameter(

+                Constants.KANDULA_RESOURCE).getValue();

+        try {

+            resource = (KandulaResource) Class.forName(resourceFile)

+                    .newInstance();

+        } catch (ClassNotFoundException e) {

+            throw new AxisFault(e);

+        } catch (InstantiationException e) {

+            throw new AxisFault(e);

+        } catch (IllegalAccessException e) {

+            throw new AxisFault(e);

+        }

+        context.setResource(resource);

+

+        String id = KandulaUtils.getRandomStringOf18Characters();

+        Store store = StorageFactory.getInstance().getStore();

+        context.setProperty(AbstractContext.REQUESTER_ID, id);

+        store.put(id, context);

+        ParticipantTransactionManager txManager = new ParticipantTransactionManager();

+        try {

+            RegistrationCoordinatorPortTypeRawXMLStub stub = new RegistrationCoordinatorPortTypeRawXMLStub(

+                    ".", coorContext.getRegistrationService());

+            // TODO: try to get the protocol through configuration parameter 

+            stub.registerOperation(resource.getProtocol(), coorContext

+                    .getRegistrationService(), id);

+        } catch (IOException e) {

+            throw new AxisFault(e);

+        } catch (AbstractKandulaException e) {

+            AxisFault e1 = new AxisFault(e);

+            e1.setFaultCode(e.getFaultCode());

+            throw e1;

+        }

+

+    }

+}

+

diff --git a/src/org/apache/kandula/utility/EndpointReferenceFactory.java b/src/org/apache/kandula/utility/EndpointReferenceFactory.java
index f2d296d..e04e140 100644
--- a/src/org/apache/kandula/utility/EndpointReferenceFactory.java
+++ b/src/org/apache/kandula/utility/EndpointReferenceFactory.java
@@ -19,10 +19,9 @@
 import java.io.IOException;

 import java.util.Properties;

 

-import javax.xml.namespace.QName;

-

 import org.apache.axis2.addressing.AnyContentType;

 import org.apache.axis2.addressing.EndpointReference;

+import org.apache.kandula.Constants;

 import org.apache.kandula.wsat.completion.CompletionInitiatorServiceListener;

 

 /**

@@ -68,11 +67,10 @@
     public EndpointReference getRegistrationEndpoint(String id) {

         //TODO set this somehow reading the conf file

         EndpointReference epr = new EndpointReference(

-                "http://localhost:8081/axis/services/RegistrationCoordinator");

-        AnyContentType refProperties = new AnyContentType();

-        refProperties.addReferenceValue(new QName(

-                "http://ws.apache.org/Kandula", "id"), id);

-        epr.setReferenceProperties(refProperties);

+                "http://localhost:8082/axis/services/RegistrationCoordinator");

+        AnyContentType refParameters = new AnyContentType();

+        refParameters.addReferenceValue(Constants.TRANSACTION_ID_PARAMETER, id);

+        epr.setReferenceParameters(refParameters);

         return epr;

     }

 

@@ -81,10 +79,9 @@
         CompletionInitiatorServiceListener serviceListener = CompletionInitiatorServiceListener

                 .getInstance();

         EndpointReference epr = serviceListener.getEpr();

-        AnyContentType refProperties = new AnyContentType();

-        refProperties.addReferenceValue(new QName(

-                "http://ws.apache.org/Kandula", "id"), id);

-        epr.setReferenceProperties(refProperties);

+        AnyContentType refParameters = new AnyContentType();

+        refParameters.addReferenceValue(Constants.REQUESTER_ID_PARAMETER, id);

+        epr.setReferenceParameters(refParameters);

         return epr;

     }

 

@@ -92,21 +89,19 @@
         //TODO set this somehow reading the conf file

         EndpointReference epr = new EndpointReference(

                 "http://localhost:8082/axis/services/CompletionCoordinator");

-        AnyContentType refProperties = new AnyContentType();

-        refProperties.addReferenceValue(new QName(

-                "http://ws.apache.org/Kandula", "id"), id);

-        epr.setReferenceProperties(refProperties);

+        AnyContentType refParameters = new AnyContentType();

+        refParameters.addReferenceValue(Constants.TRANSACTION_ID_PARAMETER, id);

+        epr.setReferenceParameters(refParameters);

         return epr;

     }

 

     public EndpointReference get2PCEndpoint(String id) {

         //TODO set this somehow reading the conf file

         EndpointReference epr = new EndpointReference(

-                "http://localhost:8081/axis/services/RegistrationCoordinator");

-        AnyContentType refProperties = new AnyContentType();

-        refProperties.addReferenceValue(new QName(

-                "http://ws.apache.org/Kandula", "id"), id);

-        epr.setReferenceProperties(refProperties);

+                "http://localhost:8082/axis/services/RegistrationCoordinator");

+        AnyContentType refParameters = new AnyContentType();

+        refParameters.addReferenceValue(Constants.TRANSACTION_ID_PARAMETER, id);

+        epr.setReferenceParameters(refParameters);

         return epr;

     }

     //	public EndpointReferenceTypeImpl

diff --git a/src/org/apache/kandula/utility/KandulaListener.java b/src/org/apache/kandula/utility/KandulaListener.java
index 3e1bbb6..25a3071 100644
--- a/src/org/apache/kandula/utility/KandulaListener.java
+++ b/src/org/apache/kandula/utility/KandulaListener.java
@@ -92,6 +92,6 @@
 

     public String getHost() throws UnknownHostException {

         return "http://" + InetAddress.getLocalHost().getHostAddress() + ":"

-                + SERVER_PORT + "/axis2/services/";

+                + (SERVER_PORT + 1) + "/axis2/services/";

     }

 }
\ No newline at end of file
diff --git a/src/org/apache/kandula/utility/KandulaUtils.java b/src/org/apache/kandula/utility/KandulaUtils.java
index 14aa1ba..d54e4c0 100644
--- a/src/org/apache/kandula/utility/KandulaUtils.java
+++ b/src/org/apache/kandula/utility/KandulaUtils.java
@@ -47,10 +47,10 @@
                 wsAddressing);
         addressElement.setText(epr.getAddress());
         parentEPR.addChild(addressElement);
-        AnyContentType referenceValues = epr.getReferenceProperties();
+        AnyContentType referenceValues = epr.getReferenceParameters();
         if (referenceValues != null) {
             OMElement refPropertyElement = factory.createOMElement(
-                    "ReferenceProperties", wsAddressing);
+                    "ReferenceParameters", wsAddressing);
             parentEPR.addChild(refPropertyElement);
             Iterator iterator = referenceValues.getKeys();
             while (iterator.hasNext()) {
@@ -75,14 +75,14 @@
                 new QName("Address")).getText());
         AnyContentType referenceProperties = new AnyContentType();
         OMElement referencePropertiesElement = eprElement
-                .getFirstChildWithName(new QName("ReferenceProperties"));
+                .getFirstChildWithName(new QName("ReferenceParameters"));
         Iterator propertyIter = referencePropertiesElement.getChildElements();
         while (propertyIter.hasNext()) {
             OMElement element = (OMElement) propertyIter.next();
             referenceProperties.addReferenceValue(element.getQName(), element
                     .getText());
         }
-        epr.setReferenceProperties(referenceProperties);
+        epr.setReferenceParameters(referenceProperties);
         return epr;
     }
 
diff --git a/src/org/apache/kandula/wsat/completion/CompletionCoordinatorPortTypeRawXMLStub.java b/src/org/apache/kandula/wsat/completion/CompletionCoordinatorPortTypeRawXMLStub.java
index 40528a8..a640fac 100644
--- a/src/org/apache/kandula/wsat/completion/CompletionCoordinatorPortTypeRawXMLStub.java
+++ b/src/org/apache/kandula/wsat/completion/CompletionCoordinatorPortTypeRawXMLStub.java
@@ -2,6 +2,7 @@
 
 import org.apache.axis2.AxisFault;
 import org.apache.axis2.addressing.EndpointReference;
+import org.apache.axis2.description.OutOnlyOperationDescription;
 import org.apache.kandula.Constants;
 import org.apache.kandula.faults.AbstractKandulaException;
 import org.apache.kandula.wsat.AbstractATNotifierStub;
@@ -21,13 +22,13 @@
         org.apache.axis2.description.OperationDescription operation;
         operations = new org.apache.axis2.description.OperationDescription[2];
 
-        operation = new org.apache.axis2.description.OperationDescription();
+        operation = new OutOnlyOperationDescription();
         operation.setName(new javax.xml.namespace.QName(Constants.WS_AT,
                 "commitOperation"));
         operations[0] = operation;
         _service.addOperation(operation);
 
-        operation = new org.apache.axis2.description.OperationDescription();
+        operation = new OutOnlyOperationDescription();
         operation.setName(new javax.xml.namespace.QName(Constants.WS_AT,
                 "rollbackOperation"));
         operations[1] = operation;
diff --git a/src/org/apache/kandula/wsat/completion/CompletionInitiatorPortTypeRawXMLStub.java b/src/org/apache/kandula/wsat/completion/CompletionInitiatorPortTypeRawXMLStub.java
index 85e9df2..e3aeb61 100644
--- a/src/org/apache/kandula/wsat/completion/CompletionInitiatorPortTypeRawXMLStub.java
+++ b/src/org/apache/kandula/wsat/completion/CompletionInitiatorPortTypeRawXMLStub.java
@@ -3,6 +3,7 @@
 import org.apache.axis2.AxisFault;
 import org.apache.axis2.addressing.EndpointReference;
 import org.apache.axis2.deployment.DeploymentException;
+import org.apache.axis2.description.OutOnlyOperationDescription;
 import org.apache.kandula.Constants;
 import org.apache.kandula.faults.AbstractKandulaException;
 import org.apache.kandula.faults.KandulaGeneralException;
@@ -23,13 +24,13 @@
         org.apache.axis2.description.OperationDescription operation;
         operations = new org.apache.axis2.description.OperationDescription[2];
 
-        operation = new org.apache.axis2.description.OperationDescription();
+        operation = new OutOnlyOperationDescription();
         operation.setName(new javax.xml.namespace.QName(Constants.WS_AT,
                 "committedOperation"));
         operations[0] = operation;
         _service.addOperation(operation);
 
-        operation = new org.apache.axis2.description.OperationDescription();
+        operation = new OutOnlyOperationDescription();
         operation.setName(new javax.xml.namespace.QName(Constants.WS_AT,
                 "abortedOperation"));
         operations[1] = operation;
diff --git a/src/org/apache/kandula/wsat/completion/CompletionInitiatorServiceListener.java b/src/org/apache/kandula/wsat/completion/CompletionInitiatorServiceListener.java
index 033ca22..325042e 100644
--- a/src/org/apache/kandula/wsat/completion/CompletionInitiatorServiceListener.java
+++ b/src/org/apache/kandula/wsat/completion/CompletionInitiatorServiceListener.java
@@ -21,6 +21,7 @@
 import javax.xml.namespace.QName;
 
 import org.apache.axis2.addressing.EndpointReference;
+import org.apache.axis2.description.InOnlyOperationDescription;
 import org.apache.axis2.description.ParameterImpl;
 import org.apache.axis2.description.ServiceDescription;
 import org.apache.axis2.receivers.AbstractMessageReceiver;
@@ -68,7 +69,7 @@
                 "committedOperation");
         org.apache.axis2.description.OperationDescription committedOperationDesc;
         String committedMapping = Constants.WS_AT_COMMITTED;
-        committedOperationDesc = new org.apache.axis2.description.OperationDescription();
+        committedOperationDesc = new InOnlyOperationDescription();
         committedOperationDesc.setName(committedOperationName);
         committedOperationDesc
                 .setMessageReceiver(new RawXMLINOnlyMessageReceiver());
@@ -80,7 +81,7 @@
                 "abortedOperation");
         org.apache.axis2.description.OperationDescription abortedOperationDesc;
         String abortedMapping = Constants.WS_AT_ABORTED;
-        abortedOperationDesc = new org.apache.axis2.description.OperationDescription();
+        abortedOperationDesc = new InOnlyOperationDescription();
         abortedOperationDesc.setName(abortedOperationName);
         abortedOperationDesc
                 .setMessageReceiver(new RawXMLINOnlyMessageReceiver());
diff --git a/src/org/apache/kandula/wsat/twopc/CoordinatorPortTypeRawXMLSkeleton.java b/src/org/apache/kandula/wsat/twopc/CoordinatorPortTypeRawXMLSkeleton.java
index d0fa1ae..e2f839d 100644
--- a/src/org/apache/kandula/wsat/twopc/CoordinatorPortTypeRawXMLSkeleton.java
+++ b/src/org/apache/kandula/wsat/twopc/CoordinatorPortTypeRawXMLSkeleton.java
@@ -21,9 +21,9 @@
     public OMElement preparedOperation(OMElement requestElement)
             throws AxisFault {
         String activityId = Coordinator.ACTIVITY_ID;
-        ATCoordinator coordinator= new ATCoordinator();
+        ATCoordinator coordinator = new ATCoordinator();
         try {
-            coordinator.countVote(activityId,Vote.PREPARED,null);
+            coordinator.countVote(activityId, Vote.PREPARED, null);
         } catch (AbstractKandulaException e) {
             AxisFault fault = new AxisFault(e);
             fault.setFaultCode(e.getFaultCode());
@@ -39,9 +39,9 @@
     public OMElement abortedOperation(OMElement requestElement)
             throws AxisFault {
         String activityId = Coordinator.ACTIVITY_ID;
-        ATCoordinator coordinator= new ATCoordinator();
+        ATCoordinator coordinator = new ATCoordinator();
         try {
-            coordinator.countVote(activityId,Vote.ABORT,null);
+            coordinator.countVote(activityId, Vote.ABORT, null);
         } catch (AbstractKandulaException e) {
             AxisFault fault = new AxisFault(e);
             fault.setFaultCode(e.getFaultCode());
@@ -57,9 +57,9 @@
     public OMElement readOnlyOperation(OMElement requestElement)
             throws AxisFault {
         String activityId = Coordinator.ACTIVITY_ID;
-        ATCoordinator coordinator= new ATCoordinator();
+        ATCoordinator coordinator = new ATCoordinator();
         try {
-            coordinator.countVote(activityId,Vote.READ_ONLY,null);
+            coordinator.countVote(activityId, Vote.READ_ONLY, null);
         } catch (AbstractKandulaException e) {
             AxisFault fault = new AxisFault(e);
             fault.setFaultCode(e.getFaultCode());
diff --git a/src/org/apache/kandula/wsat/twopc/CoordinatorPortTypeRawXMLStub.java b/src/org/apache/kandula/wsat/twopc/CoordinatorPortTypeRawXMLStub.java
index 0da2eff..4cbbfd1 100644
--- a/src/org/apache/kandula/wsat/twopc/CoordinatorPortTypeRawXMLStub.java
+++ b/src/org/apache/kandula/wsat/twopc/CoordinatorPortTypeRawXMLStub.java
@@ -1,6 +1,7 @@
 package org.apache.kandula.wsat.twopc;
 
 import org.apache.axis2.addressing.EndpointReference;
+import org.apache.axis2.description.OutOnlyOperationDescription;
 import org.apache.kandula.Constants;
 import org.apache.kandula.faults.AbstractKandulaException;
 import org.apache.kandula.wsat.AbstractATNotifierStub;
@@ -19,29 +20,29 @@
         org.apache.axis2.description.OperationDescription operation;
         operations = new org.apache.axis2.description.OperationDescription[5];
 
-        operation = new org.apache.axis2.description.OperationDescription();
+        operation = new OutOnlyOperationDescription();
         operation.setName(new javax.xml.namespace.QName(Constants.WS_AT,
                 "PreparedOperation"));
         operations[0] = operation;
         _service.addOperation(operation);
 
-        operation = new org.apache.axis2.description.OperationDescription();
+        operation = new OutOnlyOperationDescription();
         operation.setName(new javax.xml.namespace.QName(Constants.WS_AT,
                 "AbortedOperation"));
         operations[1] = operation;
         _service.addOperation(operation);
-        operation = new org.apache.axis2.description.OperationDescription();
+        operation = new OutOnlyOperationDescription();
         operation.setName(new javax.xml.namespace.QName(Constants.WS_AT,
                 "ReadOnlyOperation"));
         operations[2] = operation;
         _service.addOperation(operation);
 
-        operation = new org.apache.axis2.description.OperationDescription();
+        operation = new OutOnlyOperationDescription();
         operation.setName(new javax.xml.namespace.QName(Constants.WS_AT,
                 "CommittedOperation"));
         operations[3] = operation;
         _service.addOperation(operation);
-        operation = new org.apache.axis2.description.OperationDescription();
+        operation = new OutOnlyOperationDescription();
         operation.setName(new javax.xml.namespace.QName(Constants.WS_AT,
                 "ReplayOperation"));
         operations[4] = operation;
diff --git a/src/org/apache/kandula/wsat/twopc/ParticipantPortTypeRawXMLSkeleton.java b/src/org/apache/kandula/wsat/twopc/ParticipantPortTypeRawXMLSkeleton.java
index 21d88f5..aeb0ee0 100644
--- a/src/org/apache/kandula/wsat/twopc/ParticipantPortTypeRawXMLSkeleton.java
+++ b/src/org/apache/kandula/wsat/twopc/ParticipantPortTypeRawXMLSkeleton.java
@@ -1,7 +1,14 @@
 package org.apache.kandula.wsat.twopc;

 

+import org.apache.axis2.AxisFault;

 import org.apache.axis2.context.MessageContext;

 import org.apache.axis2.om.OMElement;

+import org.apache.kandula.Constants;

+import org.apache.kandula.context.AbstractContext;

+import org.apache.kandula.faults.InvalidStateException;

+import org.apache.kandula.participant.ParticipantTransactionManager;

+import org.apache.kandula.storage.StorageFactory;

+import org.apache.kandula.storage.Store;

 

 /*

  * Copyright 2004,2005 The Apache Software Foundation.

@@ -32,7 +39,18 @@
         this.msgContext = context;

     }

 

-    public OMElement prepareOperation(OMElement requestEle) {

+    public OMElement prepareOperation(OMElement requestEle) throws AxisFault {

+        OMElement header = msgContext.getEnvelope().getHeader();

+        String requesterID = header.getFirstChildWithName(

+                Constants.REQUESTER_ID_PARAMETER).getText();

+        Store store = StorageFactory.getInstance().getStore();

+        AbstractContext context = (AbstractContext)store.get(requesterID);

+        ParticipantTransactionManager txManager = new ParticipantTransactionManager();

+        try {

+            txManager.prepare(context);

+        } catch (InvalidStateException e) {

+           throw new AxisFault(e);

+        }

         return null;

 

     }

diff --git a/src/org/apache/kandula/wsat/twopc/ParticipantPortTypeRawXMLStub.java b/src/org/apache/kandula/wsat/twopc/ParticipantPortTypeRawXMLStub.java
index 3a6c4f1..a9f2315 100644
--- a/src/org/apache/kandula/wsat/twopc/ParticipantPortTypeRawXMLStub.java
+++ b/src/org/apache/kandula/wsat/twopc/ParticipantPortTypeRawXMLStub.java
@@ -3,6 +3,7 @@
 import org.apache.axis2.AxisFault;
 import org.apache.axis2.addressing.EndpointReference;
 import org.apache.axis2.deployment.DeploymentException;
+import org.apache.axis2.description.OutOnlyOperationDescription;
 import org.apache.kandula.Constants;
 import org.apache.kandula.faults.AbstractKandulaException;
 import org.apache.kandula.faults.KandulaGeneralException;
@@ -22,19 +23,19 @@
         org.apache.axis2.description.OperationDescription operation;
         operations = new org.apache.axis2.description.OperationDescription[3];
 
-        operation = new org.apache.axis2.description.OperationDescription();
+        operation = new OutOnlyOperationDescription();
         operation.setName(new javax.xml.namespace.QName(Constants.WS_AT,
                 "prepareOperation"));
         operations[0] = operation;
         _service.addOperation(operation);
 
-        operation = new org.apache.axis2.description.OperationDescription();
+        operation = new OutOnlyOperationDescription();
         operation.setName(new javax.xml.namespace.QName(Constants.WS_AT,
-                "committOperation"));
+                "commitOperation"));
         operations[1] = operation;
         _service.addOperation(operation);
 
-        operation = new org.apache.axis2.description.OperationDescription();
+        operation = new OutOnlyOperationDescription();
         operation.setName(new javax.xml.namespace.QName(Constants.WS_AT,
                 "rollbackOperation"));
         operations[2] = operation;
diff --git a/src/org/apache/kandula/wsat/twopc/ParticipantServiceListener.java b/src/org/apache/kandula/wsat/twopc/ParticipantServiceListener.java
index 7a9553b..db12c83 100644
--- a/src/org/apache/kandula/wsat/twopc/ParticipantServiceListener.java
+++ b/src/org/apache/kandula/wsat/twopc/ParticipantServiceListener.java
@@ -21,6 +21,7 @@
 import javax.xml.namespace.QName;
 
 import org.apache.axis2.addressing.EndpointReference;
+import org.apache.axis2.description.InOnlyOperationDescription;
 import org.apache.axis2.description.ParameterImpl;
 import org.apache.axis2.description.ServiceDescription;
 import org.apache.axis2.receivers.AbstractMessageReceiver;
@@ -67,7 +68,7 @@
                 "prepareOperation");
         org.apache.axis2.description.OperationDescription prepareOperationDesc;
         String prepareMapping = Constants.WS_AT_PREPARE;
-        prepareOperationDesc = new org.apache.axis2.description.OperationDescription();
+        prepareOperationDesc = new InOnlyOperationDescription();
         prepareOperationDesc.setName(prepareOperationName);
         prepareOperationDesc
                 .setMessageReceiver(new RawXMLINOnlyMessageReceiver());
@@ -79,7 +80,7 @@
                 "commitOperation");
         org.apache.axis2.description.OperationDescription commitOperationDesc;
         String commitMapping = Constants.WS_AT_COMMIT;
-        commitOperationDesc = new org.apache.axis2.description.OperationDescription();
+        commitOperationDesc = new InOnlyOperationDescription();
         commitOperationDesc.setName(commitOperationName);
         commitOperationDesc
                 .setMessageReceiver(new RawXMLINOnlyMessageReceiver());
@@ -91,7 +92,7 @@
                 "rollbackOperation");
         org.apache.axis2.description.OperationDescription rollbackOperationDesc;
         String rollbackMapping = Constants.WS_AT_ROLLBACK;
-        rollbackOperationDesc = new org.apache.axis2.description.OperationDescription();
+        rollbackOperationDesc = new InOnlyOperationDescription();
         rollbackOperationDesc.setName(rollbackOperationName);
         rollbackOperationDesc
                 .setMessageReceiver(new RawXMLINOnlyMessageReceiver());
diff --git a/src/org/apache/kandula/wscoor/ActivationCoordinatorPortTypeRawXMLStub.java b/src/org/apache/kandula/wscoor/ActivationCoordinatorPortTypeRawXMLStub.java
index 4c1e08e..5a75a50 100644
--- a/src/org/apache/kandula/wscoor/ActivationCoordinatorPortTypeRawXMLStub.java
+++ b/src/org/apache/kandula/wscoor/ActivationCoordinatorPortTypeRawXMLStub.java
@@ -1,159 +1,160 @@
-/*
- * Copyright  2004 The Apache Software Foundation.
- *
- *  Licensed under the Apache License, Version 2.0 (the "License");
- *  you may not use this file except in compliance with the License.
- *  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing, software
- *  distributed under the License is distributed on an "AS IS" BASIS,
- *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *  See the License for the specific language governing permissions and
- *  limitations under the License.
- *
- */
-package org.apache.kandula.wscoor;
-
-import java.io.IOException;
-
-import javax.xml.namespace.QName;
-
-import org.apache.axis2.addressing.AddressingConstants;
-import org.apache.axis2.addressing.AnyContentType;
-import org.apache.axis2.addressing.EndpointReference;
-import org.apache.axis2.clientapi.MessageSender;
-import org.apache.axis2.description.ParameterImpl;
-import org.apache.axis2.description.ServiceDescription;
-import org.apache.axis2.om.OMAbstractFactory;
-import org.apache.axis2.om.OMElement;
-import org.apache.axis2.om.OMNamespace;
-import org.apache.axis2.receivers.AbstractMessageReceiver;
-import org.apache.axis2.receivers.RawXMLINOnlyMessageReceiver;
-import org.apache.kandula.Constants;
-import org.apache.kandula.utility.KandulaListener;
-
-/**
- * @author <a href="mailto:thilina@opensource.lk"> Thilina Gunarathne </a>
- */
-
-public class ActivationCoordinatorPortTypeRawXMLStub extends
-        org.apache.axis2.clientapi.Stub {
-
-    public static final String AXIS2_HOME = ".";
-
-    protected static org.apache.axis2.description.OperationDescription[] operations;
-
-    static {
-
-        //creating the Service
-        _service = new org.apache.axis2.description.ServiceDescription(
-                new javax.xml.namespace.QName(
-                        "http://schemas.xmlsoap.org/ws/2003/09/wscoor",
-                        "ActivationCoordinatorPortType"));
-
-        //creating the operations
-        org.apache.axis2.description.OperationDescription operationDesc;
-        operations = new org.apache.axis2.description.OperationDescription[1];
-
-        operationDesc = new org.apache.axis2.description.OperationDescription();
-        operationDesc.setName(new javax.xml.namespace.QName(
-                "http://schemas.xmlsoap.org/ws/2003/09/wscoor",
-                "CreateCoordinationContextOperation"));
-        operations[0] = operationDesc;
-        _service.addOperation(operationDesc);
-
-    }
-
-    /**
-     * Constructor
-     */
-    public ActivationCoordinatorPortTypeRawXMLStub(String axis2Home,
-            EndpointReference targetEndpoint) throws java.lang.Exception {
-        this.toEPR = targetEndpoint;
-        //creating the configuration
-        _configurationContext = new org.apache.axis2.context.ConfigurationContextFactory()
-                .buildClientConfigurationContext(axis2Home);
-
-        _configurationContext.getAxisConfiguration().addService(_service);
-        _serviceContext = _service.getParent().getServiceGroupContext(
-                _configurationContext).getServiceContext(
-                _service.getName().getLocalPart());
-
-    }
-
-    public void createCoordinationContextOperation(String coordinationType,
-            String id) throws IOException {
-
-        EndpointReference replyToEpr;
-
-        org.apache.axis2.context.MessageContext messageContext = getMessageContext();
-        messageContext.setProperty(AddressingConstants.WS_ADDRESSING_VERSION,
-                AddressingConstants.Submission.WSA_NAMESPACE);
-        org.apache.axis2.soap.SOAPEnvelope env = createSOAPEnvelope(coordinationType);
-        messageContext.setEnvelope(env);
-
-        replyToEpr = setupListener();
-        AnyContentType refProperties = new AnyContentType();
-        refProperties.addReferenceValue(new QName(
-                "http://ws.apache.org/kandula", "id"), id);
-        replyToEpr.setReferenceParameters(refProperties);
-
-        MessageSender messageSender = new MessageSender(_serviceContext);
-        messageSender.setReplyTo(replyToEpr);
-        messageSender.setTo(this.toEPR);
-        messageSender
-                .setWsaAction(Constants.WS_COOR_CREATE_COORDINATIONCONTEXT);
-        messageSender
-                .setSenderTransport(org.apache.axis2.Constants.TRANSPORT_HTTP);
-        messageSender.send(operations[0], messageContext);
-
-    }
-
-    private org.apache.axis2.soap.SOAPEnvelope createSOAPEnvelope(
-            String coordinationType) {
-        org.apache.axis2.soap.SOAPEnvelope env = super.createEnvelope();
-        org.apache.axis2.soap.SOAPFactory factory = OMAbstractFactory
-                .getSOAP12Factory();
-        OMNamespace wsCoor = factory.createOMNamespace(Constants.WS_COOR,
-                "wscoor");
-        OMElement request = factory.createOMElement(
-                "CreateCoordinationContext", wsCoor);
-        OMElement coorType = factory
-                .createOMElement("CoordinationType", wsCoor);
-        coorType.setText(coordinationType);
-        request.addChild(coorType);
-        env.getBody().addChild(request);
-        return env;
-    }
-
-    private EndpointReference setupListener() throws IOException {
-        QName serviceName = new QName("ActivationRequesterPortType");
-        QName operationName = new QName(Constants.WS_COOR,
-                "createCoordinationContextResponseOperation");
-        org.apache.axis2.description.OperationDescription responseOperationDesc;
-        String className = ActivationRequesterPortTypeRawXMLSkeleton.class
-                .getName();
-        String mapping = Constants.WS_COOR_CREATE_COORDINATIONCONTEXT_RESPONSE;
-
-        KandulaListener listener = KandulaListener.getInstance();
-        ServiceDescription service = new ServiceDescription(serviceName);
-        service.addParameter(new ParameterImpl(
-                AbstractMessageReceiver.SERVICE_CLASS, className));
-        service.setFileName(className);
-
-        responseOperationDesc = new org.apache.axis2.description.OperationDescription();
-        responseOperationDesc.setName(operationName);
-        responseOperationDesc
-                .setMessageReceiver(new RawXMLINOnlyMessageReceiver());
-
-        // Adding the WSA Action mapping to the operation
-        service.addMapping(mapping, responseOperationDesc);
-        service.addOperation(responseOperationDesc);
-        listener.addService(service);
-        listener.start();
-        return new EndpointReference(listener.getHost()
-                + serviceName.getLocalPart());
-    }
+/*

+ * Copyright  2004 The Apache Software Foundation.

+ *

+ *  Licensed under the Apache License, Version 2.0 (the "License");

+ *  you may not use this file except in compliance with the License.

+ *  You may obtain a copy of the License at

+ *

+ *      http://www.apache.org/licenses/LICENSE-2.0

+ *

+ *  Unless required by applicable law or agreed to in writing, software

+ *  distributed under the License is distributed on an "AS IS" BASIS,

+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

+ *  See the License for the specific language governing permissions and

+ *  limitations under the License.

+ *

+ */

+package org.apache.kandula.wscoor;

+

+import java.io.IOException;

+

+import javax.xml.namespace.QName;

+

+import org.apache.axis2.addressing.AddressingConstants;

+import org.apache.axis2.addressing.AnyContentType;

+import org.apache.axis2.addressing.EndpointReference;

+import org.apache.axis2.clientapi.MessageSender;

+import org.apache.axis2.description.InOnlyOperationDescription;

+import org.apache.axis2.description.OutInOperationDescription;

+import org.apache.axis2.description.ParameterImpl;

+import org.apache.axis2.description.ServiceDescription;

+import org.apache.axis2.om.OMAbstractFactory;

+import org.apache.axis2.om.OMElement;

+import org.apache.axis2.om.OMNamespace;

+import org.apache.axis2.receivers.AbstractMessageReceiver;

+import org.apache.axis2.receivers.RawXMLINOnlyMessageReceiver;

+import org.apache.kandula.Constants;

+import org.apache.kandula.utility.KandulaListener;

+

+/**

+ * @author <a href="mailto:thilina@opensource.lk"> Thilina Gunarathne </a>

+ */

+

+public class ActivationCoordinatorPortTypeRawXMLStub extends

+        org.apache.axis2.clientapi.Stub {

+

+    public static final String AXIS2_HOME = ".";

+

+    protected static org.apache.axis2.description.OperationDescription[] operations;

+

+    static {

+

+        //creating the Service

+        _service = new org.apache.axis2.description.ServiceDescription(

+                new javax.xml.namespace.QName(

+                        "http://schemas.xmlsoap.org/ws/2003/09/wscoor",

+                        "ActivationCoordinatorPortType"));

+

+        //creating the operations

+        org.apache.axis2.description.OperationDescription operationDesc;

+        operations = new org.apache.axis2.description.OperationDescription[1];

+

+        operationDesc = new OutInOperationDescription();

+        operationDesc.setName(new javax.xml.namespace.QName(

+                "http://schemas.xmlsoap.org/ws/2003/09/wscoor",

+                "CreateCoordinationContextOperation"));

+        operations[0] = operationDesc;

+        _service.addOperation(operationDesc);

+

+    }

+

+    /**

+     * Constructor

+     */

+    public ActivationCoordinatorPortTypeRawXMLStub(String axis2Home,

+            EndpointReference targetEndpoint) throws java.lang.Exception {

+        this.toEPR = targetEndpoint;

+        //creating the configuration

+        _configurationContext = new org.apache.axis2.context.ConfigurationContextFactory()

+                .buildClientConfigurationContext(axis2Home);

+

+        _configurationContext.getAxisConfiguration().addService(_service);

+        _serviceContext = _service.getParent().getServiceGroupContext(

+                _configurationContext).getServiceContext(

+                _service.getName().getLocalPart());

+

+    }

+

+    public void createCoordinationContextOperation(String coordinationType,

+            String id) throws IOException {

+

+        EndpointReference replyToEpr;

+

+        org.apache.axis2.context.MessageContext messageContext = getMessageContext();

+        messageContext.setProperty(AddressingConstants.WS_ADDRESSING_VERSION,

+                AddressingConstants.Submission.WSA_NAMESPACE);

+        org.apache.axis2.soap.SOAPEnvelope env = createSOAPEnvelope(coordinationType);

+        messageContext.setEnvelope(env);

+

+        replyToEpr = setupListener();

+        AnyContentType refParameters = new AnyContentType();

+        refParameters.addReferenceValue(Constants.REQUESTER_ID_PARAMETER, id);

+        replyToEpr.setReferenceParameters(refParameters);

+

+        MessageSender messageSender = new MessageSender(_serviceContext);

+        messageSender.setReplyTo(replyToEpr);

+        messageSender.setTo(this.toEPR);

+        messageSender

+                .setWsaAction(Constants.WS_COOR_CREATE_COORDINATIONCONTEXT);

+        messageSender

+                .setSenderTransport(org.apache.axis2.Constants.TRANSPORT_HTTP);

+        messageSender.send(operations[0], messageContext);

+

+    }

+

+    private org.apache.axis2.soap.SOAPEnvelope createSOAPEnvelope(

+            String coordinationType) {

+        org.apache.axis2.soap.SOAPEnvelope env = super.createEnvelope();

+        org.apache.axis2.soap.SOAPFactory factory = OMAbstractFactory

+                .getSOAP12Factory();

+        OMNamespace wsCoor = factory.createOMNamespace(Constants.WS_COOR,

+                "wscoor");

+        OMElement request = factory.createOMElement(

+                "CreateCoordinationContext", wsCoor);

+        OMElement coorType = factory

+                .createOMElement("CoordinationType", wsCoor);

+        coorType.setText(coordinationType);

+        request.addChild(coorType);

+        env.getBody().addChild(request);

+        return env;

+    }

+

+    private EndpointReference setupListener() throws IOException {

+        QName serviceName = new QName("ActivationRequesterPortType");

+        QName operationName = new QName(Constants.WS_COOR,

+                "createCoordinationContextResponseOperation");

+        org.apache.axis2.description.OperationDescription responseOperationDesc;

+        String className = ActivationRequesterPortTypeRawXMLSkeleton.class

+                .getName();

+        String mapping = Constants.WS_COOR_CREATE_COORDINATIONCONTEXT_RESPONSE;

+

+        KandulaListener listener = KandulaListener.getInstance();

+        ServiceDescription service = new ServiceDescription(serviceName);

+        service.addParameter(new ParameterImpl(

+                AbstractMessageReceiver.SERVICE_CLASS, className));

+        service.setFileName(className);

+

+        responseOperationDesc = new InOnlyOperationDescription();

+        responseOperationDesc.setName(operationName);

+        responseOperationDesc

+                .setMessageReceiver(new RawXMLINOnlyMessageReceiver());

+

+        // Adding the WSA Action mapping to the operation

+        service.addMapping(mapping, responseOperationDesc);

+        service.addOperation(responseOperationDesc);

+        listener.addService(service);

+        listener.start();

+        return new EndpointReference(listener.getHost()

+                + serviceName.getLocalPart());

+    }

 }
\ No newline at end of file
diff --git a/src/org/apache/kandula/wscoor/ActivationPortTypeRawXMLAsyncMessageReceiver.java b/src/org/apache/kandula/wscoor/ActivationPortTypeRawXMLAsyncMessageReceiver.java
index f469d66..460980f 100644
--- a/src/org/apache/kandula/wscoor/ActivationPortTypeRawXMLAsyncMessageReceiver.java
+++ b/src/org/apache/kandula/wscoor/ActivationPortTypeRawXMLAsyncMessageReceiver.java
@@ -29,11 +29,8 @@
 
     public void invokeBusinessLogic(
             org.apache.axis2.context.MessageContext msgContext,
-            org.apache.axis2.context.MessageContext newMsgContext/*
-                                                                  * ,
-                                                                  * ServerCallback
-                                                                  * callback
-                                                                  */) throws org.apache.axis2.AxisFault {
+            org.apache.axis2.context.MessageContext newMsgContext)
+            throws org.apache.axis2.AxisFault {
 
         try {
 
@@ -60,7 +57,7 @@
                     //doc style
                     response = skel
                             .createCoordinationContextOperation((org.apache.axis2.om.OMElement) msgContext
-                                    .getEnvelope().getBody().getFirstChild()
+                                    .getEnvelope().getBody().getFirstElement()
                                     .detach());
 
                     //Create a default envelop
diff --git a/src/org/apache/kandula/wscoor/ActivationRequesterPortTypeRawXMLSkeleton.java b/src/org/apache/kandula/wscoor/ActivationRequesterPortTypeRawXMLSkeleton.java
index 935efcd..bfe1f14 100644
--- a/src/org/apache/kandula/wscoor/ActivationRequesterPortTypeRawXMLSkeleton.java
+++ b/src/org/apache/kandula/wscoor/ActivationRequesterPortTypeRawXMLSkeleton.java
@@ -2,9 +2,9 @@
 

 import org.apache.axis2.context.MessageContext;

 import org.apache.axis2.om.OMElement;

+import org.apache.kandula.Constants;

 import org.apache.kandula.context.AbstractContext;

 import org.apache.kandula.context.coordination.CoordinationContext;

-import org.apache.kandula.initiator.TransactionManager;

 import org.apache.kandula.storage.StorageFactory;

 

 /*

@@ -40,11 +40,14 @@
             OMElement responseElement) {

         OMElement response = responseElement.getFirstElement();

         if ("CoordinationContext".equals(response.getLocalName())) {

-            msgContext.getMessageInformationHeaders().getReferenceParameters();

+            OMElement header = msgContext.getEnvelope().getHeader();

+            String requesterID = header.getFirstChildWithName(

+                    Constants.REQUESTER_ID_PARAMETER).getText();

+            //msgContext.getMessageInformationHeaders().getReferenceParameters();

             CoordinationContext coordinationContext = CoordinationContext.Factory

                     .newContext(response);

             AbstractContext context = (AbstractContext) StorageFactory

-                    .getInstance().getStore().get(TransactionManager.tempID);

+                    .getInstance().getStore().get(requesterID);

             context.setCoordinationContext(coordinationContext);

         }

         return null;

diff --git a/src/org/apache/kandula/wscoor/RegistrationCoordinatorPortTypeRawXMLStub.java b/src/org/apache/kandula/wscoor/RegistrationCoordinatorPortTypeRawXMLStub.java
index 3a3a439..2a0df01 100644
--- a/src/org/apache/kandula/wscoor/RegistrationCoordinatorPortTypeRawXMLStub.java
+++ b/src/org/apache/kandula/wscoor/RegistrationCoordinatorPortTypeRawXMLStub.java
@@ -4,9 +4,12 @@
 
 import javax.xml.namespace.QName;
 
+import org.apache.axis2.AxisFault;
 import org.apache.axis2.addressing.AnyContentType;
 import org.apache.axis2.addressing.EndpointReference;
 import org.apache.axis2.clientapi.MessageSender;
+import org.apache.axis2.description.InOnlyOperationDescription;
+import org.apache.axis2.description.OutInOperationDescription;
 import org.apache.axis2.description.ParameterImpl;
 import org.apache.axis2.description.ServiceDescription;
 import org.apache.axis2.om.OMAbstractFactory;
@@ -15,6 +18,8 @@
 import org.apache.axis2.receivers.AbstractMessageReceiver;
 import org.apache.axis2.receivers.RawXMLINOnlyMessageReceiver;
 import org.apache.kandula.Constants;
+import org.apache.kandula.faults.AbstractKandulaException;
+import org.apache.kandula.faults.KandulaGeneralException;
 import org.apache.kandula.utility.KandulaListener;
 import org.apache.kandula.utility.KandulaUtils;
 
@@ -36,7 +41,7 @@
         org.apache.axis2.description.OperationDescription __operation;
         _operations = new org.apache.axis2.description.OperationDescription[1];
 
-        __operation = new org.apache.axis2.description.OperationDescription();
+        __operation = new OutInOperationDescription();
         __operation.setName(new javax.xml.namespace.QName(
                 "http://schemas.xmlsoap.org/ws/2003/09/wscoor",
                 "RegisterOperation"));
@@ -49,12 +54,18 @@
      * Constructor
      */
     public RegistrationCoordinatorPortTypeRawXMLStub(String axis2Home,
-            EndpointReference targetEndpoint) throws java.lang.Exception {
+            EndpointReference targetEndpoint) throws AbstractKandulaException {
         this.toEPR = targetEndpoint;
-        //creating the configuration
-        _configurationContext = new org.apache.axis2.context.ConfigurationContextFactory()
-                .buildClientConfigurationContext(axis2Home);
-        _configurationContext.getAxisConfiguration().addService(_service);
+        try {
+            //creating the configuration
+            _configurationContext = new org.apache.axis2.context.ConfigurationContextFactory()
+                    .buildClientConfigurationContext(axis2Home);
+
+            _configurationContext.getAxisConfiguration().addService(_service);
+        } catch (AxisFault e1) {
+            throw new KandulaGeneralException(e1);
+        }
+
         _serviceContext = _service.getParent().getServiceGroupContext(
                 _configurationContext).getServiceContext(
                 _service.getName().getLocalPart());
@@ -71,10 +82,9 @@
         messageContext.setEnvelope(env);
 
         replyToEpr = setupListener();
-        AnyContentType refProperties = new AnyContentType();
-        refProperties.addReferenceValue(new QName(
-                "http://ws.apache.org/kandula", id), id);
-        replyToEpr.setReferenceProperties(refProperties);
+        AnyContentType refParameters = new AnyContentType();
+        refParameters.addReferenceValue(Constants.REQUESTER_ID_PARAMETER, id);
+        replyToEpr.setReferenceParameters(refParameters);
 
         MessageSender messageSender = new MessageSender(_serviceContext);
         messageSender.setReplyTo(replyToEpr);
@@ -122,7 +132,7 @@
                 AbstractMessageReceiver.SERVICE_CLASS, className));
         service.setFileName(className);
 
-        responseOperationDesc = new org.apache.axis2.description.OperationDescription();
+        responseOperationDesc = new InOnlyOperationDescription();
         responseOperationDesc.setName(operationName);
         responseOperationDesc
                 .setMessageReceiver(new RawXMLINOnlyMessageReceiver());
diff --git a/src/org/apache/kandula/wscoor/RegistrationPortTypeRawXMLAsyncMessageReceiver.java b/src/org/apache/kandula/wscoor/RegistrationPortTypeRawXMLAsyncMessageReceiver.java
index 09aa6a5..dfe2f51 100644
--- a/src/org/apache/kandula/wscoor/RegistrationPortTypeRawXMLAsyncMessageReceiver.java
+++ b/src/org/apache/kandula/wscoor/RegistrationPortTypeRawXMLAsyncMessageReceiver.java
@@ -29,11 +29,8 @@
 
     public void invokeBusinessLogic(
             org.apache.axis2.context.MessageContext msgContext,
-            org.apache.axis2.context.MessageContext newMsgContext/*
-                                                                  * ,
-                                                                  * ServerCallback
-                                                                  * callback
-                                                                  */) throws org.apache.axis2.AxisFault {
+            org.apache.axis2.context.MessageContext newMsgContext)
+            throws org.apache.axis2.AxisFault {
 
         try {
 
@@ -60,7 +57,7 @@
                     //doc style
                     response = skel
                             .registerOperation((org.apache.axis2.om.OMElement) msgContext
-                                    .getEnvelope().getBody().getFirstChild()
+                                    .getEnvelope().getBody().getFirstElement()
                                     .detach());
 
                     //Create a default envelop
diff --git a/src/org/apache/kandula/wscoor/RegistrationRequesterPortTypeRawXMLSkeleton.java b/src/org/apache/kandula/wscoor/RegistrationRequesterPortTypeRawXMLSkeleton.java
index 0b5451b..e49860a 100644
--- a/src/org/apache/kandula/wscoor/RegistrationRequesterPortTypeRawXMLSkeleton.java
+++ b/src/org/apache/kandula/wscoor/RegistrationRequesterPortTypeRawXMLSkeleton.java
@@ -3,9 +3,9 @@
 import org.apache.axis2.addressing.EndpointReference;

 import org.apache.axis2.context.MessageContext;

 import org.apache.axis2.om.OMElement;

+import org.apache.kandula.Constants;

 import org.apache.kandula.context.AbstractContext;

 import org.apache.kandula.context.at.ATActivityContext;

-import org.apache.kandula.initiator.TransactionManager;

 import org.apache.kandula.storage.StorageFactory;

 import org.apache.kandula.utility.KandulaUtils;

 

@@ -41,10 +41,13 @@
     public OMElement registerResponseOperation(OMElement responseElement) {

         OMElement response = responseElement.getFirstElement();

         if ("CoordinatorProtocolService".equals(response.getLocalName())) {

+            OMElement header = msgContext.getEnvelope().getHeader();

+            String requesterID = header.getFirstChildWithName(

+                    Constants.REQUESTER_ID_PARAMETER).getText();

             EndpointReference coordinatorService = KandulaUtils

                     .endpointFromOM(response.getFirstElement());

             AbstractContext context = (AbstractContext) StorageFactory

-                    .getInstance().getStore().get(TransactionManager.tempID);

+                    .getInstance().getStore().get(requesterID);

             context.setProperty(ATActivityContext.COORDINATION_EPR,

                     coordinatorService);

         }