tying the RawXML skeletons with the core...

diff --git a/project.xml b/project.xml
index 1ab633f..99dca2a 100644
--- a/project.xml
+++ b/project.xml
@@ -44,10 +44,10 @@
   <!-- the version control repository and http url for online access

        the connection element has the form:

        scm:<system>:<system specific connection string> -->

-  <repository>

-    <connection>scm|svn|https://svn.apache.org/repos/asf/webservices/kandula/trunk/java/</connection>

+  <!--repository>

+    <connection>scm: svn:https://svn.apache.org/repos/asf/webservices/kandula/trunk/java/</connection>

     <url>http://svn.apache.org/repos/asf/webservices/kandula/trunk/java/</url>

-  </repository>

+  </repository-->

 

   <!-- any mailing lists for the project -->

     <mailingLists>

@@ -251,15 +251,14 @@
     <!-- ======= -->

 

     <reports>

-     <report>maven-license-plugin</report>

+     <report>maven-changes-plugin</report>

+        <report>maven-jdepend-plugin</report>

         <report>maven-checkstyle-plugin</report>

         <report>maven-pmd-plugin</report>

-        <report>maven-jdepend-plugin</report>

-        <report>maven-jxr-plugin</report>

-        <report>maven-javadoc-plugin</report>

         <report>maven-junit-report-plugin</report>

-        <report>maven-clover-plugin</report>

-        <report>maven-changes-plugin</report>

+        <report>maven-license-plugin</report>

+        <report>maven-jxr-plugin</report>

+

     </reports>

 </project>

 

diff --git a/src/org/apache/kandula/Constants.java b/src/org/apache/kandula/Constants.java
index 43d9f17..a90ea02 100644
--- a/src/org/apache/kandula/Constants.java
+++ b/src/org/apache/kandula/Constants.java
@@ -20,7 +20,7 @@
  * @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";
@@ -34,9 +34,9 @@
     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";
@@ -62,7 +62,7 @@
     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";
diff --git a/src/org/apache/kandula/Status.java b/src/org/apache/kandula/Status.java
index c04ae5c..61369e9 100644
--- a/src/org/apache/kandula/Status.java
+++ b/src/org/apache/kandula/Status.java
@@ -20,8 +20,9 @@
  * @author <a href="mailto:thilina@opensource.lk"> Thilina Gunarathne </a>
  */
 abstract public interface Status {
+    //TODO remove the inner interfaces.. 
     interface ParticipantStatus {
-        
+
         public static final int STATUS_VOLATILE_PREPARING = 20;
 
         public static final int STATUS_DURABLE_PREPARING = 21;
@@ -29,7 +30,9 @@
         public static final int STATUS_ABORTED = 22;
 
         public static final int STATUS_READ_ONLY = 23;
-        
+
+        public static final int STATUS_COMMITED = 24;
+
     }
 
     interface CoordinatorStatus {
@@ -45,6 +48,8 @@
         public static final int STATUS_PREPARING_VOLATILE = 12;
 
         public static final int STATUS_PREPARED_SUCCESS = 13;
+
+        public static final int STATUS_READ_ONLY = 23;
         
         public static final int STATUS_PREPARED = 14;
 
diff --git a/src/org/apache/kandula/context/AbstractContext.java b/src/org/apache/kandula/context/AbstractContext.java
index 607334a..4d1500e 100644
--- a/src/org/apache/kandula/context/AbstractContext.java
+++ b/src/org/apache/kandula/context/AbstractContext.java
@@ -32,7 +32,7 @@
  */
 public abstract class AbstractContext {
 
-    private HashMap propertyBag;
+    private final HashMap propertyBag;
 
     protected String activityID;
 
@@ -60,23 +60,25 @@
                 activityID, coordinationType, registrationEpr);
     }
 
-    public CoordinationContext getCoordinationContext() {
+    public final CoordinationContext getCoordinationContext() {
         return coordinationContext;
     }
 
-    public void setCoordinationContext(CoordinationContext context) {
+    public final void setCoordinationContext(CoordinationContext context) {
         this.coordinationContext = context;
     }
 
-    public int getStatus() {
+    public final int getStatus() {
         return status;
     }
 
-    public void setStatus(int value) {
+    // we can use a publisher-subscriber in the future to notify listeners abt
+    // state changes.
+    public final void setStatus(int value) {
         status = value;
     }
 
-    public synchronized void lock() {
+    public final synchronized void lock() {
         if (locked) {
             while (locked) {
                 try {
@@ -92,20 +94,21 @@
         locked = true;
     }
 
-    public synchronized void unlock() {
+    public final synchronized void unlock() {
         if (!locked)
             throw new IllegalStateException();
         locked = false;
         notify();
     }
 
-    public void setProperty(Object key, Object value) {
+    public final void setProperty(Object key, Object value) {
         propertyBag.put(key, value);
 
     }
 
-    public Object getProperty(Object key) {
+    public final Object getProperty(Object key) {
         return propertyBag.get(key);
     }
+
     public abstract String getCoordinationType();
 }
\ No newline at end of file
diff --git a/src/org/apache/kandula/context/ContextFactory.java b/src/org/apache/kandula/context/ContextFactory.java
index a96514b..dde0995 100644
--- a/src/org/apache/kandula/context/ContextFactory.java
+++ b/src/org/apache/kandula/context/ContextFactory.java
@@ -41,7 +41,7 @@
     }
 
     public AbstractContext createActivity(String protocol,
-                                          EndpointReference activationEPR) throws InvalidProtocolException {
+            EndpointReference activationEPR) throws InvalidProtocolException {
         if (org.apache.kandula.Constants.WS_AT.equalsIgnoreCase(protocol)) {
             return new ATActivityContext(activationEPR);
         } else {
@@ -50,7 +50,7 @@
     }
 
     public AbstractContext createActivity(CoordinationContext context)
-            throws InvalidProtocolException{
+            throws InvalidProtocolException {
         if (org.apache.kandula.Constants.WS_AT.equalsIgnoreCase(context
                 .getCoordinationType())) {
             return new ATActivityContext(context);
diff --git a/src/org/apache/kandula/context/Participant.java b/src/org/apache/kandula/context/Participant.java
index 4c4a5d8..ecba70d 100644
--- a/src/org/apache/kandula/context/Participant.java
+++ b/src/org/apache/kandula/context/Participant.java
@@ -1,52 +1,88 @@
 /*
-* 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.
-*
-*/
+ * 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.context;
 
 import org.apache.axis2.addressing.EndpointReference;
 
 /**
- * @author <a href="mailto:thilina@opensource.lk"> Thilina Gunarathne </a>
- *         <p/>
- *         Used to store the details about the participant & to store the runtime status
- *         of Participants
+ * @author <a href="mailto:thilina@opensource.lk"> Thilina Gunarathne </a> <p/>
+ *         Used to store the details about the participant & to store the
+ *         runtime status of Participants
  */
+//TODO see whether we can avoid this class
 public class Participant {
+    
     private EndpointReference epr;
-    private String protocol;
-    private int status;
 
+    private String protocol;
+
+    private int status;
+    
+    private String enlistmentId;
+
+    
     /**
      * @param epr
      * @param protocol
-     * @param activityId
+     * @param enlistmentId
      */
-    public Participant(EndpointReference epr, String protocol) {
+    public Participant(EndpointReference epr, String protocol,
+            String enlistmentId) {
         super();
         this.epr = epr;
         this.protocol = protocol;
+        this.enlistmentId = enlistmentId;
     }
-
-    public void setStatus(int status) {
-        this.status = status;
+    
+    /**
+     * @return Returns the enlistmentId.
+     */
+    public String getEnlistmentId() {
+        return enlistmentId;
     }
-
+    
+    /**
+     * @return Returns the epr.
+     */
+    public EndpointReference getEpr() {
+        return epr;
+    }
+    /**
+     * @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.
+     */
+    public void setStatus(int status) {
+        this.status = status;
+    }
+    /**
+     * @return Returns the protocol.
+     */
+    public String getProtocol() {
+        return protocol;
+    }
 }
\ No newline at end of file
diff --git a/src/org/apache/kandula/context/at/ATActivityContext.java b/src/org/apache/kandula/context/at/ATActivityContext.java
index 816d372..7ffbd9c 100644
--- a/src/org/apache/kandula/context/at/ATActivityContext.java
+++ b/src/org/apache/kandula/context/at/ATActivityContext.java
@@ -45,6 +45,9 @@
 
     private Hashtable durableParticipantsTable;
 
+    //TODO : check whether there can be more than 1 initiator
+    private EndpointReference completionParticipant;
+
     private boolean subVolatileRegistered = false;
 
     private boolean subDurableRegistered = false;
@@ -52,12 +55,11 @@
     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
      */
@@ -69,13 +71,15 @@
     }
 
     /**
-     * @param context To be used when coordinator is used as a sub ordinate to an another  cooordinator
+     * @param context
+     *            To be used when coordinator is used as a sub ordinate to an
+     *            another cooordinator
      */
     public ATActivityContext(CoordinationContext context) {
         subOrdinate = true;
         parentEPR = context.getRegistrationService();
-//        context.setRegistrationService(EndpointReferenceFactory.getInstance()
-//                .getRegistrationEndpoint());
+        //        context.setRegistrationService(EndpointReferenceFactory.getInstance()
+        //                .getRegistrationEndpoint());
         this.setStatus(Status.CoordinatorStatus.STATUS_ACTIVE);
         volatileParticipantsTable = new Hashtable();
         durableParticipantsTable = new Hashtable();
@@ -83,11 +87,13 @@
     }
 
     /**
-     * @param id To be used when using as the requester
+     * @param id
+     *            To be used when using as the requester
      */
     public ATActivityContext(EndpointReference activationEPR) {
         super();
-        this.setProperty(REQUESTER_ID, KandulaUtils.getRandomStringOf18Characters());
+        this.setProperty(REQUESTER_ID, KandulaUtils
+                .getRandomStringOf18Characters());
         this.setProperty(ACTIVATION_EPR, activationEPR);
     }
 
@@ -97,41 +103,44 @@
      * @return Coordinator protocol service.
      * @throws AbstractKandulaException
      */
-    public EndpointReference addParticipant(EndpointReference participantEPR, String protocol)
-            throws AbstractKandulaException {
+    public EndpointReference addParticipant(EndpointReference participantEPR,
+            String protocol) throws AbstractKandulaException {
+        String enlistmentID = KandulaUtils.getRandomStringOf18Characters();
         if (Constants.WS_AT_VOLATILE2PC.equals(protocol)) {
-            addVolatileParticipant(participantEPR);
-            return EndpointReferenceFactory.getInstance().get2PCEndpoint(this.activityID);
+            addVolatileParticipant(participantEPR,enlistmentID);
+            return EndpointReferenceFactory.getInstance().get2PCEndpoint(
+                    this.activityID);
         } else if (Constants.WS_AT_DURABLE2PC.equals(protocol)) {
-            addDurableParticipant(participantEPR);
-            return EndpointReferenceFactory.getInstance().get2PCEndpoint(this.activityID);
+            addDurableParticipant(participantEPR,enlistmentID);
+            return EndpointReferenceFactory.getInstance().get2PCEndpoint(
+                    this.activityID);
         } else if (Constants.WS_AT_COMPLETION.equals(protocol)) {
-            //TODO keep track of requesters
-            return EndpointReferenceFactory.getInstance().getCompletionEndpoint(this.activityID);
+            completionParticipant = participantEPR;
+            return EndpointReferenceFactory.getInstance()
+                    .getCompletionEndpoint(this.activityID);
         } else {
             throw new InvalidProtocolException();
         }
     }
 
-    public void addVolatileParticipant(EndpointReference participantEPR)
+    public void addVolatileParticipant(EndpointReference participantEPR, String enlistmentID)
             throws AbstractKandulaException {
         if (volatileParticipantsTable.contains(participantEPR))
             throw new AlreadyRegisteredException();
-        volatileParticipantsTable.put(participantEPR, new Participant(
-                participantEPR, Constants.WS_AT_VOLATILE2PC));
-
+        Participant participant = new Participant(participantEPR, Constants.WS_AT_VOLATILE2PC,enlistmentID);
+        volatileParticipantsTable.put(enlistmentID, participant);
     }
 
-    public void addDurableParticipant(EndpointReference participantEPR)
+    public void addDurableParticipant(EndpointReference participantEPR, String enlistmentID)
             throws AlreadyRegisteredException {
         if (durableParticipantsTable.contains(participantEPR))
             throw new AlreadyRegisteredException();
-        durableParticipantsTable.put(participantEPR, new Participant(
-                participantEPR, Constants.WS_AT_DURABLE2PC));
+        Participant participant = new Participant(participantEPR, Constants.WS_AT_DURABLE2PC,enlistmentID);
+        durableParticipantsTable.put(enlistmentID, participant);
 
     }
 
-    public Iterator getRegisteredParticipants(String protocol) {
+    public Iterator getRegistered2PCParticipants(String protocol) {
         if (protocol.equals(Constants.WS_AT_VOLATILE2PC)) {
             return volatileParticipantsTable.values().iterator();
         } else if (protocol.equals(Constants.WS_AT_DURABLE2PC)) {
@@ -140,16 +149,44 @@
         return null;
     }
 
-    public Iterator getAllParticipants() {
+    public Iterator getAll2PCParticipants() {
         LinkedList list = new LinkedList(volatileParticipantsTable.values());
         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
+        {
+            return null;
+        }
+    }
+
+    /**
+     * @return the completion initiator epr
+     */
+    public EndpointReference getCompletionParticipant() {
+        return completionParticipant;
+    }
 
     public void countPreparing() {
         preparingParticipantsCount++;
 
     }
+    
+    public void decrementPreparing()
+    {
+        preparingParticipantsCount--;
+    }
 
     public boolean hasMorePreparing() {
         return (preparingParticipantsCount > 0);
@@ -171,6 +208,7 @@
     public void setSubDurableRegistered(boolean value) {
         subDurableRegistered = value;
     }
+
     //    public void prepared(Participant participant)
     //    {
     //        if (participant.getStatus()==Status.ParticipantStatus.STATUS_ABORTED)
@@ -179,7 +217,6 @@
     //        }
     //    }
 
-    
     public String getCoordinationType() {
         return Constants.WS_AT;
     }
diff --git a/src/org/apache/kandula/context/coordination/CoordinationContext.java b/src/org/apache/kandula/context/coordination/CoordinationContext.java
index dc21655..6753b49 100644
--- a/src/org/apache/kandula/context/coordination/CoordinationContext.java
+++ b/src/org/apache/kandula/context/coordination/CoordinationContext.java
@@ -44,17 +44,19 @@
     public abstract Object getCoordinationContextType();
 
     public static final class Factory {
-        public static CoordinationContext newContext(String activityId ,String coordinationType, EndpointReference epr) {
-            return new SimpleCoordinationContext(activityId,coordinationType, epr);
+        public static CoordinationContext newContext(String activityId,
+                String coordinationType, EndpointReference epr) {
+            return new SimpleCoordinationContext(activityId, coordinationType,
+                    epr);
         }
 
         public static CoordinationContext newContext(OMElement contextElement) {
             return new SimpleCoordinationContext(contextElement);
         }
 
-//        public static CoordinationContext newInstance(Object contextType) {
-//            return new XmlBeansTypeCoordinationContext(contextType);
-//        }
+        //        public static CoordinationContext newInstance(Object contextType) {
+        //            return new XmlBeansTypeCoordinationContext(contextType);
+        //        }
 
         private Factory() {
         } // No instance of this class allowed
diff --git a/src/org/apache/kandula/context/coordination/SimpleCoordinationContext.java b/src/org/apache/kandula/context/coordination/SimpleCoordinationContext.java
index 8a98d5e..a9ab027 100644
--- a/src/org/apache/kandula/context/coordination/SimpleCoordinationContext.java
+++ b/src/org/apache/kandula/context/coordination/SimpleCoordinationContext.java
@@ -16,10 +16,14 @@
  */
 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.AddressingConstants.Final;
 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;
@@ -27,9 +31,6 @@
 import org.apache.kandula.Constants;
 import org.apache.kandula.utility.KandulaUtils;
 
-import javax.xml.namespace.QName;
-import java.util.Iterator;
-
 /**
  * @author <a href="mailto:thilina@opensource.lk"> Thilina Gunarathne </a>
  */
@@ -44,9 +45,10 @@
 
     private OMElement contextElement = null;
 
-    public SimpleCoordinationContext(String activityID,String coordinationType, EndpointReference epr) {
+    public SimpleCoordinationContext(String activityID,
+            String coordinationType, EndpointReference epr) {
         this.activityID = activityID;
-        this.coordinationType  = coordinationType;
+        this.coordinationType = coordinationType;
         this.registrationServiceEpr = epr;
     }
 
@@ -57,9 +59,10 @@
                 new QName("Identifier")).getText();
         coordinationType = contextElement.getFirstChildWithName(
                 new QName("CoordinationType")).getText();
-        OMElement registrationElement = contextElement.getFirstChildWithName(
-                new QName("RegistrationService"));
-        registrationServiceEpr = KandulaUtils.endpointFromOM(registrationElement);
+        OMElement registrationElement = contextElement
+                .getFirstChildWithName(new QName("RegistrationService"));
+        registrationServiceEpr = KandulaUtils
+                .endpointFromOM(registrationElement);
     }
 
     public String getActivityID() {
diff --git a/src/org/apache/kandula/coordinator/Coordinator.java b/src/org/apache/kandula/coordinator/Coordinator.java
index 0f7f5b3..7932e01 100644
--- a/src/org/apache/kandula/coordinator/Coordinator.java
+++ b/src/org/apache/kandula/coordinator/Coordinator.java
@@ -40,8 +40,7 @@
     }

 

     /**

-     * @param Coordination

-     *            Type

+     * @param coordinationType

      * @return the Coordination Context created <p/>Initiators can use this to

      *         Create new Distributed transactions.This will take in the

      *         Coordination Type and will create an instance of the reapective

@@ -56,13 +55,12 @@
         AbstractContext context = factory.createActivity(coordinationType);

         context.getCoordinationContext().setExpires(expires);

         ACTIVITY_ID = context.getCoordinationContext().getActivityID();

-        store.put(context.getCoordinationContext().getActivityID(),

-                context);

+        store.put(context.getCoordinationContext().getActivityID(), context);

         return context;

     }

 

     /**

-     * @param CoordinationContext

+     * @param coorContext

      * @return the interposed Coordination Context created <p/>Participants

      *         decided to use this Coordinator as a interposed

      *         sub-coordinator.The newly created CoordinationContext will

@@ -74,15 +72,14 @@
             CoordinationContext coorContext) throws AbstractKandulaException {

         ContextFactory factory = ContextFactory.getInstance();

         AbstractContext context = factory.createActivity(coorContext);

-        store.put(context.getCoordinationContext().getActivityID(),

-                context);

+        store.put(context.getCoordinationContext().getActivityID(), context);

         return context;

     }

 

     /**

-     * @param coordinationProtocol

+     * @param protocol

      * @param participantEPR

-     * @param Activity-id

+     * @param id

      * @return Should return the particular Coordiators End Point Reference <p/>

      *         This method provides the functional logic for participants to

      *         register for a particular transaction activity which was created

@@ -106,6 +103,6 @@
     }

 

     private AbstractContext getCoordinationContext(String id) {

-        return (AbstractContext)store.get(id);

+        return (AbstractContext) store.get(id);

     }

 }
\ No newline at end of file
diff --git a/src/org/apache/kandula/coordinator/CoordinatorUtils.java b/src/org/apache/kandula/coordinator/CoordinatorUtils.java
deleted file mode 100644
index ac461fa..0000000
--- a/src/org/apache/kandula/coordinator/CoordinatorUtils.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * 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.coordinator;
-
-import java.util.Random;
-
-import org.apache.kandula.context.AbstractContext;
-
-/**
- * @author <a href="mailto:thilina@opensource.lk"> Thilina Gunarathne </a>
- */
-public class CoordinatorUtils {
-    private static Random myRand = null;
-
-    public static AbstractContext getActivityContext(String id) {
-        return null;
-    }
-}
\ No newline at end of file
diff --git a/src/org/apache/kandula/coordinator/Registerable.java b/src/org/apache/kandula/coordinator/Registerable.java
index 3fcb218..6e0597c 100644
--- a/src/org/apache/kandula/coordinator/Registerable.java
+++ b/src/org/apache/kandula/coordinator/Registerable.java
@@ -38,7 +38,8 @@
                 return new ATCoordinator();

 

             } else {

-                throw new InvalidProtocolException("Unsupported Coordination Type");

+                throw new InvalidProtocolException(

+                        "Unsupported Coordination Type");

             }

         }

 

diff --git a/src/org/apache/kandula/coordinator/at/ATCoordinator.java b/src/org/apache/kandula/coordinator/at/ATCoordinator.java
index f9ba140..9fd7977 100644
--- a/src/org/apache/kandula/coordinator/at/ATCoordinator.java
+++ b/src/org/apache/kandula/coordinator/at/ATCoordinator.java
@@ -23,251 +23,308 @@
 import org.apache.kandula.Status;
 import org.apache.kandula.Status.CoordinatorStatus;
 import org.apache.kandula.context.AbstractContext;
+import org.apache.kandula.context.Participant;
 import org.apache.kandula.context.at.ATActivityContext;
-import org.apache.kandula.coordinator.CoordinatorUtils;
 import org.apache.kandula.coordinator.Registerable;
 import org.apache.kandula.faults.AbstractKandulaException;
-import org.apache.kandula.faults.InvalidProtocolException;
 import org.apache.kandula.faults.InvalidStateException;
+import org.apache.kandula.participant.Vote;
+import org.apache.kandula.storage.StorageFactory;
+import org.apache.kandula.storage.Store;
+import org.apache.kandula.wsat.completion.CompletionInitiatorPortTypeRawXMLStub;
+import org.apache.kandula.wsat.twopc.ParticipantPortTypeRawXMLStub;
 
 /**
  * @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 {
-        context.lock();
-        switch (context.getStatus()) {
-            case CoordinatorStatus.STATUS_PREPARING_DURABLE:
-                context.unlock();
-                this.abort(context);
-                throw new InvalidStateException(
-                        "Coordinator is in preparing state - Durable ");
-            case CoordinatorStatus.STATUS_PREPARED_SUCCESS:
-                context.unlock();
-                throw new InvalidStateException(
-                        "Coordinator is in prepared success state");
-            case CoordinatorStatus.STATUS_COMMITTING:
-                context.unlock();
-                throw new InvalidStateException(
-                        "Coordinator is in committing state");
-            case CoordinatorStatus.STATUS_ABORTING:
-                throw new InvalidStateException("Coordinator is in Aborting state");
-            case CoordinatorStatus.STATUS_ACTIVE:
-            case CoordinatorStatus.STATUS_PREPARING_VOLATILE:
-                return addParticipant(context, protocol, participantEPR);
-            case CoordinatorStatus.STATUS_NONE:
-            default:
-                context.unlock();
-                throw new InvalidStateException();
+            EndpointReference participantEPR) throws AbstractKandulaException {
+        ATActivityContext atContext = (ATActivityContext) context;
+        atContext.lock();
+        switch (atContext.getStatus()) {
+        case CoordinatorStatus.STATUS_PREPARING_DURABLE:
+            atContext.unlock();
+            try {
+                this.abortActivity(atContext);
+            } catch (Exception e) {
+                throw new InvalidStateException(e);
+            }
+            throw new InvalidStateException(
+                    "Coordinator is in preparing state - Durable ");
+        case CoordinatorStatus.STATUS_PREPARED_SUCCESS:
+            atContext.unlock();
+            throw new InvalidStateException(
+                    "Coordinator is in prepared success state");
+        case CoordinatorStatus.STATUS_COMMITTING:
+            atContext.unlock();
+            throw new InvalidStateException(
+                    "Coordinator is in committing state");
+        case CoordinatorStatus.STATUS_ABORTING:
+            atContext.unlock();
+            throw new InvalidStateException("Coordinator is in Aborting state");
+        case CoordinatorStatus.STATUS_ACTIVE:
+        case CoordinatorStatus.STATUS_PREPARING_VOLATILE:
+            atContext.unlock();
+            return atContext.addParticipant( participantEPR,protocol);
+        case CoordinatorStatus.STATUS_NONE:
+        default:
+            atContext.unlock();
+            throw new InvalidStateException();
         }
     }
 
     /**
-     * @param Activity Id taken from the Request
-     * @return should be a notification This wraps the Commit operation defined
-     *         in Ws-AtomicTransaction specification.
+     * should send be a notification This wraps the Commit operation defined in
+     * Ws-AtomicTransaction specification.
+     * 
+     * @throws Exception
      */
-    public String commitOperation(String id) throws IllegalAccessException {
-        AbstractContext context = CoordinatorUtils.getActivityContext(id);
-        // if store throws a Exception capture it
-        if (context == null) {
+    public void commitOperation(String id) throws AbstractKandulaException {
+        CompletionInitiatorPortTypeRawXMLStub stub;
+        ATActivityContext atContext = (ATActivityContext)store.get(id);
+        
+        if (atContext == null) {
             throw new IllegalStateException(
                     "No Activity Found for this Activity ID");
         }
 
         /*
-         * Check for states Do we need to lock the activity
+         * Check for states TODO Do we actually need to lock the activity
          */
-        context.lock();
-        switch (context.getStatus()) {
-            case CoordinatorStatus.STATUS_NONE:
-            case CoordinatorStatus.STATUS_ABORTING:
-                context.unlock();
-                return "Aborted";
-            case CoordinatorStatus.STATUS_PREPARING_DURABLE:
-            case CoordinatorStatus.STATUS_PREPARING_VOLATILE:
-            case CoordinatorStatus.STATUS_PREPARED_SUCCESS:
-                //If prepared success Ignore this message
-                context.unlock();
-                return null;
-            case CoordinatorStatus.STATUS_COMMITTING:
-                context.unlock();
-                return "Committed";
-            case Status.CoordinatorStatus.STATUS_ACTIVE:
-                int result;
-                result = volatilePrepare(context);
-
-                if (result == Status.CoordinatorStatus.STATUS_ABORTING) {
-                    context.lock();
-                    context.setStatus(Status.CoordinatorStatus.STATUS_ABORTING);
-                    context.unlock();
-                    abort(context);
+        atContext.lock();
+        switch (atContext.getStatus()) {
+        case CoordinatorStatus.STATUS_NONE:
+        case CoordinatorStatus.STATUS_ABORTING:
+            atContext.unlock();
+            stub = new CompletionInitiatorPortTypeRawXMLStub(".", atContext
+                    .getCompletionParticipant());
+            stub.abortedOperation();
+            break;
+        case CoordinatorStatus.STATUS_PREPARING_DURABLE:
+        case CoordinatorStatus.STATUS_PREPARING_VOLATILE:
+        case CoordinatorStatus.STATUS_PREPARED_SUCCESS:
+            //If prepared success Ignore this message
+            atContext.unlock();
+            break;
+        case CoordinatorStatus.STATUS_COMMITTING:
+            atContext.unlock();
+            stub = new CompletionInitiatorPortTypeRawXMLStub(".", atContext
+                    .getCompletionParticipant());
+            stub.committedOperation();
+            break;
+        case Status.CoordinatorStatus.STATUS_ACTIVE:
+            atContext.setStatus(Status.CoordinatorStatus.STATUS_PREPARING);
+            atContext.unlock();
+            volatilePrepare(atContext);
+            // wait till all the Volatile prepare()'s are done
+            while (atContext.hasMorePreparing()) {
+                if (atContext.getStatus() == Status.CoordinatorStatus.STATUS_ABORTING)
+                {
+                    abortActivity(atContext);
+                stub = new CompletionInitiatorPortTypeRawXMLStub(".", atContext
+                        .getCompletionParticipant());
+                stub.abortedOperation();
+                return;
                 }
+            }
+            durablePrepare(atContext);
+            //wait till all the Durable prepare()'s are done
+            while (atContext.hasMorePreparing()) {
+                if (atContext.getStatus() == Status.CoordinatorStatus.STATUS_ABORTING)
+                    abortActivity(atContext);
 
-                result = commit(context);
-                return null;
-            default:
-                context.unlock();
-                return null;
+                return;
+            }
+            commitActivity(atContext);
+            break;
+        default:
+            atContext.unlock();
+            break;
         }
 
     }
 
-    public String rollbackOperation(String id) throws IllegalAccessException {
-        AbstractContext context = CoordinatorUtils.getActivityContext(id);
+    public void rollbackOperation(String id) throws Exception {
+        CompletionInitiatorPortTypeRawXMLStub stub;
+        ATActivityContext atContext = (ATActivityContext)store.get(id);
+
         // if store throws a Exception capture it
-        if (context == null) {
+        if (atContext == null) {
             throw new IllegalStateException(
                     "No Activity Found for this Activity ID");
         }
         /*
-         * Check for states Do we need to lock the activity
+         * Check for states TODO Do we need to lock the activity
          */
-        context.lock();
-        switch (context.getStatus()) {
-            case CoordinatorStatus.STATUS_NONE:
-            case CoordinatorStatus.STATUS_ABORTING:
-                context.unlock();
-                return "Aborted";
-            case CoordinatorStatus.STATUS_PREPARING_DURABLE:
-            case CoordinatorStatus.STATUS_PREPARING_VOLATILE:
-            case CoordinatorStatus.STATUS_PREPARED_SUCCESS:
-                //If prepared success Ignore this message
-                context.unlock();
-                return null;
-            case CoordinatorStatus.STATUS_COMMITTING:
-                context.unlock();
-                return "Committed";
-            case Status.CoordinatorStatus.STATUS_ACTIVE:
-                context.setStatus(Status.CoordinatorStatus.STATUS_ABORTING);
-                context.unlock();
-                int result = abort(context);
-                //                if (result ==fdsfsfd)
-                //                {
-                //                    throw new Exception
-                //                }
-
-                return null;
-            default:
-                context.unlock();
-                return null;
+        atContext.lock();
+        switch (atContext.getStatus()) {
+        case CoordinatorStatus.STATUS_NONE:
+        case CoordinatorStatus.STATUS_ABORTING:
+            atContext.unlock();
+            stub = new CompletionInitiatorPortTypeRawXMLStub(".", atContext
+                    .getCompletionParticipant());
+            stub.abortedOperation();
+            break;
+        case CoordinatorStatus.STATUS_PREPARING_DURABLE:
+        case CoordinatorStatus.STATUS_PREPARING_VOLATILE:
+        case CoordinatorStatus.STATUS_PREPARED_SUCCESS:
+            //If prepared success Ignoring
+            atContext.unlock();
+            break;
+        case CoordinatorStatus.STATUS_COMMITTING:
+            atContext.unlock();
+            stub = new CompletionInitiatorPortTypeRawXMLStub(".", atContext
+                    .getCompletionParticipant());
+            stub.committedOperation();
+            break;
+        case Status.CoordinatorStatus.STATUS_ACTIVE:
+            atContext.setStatus(Status.CoordinatorStatus.STATUS_ABORTING);
+            atContext.unlock();
+            abortActivity(atContext);
+            break;
+        default:
+            atContext.unlock();
+            break;
         }
     }
 
     /**
      * @param context
-     * @return the status of the Activity after the volatile preparation
+     * @throws Exception
      * @see This methode issues the oneway prepare() message. Does not wait till
      *      partipants responds. Used in 2PC after user commits as well as in
      *      subordinate scenerio, when parent issues volatile prepare(). One can
      *      check if there are any more participants to be responded by checking
      *      the hasMorePreparing() methode of the context.
      */
-    public int volatilePrepare(AbstractContext context) {
+    public void volatilePrepare(AbstractContext context)
+            throws AbstractKandulaException {
+        ParticipantPortTypeRawXMLStub stub = new ParticipantPortTypeRawXMLStub(
+                ".");
         ATActivityContext atContext = (ATActivityContext) context;
         Iterator volatilePartipantIterator = atContext
-                .getRegisteredParticipants(Constants.WS_AT_VOLATILE2PC);
+                .getRegistered2PCParticipants(Constants.WS_AT_VOLATILE2PC);
         if (volatilePartipantIterator.hasNext()) {
+            atContext.lock();
             atContext
                     .setStatus(Status.CoordinatorStatus.STATUS_PREPARING_VOLATILE);
             atContext.unlock();
             while (volatilePartipantIterator.hasNext()) {
                 atContext.countPreparing();
-                // participantPortType port
-                // port.prepare
+                stub.prepareOperation(((Participant) volatilePartipantIterator
+                        .next()).getEpr());
             }
         }
-        return atContext.getStatus();
+    }
+    
+    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))
+        {
+            participant.setStatus(Status.ParticipantStatus.STATUS_ABORTED);
+            abortActivity(context);
+        }
+        context.decrementPreparing();
     }
 
     /**
      * @param context
-     * @return the status of the Activity after the Durable preparation
+     * @throws Exception
      * @see This methode issues the oneway prepare() message. Does not wait till
      *      partipants responds. Used in 2PC after user commits as well as in
      *      subordinate scenerio, when parent issues Durable prepare(). One can
      *      check if there are any more participants to be responded by checking
      *      the hasMorePreparing() methode of the context.
      */
-    public int durablePrepare(AbstractContext context) {
+    public void durablePrepare(AbstractContext context)
+            throws AbstractKandulaException {
+        ParticipantPortTypeRawXMLStub stub = new ParticipantPortTypeRawXMLStub(
+                ".");
         ATActivityContext atContext = (ATActivityContext) context;
         Iterator durablePartipantIterator = atContext
-                .getRegisteredParticipants(Constants.WS_AT_DURABLE2PC);
+                .getRegistered2PCParticipants(Constants.WS_AT_DURABLE2PC);
         if (durablePartipantIterator.hasNext()) {
-            // wait till all the Volatile prepare()'s are done
-            while (atContext.hasMorePreparing()) {
-                if (atContext.getStatus() == Status.CoordinatorStatus.STATUS_ABORTING)
-                    return Status.CoordinatorStatus.STATUS_ABORTING;
-            }
+
             atContext.lock();
             atContext
                     .setStatus(Status.CoordinatorStatus.STATUS_PREPARING_DURABLE);
             atContext.unlock();
             while (durablePartipantIterator.hasNext()) {
                 atContext.countPreparing();
-                //port.prepare
+                stub.prepareOperation(((Participant) durablePartipantIterator
+                        .next()).getEpr());
             }
         }
-        return atContext.getStatus();
     }
 
     /**
      * @param context
-     * @return the status of the Activity
+     * @throws Exception
      * @see This will send the commit() messages to all the participants
      *      registered for the Transaction Must check whether all the
      *      participants have replied to the prepare()
      */
-    public int commit(AbstractContext context) {
-        // check whether all participants are prepared
+    private void commitActivity(AbstractContext context)
+            throws AbstractKandulaException {
+        // check whether all participants have prepared
+        ParticipantPortTypeRawXMLStub stub = new ParticipantPortTypeRawXMLStub(
+                ".");
         ATActivityContext atContext = (ATActivityContext) context;
-        while (atContext.hasMorePreparing()) {
-            if (atContext.getStatus() == Status.CoordinatorStatus.STATUS_ABORTING)
-                return Status.CoordinatorStatus.STATUS_ABORTING;
-        }
+
         atContext.lock();
         atContext.setStatus(Status.CoordinatorStatus.STATUS_COMMITTING);
         atContext.unlock();
-        Iterator participants = atContext.getAllParticipants();
-
+        Iterator participants = atContext.getAll2PCParticipants();
         while (participants.hasNext()) {
-            //port.commit(participant)
+            stub.commitOperation(((Participant) participants.next()).getEpr());
         }
-        return Status.CoordinatorStatus.STATUS_COMMITTING;
+        CompletionInitiatorPortTypeRawXMLStub completionStub = new CompletionInitiatorPortTypeRawXMLStub(
+                ".", atContext.getCompletionParticipant());
+        completionStub.committedOperation();
     }
 
     /**
      * @param context
-     * @return the status of the Activity
+     * @throws Exception
      * @see This will send the rollback() messages to all the participants
      *      registered for the Transaction Do not have to check whether all the
      *      participants have replied to the prepare()
      */
-    public int abort(AbstractContext context) {
+    private void abortActivity(AbstractContext context)
+            throws AbstractKandulaException {
+        ParticipantPortTypeRawXMLStub stub = new ParticipantPortTypeRawXMLStub(
+                ".");
         ATActivityContext atContext = (ATActivityContext) context;
         atContext.lock();
         atContext.setStatus(Status.CoordinatorStatus.STATUS_ABORTING);
         atContext.unlock();
-        Iterator participants = atContext.getAllParticipants();
+        Iterator participants = atContext.getAll2PCParticipants();
 
         while (participants.hasNext()) {
-            //port.rollback(participant)
+            stub
+                    .rollbackOperation(((Participant) participants.next())
+                            .getEpr());
         }
-        return Status.CoordinatorStatus.STATUS_ABORTING;
+        CompletionInitiatorPortTypeRawXMLStub completionStub = new CompletionInitiatorPortTypeRawXMLStub(
+                ".", atContext.getCompletionParticipant());
+        completionStub.abortedOperation();
     }
 
-    public EndpointReference addParticipant(AbstractContext context, String protocol,
-                                            EndpointReference participantEPR) throws AbstractKandulaException {
-        ATActivityContext atContext = (ATActivityContext) context;
-        if (protocol.equals(Constants.WS_AT_DURABLE2PC))
-            return atContext.addParticipant(participantEPR, protocol);
-        else if (protocol.equals(Constants.WS_AT_VOLATILE2PC))
-            return atContext.addParticipant(participantEPR, protocol);
-        else if (protocol.equals(Constants.WS_AT_COMPLETION))
-            return atContext.addParticipant(participantEPR, protocol);
-        else
-            throw new InvalidProtocolException();
-    }
 }
\ No newline at end of file
diff --git a/src/org/apache/kandula/coordinator/at/ATSubCoordinator.java b/src/org/apache/kandula/coordinator/at/ATSubCoordinator.java
index ec1bca1..ed4809e 100644
--- a/src/org/apache/kandula/coordinator/at/ATSubCoordinator.java
+++ b/src/org/apache/kandula/coordinator/at/ATSubCoordinator.java
@@ -28,18 +28,19 @@
  */
 public class ATSubCoordinator extends ATCoordinator {
 
-    public String commitOperation(String id) throws IllegalAccessException {
-        throw new IllegalAccessException(
+    public void commitOperation(String id) throws AbstractKandulaException {
+        throw new InvalidProtocolException(
                 "This activity is a Sub Ordinate activity. Completion Protocol not supported.");
     }
 
-    public String rollbackOperation(String id) throws IllegalAccessException {
-        throw new IllegalAccessException(
+    public void rollbackOperation(String id) throws AbstractKandulaException {
+        throw new InvalidProtocolException(
                 "This activity is a Sub Ordinate activity. Completion Protocol not supported.");
     }
 
-    public EndpointReference addParticipant(AbstractContext context, String protocol,
-                                            EndpointReference participantEPR) throws AbstractKandulaException {
+    public EndpointReference addParticipant(AbstractContext context,
+            String protocol, EndpointReference participantEPR)
+            throws AbstractKandulaException {
         ATActivityContext atContext = (ATActivityContext) context;
         if (protocol.equals(Constants.WS_AT_DURABLE2PC)) {
             if (!atContext.getSubDurableRegistered()) {
diff --git a/src/org/apache/kandula/coordinator/ba/BACoordinator.java b/src/org/apache/kandula/coordinator/ba/BACoordinator.java
index 01aef46..059f2c8 100644
--- a/src/org/apache/kandula/coordinator/ba/BACoordinator.java
+++ b/src/org/apache/kandula/coordinator/ba/BACoordinator.java
@@ -26,7 +26,9 @@
  */
 public class BACoordinator implements Registerable {
 
-    public EndpointReference register(AbstractContext context, String protocol, EndpointReference participantEPR) throws AbstractKandulaException {
-        return null;  //To change body of implemented methods use File | Settings | File Templates.
+    public EndpointReference register(AbstractContext context, String protocol,
+            EndpointReference participantEPR) throws AbstractKandulaException {
+        return null; //To change body of implemented methods use File |
+                     // Settings | File Templates.
     }
 }
\ No newline at end of file
diff --git a/src/org/apache/kandula/faults/AbstractKandulaException.java b/src/org/apache/kandula/faults/AbstractKandulaException.java
index 1c09edb..ccdc007 100644
--- a/src/org/apache/kandula/faults/AbstractKandulaException.java
+++ b/src/org/apache/kandula/faults/AbstractKandulaException.java
@@ -19,29 +19,33 @@
 /**
  * @author <a href="mailto:thilina@opensource.lk"> Thilina Gunarathne </a>
  */
-public abstract class AbstractKandulaException extends Exception{
-    
+public abstract class AbstractKandulaException extends Exception {
+
     public AbstractKandulaException() {
         super();
     }
 
     /**
-     * @param arg0 - String
+     * @param arg0 -
+     *            String
      */
     public AbstractKandulaException(String arg0) {
         super(arg0);
     }
 
     /**
-     * @param arg0 - Throwable
+     * @param arg0 -
+     *            Throwable
      */
     public AbstractKandulaException(Throwable arg0) {
         super(arg0);
     }
 
     /**
-     * @param arg0 - String
-     * @param arg1 - Throwable
+     * @param arg0 -
+     *            String
+     * @param arg1 -
+     *            Throwable
      */
     public AbstractKandulaException(String arg0, Throwable arg1) {
         super(arg0, arg1);
@@ -53,8 +57,7 @@
 
     public abstract String getFaultReason();
 
-    public String getFaultDetail()
-    {
+    public String getFaultDetail() {
         return this.toString();
     }
 
diff --git a/src/org/apache/kandula/faults/InvalidParameterException.java b/src/org/apache/kandula/faults/InvalidParameterException.java
index 28fa137..1c723a3 100644
--- a/src/org/apache/kandula/faults/InvalidParameterException.java
+++ b/src/org/apache/kandula/faults/InvalidParameterException.java
@@ -22,7 +22,7 @@
 public class InvalidParameterException extends AbstractKandulaException {
 
     /**
-     * 
+     *  
      */
     public InvalidParameterException() {
         super();
@@ -50,21 +50,27 @@
         super(arg0, arg1);
     }
 
-    /* (non-Javadoc)
+    /*
+     * (non-Javadoc)
+     * 
      * @see org.apache.kandula.faults.KandulaFault#getFaultCode()
      */
     public String getFaultCode() {
         return "Sender";
     }
 
-    /* (non-Javadoc)
+    /*
+     * (non-Javadoc)
+     * 
      * @see org.apache.kandula.faults.KandulaFault#getFaultSubcode()
      */
     public String getFaultSubcode() {
         return "wscoor:InvalidParameters";
     }
 
-    /* (non-Javadoc)
+    /*
+     * (non-Javadoc)
+     * 
      * @see org.apache.kandula.faults.KandulaFault#getFaultReason()
      */
     public String getFaultReason() {
diff --git a/src/org/apache/kandula/faults/InvalidProtocolException.java b/src/org/apache/kandula/faults/InvalidProtocolException.java
index 61c6ccf..1bedfb1 100644
--- a/src/org/apache/kandula/faults/InvalidProtocolException.java
+++ b/src/org/apache/kandula/faults/InvalidProtocolException.java
@@ -22,7 +22,7 @@
 public class InvalidProtocolException extends AbstractKandulaException {
 
     /**
-     * 
+     *  
      */
     public InvalidProtocolException() {
         super();
@@ -50,24 +50,30 @@
         super(arg0, arg1);
     }
 
-    /* (non-Javadoc)
+    /*
+     * (non-Javadoc)
+     * 
      * @see org.apache.kandula.faults.KandulaFault#getFaultCode()
      */
     public String getFaultCode() {
         return "Sender";
     }
 
-    /* (non-Javadoc)
+    /*
+     * (non-Javadoc)
+     * 
      * @see org.apache.kandula.faults.KandulaFault#getFaultSubcode()
      */
     public String getFaultSubcode() {
         return "wscoor:InvalidProtocol";
     }
 
-    /* (non-Javadoc)
+    /*
+     * (non-Javadoc)
+     * 
      * @see org.apache.kandula.faults.KandulaFault#getFaultReason()
      */
     public String getFaultReason() {
         return "The protocol is invalid or is not supported by the coordinator.";
     }
-}
+}
\ No newline at end of file
diff --git a/src/org/apache/kandula/faults/InvalidStateException.java b/src/org/apache/kandula/faults/InvalidStateException.java
index 4fb0d07..d08d0d7 100644
--- a/src/org/apache/kandula/faults/InvalidStateException.java
+++ b/src/org/apache/kandula/faults/InvalidStateException.java
@@ -22,7 +22,7 @@
 public class InvalidStateException extends AbstractKandulaException {
 
     /**
-     * 
+     *  
      */
     public InvalidStateException() {
         super();
@@ -50,21 +50,27 @@
         super(arg0, arg1);
     }
 
-    /* (non-Javadoc)
+    /*
+     * (non-Javadoc)
+     * 
      * @see org.apache.kandula.faults.KandulaFault#getFaultCode()
      */
     public String getFaultCode() {
         return "Sender";
     }
 
-    /* (non-Javadoc)
+    /*
+     * (non-Javadoc)
+     * 
      * @see org.apache.kandula.faults.KandulaFault#getFaultSubcode()
      */
     public String getFaultSubcode() {
         return "wscoor:InvalidState";
     }
 
-    /* (non-Javadoc)
+    /*
+     * (non-Javadoc)
+     * 
      * @see org.apache.kandula.faults.KandulaFault#getFaultReason()
      */
     public String getFaultReason() {
diff --git a/src/org/apache/kandula/faults/NoActivityException.java b/src/org/apache/kandula/faults/NoActivityException.java
index 26c2151..455679b 100644
--- a/src/org/apache/kandula/faults/NoActivityException.java
+++ b/src/org/apache/kandula/faults/NoActivityException.java
@@ -22,7 +22,7 @@
 public class NoActivityException extends AbstractKandulaException {
 
     /**
-     * 
+     *  
      */
     public NoActivityException() {
         super();
@@ -50,21 +50,27 @@
         super(arg0, arg1);
     }
 
-    /* (non-Javadoc)
+    /*
+     * (non-Javadoc)
+     * 
      * @see org.apache.kandula.faults.KandulaFault#getFaultCode()
      */
     public String getFaultCode() {
         return "Sender";
     }
 
-    /* (non-Javadoc)
+    /*
+     * (non-Javadoc)
+     * 
      * @see org.apache.kandula.faults.KandulaFault#getFaultSubcode()
      */
     public String getFaultSubcode() {
         return "wscoor:NoActivity";
     }
 
-    /* (non-Javadoc)
+    /*
+     * (non-Javadoc)
+     * 
      * @see org.apache.kandula.faults.KandulaFault#getFaultReason()
      */
     public String getFaultReason() {
diff --git a/src/org/apache/kandula/initiator/TransactionManager.java b/src/org/apache/kandula/initiator/TransactionManager.java
index 920f578..0685373 100644
--- a/src/org/apache/kandula/initiator/TransactionManager.java
+++ b/src/org/apache/kandula/initiator/TransactionManager.java
@@ -44,9 +44,10 @@
     public static String tempID;

 

     public TransactionManager(String coordinationType,

-                              EndpointReference coordinatorEPR) throws AbstractKandulaException {

+            EndpointReference coordinatorEPR) throws AbstractKandulaException {

         threadInfo = new ThreadLocal();

-        //ATInitiatorTransaction transaction = new ATInitiatorTransaction(coordinatorEPR);

+        //ATInitiatorTransaction transaction = new

+        // ATInitiatorTransaction(coordinatorEPR);

         AbstractContext context = ContextFactory.getInstance().createActivity(

                 coordinationType, coordinatorEPR);

         if (threadInfo.get() != null)

@@ -55,8 +56,7 @@
         //TODO remove this when we get replyTo reference properties correctly

         tempID = (String) context.getProperty(ATActivityContext.REQUESTER_ID);

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

-        store.put(context.getProperty(ATActivityContext.REQUESTER_ID),

-                context);

+        store.put(context.getProperty(ATActivityContext.REQUESTER_ID), context);

     }

 

     /**

@@ -68,7 +68,7 @@
                 .getProperty(ATActivityContext.REQUESTER_ID);

         ActivationCoordinatorPortTypeRawXMLStub activationCoordinator = new ActivationCoordinatorPortTypeRawXMLStub(

                 ".", (EndpointReference) context

-                .getProperty(ATActivityContext.ACTIVATION_EPR));

+                        .getProperty(ATActivityContext.ACTIVATION_EPR));

         activationCoordinator.createCoordinationContextOperation(

                 org.apache.kandula.Constants.WS_AT, id);

         while (context.getCoordinationContext() == null) {

@@ -82,22 +82,26 @@
         registrationCoordinator.registerOperation(

                 org.apache.kandula.Constants.WS_AT_COMPLETION,

                 registrationRequeterPortEPR, id);

-        while (context.getProperty(ATActivityContext.COORDINATION_EPR)==null) {

+        while (context.getProperty(ATActivityContext.COORDINATION_EPR) == null) {

             Thread.sleep(10);

         }

     }

 

     public void commit() throws AbstractKandulaException, IOException {

         AbstractContext context = getTransaction();

-        EndpointReference coordinationEPR = (EndpointReference)context.getProperty(ATActivityContext.COORDINATION_EPR);

-        CompletionCoordinatorPortTypeRawXMLStub stub = new CompletionCoordinatorPortTypeRawXMLStub(".",coordinationEPR);

+        EndpointReference coordinationEPR = (EndpointReference) context

+                .getProperty(ATActivityContext.COORDINATION_EPR);

+        CompletionCoordinatorPortTypeRawXMLStub stub = new CompletionCoordinatorPortTypeRawXMLStub(

+                ".", coordinationEPR);

         stub.commitOperation();

     }

 

     public void rollback() throws AbstractKandulaException, IOException {

         AbstractContext context = getTransaction();

-        EndpointReference coordinationEPR = (EndpointReference)context.getProperty(ATActivityContext.COORDINATION_EPR);

-        CompletionCoordinatorPortTypeRawXMLStub stub = new CompletionCoordinatorPortTypeRawXMLStub(".",coordinationEPR);

+        EndpointReference coordinationEPR = (EndpointReference) context

+                .getProperty(ATActivityContext.COORDINATION_EPR);

+        CompletionCoordinatorPortTypeRawXMLStub stub = new CompletionCoordinatorPortTypeRawXMLStub(

+                ".", coordinationEPR);

         stub.rollbackOperation();

     }

 

@@ -120,8 +124,8 @@
 

     private AbstractContext getTransaction() throws AbstractKandulaException {

         Object key = threadInfo.get();

-        AbstractContext context = (AbstractContext) StorageFactory.getInstance().getStore()

-                .get(key);

+        AbstractContext context = (AbstractContext) StorageFactory

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

         if (context == null) {

             throw new InvalidStateException("No Activity Found");

         }

diff --git a/src/org/apache/kandula/initiator/TransactionOutHandler.java b/src/org/apache/kandula/initiator/TransactionOutHandler.java
index 878e9d6..3af3588 100644
--- a/src/org/apache/kandula/initiator/TransactionOutHandler.java
+++ b/src/org/apache/kandula/initiator/TransactionOutHandler.java
@@ -1,18 +1,18 @@
 /*

- * 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.

- *

+ * 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.initiator;

 

@@ -25,21 +25,20 @@
 import org.apache.kandula.context.coordination.CoordinationContext;

 import org.apache.kandula.storage.StorageFactory;

 

-

 public class TransactionOutHandler extends AbstractHandler {

     private ThreadLocal threadInfo = new ThreadLocal();

 

     public void invoke(MessageContext msgContext) throws AxisFault {

         Object key = threadInfo.get();

         if (null != key) {

-            AbstractContext context = (AbstractContext)StorageFactory.getInstance().getStore()

-                    .get(key);

+            AbstractContext context = (AbstractContext) StorageFactory

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

             if (context == null) {

                 throw new AxisFault("IllegalState");

             }

 

-            MessageInformationHeaders messageInformationHeaders =

-                    msgContext.getMessageInformationHeaders();

+            MessageInformationHeaders messageInformationHeaders = msgContext

+                    .getMessageInformationHeaders();

             SOAPHeader soapHeader = msgContext.getEnvelope().getHeader();

             CoordinationContext coorContext = context.getCoordinationContext();

             soapHeader.addChild(coorContext.toOM());

diff --git a/src/org/apache/kandula/participant/KandulaResource.java b/src/org/apache/kandula/participant/KandulaResource.java
index 3d7bfc9..f20ff2f 100644
--- a/src/org/apache/kandula/participant/KandulaResource.java
+++ b/src/org/apache/kandula/participant/KandulaResource.java
@@ -21,6 +21,8 @@
  */

 public interface KandulaResource {

     public void commit();

+

     public void rollback();

+

     public Vote prepare();

-}

+}
\ 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 cdf174b..3c1ad50 100644
--- a/src/org/apache/kandula/participant/ParticipantTransactionManager.java
+++ b/src/org/apache/kandula/participant/ParticipantTransactionManager.java
@@ -21,17 +21,14 @@
 import org.apache.kandula.context.at.ATParticipantContext;
 import org.apache.kandula.faults.InvalidStateException;
 
-
 /**
  * @author <a href="mailto:thilina@opensource.lk"> Thilina Gunarathne </a>
  */
 public class ParticipantTransactionManager {
-    public Vote prepare(AbstractContext context) throws InvalidStateException
-    {
-        ATParticipantContext atContext = (ATParticipantContext)context;
+    public Vote prepare(AbstractContext context) throws InvalidStateException {
+        ATParticipantContext atContext = (ATParticipantContext) context;
         atContext.lock();
-        switch (context.getStatus())
-        {
+        switch (context.getStatus()) {
         case (Status.CoordinatorStatus.STATUS_NONE):
             //TODO send aborted
             atContext.unlock();
@@ -44,14 +41,14 @@
             return Vote.NONE;
         case (Status.CoordinatorStatus.STATUS_PREPARED_SUCCESS):
             atContext.unlock();
-        	return Vote.PREPARED;
+            return Vote.PREPARED;
         case (Status.CoordinatorStatus.STATUS_ACTIVE):
             atContext.setStatus(Status.CoordinatorStatus.STATUS_PREPARING);
-        	KandulaResource resource = atContext.getResource();
-        	return resource.prepare();
+            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/Vote.java b/src/org/apache/kandula/participant/Vote.java
index f0ef0d8..adc5a47 100644
--- a/src/org/apache/kandula/participant/Vote.java
+++ b/src/org/apache/kandula/participant/Vote.java
@@ -16,28 +16,26 @@
  */
 package org.apache.kandula.participant;
 
-
 /**
  * @author <a href="mailto:thilina@opensource.lk"> Thilina Gunarathne </a>
  */
 public class Vote {
-    
+
     public static Vote READ_ONLY = new Vote("VoteReadOnly");
-    
+
     public static Vote ABORT = new Vote("VoteAbort");
-    
+
     public static Vote PREPARED = new Vote("VotePrepared");
-    
+
     public static Vote NONE = new Vote("");
-    
+
     private String state;
-    
-    public Vote(String outcome)
-    {
+
+    public Vote(String outcome) {
         this.state = outcome;
     }
-    public String getOutcome()
-    {
+
+    public String getOutcome() {
         return state;
     }
-}
+}
\ No newline at end of file
diff --git a/src/org/apache/kandula/storage/Axis1Store.java b/src/org/apache/kandula/storage/Axis1Store.java
index f4e00b8..2e5dfd3 100644
--- a/src/org/apache/kandula/storage/Axis1Store.java
+++ b/src/org/apache/kandula/storage/Axis1Store.java
@@ -16,34 +16,40 @@
  */
 package org.apache.kandula.storage;
 
-
 /**
  * @author <a href="mailto:thilina@opensource.lk"> Thilina Gunarathne </a>
  */
 public class Axis1Store implements Store {
 
-    /* (non-Javadoc)
-      * @see org.apache.kandula.storage.Store#putContext(java.lang.String, org.apache.kandula.context.coordination.CoordinationContext)
-      */
+    /*
+     * (non-Javadoc)
+     * 
+     * @see org.apache.kandula.storage.Store#putContext(java.lang.String,
+     *      org.apache.kandula.context.coordination.CoordinationContext)
+     */
     public void put(Object id, Object context) {
         // TODO Auto-generated method stub
 
     }
 
-    /* (non-Javadoc)
-      * @see org.apache.kandula.storage.Store#getContext(java.lang.String)
-      */
+    /*
+     * (non-Javadoc)
+     * 
+     * @see org.apache.kandula.storage.Store#getContext(java.lang.String)
+     */
     public Object get(Object id) {
 
         return null;
     }
 
-    /* (non-Javadoc)
-      * @see org.apache.kandula.storage.Store#forgetContext(java.lang.String)
-      */
+    /*
+     * (non-Javadoc)
+     * 
+     * @see org.apache.kandula.storage.Store#forgetContext(java.lang.String)
+     */
     public void forget(Object id) {
         // TODO Auto-generated method stub
 
     }
 
-}
+}
\ No newline at end of file
diff --git a/src/org/apache/kandula/storage/Axis2Store.java b/src/org/apache/kandula/storage/Axis2Store.java
index b2b5fc1..a2f911c 100644
--- a/src/org/apache/kandula/storage/Axis2Store.java
+++ b/src/org/apache/kandula/storage/Axis2Store.java
@@ -16,23 +16,27 @@
  */
 package org.apache.kandula.storage;
 
-
 /**
  * @author <a href="mailto:thilina@opensource.lk"> Thilina Gunarathne </a>
  */
 public class Axis2Store implements Store {
 
-    /* (non-Javadoc)
-      * @see org.apache.kandula.storage.Store#putContext(java.lang.String, org.apache.kandula.context.coordination.CoordinationContext)
-      */
+    /*
+     * (non-Javadoc)
+     * 
+     * @see org.apache.kandula.storage.Store#putContext(java.lang.String,
+     *      org.apache.kandula.context.coordination.CoordinationContext)
+     */
     public void put(Object id, Object context) {
         // TODO Auto-generated method stub
 
     }
 
-    /* (non-Javadoc)
-      * @see org.apache.kandula.storage.Store#getContext(java.lang.String)
-      */
+    /*
+     * (non-Javadoc)
+     * 
+     * @see org.apache.kandula.storage.Store#getContext(java.lang.String)
+     */
     public Object get(Object id) {
         return null;
 
@@ -41,4 +45,4 @@
     public void forget(Object id) {
     }
 
-}
+}
\ No newline at end of file
diff --git a/src/org/apache/kandula/storage/SimpleStore.java b/src/org/apache/kandula/storage/SimpleStore.java
index 5041955..be7f282 100644
--- a/src/org/apache/kandula/storage/SimpleStore.java
+++ b/src/org/apache/kandula/storage/SimpleStore.java
@@ -16,10 +16,10 @@
  */
 package org.apache.kandula.storage;
 
-import org.apache.kandula.context.AbstractContext;
-
 import java.util.HashMap;
 
+import org.apache.kandula.context.AbstractContext;
+
 /**
  * @author <a href="mailto:thilina@opensource.lk"> Thilina Gunarathne </a>
  */
@@ -27,9 +27,12 @@
 
     private HashMap contextMap;
 
-    /* (non-Javadoc)
-    * @see org.apache.kandula.storage.Store#putContext(java.lang.String, org.apache.kandula.context.ActivityContext)
-    */
+    /*
+     * (non-Javadoc)
+     * 
+     * @see org.apache.kandula.storage.Store#putContext(java.lang.String,
+     *      org.apache.kandula.context.ActivityContext)
+     */
     public SimpleStore() {
         contextMap = new HashMap();
     }
@@ -38,18 +41,22 @@
         contextMap.put(id, context);
     }
 
-    /* (non-Javadoc)
+    /*
+     * (non-Javadoc)
+     * 
      * @see org.apache.kandula.storage.Store#getContext(java.lang.String)
      */
     public Object get(Object id) {
         return (AbstractContext) contextMap.get(id);
     }
 
-    /* (non-Javadoc)
+    /*
+     * (non-Javadoc)
+     * 
      * @see org.apache.kandula.storage.Store#forgetContext(java.lang.String)
      */
     public void forget(Object id) {
         contextMap.remove(id);
     }
 
-}
+}
\ No newline at end of file
diff --git a/src/org/apache/kandula/storage/StorageFactory.java b/src/org/apache/kandula/storage/StorageFactory.java
index 2d8bd5c..17849dc 100644
--- a/src/org/apache/kandula/storage/StorageFactory.java
+++ b/src/org/apache/kandula/storage/StorageFactory.java
@@ -16,12 +16,12 @@
  */
 package org.apache.kandula.storage;
 
-
 /**
  * @author <a href="mailto:thilina@opensource.lk"> Thilina Gunarathne </a>
  */
 public class StorageFactory {
     private static StorageFactory instance = new StorageFactory();
+
     private Store store;
 
     public static StorageFactory getInstance() {
@@ -34,4 +34,4 @@
         }
         return store;
     }
-}
+}
\ No newline at end of file
diff --git a/src/org/apache/kandula/storage/Store.java b/src/org/apache/kandula/storage/Store.java
index 8aa029b..24086ab 100644
--- a/src/org/apache/kandula/storage/Store.java
+++ b/src/org/apache/kandula/storage/Store.java
@@ -16,7 +16,6 @@
  */
 package org.apache.kandula.storage;
 
-
 /**
  * @author <a href="mailto:thilina@opensource.lk"> Thilina Gunarathne </a>
  */
@@ -26,4 +25,4 @@
     Object get(Object id);
 
     void forget(Object id);
-}
+}
\ No newline at end of file
diff --git a/src/org/apache/kandula/utility/EndpointReferenceFactory.java b/src/org/apache/kandula/utility/EndpointReferenceFactory.java
index 5e97332..f2d296d 100644
--- a/src/org/apache/kandula/utility/EndpointReferenceFactory.java
+++ b/src/org/apache/kandula/utility/EndpointReferenceFactory.java
@@ -17,8 +17,6 @@
 package org.apache.kandula.utility;

 

 import java.io.IOException;

-import java.io.InputStream;

-import java.net.InetAddress;

 import java.util.Properties;

 

 import javax.xml.namespace.QName;

@@ -48,27 +46,19 @@
     String location = null;

 

     private EndpointReferenceFactory() {

-/*

-        InputStream in = getClass().getClassLoader().getResourceAsStream(

-                PROPERTY_FILE);

-        properties = new Properties();

-        try {

-            properties.load(in);

-            in.close();

-            String host = properties.getProperty(HOST_PROPERTY);

-            if (host == null)

-                host = InetAddress.getLocalHost().getHostAddress();

-            location = properties.getProperty(PROTOCOL_PROPERTY) + "://" + host

-                    + ":" + properties.getProperty(PORT_PROPERTY);

-        } catch (Exception e) {

-            if (e instanceof RuntimeException)

-                throw (RuntimeException) e;

-            else

-                throw new RuntimeException(e);

-        }

-*/

+        /*

+         * InputStream in = getClass().getClassLoader().getResourceAsStream(

+         * PROPERTY_FILE); properties = new Properties(); try {

+         * properties.load(in); in.close(); String host =

+         * properties.getProperty(HOST_PROPERTY); if (host == null) host =

+         * InetAddress.getLocalHost().getHostAddress(); location =

+         * properties.getProperty(PROTOCOL_PROPERTY) + "://" + host + ":" +

+         * properties.getProperty(PORT_PROPERTY); } catch (Exception e) { if (e

+         * instanceof RuntimeException) throw (RuntimeException) e; else throw

+         * new RuntimeException(e); }

+         */

     }

-    

+

     public static EndpointReferenceFactory getInstance() {

         if (instance == null)

             instance = new EndpointReferenceFactory();

@@ -80,18 +70,20 @@
         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);

+        refProperties.addReferenceValue(new QName(

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

         epr.setReferenceProperties(refProperties);

         return epr;

     }

 

-    public EndpointReference getCompletionParticipantEndpoint(String id) throws IOException {

-        CompletionInitiatorServiceListener serviceListener = CompletionInitiatorServiceListener.getInstance();

+    public EndpointReference getCompletionParticipantEndpoint(String id)

+            throws IOException {

+        CompletionInitiatorServiceListener serviceListener = CompletionInitiatorServiceListener

+                .getInstance();

         EndpointReference epr = serviceListener.getEpr();

         AnyContentType refProperties = new AnyContentType();

-        refProperties.addReferenceValue(

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

+        refProperties.addReferenceValue(new QName(

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

         epr.setReferenceProperties(refProperties);

         return epr;

     }

@@ -99,10 +91,10 @@
     public EndpointReference getCompletionEndpoint(String id) {

         //TODO set this somehow reading the conf file

         EndpointReference epr = new EndpointReference(

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

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

         AnyContentType refProperties = new AnyContentType();

-        refProperties.addReferenceValue(

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

+        refProperties.addReferenceValue(new QName(

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

         epr.setReferenceProperties(refProperties);

         return epr;

     }

@@ -112,8 +104,8 @@
         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);

+        refProperties.addReferenceValue(new QName(

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

         epr.setReferenceProperties(refProperties);

         return epr;

     }

diff --git a/src/org/apache/kandula/utility/KandulaListener.java b/src/org/apache/kandula/utility/KandulaListener.java
index a716647..3e1bbb6 100644
--- a/src/org/apache/kandula/utility/KandulaListener.java
+++ b/src/org/apache/kandula/utility/KandulaListener.java
@@ -16,24 +16,16 @@
  */

 package org.apache.kandula.utility;

 

-import org.apache.axis2.AxisFault;

-import org.apache.axis2.context.ConfigurationContext;

-import org.apache.axis2.description.OperationDescription;

-import org.apache.axis2.description.Parameter;

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

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

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

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

-import org.apache.axis2.transport.http.SimpleHTTPServer;

-import org.apache.axis2.util.Utils;

-import org.apache.kandula.Constants;

-import org.apache.wsdl.WSDLService;

-

-import javax.xml.namespace.QName;

 import java.io.IOException;

 import java.net.InetAddress;

 import java.net.UnknownHostException;

 

+import org.apache.axis2.AxisFault;

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

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

+import org.apache.axis2.transport.http.SimpleHTTPServer;

+import org.apache.axis2.util.Utils;

+

 /**

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

  */

@@ -84,12 +76,13 @@
     /**

      * @param serviceName

      * @param operationName

-     * @throws AxisFault To add services with only one operation, which is the

-     *                   frequent case in reponses

+     * @throws AxisFault

+     *             To add services with only one operation, which is the

+     *             frequent case in reponses

      */

     public void addService(ServiceDescription service) throws AxisFault {

         org.apache.axis2.description.OperationDescription responseOperationDesc;

-        

+

         service.setClassLoader(Thread.currentThread().getContextClassLoader());

 

         responseConfigurationContext.getAxisConfiguration().addService(service);

@@ -98,7 +91,7 @@
     }

 

     public String getHost() throws UnknownHostException {

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

-                + "/axis2/services/";

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

+                + SERVER_PORT + "/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 56d96d3..14aa1ba 100644
--- a/src/org/apache/kandula/utility/KandulaUtils.java
+++ b/src/org/apache/kandula/utility/KandulaUtils.java
@@ -16,15 +16,6 @@
  */
 package org.apache.kandula.utility;
 
-import org.apache.axis2.addressing.AddressingConstants;
-import org.apache.axis2.addressing.AddressingConstants.Final;
-import org.apache.axis2.addressing.AnyContentType;
-import org.apache.axis2.addressing.EndpointReference;
-import org.apache.axis2.om.OMElement;
-import org.apache.axis2.om.OMNamespace;
-import org.apache.axis2.soap.SOAPFactory;
-
-import javax.xml.namespace.QName;
 import java.net.InetAddress;
 import java.net.UnknownHostException;
 import java.security.MessageDigest;
@@ -32,12 +23,23 @@
 import java.util.Iterator;
 import java.util.Random;
 
+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.OMElement;
+import org.apache.axis2.om.OMNamespace;
+import org.apache.axis2.soap.SOAPFactory;
+
 /**
  * @author <a href="mailto:thilina@opensource.lk"> Thilina Gunarathne </a>
  */
 public class KandulaUtils {
-    
-    public static void endpointToOM(EndpointReference epr, OMElement parentEPR, SOAPFactory factory) {
+
+    public static void endpointToOM(EndpointReference epr, OMElement parentEPR,
+            SOAPFactory factory) {
         OMNamespace wsAddressing = factory.createOMNamespace(
                 AddressingConstants.Submission.WSA_NAMESPACE,
                 AddressingConstants.WSA_DEFAULT_PRFIX);
@@ -66,12 +68,11 @@
             }
         }
     }
-    
-    public static EndpointReference endpointFromOM(OMElement eprElement)
-    {
+
+    public static EndpointReference endpointFromOM(OMElement eprElement) {
         EndpointReference epr;
-        epr = new EndpointReference(eprElement
-                .getFirstChildWithName(new QName("Address")).getText());
+        epr = new EndpointReference(eprElement.getFirstChildWithName(
+                new QName("Address")).getText());
         AnyContentType referenceProperties = new AnyContentType();
         OMElement referencePropertiesElement = eprElement
                 .getFirstChildWithName(new QName("ReferenceProperties"));
@@ -88,7 +89,7 @@
     /**
      * MD5 a random string with localhost/date etc will return 128 bits
      * construct a string of 18 characters from those bits.
-     *
+     * 
      * @return string
      */
     public static String getRandomStringOf18Characters() {
@@ -122,8 +123,10 @@
             sb2.append(Integer.toHexString(b));
         }
         int begin = myRand.nextInt();
-        if (begin < 0) begin = begin * -1;
+        if (begin < 0)
+            begin = begin * -1;
         begin = begin % 8;
-        return new String(sb2.toString().substring(begin, begin + 18)).toUpperCase();
+        return new String(sb2.toString().substring(begin, begin + 18))
+                .toUpperCase();
     }
-}
+}
\ No newline at end of file
diff --git a/src/org/apache/kandula/wsat/AbstractATNotifierStub.java b/src/org/apache/kandula/wsat/AbstractATNotifierStub.java
index e0efa7e..e8c31d8 100644
--- a/src/org/apache/kandula/wsat/AbstractATNotifierStub.java
+++ b/src/org/apache/kandula/wsat/AbstractATNotifierStub.java
@@ -18,6 +18,7 @@
 
 import java.io.IOException;
 
+import org.apache.axis2.AxisFault;
 import org.apache.axis2.addressing.EndpointReference;
 import org.apache.axis2.clientapi.MessageSender;
 import org.apache.axis2.clientapi.Stub;
@@ -25,34 +26,59 @@
 import org.apache.axis2.om.OMElement;
 import org.apache.axis2.om.OMNamespace;
 import org.apache.kandula.Constants;
+import org.apache.kandula.faults.AbstractKandulaException;
+import org.apache.kandula.faults.KandulaGeneralException;
 
 /**
  * @author <a href="mailto:thilina@opensource.lk"> Thilina Gunarathne </a>
  */
 public abstract class AbstractATNotifierStub extends Stub {
     protected static org.apache.axis2.description.OperationDescription[] operations;
+
     public AbstractATNotifierStub() {
         super();
     }
-    protected void notify(String localName, String action, int opIndex,
-            EndpointReference replyToEPR) throws IOException {
-        org.apache.axis2.context.MessageContext messageContext = getMessageContext();
-        org.apache.axis2.soap.SOAPEnvelope env = super.createEnvelope();
-        org.apache.axis2.soap.SOAPFactory factory = OMAbstractFactory
-                .getSOAP12Factory();
-        OMNamespace wsAT = factory.createOMNamespace(Constants.WS_AT, "wsat");
-        OMElement request = factory.createOMElement(localName, wsAT);
-        env.getBody().addChild(request);
-        messageContext.setEnvelope(env);
 
-        MessageSender messageSender = new MessageSender(_serviceContext);
-        messageSender.setTo(this.toEPR);
-        if (replyToEPR != null) {
-            messageSender.setReplyTo(replyToEPR);
+    /**
+     * Provides common functionality for stubs to send notification messages
+     * 
+     * @param localName :
+     *            name of the notification message
+     * @param action :
+     *            ws-a action value for the notification message
+     * @param opIndex :
+     *            operation index in the operations array
+     * @param replyToEPR :
+     *            notification messages except termination messages should send
+     *            this
+     * @throws IOException
+     */
+    protected void notify(String localName, String action, int opIndex,
+            EndpointReference replyToEPR) throws AbstractKandulaException {
+        org.apache.axis2.context.MessageContext messageContext;
+        try {
+            messageContext = getMessageContext();
+
+            org.apache.axis2.soap.SOAPEnvelope env = super.createEnvelope();
+            org.apache.axis2.soap.SOAPFactory factory = OMAbstractFactory
+                    .getSOAP12Factory();
+            OMNamespace wsAT = factory.createOMNamespace(Constants.WS_AT,
+                    "wsat");
+            OMElement request = factory.createOMElement(localName, wsAT);
+            env.getBody().addChild(request);
+            messageContext.setEnvelope(env);
+
+            MessageSender messageSender = new MessageSender(_serviceContext);
+            messageSender.setTo(this.toEPR);
+            if (replyToEPR != null) {
+                messageSender.setReplyTo(replyToEPR);
+            }
+            messageSender.setWsaAction(action);
+            messageSender
+                    .setSenderTransport(org.apache.axis2.Constants.TRANSPORT_HTTP);
+            messageSender.send(operations[opIndex], messageContext);
+        } catch (AxisFault e) {
+            throw new KandulaGeneralException(e);
         }
-        messageSender.setWsaAction(action);
-        messageSender
-                .setSenderTransport(org.apache.axis2.Constants.TRANSPORT_HTTP);
-        messageSender.send(operations[opIndex], messageContext);
     }
-}
+}
\ No newline at end of file
diff --git a/src/org/apache/kandula/wsat/completion/CompletionCoordinatorPortTypeRawXMLSkeleton.java b/src/org/apache/kandula/wsat/completion/CompletionCoordinatorPortTypeRawXMLSkeleton.java
index d5b0632..c6717ab 100644
--- a/src/org/apache/kandula/wsat/completion/CompletionCoordinatorPortTypeRawXMLSkeleton.java
+++ b/src/org/apache/kandula/wsat/completion/CompletionCoordinatorPortTypeRawXMLSkeleton.java
@@ -1,12 +1,10 @@
 package org.apache.kandula.wsat.completion;
 
-import javax.xml.namespace.QName;
-
 import org.apache.axis2.AxisFault;
-import org.apache.axis2.context.MessageContext;
 import org.apache.axis2.om.OMElement;
 import org.apache.kandula.context.AbstractContext;
 import org.apache.kandula.coordinator.Coordinator;
+import org.apache.kandula.coordinator.at.ATCoordinator;
 import org.apache.kandula.faults.AbstractKandulaException;
 
 /**
@@ -17,76 +15,40 @@
 
     /**
      * @param requestElement
-     * @throws AbstractKandulaException
+     * @throws AxisFault
      */
     public OMElement commitOperation(OMElement requestElement) throws AxisFault {
         AbstractContext context;
+        String activityId;
         System.out.println("Visited Commit operation");
-        //        /*
-        //         * Extracting data from the incoming message
-        //         */
-        //        String coordinationType = requestElement.getFirstChildWithName(
-        //                new QName("CoordinationType")).getText();
-        //        OMElement expiresElement = requestElement
-        //                .getFirstChildWithName(new QName("Expires"));
-        //        String expires = null;
-        //        long expiresL = 0;
-        //        if (expiresElement != null) {
-        //            expires = expiresElement.getText();
-        //            if ((expires != null) && (expires.equals(""))) {
-        //                expiresL = Long.parseLong(expires);
-        //            }
-        //        }
-        //
-        //        /*
-        //         * Creating the Coordination Context
-        //         */
-        //        try {
-        //            Coordinator coordinator = new Coordinator();
-        //            context = coordinator.createCoordinationContext(coordinationType,
-        //                    expiresL);
-        //            return context.getCoordinationContext().toOM();
-        //        } catch (AbstractKandulaException e) {
-        //            AxisFault fault = new AxisFault(e);
-        //            fault.setFaultCode(e.getFaultCode());
-        //            throw fault;
-        //        }
+        activityId = Coordinator.ACTIVITY_ID;
+
+        // TODO do we need to check the incoming message
+        try {
+            ATCoordinator coordinator = new ATCoordinator();
+            coordinator.commitOperation(activityId);
+        } catch (AbstractKandulaException e) {
+            AxisFault fault = new AxisFault(e);
+            fault.setFaultCode(e.getFaultCode());
+            throw fault;
+        }
         return null;
     }
 
     public OMElement rollbackOperation(OMElement requestElement)
             throws AxisFault {
         AbstractContext context;
-        System.out.println("Visited Commit operation");
-        ///*
-        // * Extracting data from the incoming message
-        // */
-        //String coordinationType = requestElement.getFirstChildWithName(
-        //        new QName("CoordinationType")).getText();
-        //OMElement expiresElement = requestElement
-        //        .getFirstChildWithName(new QName("Expires"));
-        //String expires = null;
-        //long expiresL = 0;
-        //if (expiresElement != null) {
-        //    expires = expiresElement.getText();
-        //    if ((expires != null) && (expires.equals(""))) {
-        //        expiresL = Long.parseLong(expires);
-        //    }
-        //}
-        //
-        ///*
-        // * Creating the Coordination Context
-        // */
-        //try {
-        //    Coordinator coordinator = new Coordinator();
-        //    context = coordinator.createCoordinationContext(coordinationType,
-        //            expiresL);
-        //    return context.getCoordinationContext().toOM();
-        //} catch (AbstractKandulaException e) {
-        //    AxisFault fault = new AxisFault(e);
-        //    fault.setFaultCode(e.getFaultCode());
-        //    throw fault;
-        //}
+        String activityId;
+        System.out.println("Visited rollback operation");
+        activityId = Coordinator.ACTIVITY_ID;
+        try {
+            ATCoordinator coordinator = new ATCoordinator();
+            coordinator.commitOperation(activityId);
+        } catch (AbstractKandulaException e) {
+            AxisFault fault = new AxisFault(e);
+            fault.setFaultCode(e.getFaultCode());
+            throw fault;
+        }
         return null;
     }
 
diff --git a/src/org/apache/kandula/wsat/completion/CompletionCoordinatorPortTypeRawXMLStub.java b/src/org/apache/kandula/wsat/completion/CompletionCoordinatorPortTypeRawXMLStub.java
index 33f0cfa..40528a8 100644
--- a/src/org/apache/kandula/wsat/completion/CompletionCoordinatorPortTypeRawXMLStub.java
+++ b/src/org/apache/kandula/wsat/completion/CompletionCoordinatorPortTypeRawXMLStub.java
@@ -1,14 +1,9 @@
 package org.apache.kandula.wsat.completion;
 
-import java.io.IOException;
-
 import org.apache.axis2.AxisFault;
 import org.apache.axis2.addressing.EndpointReference;
-import org.apache.axis2.clientapi.MessageSender;
-import org.apache.axis2.om.OMAbstractFactory;
-import org.apache.axis2.om.OMElement;
-import org.apache.axis2.om.OMNamespace;
 import org.apache.kandula.Constants;
+import org.apache.kandula.faults.AbstractKandulaException;
 import org.apache.kandula.wsat.AbstractATNotifierStub;
 
 public class CompletionCoordinatorPortTypeRawXMLStub extends
@@ -41,6 +36,7 @@
 
     /**
      * Constructor
+     * 
      * @throws AxisFault
      */
     public CompletionCoordinatorPortTypeRawXMLStub(String axis2Home,
@@ -55,13 +51,13 @@
                 _service.getName().getLocalPart());
     }
 
-    public void commitOperation() throws IOException {
+    public void commitOperation() throws AbstractKandulaException {
         //TODO must send reply to epr
         this.notify("Commit", Constants.WS_AT_COMMIT, 0, null);
 
     }
 
-    public void rollbackOperation() throws IOException {
+    public void rollbackOperation() throws AbstractKandulaException {
         //TODO must send reply to EPR
         this.notify("Rollback", Constants.WS_AT_ROLLBACK, 1, null);
 
diff --git a/src/org/apache/kandula/wsat/completion/CompletionInitiatorPortTypeRawXMLSkeleton.java b/src/org/apache/kandula/wsat/completion/CompletionInitiatorPortTypeRawXMLSkeleton.java
index accf9cc..01a10cd 100644
--- a/src/org/apache/kandula/wsat/completion/CompletionInitiatorPortTypeRawXMLSkeleton.java
+++ b/src/org/apache/kandula/wsat/completion/CompletionInitiatorPortTypeRawXMLSkeleton.java
@@ -2,10 +2,10 @@
 

 import org.apache.axis2.context.MessageContext;

 import org.apache.axis2.om.OMElement;

+import org.apache.kandula.Status;

 import org.apache.kandula.context.AbstractContext;

 import org.apache.kandula.initiator.TransactionManager;

 import org.apache.kandula.storage.StorageFactory;

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

 

 /*

  * Copyright 2004,2005 The Apache Software Foundation.

@@ -37,21 +37,24 @@
     }

 

     public OMElement committedOperation(OMElement requestElement) {

-        if ("CoordinationContext".equals(requestElement.getLocalName())) {

-            msgContext.getMessageInformationHeaders().getReferenceParameters();

-            CoordinationContext coordinationContext = CoordinationContext.Factory.newContext(requestElement);

-            AbstractContext context = (AbstractContext)StorageFactory.getInstance().getStore().get(TransactionManager.tempID);

-          //  context.setCoordinationContext(coordinationContext);

-        }

+        //TODO use refrence parameters for this

+        //Have to wait till Axis2 Addressing get this correctly

+        //String requesterID ;

+

+        AbstractContext context = (AbstractContext) StorageFactory

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

+        context.setStatus(Status.ParticipantStatus.STATUS_COMMITED);

         return null;

     }

+

     public OMElement abortedOperation(OMElement requestElement) {

-        if ("CoordinationContext".equals(requestElement.getLocalName())) {

-            msgContext.getMessageInformationHeaders().getReferenceParameters();

-            CoordinationContext coordinationContext = CoordinationContext.Factory.newContext(requestElement);

-            AbstractContext context = (AbstractContext)StorageFactory.getInstance().getStore().get(TransactionManager.tempID);

-            //context.setCoordinationContext(coordinationContext);

-        }

+        //      TODO use refrence parameters for this

+        //Have to wait till Axis2 Addressing get this correctly

+        //String requesterID ;

+

+        AbstractContext context = (AbstractContext) StorageFactory

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

+        context.setStatus(Status.ParticipantStatus.STATUS_ABORTED);

         return null;

     }

 }
\ No newline at end of file
diff --git a/src/org/apache/kandula/wsat/completion/CompletionInitiatorPortTypeRawXMLStub.java b/src/org/apache/kandula/wsat/completion/CompletionInitiatorPortTypeRawXMLStub.java
index 4dcf563..85e9df2 100644
--- a/src/org/apache/kandula/wsat/completion/CompletionInitiatorPortTypeRawXMLStub.java
+++ b/src/org/apache/kandula/wsat/completion/CompletionInitiatorPortTypeRawXMLStub.java
@@ -1,9 +1,11 @@
 package org.apache.kandula.wsat.completion;
 
-import java.io.IOException;
-
+import org.apache.axis2.AxisFault;
 import org.apache.axis2.addressing.EndpointReference;
+import org.apache.axis2.deployment.DeploymentException;
 import org.apache.kandula.Constants;
+import org.apache.kandula.faults.AbstractKandulaException;
+import org.apache.kandula.faults.KandulaGeneralException;
 import org.apache.kandula.wsat.AbstractATNotifierStub;
 
 public class CompletionInitiatorPortTypeRawXMLStub extends
@@ -36,24 +38,32 @@
 
     /**
      * Constructor
+     * 
+     * @throws AbstractKandulaException
      */
     public CompletionInitiatorPortTypeRawXMLStub(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 (DeploymentException e) {
+            throw new KandulaGeneralException(e);
+        } catch (AxisFault e1) {
+            throw new KandulaGeneralException(e1);
+        }
         _serviceContext = _service.getParent().getServiceGroupContext(
                 _configurationContext).getServiceContext(
                 _service.getName().getLocalPart());
     }
 
-    public void committedOperation() throws IOException {
+    public void committedOperation() throws AbstractKandulaException {
         this.notify("Committed", Constants.WS_AT_COMMITTED, 0, null);
     }
 
-    public void abortedOperation() throws IOException {
+    public void abortedOperation() throws AbstractKandulaException {
         this.notify("Aborted", Constants.WS_AT_ABORTED, 1, null);
     }
 
diff --git a/src/org/apache/kandula/wsat/completion/CompletionInitiatorServiceListener.java b/src/org/apache/kandula/wsat/completion/CompletionInitiatorServiceListener.java
index 136d7dd..033ca22 100644
--- a/src/org/apache/kandula/wsat/completion/CompletionInitiatorServiceListener.java
+++ b/src/org/apache/kandula/wsat/completion/CompletionInitiatorServiceListener.java
@@ -34,7 +34,8 @@
 public class CompletionInitiatorServiceListener {
 
     private static CompletionInitiatorServiceListener instance = null;
-    private EndpointReference epr=null;
+
+    private EndpointReference epr = null;
 
     private CompletionInitiatorServiceListener() {
         super();
@@ -47,14 +48,13 @@
         return instance;
     }
 
-    public EndpointReference getEpr() throws IOException
-    {
-        if (epr==null)
-        {
+    public EndpointReference getEpr() throws IOException {
+        if (epr == null) {
             this.epr = setupListener();
         }
         return this.epr;
     }
+
     private EndpointReference setupListener() throws IOException {
         QName serviceName = new QName("CompletionInitiatorPortType");
         String className = CompletionInitiatorPortTypeRawXMLSkeleton.class
diff --git a/src/org/apache/kandula/wsat/twopc/CoordinatorPortTypeRawXMLSkeleton.java b/src/org/apache/kandula/wsat/twopc/CoordinatorPortTypeRawXMLSkeleton.java
index ea5d2f5..d0fa1ae 100644
--- a/src/org/apache/kandula/wsat/twopc/CoordinatorPortTypeRawXMLSkeleton.java
+++ b/src/org/apache/kandula/wsat/twopc/CoordinatorPortTypeRawXMLSkeleton.java
@@ -1,50 +1,73 @@
 package org.apache.kandula.wsat.twopc;
 
-import javax.xml.namespace.QName;
-
 import org.apache.axis2.AxisFault;
-import org.apache.axis2.context.MessageContext;
 import org.apache.axis2.om.OMElement;
 import org.apache.kandula.context.AbstractContext;
 import org.apache.kandula.coordinator.Coordinator;
+import org.apache.kandula.coordinator.at.ATCoordinator;
 import org.apache.kandula.faults.AbstractKandulaException;
+import org.apache.kandula.participant.Vote;
 
 /**
  * Auto generated java skeleton for the service by the Axis code generator
  */
 
 public class CoordinatorPortTypeRawXMLSkeleton {
-    
+
     /**
      * @param requestElement
      * @throws AbstractKandulaException
      */
     public OMElement preparedOperation(OMElement requestElement)
             throws AxisFault {
-        AbstractContext context;
-        System.out.println("Visited Commit operation");
+        String activityId = Coordinator.ACTIVITY_ID;
+        ATCoordinator coordinator= new ATCoordinator();
+        try {
+            coordinator.countVote(activityId,Vote.PREPARED,null);
+        } catch (AbstractKandulaException e) {
+            AxisFault fault = new AxisFault(e);
+            fault.setFaultCode(e.getFaultCode());
+            throw fault;
+        }
         return null;
     }
+
     /**
      * @param requestElement
      * @throws AbstractKandulaException
      */
     public OMElement abortedOperation(OMElement requestElement)
             throws AxisFault {
-        AbstractContext context;
-        System.out.println("Visited Commit operation");
+        String activityId = Coordinator.ACTIVITY_ID;
+        ATCoordinator coordinator= new ATCoordinator();
+        try {
+            coordinator.countVote(activityId,Vote.ABORT,null);
+        } catch (AbstractKandulaException e) {
+            AxisFault fault = new AxisFault(e);
+            fault.setFaultCode(e.getFaultCode());
+            throw fault;
+        }
         return null;
     }
+
     /**
      * @param requestElement
      * @throws AbstractKandulaException
      */
     public OMElement readOnlyOperation(OMElement requestElement)
             throws AxisFault {
-        AbstractContext context;
-        System.out.println("Visited Commit operation");
+        String activityId = Coordinator.ACTIVITY_ID;
+        ATCoordinator coordinator= new ATCoordinator();
+        try {
+            coordinator.countVote(activityId,Vote.READ_ONLY,null);
+        } catch (AbstractKandulaException e) {
+            AxisFault fault = new AxisFault(e);
+            fault.setFaultCode(e.getFaultCode());
+            throw fault;
+        }
         return null;
     }
+
     /**
      * @param requestElement
      * @throws AbstractKandulaException
@@ -55,12 +78,12 @@
         System.out.println("Visited Commit operation");
         return null;
     }
+
     /**
      * @param requestElement
      * @throws AbstractKandulaException
      */
-    public OMElement replayOperation(OMElement requestElement)
-            throws AxisFault {
+    public OMElement replayOperation(OMElement requestElement) throws AxisFault {
         AbstractContext context;
         System.out.println("Visited Commit operation");
         return null;
diff --git a/src/org/apache/kandula/wsat/twopc/CoordinatorPortTypeRawXMLStub.java b/src/org/apache/kandula/wsat/twopc/CoordinatorPortTypeRawXMLStub.java
index 217f1e4..0da2eff 100644
--- a/src/org/apache/kandula/wsat/twopc/CoordinatorPortTypeRawXMLStub.java
+++ b/src/org/apache/kandula/wsat/twopc/CoordinatorPortTypeRawXMLStub.java
@@ -1,13 +1,8 @@
 package org.apache.kandula.wsat.twopc;
 
-import java.io.IOException;
-
 import org.apache.axis2.addressing.EndpointReference;
-import org.apache.axis2.clientapi.MessageSender;
-import org.apache.axis2.om.OMAbstractFactory;
-import org.apache.axis2.om.OMElement;
-import org.apache.axis2.om.OMNamespace;
 import org.apache.kandula.Constants;
+import org.apache.kandula.faults.AbstractKandulaException;
 import org.apache.kandula.wsat.AbstractATNotifierStub;
 
 public class CoordinatorPortTypeRawXMLStub extends AbstractATNotifierStub {
@@ -68,26 +63,26 @@
                 _service.getName().getLocalPart());
     }
 
-    public void preparedOperation() throws IOException {
+    public void preparedOperation() throws AbstractKandulaException {
         // must send reply to epr
         this.notify("Prepared", Constants.WS_AT_PREPARED, 0, null);
     }
 
-    public void abortedOperation() throws IOException {
+    public void abortedOperation() throws AbstractKandulaException {
         this.notify("Aborted", Constants.WS_AT_ABORTED, 1, null);
     }
 
-    public void readOnlyOperation() throws IOException {
+    public void readOnlyOperation() throws AbstractKandulaException {
         this.notify("ReadOnly", Constants.WS_AT_READONLY, 2, null);
 
     }
 
-    public void committedOperation() throws IOException {
+    public void committedOperation() throws AbstractKandulaException {
         this.notify("Committed", Constants.WS_AT_COMMITTED, 3, null);
 
     }
 
-    public void replayOperation() throws IOException {
+    public void replayOperation() throws AbstractKandulaException {
         //must send reply to epr
         this.notify("Replay", Constants.WS_AT_REPLAY, 4, null);
     }
diff --git a/src/org/apache/kandula/wsat/twopc/ParticipantPortTypeRawXMLSkeleton.java b/src/org/apache/kandula/wsat/twopc/ParticipantPortTypeRawXMLSkeleton.java
index 5ffed54..21d88f5 100644
--- a/src/org/apache/kandula/wsat/twopc/ParticipantPortTypeRawXMLSkeleton.java
+++ b/src/org/apache/kandula/wsat/twopc/ParticipantPortTypeRawXMLSkeleton.java
@@ -1,14 +1,7 @@
 package org.apache.kandula.wsat.twopc;

 

-import java.io.IOException;

-

 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.initiator.TransactionManager;

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

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

 

 /*

  * Copyright 2004,2005 The Apache Software Foundation.

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

     }

 

-    public OMElement prepareOperation(OMElement requestEle){

-      return null;

+    public OMElement prepareOperation(OMElement requestEle) {

+        return null;

 

     }

 

@@ -48,7 +41,7 @@
         return null;

     }

 

-    public OMElement rollbackOperation(OMElement requestEle){

+    public OMElement rollbackOperation(OMElement requestEle) {

         return null;

     }

 }
\ No newline at end of file
diff --git a/src/org/apache/kandula/wsat/twopc/ParticipantPortTypeRawXMLStub.java b/src/org/apache/kandula/wsat/twopc/ParticipantPortTypeRawXMLStub.java
index f66cf69..3a6c4f1 100644
--- a/src/org/apache/kandula/wsat/twopc/ParticipantPortTypeRawXMLStub.java
+++ b/src/org/apache/kandula/wsat/twopc/ParticipantPortTypeRawXMLStub.java
@@ -1,9 +1,11 @@
 package org.apache.kandula.wsat.twopc;
 
-import java.io.IOException;
-
+import org.apache.axis2.AxisFault;
 import org.apache.axis2.addressing.EndpointReference;
+import org.apache.axis2.deployment.DeploymentException;
 import org.apache.kandula.Constants;
+import org.apache.kandula.faults.AbstractKandulaException;
+import org.apache.kandula.faults.KandulaGeneralException;
 import org.apache.kandula.wsat.AbstractATNotifierStub;
 
 public class ParticipantPortTypeRawXMLStub extends AbstractATNotifierStub {
@@ -42,32 +44,44 @@
     /**
      * Constructor
      */
-    public ParticipantPortTypeRawXMLStub(String axis2Home,
-            EndpointReference targetEndpoint) throws java.lang.Exception {
-        this.toEPR = targetEndpoint;
+    public ParticipantPortTypeRawXMLStub(String axis2Home)
+            throws AbstractKandulaException {
+
         //creating the configuration
-        _configurationContext = new org.apache.axis2.context.ConfigurationContextFactory()
-                .buildClientConfigurationContext(axis2Home);
-        _configurationContext.getAxisConfiguration().addService(_service);
+        try {
+            _configurationContext = new org.apache.axis2.context.ConfigurationContextFactory()
+                    .buildClientConfigurationContext(axis2Home);
+            _configurationContext.getAxisConfiguration().addService(_service);
+        } catch (DeploymentException e) {
+            throw new KandulaGeneralException(e);
+        } catch (AxisFault e1) {
+            throw new KandulaGeneralException(e1);
+        }
         _serviceContext = _service.getParent().getServiceGroupContext(
                 _configurationContext).getServiceContext(
                 _service.getName().getLocalPart());
     }
 
-    public void prepareOperation() throws IOException {
+    public void prepareOperation(EndpointReference targetEndpoint)
+            throws AbstractKandulaException {
         //TODO must send reply TO epr
+        this.toEPR = targetEndpoint;
         this.notify("Prepare", Constants.WS_AT_PREPARE, 0, null);
 
     }
 
-    public void commitOperation() throws IOException {
+    public void commitOperation(EndpointReference targetEndpoint)
+            throws AbstractKandulaException {
         //TODO must send reply to epr
+        this.toEPR = targetEndpoint;
         this.notify("Commit", Constants.WS_AT_COMMIT, 1, null);
 
     }
 
-    public void rollbackOperation() throws IOException {
+    public void rollbackOperation(EndpointReference targetEndpoint)
+            throws AbstractKandulaException {
         //TODO must send reply to epr
+        this.toEPR = targetEndpoint;
         this.notify("Rollback", Constants.WS_AT_ROLLBACK, 2, null);
     }
 
diff --git a/src/org/apache/kandula/wsat/twopc/ParticipantServiceListener.java b/src/org/apache/kandula/wsat/twopc/ParticipantServiceListener.java
index 2dadb21..7a9553b 100644
--- a/src/org/apache/kandula/wsat/twopc/ParticipantServiceListener.java
+++ b/src/org/apache/kandula/wsat/twopc/ParticipantServiceListener.java
@@ -23,12 +23,10 @@
 import org.apache.axis2.addressing.EndpointReference;
 import org.apache.axis2.description.ParameterImpl;
 import org.apache.axis2.description.ServiceDescription;
-import org.apache.axis2.om.OMElement;
 import org.apache.axis2.receivers.AbstractMessageReceiver;
 import org.apache.axis2.receivers.RawXMLINOnlyMessageReceiver;
 import org.apache.kandula.Constants;
 import org.apache.kandula.utility.KandulaListener;
-import org.apache.kandula.wsat.completion.CompletionInitiatorPortTypeRawXMLSkeleton;
 
 /**
  * @author <a href="mailto:thilina@opensource.lk"> Thilina Gunarathne </a>
@@ -59,8 +57,7 @@
 
     private EndpointReference setupListener() throws IOException {
         QName serviceName = new QName("ParticipantPortType");
-        String className = ParticipantPortTypeRawXMLSkeleton.class
-                .getName();
+        String className = ParticipantPortTypeRawXMLSkeleton.class.getName();
         ServiceDescription service = new ServiceDescription(serviceName);
         service.addParameter(new ParameterImpl(
                 AbstractMessageReceiver.SERVICE_CLASS, className));
diff --git a/src/org/apache/kandula/wscoor/ActivationCoordinatorPortTypeRawXMLStub.java b/src/org/apache/kandula/wscoor/ActivationCoordinatorPortTypeRawXMLStub.java
index a427074..4c1e08e 100644
--- a/src/org/apache/kandula/wscoor/ActivationCoordinatorPortTypeRawXMLStub.java
+++ b/src/org/apache/kandula/wscoor/ActivationCoordinatorPortTypeRawXMLStub.java
@@ -16,6 +16,10 @@
  */
 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;
@@ -30,9 +34,6 @@
 import org.apache.kandula.Constants;
 import org.apache.kandula.utility.KandulaListener;
 
-import javax.xml.namespace.QName;
-import java.io.IOException;
-
 /**
  * @author <a href="mailto:thilina@opensource.lk"> Thilina Gunarathne </a>
  */
diff --git a/src/org/apache/kandula/wscoor/ActivationPortTypeRawXMLAsyncMessageReceiver.java b/src/org/apache/kandula/wscoor/ActivationPortTypeRawXMLAsyncMessageReceiver.java
index 8fedfd5..f469d66 100644
--- a/src/org/apache/kandula/wscoor/ActivationPortTypeRawXMLAsyncMessageReceiver.java
+++ b/src/org/apache/kandula/wscoor/ActivationPortTypeRawXMLAsyncMessageReceiver.java
@@ -29,16 +29,20 @@
 
     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/*
+                                                                  * ,
+                                                                  * ServerCallback
+                                                                  * callback
+                                                                  */) throws org.apache.axis2.AxisFault {
 
         try {
 
             // get the implementation class for the Web Service
             Object obj = getTheImplementationObject(msgContext);
-            
+
             //Inject the Message Context if it is asked for
-            DependencyManager.configureBusinessLogicProvider(obj, msgContext, newMsgContext);
+            DependencyManager.configureBusinessLogicProvider(obj, msgContext,
+                    newMsgContext);
 
             ActivationPortTypeRawXMLSkeleton skel = (ActivationPortTypeRawXMLSkeleton) obj;
             //Out Envelop
@@ -50,7 +54,7 @@
             String methodName;
             if (op.getName() != null
                     & (methodName = op.getName().getLocalPart()) != null) {
-                if (methodName.equals("createCoordinationContextOperation")) {
+                if (("createCoordinationContextOperation").equals(methodName)) {
                     OMElement response = null;
 
                     //doc style
@@ -66,7 +70,8 @@
                     envelope.getBody().setFirstChild(response);
                 }
                 newMsgContext.setEnvelope(envelope);
-                newMsgContext.setWSAAction(Constants.WS_COOR_CREATE_COORDINATIONCONTEXT_RESPONSE);
+                newMsgContext
+                        .setWSAAction(Constants.WS_COOR_CREATE_COORDINATIONCONTEXT_RESPONSE);
             }
         } catch (Exception e) {
             throw AxisFault.makeFault(e);
diff --git a/src/org/apache/kandula/wscoor/ActivationPortTypeRawXMLSkeleton.java b/src/org/apache/kandula/wscoor/ActivationPortTypeRawXMLSkeleton.java
index c40ade0..c182c19 100644
--- a/src/org/apache/kandula/wscoor/ActivationPortTypeRawXMLSkeleton.java
+++ b/src/org/apache/kandula/wscoor/ActivationPortTypeRawXMLSkeleton.java
@@ -54,7 +54,8 @@
             SOAPFactory factory = OMAbstractFactory.getSOAP12Factory();
             OMNamespace wsCoor = factory.createOMNamespace(Constants.WS_COOR,
                     "wscoor");
-            OMElement responseEle = factory.createOMElement("CreateCoordinationContextResponse",wsCoor);
+            OMElement responseEle = factory.createOMElement(
+                    "CreateCoordinationContextResponse", wsCoor);
             responseEle.addChild(context.getCoordinationContext().toOM());
             return responseEle;
         } catch (AbstractKandulaException e) {
diff --git a/src/org/apache/kandula/wscoor/ActivationRequesterPortTypeRawXMLSkeleton.java b/src/org/apache/kandula/wscoor/ActivationRequesterPortTypeRawXMLSkeleton.java
index 3d0ed0b..935efcd 100644
--- a/src/org/apache/kandula/wscoor/ActivationRequesterPortTypeRawXMLSkeleton.java
+++ b/src/org/apache/kandula/wscoor/ActivationRequesterPortTypeRawXMLSkeleton.java
@@ -3,9 +3,9 @@
 import org.apache.axis2.context.MessageContext;

 import org.apache.axis2.om.OMElement;

 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;

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

 

 /*

  * Copyright 2004,2005 The Apache Software Foundation.

@@ -36,12 +36,15 @@
         this.msgContext = context;

     }

 

-    public OMElement createCoordinationContextResponseOperation(OMElement responseElement) {

+    public OMElement createCoordinationContextResponseOperation(

+            OMElement responseElement) {

         OMElement response = responseElement.getFirstElement();

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

             msgContext.getMessageInformationHeaders().getReferenceParameters();

-            CoordinationContext coordinationContext = CoordinationContext.Factory.newContext(response);

-            AbstractContext context = (AbstractContext)StorageFactory.getInstance().getStore().get(TransactionManager.tempID);

+            CoordinationContext coordinationContext = CoordinationContext.Factory

+                    .newContext(response);

+            AbstractContext context = (AbstractContext) StorageFactory

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

             context.setCoordinationContext(coordinationContext);

         }

         return null;

diff --git a/src/org/apache/kandula/wscoor/RegistrationCoordinatorPortTypeRawXMLStub.java b/src/org/apache/kandula/wscoor/RegistrationCoordinatorPortTypeRawXMLStub.java
index b39a0df..3a3a439 100644
--- a/src/org/apache/kandula/wscoor/RegistrationCoordinatorPortTypeRawXMLStub.java
+++ b/src/org/apache/kandula/wscoor/RegistrationCoordinatorPortTypeRawXMLStub.java
@@ -1,5 +1,9 @@
 package org.apache.kandula.wscoor;
 
+import java.io.IOException;
+
+import javax.xml.namespace.QName;
+
 import org.apache.axis2.addressing.AnyContentType;
 import org.apache.axis2.addressing.EndpointReference;
 import org.apache.axis2.clientapi.MessageSender;
@@ -14,9 +18,6 @@
 import org.apache.kandula.utility.KandulaListener;
 import org.apache.kandula.utility.KandulaUtils;
 
-import javax.xml.namespace.QName;
-import java.io.IOException;
-
 public class RegistrationCoordinatorPortTypeRawXMLStub extends
         org.apache.axis2.clientapi.Stub {
     public static final String AXIS2_HOME = ".";
diff --git a/src/org/apache/kandula/wscoor/RegistrationPortTypeRawXMLAsyncMessageReceiver.java b/src/org/apache/kandula/wscoor/RegistrationPortTypeRawXMLAsyncMessageReceiver.java
index 4d90897..09aa6a5 100644
--- a/src/org/apache/kandula/wscoor/RegistrationPortTypeRawXMLAsyncMessageReceiver.java
+++ b/src/org/apache/kandula/wscoor/RegistrationPortTypeRawXMLAsyncMessageReceiver.java
@@ -29,8 +29,11 @@
 
     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/*
+                                                                  * ,
+                                                                  * ServerCallback
+                                                                  * callback
+                                                                  */) throws org.apache.axis2.AxisFault {
 
         try {
 
@@ -38,7 +41,8 @@
             Object obj = getTheImplementationObject(msgContext);
 
             //Inject the Message Context if it is asked for
-            DependencyManager.configureBusinessLogicProvider(obj, msgContext, newMsgContext);
+            DependencyManager.configureBusinessLogicProvider(obj, msgContext,
+                    newMsgContext);
 
             RegistrationPortTypeRawXMLSkeleton skel = (RegistrationPortTypeRawXMLSkeleton) obj;
             //Out Envelop
@@ -50,7 +54,7 @@
             String methodName;
             if (op.getName() != null
                     & (methodName = op.getName().getLocalPart()) != null) {
-                if (methodName.equals("registerOperation")) {
+                if (("registerOperation").equals(methodName)) {
                     OMElement response = null;
 
                     //doc style
diff --git a/src/org/apache/kandula/wscoor/RegistrationPortTypeRawXMLSkeleton.java b/src/org/apache/kandula/wscoor/RegistrationPortTypeRawXMLSkeleton.java
index fd9a26b..b15e327 100644
--- a/src/org/apache/kandula/wscoor/RegistrationPortTypeRawXMLSkeleton.java
+++ b/src/org/apache/kandula/wscoor/RegistrationPortTypeRawXMLSkeleton.java
@@ -17,12 +17,10 @@
 package org.apache.kandula.wscoor;
 
 import java.util.ArrayList;
-import java.util.Iterator;
 
 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.context.MessageContext;
 import org.apache.axis2.om.OMAbstractFactory;
@@ -45,42 +43,43 @@
         this.msgContext = msgContext;
     }
 
-    public OMElement registerOperation(OMElement request)
-            throws AxisFault {
+    public OMElement registerOperation(OMElement request) throws AxisFault {
 
         String protocolIdentifier;
         EndpointReference participantEPR;
         String activityId;
 
         /*
-         * Extracting data from the received message 
+         * Extracting data from the received message
          */
         protocolIdentifier = request.getFirstChildWithName(
                 new QName("ProtocolIdentifier")).getText();
         OMElement participantEPRElement = request
                 .getFirstChildWithName(new QName("ParticipantProtocolService"));
-        //Extracting the participant EPR 
+        //Extracting the participant EPR
         participantEPR = KandulaUtils.endpointFromOM(participantEPRElement);
 
         //have to extract the reference parameter "id". Axis2 does not support
         ArrayList list = msgContext.getMessageInformationHeaders()
                 .getReferenceParameters();
-        //TODO :Have to use the Activity ID came with EPR as a reference property
+        //TODO :Have to use the Activity ID came with EPR as a reference
+        // property
         activityId = Coordinator.ACTIVITY_ID;
 
         /*
          * Registering the participant for the activity for the given protocol
          */
-        try{
-        Coordinator coordinator = new Coordinator();
-        EndpointReference epr = coordinator.registerParticipant(activityId,
-                protocolIdentifier, participantEPR);
-        SOAPFactory factory = OMAbstractFactory.getSOAP12Factory();
-        OMNamespace wsCoor = factory.createOMNamespace(Constants.WS_COOR,
-                "wscoor");
-        OMElement responseEle = factory.createOMElement("RegisterResponse",wsCoor);
-        responseEle.addChild(toOM(epr));
-        return responseEle;
+        try {
+            Coordinator coordinator = new Coordinator();
+            EndpointReference epr = coordinator.registerParticipant(activityId,
+                    protocolIdentifier, participantEPR);
+            SOAPFactory factory = OMAbstractFactory.getSOAP12Factory();
+            OMNamespace wsCoor = factory.createOMNamespace(Constants.WS_COOR,
+                    "wscoor");
+            OMElement responseEle = factory.createOMElement("RegisterResponse",
+                    wsCoor);
+            responseEle.addChild(toOM(epr));
+            return responseEle;
         } catch (AbstractKandulaException e) {
             AxisFault fault = new AxisFault(e);
             fault.setFaultCode(e.getFaultCode());
diff --git a/src/org/apache/kandula/wscoor/RegistrationRequesterPortTypeRawXMLSkeleton.java b/src/org/apache/kandula/wscoor/RegistrationRequesterPortTypeRawXMLSkeleton.java
index 58aade3..0b5451b 100644
--- a/src/org/apache/kandula/wscoor/RegistrationRequesterPortTypeRawXMLSkeleton.java
+++ b/src/org/apache/kandula/wscoor/RegistrationRequesterPortTypeRawXMLSkeleton.java
@@ -5,7 +5,6 @@
 import org.apache.axis2.om.OMElement;

 import org.apache.kandula.context.AbstractContext;

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

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

 import org.apache.kandula.initiator.TransactionManager;

 import org.apache.kandula.storage.StorageFactory;

 import org.apache.kandula.utility.KandulaUtils;

@@ -42,9 +41,12 @@
     public OMElement registerResponseOperation(OMElement responseElement) {

         OMElement response = responseElement.getFirstElement();

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

-            EndpointReference coordinatorService  = KandulaUtils.endpointFromOM(response.getFirstElement());

-            AbstractContext context = (AbstractContext)StorageFactory.getInstance().getStore().get(TransactionManager.tempID);

-            context.setProperty(ATActivityContext.COORDINATION_EPR,coordinatorService);

+            EndpointReference coordinatorService = KandulaUtils

+                    .endpointFromOM(response.getFirstElement());

+            AbstractContext context = (AbstractContext) StorageFactory

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

+            context.setProperty(ATActivityContext.COORDINATION_EPR,

+                    coordinatorService);

         }

         return null;

     }

diff --git a/test/org/apache/kandula/context/ActivityContextTest.java b/test/org/apache/kandula/context/ActivityContextTest.java
index 886c4a2..c4a04a1 100644
--- a/test/org/apache/kandula/context/ActivityContextTest.java
+++ b/test/org/apache/kandula/context/ActivityContextTest.java
@@ -47,4 +47,4 @@
         //TODO Implement unlock().
     }
 
-}
+}
\ No newline at end of file
diff --git a/test/org/apache/kandula/coordinator/CoordinatorImplTest.java b/test/org/apache/kandula/coordinator/CoordinatorImplTest.java
index ab992a9..87d8822 100644
--- a/test/org/apache/kandula/coordinator/CoordinatorImplTest.java
+++ b/test/org/apache/kandula/coordinator/CoordinatorImplTest.java
@@ -46,34 +46,44 @@
     }
 
     /*
-     * Class under test for ActivityContext createCoordinationContext(String, long)
+     * Class under test for ActivityContext createCoordinationContext(String,
+     * long)
      */
-    public void testCreateCoordinationContextStringlong() throws AbstractKandulaException {
+    public void testCreateCoordinationContextStringlong()
+            throws AbstractKandulaException {
         Coordinator coordinator = new Coordinator();
-        AbstractContext context = coordinator.createCoordinationContext(Constants.WS_AT, 3000);
+        AbstractContext context = coordinator.createCoordinationContext(
+                Constants.WS_AT, 3000);
         assertTrue(ATActivityContext.class.isInstance(context));
         assertNotNull(context.getCoordinationContext());
         assertTrue(context.getStatus() == Status.CoordinatorStatus.STATUS_ACTIVE);
     }
 
     /*
-     * Class under test for ActivityContext createCoordinationContext(CoordinationContext)
+     * Class under test for ActivityContext
+     * createCoordinationContext(CoordinationContext)
      */
-    public void testCreateCoordinationContextCoordinationContext() throws AbstractKandulaException {
+    public void testCreateCoordinationContextCoordinationContext()
+            throws AbstractKandulaException {
         Coordinator coordinator = new Coordinator();
-        CoordinationContext coorContext = CoordinationContext.Factory.newContext("uuid:29919219jdk02102021",Constants.WS_AT,new EndpointReference(""));
+        CoordinationContext coorContext = CoordinationContext.Factory
+                .newContext("uuid:29919219jdk02102021", Constants.WS_AT,
+                        new EndpointReference(""));
         coorContext.setExpires(3000);
         // coorContext.setRegistrationService()
-        AbstractContext context = coordinator.createCoordinationContext(coorContext);
+        AbstractContext context = coordinator
+                .createCoordinationContext(coorContext);
         assertTrue(ATActivityContext.class.isInstance(context));
         assertNotNull(context.getCoordinationContext());
         assertTrue(context.getStatus() == Status.CoordinatorStatus.STATUS_ACTIVE);
-        assertEquals(context.getCoordinationContext().getCoordinationType(), coorContext.getCoordinationType());
-        assertEquals(context.getCoordinationContext().getActivityID(), coorContext.getActivityID());
+        assertEquals(context.getCoordinationContext().getCoordinationType(),
+                coorContext.getCoordinationType());
+        assertEquals(context.getCoordinationContext().getActivityID(),
+                coorContext.getActivityID());
     }
 
     public void testRegisterParticipant() {
         //TODO Implement registerParticipant().
     }
 
-}
+}
\ No newline at end of file
diff --git a/test/org/apache/kandula/coordinator/at/ATCoordinatorTest.java b/test/org/apache/kandula/coordinator/at/ATCoordinatorTest.java
index cb1a53f..12f54aa 100644
--- a/test/org/apache/kandula/coordinator/at/ATCoordinatorTest.java
+++ b/test/org/apache/kandula/coordinator/at/ATCoordinatorTest.java
@@ -32,7 +32,7 @@
 
     /**
      * Constructor for ATCoordinatorTest.
-     *
+     * 
      * @param arg0
      */
     public ATCoordinatorTest(String arg0) {
@@ -47,4 +47,4 @@
         //TODO Implement rollbackOperation().
     }
 
-}
+}
\ No newline at end of file
diff --git a/test/org/apache/kandula/integration/CreateCoordinationContextTest.java b/test/org/apache/kandula/integration/CreateCoordinationContextTest.java
index c70e607..4f44d41 100644
--- a/test/org/apache/kandula/integration/CreateCoordinationContextTest.java
+++ b/test/org/apache/kandula/integration/CreateCoordinationContextTest.java
@@ -20,7 +20,10 @@
  * @author <a href="mailto:thilina@opensource.lk">Thilina Gunarathne </a>

  */

 

+import java.io.File;

+

 import junit.framework.TestCase;

+

 import org.apache.axis2.AxisFault;

 import org.apache.axis2.addressing.EndpointReference;

 import org.apache.axis2.context.ConfigurationContext;

@@ -29,8 +32,6 @@
 import org.apache.kandula.Constants;

 import org.apache.kandula.initiator.TransactionManager;

 

-import java.io.File;

-

 public class CreateCoordinationContextTest extends TestCase {

 

     private String repository = "test-resources/testing-repository";

@@ -39,7 +40,6 @@
 

     private boolean finish = false;

 

-

     public CreateCoordinationContextTest() {

         super(CreateCoordinationContextTest.class.getName());

     }

@@ -52,20 +52,17 @@
         ConfigurationContextFactory erfac = new ConfigurationContextFactory();

         File file = new File(repository);

         if (!file.exists()) {

-            throw new Exception(

-                    "repository directory " + file.getAbsolutePath() +

-                            " does not exists");

+            throw new Exception("repository directory "

+                    + file.getAbsolutePath() + " does not exists");

         }

-        ConfigurationContext er = erfac.buildConfigurationContext(

-                file.getAbsolutePath());

+        ConfigurationContext er = erfac.buildConfigurationContext(file

+                .getAbsolutePath());

 

         server = new SimpleHTTPServer(er, 8081);

 

         try {

             server.start();

-            System.out.print(

-                    "Server started on port " + 8081 +

-                            ".....");

+            System.out.print("Server started on port " + 8081 + ".....");

         } finally {

 

         }

@@ -76,17 +73,18 @@
             throw new AxisFault("Thread interuptted", e1);

         }

 

-

     }

 

     protected void tearDown() throws Exception {

         server.stop();

     }

 

-

     public void testEchoXMLSync() throws Exception {

-        TransactionManager tm = new TransactionManager(Constants.WS_AT, new EndpointReference("http://localhost:8081/axis/services/ActivationCoordinator"));

-        //Thread.sleep(100000);

+        TransactionManager tm = new TransactionManager(

+                Constants.WS_AT,

+                new EndpointReference(

+                        "http://localhost:8081/axis/services/ActivationCoordinator"));

+        

         tm.begin();

     }

 }
\ No newline at end of file