You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fx-dev@ws.apache.org by th...@apache.org on 2005/09/21 13:56:40 UTC

svn commit: r290684 [1/2] - in /webservices/kandula/trunk/java: ./ src/org/apache/kandula/ src/org/apache/kandula/context/ src/org/apache/kandula/context/at/ src/org/apache/kandula/context/coordination/ src/org/apache/kandula/context/coordination/simpl...

Author: thilina
Date: Wed Sep 21 04:55:49 2005
New Revision: 290684

URL: http://svn.apache.org/viewcvs?rev=290684&view=rev
Log:
Introducing the new Fault implementations (2005 August spec)
Rearchitecting the context hierachy, so that we can use the same hierachy in the participants
Introducing the new KandulaResource, which will be a standalone simple counter part for the XAResource in JTA
Introducing a MessageReceiver for the registration operation (We cannot set the response operation name when using InOutRawXMLReceiver in Axis2)


Added:
    webservices/kandula/trunk/java/src/org/apache/kandula/context/AbstractContext.java
    webservices/kandula/trunk/java/src/org/apache/kandula/context/at/ATParticipantContext.java
    webservices/kandula/trunk/java/src/org/apache/kandula/context/coordination/SimpleCoordinationContext.java
    webservices/kandula/trunk/java/src/org/apache/kandula/faults/
    webservices/kandula/trunk/java/src/org/apache/kandula/faults/AbstractKandulaException.java
    webservices/kandula/trunk/java/src/org/apache/kandula/faults/AlreadyRegisteredException.java
    webservices/kandula/trunk/java/src/org/apache/kandula/faults/ContextRefusedException.java
    webservices/kandula/trunk/java/src/org/apache/kandula/faults/InvalidParameterException.java
    webservices/kandula/trunk/java/src/org/apache/kandula/faults/InvalidProtocolException.java
    webservices/kandula/trunk/java/src/org/apache/kandula/faults/InvalidStateException.java
    webservices/kandula/trunk/java/src/org/apache/kandula/faults/NoActivityException.java
    webservices/kandula/trunk/java/src/org/apache/kandula/initiator/ATInitiatorTransaction.java
    webservices/kandula/trunk/java/src/org/apache/kandula/initiator/TransactionOutHandler.java
    webservices/kandula/trunk/java/src/org/apache/kandula/participant/KandulaResource.java
    webservices/kandula/trunk/java/src/org/apache/kandula/participant/ParticipantTransactionManager.java
    webservices/kandula/trunk/java/src/org/apache/kandula/participant/Vote.java
    webservices/kandula/trunk/java/src/org/apache/kandula/wscoor/RegistrationPortTypeRawXMLAsyncMessageReceiver.java
Removed:
    webservices/kandula/trunk/java/src/org/apache/kandula/KandulaException.java
    webservices/kandula/trunk/java/src/org/apache/kandula/context/ActivityContext.java
    webservices/kandula/trunk/java/src/org/apache/kandula/context/ActivityContextImpl.java
    webservices/kandula/trunk/java/src/org/apache/kandula/context/coordination/simple/
    webservices/kandula/trunk/java/src/org/apache/kandula/initiator/handler/
    webservices/kandula/trunk/java/src/org/apache/kandula/participant/simple/
    webservices/kandula/trunk/java/src/org/apache/kandula/typemapping/
Modified:
    webservices/kandula/trunk/java/maven.xml
    webservices/kandula/trunk/java/project.xml
    webservices/kandula/trunk/java/src/org/apache/kandula/Status.java
    webservices/kandula/trunk/java/src/org/apache/kandula/context/ContextFactory.java
    webservices/kandula/trunk/java/src/org/apache/kandula/context/at/ATActivityContext.java
    webservices/kandula/trunk/java/src/org/apache/kandula/context/coordination/CoordinationContext.java
    webservices/kandula/trunk/java/src/org/apache/kandula/coordinator/Coordinator.java
    webservices/kandula/trunk/java/src/org/apache/kandula/coordinator/CoordinatorUtils.java
    webservices/kandula/trunk/java/src/org/apache/kandula/coordinator/Registerable.java
    webservices/kandula/trunk/java/src/org/apache/kandula/coordinator/at/ATCoordinator.java
    webservices/kandula/trunk/java/src/org/apache/kandula/coordinator/at/ATSubCoordinator.java
    webservices/kandula/trunk/java/src/org/apache/kandula/coordinator/ba/BACoordinator.java
    webservices/kandula/trunk/java/src/org/apache/kandula/initiator/TransactionManager.java
    webservices/kandula/trunk/java/src/org/apache/kandula/storage/Axis1Store.java
    webservices/kandula/trunk/java/src/org/apache/kandula/storage/Axis2Store.java
    webservices/kandula/trunk/java/src/org/apache/kandula/storage/SimpleStore.java
    webservices/kandula/trunk/java/src/org/apache/kandula/storage/Store.java
    webservices/kandula/trunk/java/src/org/apache/kandula/utility/KandulaListener.java
    webservices/kandula/trunk/java/src/org/apache/kandula/wscoor/ActivationPortTypeRawXMLSkeleton.java
    webservices/kandula/trunk/java/src/org/apache/kandula/wscoor/ActivationRequesterPortTypeRawXMLSkeleton.java
    webservices/kandula/trunk/java/src/org/apache/kandula/wscoor/RegistrationPortTypeRawXMLSkeleton.java
    webservices/kandula/trunk/java/test-resources/testing-repository/services/RegistrationCoordinator.jar
    webservices/kandula/trunk/java/test/org/apache/kandula/coordinator/CoordinatorImplTest.java
    webservices/kandula/trunk/java/test/org/apache/kandula/integration/CreateCoordinationContextTest.java

Modified: webservices/kandula/trunk/java/maven.xml
URL: http://svn.apache.org/viewcvs/webservices/kandula/trunk/java/maven.xml?rev=290684&r1=290683&r2=290684&view=diff
==============================================================================
--- webservices/kandula/trunk/java/maven.xml (original)
+++ webservices/kandula/trunk/java/maven.xml Wed Sep 21 04:55:49 2005
@@ -1,78 +1,78 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <project default="jar"
-         xmlns:j="jelly:core"
-         xmlns:maven="jelly:maven"
-         xmlns:deploy="deploy"
-         xmlns:ant="jelly:ant">
-
+	xmlns:j="jelly:core"
+    xmlns:maven="jelly:maven"
+    xmlns:deploy="deploy"
+    xmlns:ant="jelly:ant">
+    
     <goal name="setclasspath">
         <path id="test.classpath">
             <path refid="maven.dependency.classpath"/>
         </path>
     </goal>
-
+    
     <postGoal name="jar">
-        <ant:mkdir dir="${basedir}/target/lib"/>
-        <deploy:copy-deps todir="${basedir}/target/lib"/>
+    	<ant:mkdir dir="${basedir}/target/lib"/>
+    	<deploy:copy-deps todir="${basedir}/target/lib"/>
     </postGoal>
-
+    
     <preGoal name="java:compile">
-        <mkdir dir="${maven.build.dir}/stubs/src"/>
-
+    <mkdir dir="${maven.build.dir}/stubs/src"/>
+    
+    	<ant:echo>+----------------------------------------+</ant:echo>
+        <ant:echo>| Code Generating For WS-Coordination    |</ant:echo>
         <ant:echo>+----------------------------------------+</ant:echo>
-        <ant:echo>| Code Generating For WS-Coordination |</ant:echo>
-        <ant:echo>+----------------------------------------+</ant:echo>
-        <java classname="org.apache.axis2.wsdl.WSDL2Java"
-              failonerror="true" fork="yes">
-            <classpath>
-                <path refid="maven.dependency.classpath"/>
-            </classpath>
-            <arg value="-ss"/>
-            <arg value="-uri"/>
-            <arg value="${basedir}/schema/wscoor.wsdl"/>
-            <arg value="-o"/>
-            <arg value="${maven.build.dir}/stubs/src/wscoor"/>
-        </java>
-
-        <ant:echo>+------------------------------------------+</ant:echo>
+    	<java classname="org.apache.axis2.wsdl.WSDL2Java"
+    		failonerror="true" fork="yes">
+    		<classpath>
+    			<path refid="maven.dependency.classpath"/>
+    		</classpath> 
+    		<arg value="-ss"/>
+    		<arg value="-uri"/>
+    		<arg value="${basedir}/schema/wscoor.wsdl"/>   		
+    		<arg value="-o"/>
+    		<arg value="${maven.build.dir}/stubs/src/wscoor"/>   
+    	</java>
+ 
+ 		<ant:echo>+------------------------------------------+</ant:echo>
         <ant:echo>| Code Generating For WS-AtomicTransaction |</ant:echo>
-        <ant:echo>+------------------------------------------+</ant:echo>
-        <java classname="org.apache.axis2.wsdl.WSDL2Java"
-              failonerror="true" fork="yes">
-            <classpath>
-                <path refid="maven.dependency.classpath"/>
-            </classpath>
-            <arg value="-uri"/>
-            <arg value="${basedir}/schema/wsat.wsdl"/>
-            <arg value="-o"/>
-            <arg value="${maven.build.dir}/stubs/src/wsat"/>
-        </java>
-
+        <ant:echo>+------------------------------------------+ </ant:echo>
+    	<java classname="org.apache.axis2.wsdl.WSDL2Java"
+    		failonerror="true" fork="yes">
+    		<classpath>
+    			<path refid="maven.dependency.classpath"/>
+    		</classpath>    		
+    		<arg value="-uri"/>
+    		<arg value="${basedir}/schema/wsat.wsdl"/>   		
+    		<arg value="-o"/>
+    		<arg value="${maven.build.dir}/stubs/src/wsat"/>  
+    	</java>
+		
         <ant:echo>Copying generated *Class(.class)* file + it's resources to Classpath</ant:echo>
-        <mkdir dir="${maven.build.dir}/classes/schema/system/foo"/>
+		<mkdir dir="${maven.build.dir}/classes/schema/system/foo"/>
         <copy todir="${maven.build.dir}/classes/schema/system/foo">
             <fileset dir="${maven.build.dir}/stubs/src/wscoor/schema/system/foo">
                 <include name="*.*"/>
             </fileset>
         </copy>
-        <ant:path
-                id="stubs.src.wscoor.dir"
-                location="${maven.build.dir}/stubs/src/wscoor"/>
-        <ant:path
-                id="stubs.src.wsat.dir"
-                location="${maven.build.dir}/stubs/src/wsat"/>
-
-        <maven:addPath
-                id="maven.compile.src.set"
-                refid="stubs.src.wscoor.dir"/>
-        <maven:addPath
-                id="maven.compile.src.set"
-                refid="stubs.src.wsat.dir"/>
+    	<ant:path
+    		id="stubs.src.wscoor.dir"
+    		location="${maven.build.dir}/stubs/src/wscoor"/> 
+    	<ant:path
+    		id="stubs.src.wsat.dir"
+    		location="${maven.build.dir}/stubs/src/wsat"/>  
+    	
+    	<maven:addPath
+    		id="maven.compile.src.set"
+    		refid="stubs.src.wscoor.dir"/>  
+    	<maven:addPath
+    		id="maven.compile.src.set"
+    		refid="stubs.src.wsat.dir"/> 	
     </preGoal>
-
+   
     <!--
     <goal name="build-samples">
-        <ant:ant antfile="build.xml" inheritall="true" inheritrefs="true" dir="src/samples/"/>
+    	<ant:ant antfile="build.xml" inheritall="true" inheritrefs="true" dir="src/samples/"/>
     </goal>
     -->
 </project>

Modified: webservices/kandula/trunk/java/project.xml
URL: http://svn.apache.org/viewcvs/webservices/kandula/trunk/java/project.xml?rev=290684&r1=290683&r2=290684&view=diff
==============================================================================
--- webservices/kandula/trunk/java/project.xml (original)
+++ webservices/kandula/trunk/java/project.xml Wed Sep 21 04:55:49 2005
@@ -125,7 +125,7 @@
         <dependency>
             <groupId>axis</groupId>
             <artifactId>axis2</artifactId>
-            <version>0.9</version>
+            <version>0.91</version>
         </dependency>
         
   <!--      

Modified: webservices/kandula/trunk/java/src/org/apache/kandula/Status.java
URL: http://svn.apache.org/viewcvs/webservices/kandula/trunk/java/src/org/apache/kandula/Status.java?rev=290684&r1=290683&r2=290684&view=diff
==============================================================================
--- webservices/kandula/trunk/java/src/org/apache/kandula/Status.java (original)
+++ webservices/kandula/trunk/java/src/org/apache/kandula/Status.java Wed Sep 21 04:55:49 2005
@@ -21,16 +21,15 @@
  */
 abstract public interface Status {
     interface ParticipantStatus {
-
+        
         public static final int STATUS_VOLATILE_PREPARING = 20;
 
         public static final int STATUS_DURABLE_PREPARING = 21;
 
-        public static final int STATUS_PREPARED = 22;
-
-        public static final int STATUS_ABORTED = 23;
+        public static final int STATUS_ABORTED = 22;
 
-        public static final int STATUS_READ_ONLY = 24;
+        public static final int STATUS_READ_ONLY = 23;
+        
     }
 
     interface CoordinatorStatus {
@@ -46,6 +45,8 @@
         public static final int STATUS_PREPARING_VOLATILE = 12;
 
         public static final int STATUS_PREPARED_SUCCESS = 13;
+        
+        public static final int STATUS_PREPARED = 14;
 
         public static final int STATUS_ABORTING = 9;
 

Added: webservices/kandula/trunk/java/src/org/apache/kandula/context/AbstractContext.java
URL: http://svn.apache.org/viewcvs/webservices/kandula/trunk/java/src/org/apache/kandula/context/AbstractContext.java?rev=290684&view=auto
==============================================================================
--- webservices/kandula/trunk/java/src/org/apache/kandula/context/AbstractContext.java (added)
+++ webservices/kandula/trunk/java/src/org/apache/kandula/context/AbstractContext.java Wed Sep 21 04:55:49 2005
@@ -0,0 +1,111 @@
+/*
+ * 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 java.util.HashMap;
+
+import javax.xml.namespace.QName;
+
+import org.apache.axis2.addressing.AnyContentType;
+import org.apache.axis2.addressing.EndpointReference;
+import org.apache.kandula.Status.CoordinatorStatus;
+import org.apache.kandula.context.coordination.CoordinationContext;
+import org.apache.kandula.utility.EndpointReferenceFactory;
+import org.apache.kandula.utility.KandulaUtils;
+
+/**
+ * @author <a href="mailto:thilina@opensource.lk"> Thilina Gunarathne </a>
+ */
+public abstract class AbstractContext {
+
+    private HashMap propertyBag;
+
+    protected String activityID;
+
+    private int status = CoordinatorStatus.STATUS_NONE;
+
+    private boolean locked = false;
+
+    protected CoordinationContext coordinationContext = null;
+
+    protected AbstractContext() {
+        propertyBag = new HashMap();
+    }
+
+    public AbstractContext(String coordinationType) {
+        propertyBag = new HashMap();
+        activityID = KandulaUtils.getRandomStringOf18Characters();
+        EndpointReference registrationEpr = EndpointReferenceFactory
+                .getInstance().getRegistrationEndpoint(activityID);
+        AnyContentType referenceProp = new AnyContentType();
+        referenceProp.addReferenceValue(new QName(
+                "http://webservice.apache.org/~thilina", "myapp", "ID"),
+                activityID);
+        registrationEpr.setReferenceProperties(referenceProp);
+        coordinationContext = CoordinationContext.Factory.newContext(
+                activityID, coordinationType, registrationEpr);
+    }
+
+    public CoordinationContext getCoordinationContext() {
+        return coordinationContext;
+    }
+
+    public void setCoordinationContext(CoordinationContext context) {
+        this.coordinationContext = context;
+    }
+
+    public int getStatus() {
+        return status;
+    }
+
+    public void setStatus(int value) {
+        status = value;
+    }
+
+    public synchronized void lock() {
+        if (locked) {
+            while (locked) {
+                try {
+                    wait();
+                } catch (InterruptedException ex) {
+                    //	ignore
+                }
+                if (status == CoordinatorStatus.STATUS_NONE)
+                    throw new IllegalStateException();
+            }
+        }
+
+        locked = true;
+    }
+
+    public synchronized void unlock() {
+        if (!locked)
+            throw new IllegalStateException();
+        locked = false;
+        notify();
+    }
+
+    public void setProperty(Object key, Object value) {
+        propertyBag.put(key, value);
+
+    }
+
+    public Object getProperty(Object key) {
+        return propertyBag.get(key);
+    }
+    public abstract String getCoordinationType();
+}
\ No newline at end of file

Modified: webservices/kandula/trunk/java/src/org/apache/kandula/context/ContextFactory.java
URL: http://svn.apache.org/viewcvs/webservices/kandula/trunk/java/src/org/apache/kandula/context/ContextFactory.java?rev=290684&r1=290683&r2=290684&view=diff
==============================================================================
--- webservices/kandula/trunk/java/src/org/apache/kandula/context/ContextFactory.java (original)
+++ webservices/kandula/trunk/java/src/org/apache/kandula/context/ContextFactory.java Wed Sep 21 04:55:49 2005
@@ -17,9 +17,9 @@
 package org.apache.kandula.context;
 
 import org.apache.axis2.addressing.EndpointReference;
-import org.apache.kandula.KandulaException;
 import org.apache.kandula.context.at.ATActivityContext;
 import org.apache.kandula.context.coordination.CoordinationContext;
+import org.apache.kandula.faults.InvalidProtocolException;
 
 /**
  * @author <a href="mailto:thilina@opensource.lk"> Thilina Gunarathne </a>
@@ -31,34 +31,31 @@
         return instance;
     }
 
-    public ActivityContext createActivity(String protocol)
-            throws KandulaException {
+    public AbstractContext createActivity(String protocol)
+            throws InvalidProtocolException {
         if (org.apache.kandula.Constants.WS_AT.equalsIgnoreCase(protocol)) {
             return new ATActivityContext();
         } else {
-            throw new KandulaException(new IllegalArgumentException(
-                    "Unsupported Protocol Type"));
+            throw new InvalidProtocolException("Unsupported Protocol Type");
         }
     }
 
-    public ActivityContext createActivity(String protocol,
-                                          EndpointReference activationEPR) throws KandulaException {
+    public AbstractContext createActivity(String protocol,
+                                          EndpointReference activationEPR) throws InvalidProtocolException {
         if (org.apache.kandula.Constants.WS_AT.equalsIgnoreCase(protocol)) {
             return new ATActivityContext(activationEPR);
         } else {
-            throw new KandulaException(new IllegalArgumentException(
-                    "Unsupported Protocol Type"));
+            throw new InvalidProtocolException("Unsupported Protocol Type");
         }
     }
 
-    public ActivityContext createActivity(CoordinationContext context)
-            throws KandulaException {
+    public AbstractContext createActivity(CoordinationContext context)
+            throws InvalidProtocolException{
         if (org.apache.kandula.Constants.WS_AT.equalsIgnoreCase(context
                 .getCoordinationType())) {
             return new ATActivityContext(context);
         } else {
-            throw new KandulaException(new IllegalArgumentException(
-                    "Unsupported Protocol Type"));
+            throw new InvalidProtocolException("Unsupported Protocol Type");
         }
     }
 }

Modified: webservices/kandula/trunk/java/src/org/apache/kandula/context/at/ATActivityContext.java
URL: http://svn.apache.org/viewcvs/webservices/kandula/trunk/java/src/org/apache/kandula/context/at/ATActivityContext.java?rev=290684&r1=290683&r2=290684&view=diff
==============================================================================
--- webservices/kandula/trunk/java/src/org/apache/kandula/context/at/ATActivityContext.java (original)
+++ webservices/kandula/trunk/java/src/org/apache/kandula/context/at/ATActivityContext.java Wed Sep 21 04:55:49 2005
@@ -16,26 +16,26 @@
  */
 package org.apache.kandula.context.at;
 
+import java.util.Hashtable;
+import java.util.Iterator;
+import java.util.LinkedList;
+
 import org.apache.axis2.addressing.EndpointReference;
 import org.apache.kandula.Constants;
-import org.apache.kandula.KandulaException;
 import org.apache.kandula.Status;
-import org.apache.kandula.context.ActivityContext;
-import org.apache.kandula.context.ActivityContextImpl;
+import org.apache.kandula.context.AbstractContext;
 import org.apache.kandula.context.Participant;
 import org.apache.kandula.context.coordination.CoordinationContext;
+import org.apache.kandula.faults.AbstractKandulaException;
+import org.apache.kandula.faults.AlreadyRegisteredException;
+import org.apache.kandula.faults.InvalidProtocolException;
 import org.apache.kandula.utility.EndpointReferenceFactory;
 import org.apache.kandula.utility.KandulaUtils;
 
-import java.util.Hashtable;
-import java.util.Iterator;
-import java.util.LinkedList;
-
 /**
  * @author <a href="mailto:thilina@opensource.lk"> Thilina Gunarathne </a>
  */
-public class ATActivityContext extends ActivityContextImpl implements
-        ActivityContext {
+public class ATActivityContext extends AbstractContext {
 
     private int preparingParticipantsCount = 0;
 
@@ -93,10 +93,10 @@
      * @param participantEPR
      * @param protocol
      * @return Coordinator protocol service.
-     * @throws KandulaException
+     * @throws AbstractKandulaException
      */
     public EndpointReference addParticipant(EndpointReference participantEPR, String protocol)
-            throws KandulaException {
+            throws AbstractKandulaException {
         if (Constants.WS_AT_VOLATILE2PC.equals(protocol)) {
             addVolatileParticipant(participantEPR);
             return EndpointReferenceFactory.getInstance().get2PCEndpoint(this.activityID);
@@ -107,23 +107,23 @@
             //TODO keep track of requesters
             return EndpointReferenceFactory.getInstance().getCompletionEndpoint(this.activityID);
         } else {
-            throw new KandulaException("UnSupported Protocol");
+            throw new InvalidProtocolException();
         }
     }
 
     public void addVolatileParticipant(EndpointReference participantEPR)
-            throws KandulaException {
+            throws AbstractKandulaException {
         if (volatileParticipantsTable.contains(participantEPR))
-            throw new KandulaException("wscoor:Already Registered");
+            throw new AlreadyRegisteredException();
         volatileParticipantsTable.put(participantEPR, new Participant(
                 participantEPR, Constants.WS_AT_VOLATILE2PC));
 
     }
 
     public void addDurableParticipant(EndpointReference participantEPR)
-            throws KandulaException {
+            throws AlreadyRegisteredException {
         if (durableParticipantsTable.contains(participantEPR))
-            throw new KandulaException("wscoor:Already Registered");
+            throw new AlreadyRegisteredException();
         durableParticipantsTable.put(participantEPR, new Participant(
                 participantEPR, Constants.WS_AT_DURABLE2PC));
 
@@ -176,5 +176,10 @@
     //            //throw new
     //        }
     //    }
+
+    
+    public String getCoordinationType() {
+        return Constants.WS_AT;
+    }
 
 }

Added: webservices/kandula/trunk/java/src/org/apache/kandula/context/at/ATParticipantContext.java
URL: http://svn.apache.org/viewcvs/webservices/kandula/trunk/java/src/org/apache/kandula/context/at/ATParticipantContext.java?rev=290684&view=auto
==============================================================================
--- webservices/kandula/trunk/java/src/org/apache/kandula/context/at/ATParticipantContext.java (added)
+++ webservices/kandula/trunk/java/src/org/apache/kandula/context/at/ATParticipantContext.java Wed Sep 21 04:55:49 2005
@@ -0,0 +1,53 @@
+/*
+ * 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.at;
+
+import org.apache.kandula.Constants;
+import org.apache.kandula.context.AbstractContext;
+import org.apache.kandula.participant.KandulaResource;
+
+/**
+ * @author <a href="mailto:thilina@opensource.lk"> Thilina Gunarathne </a>
+ */
+public class ATParticipantContext extends AbstractContext {
+    KandulaResource resource;
+
+    /**
+     * @return Returns the resource.
+     */
+    public KandulaResource getResource() {
+        return resource;
+    }
+
+    /**
+     * @param resource
+     *            The resource to set.
+     */
+    public void setResource(KandulaResource resource) {
+        this.resource = resource;
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see org.apache.kandula.context.AbstractContext#getCoordinationType()
+     */
+    public String getCoordinationType() {
+        return Constants.WS_AT;
+    }
+
+}
\ No newline at end of file

Modified: webservices/kandula/trunk/java/src/org/apache/kandula/context/coordination/CoordinationContext.java
URL: http://svn.apache.org/viewcvs/webservices/kandula/trunk/java/src/org/apache/kandula/context/coordination/CoordinationContext.java?rev=290684&r1=290683&r2=290684&view=diff
==============================================================================
--- webservices/kandula/trunk/java/src/org/apache/kandula/context/coordination/CoordinationContext.java (original)
+++ webservices/kandula/trunk/java/src/org/apache/kandula/context/coordination/CoordinationContext.java Wed Sep 21 04:55:49 2005
@@ -18,8 +18,6 @@
 
 import org.apache.axis2.addressing.EndpointReference;
 import org.apache.axis2.om.OMElement;
-import org.apache.kandula.typemapping.xmlbeansimpl.XmlBeansTypeCoordinationContext;
-import org.apache.kandula.context.coordination.simple.SimpleCoordinationContext;
 
 /**
  * @author <a href="mailto:thilina@opensource.lk"> Thilina Gunarathne </a>
@@ -46,17 +44,17 @@
     public abstract Object getCoordinationContextType();
 
     public static final class Factory {
-        public static CoordinationContext newInstance() {
-            return new SimpleCoordinationContext();
+        public static CoordinationContext newContext(String activityId ,String coordinationType, EndpointReference epr) {
+            return new SimpleCoordinationContext(activityId,coordinationType, epr);
         }
 
-        public static CoordinationContext newInstance(OMElement contextElement) {
+        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

Added: webservices/kandula/trunk/java/src/org/apache/kandula/context/coordination/SimpleCoordinationContext.java
URL: http://svn.apache.org/viewcvs/webservices/kandula/trunk/java/src/org/apache/kandula/context/coordination/SimpleCoordinationContext.java?rev=290684&view=auto
==============================================================================
--- webservices/kandula/trunk/java/src/org/apache/kandula/context/coordination/SimpleCoordinationContext.java (added)
+++ webservices/kandula/trunk/java/src/org/apache/kandula/context/coordination/SimpleCoordinationContext.java Wed Sep 21 04:55:49 2005
@@ -0,0 +1,170 @@
+/*
+ * 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.coordination;
+
+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.OMAbstractFactory;
+import org.apache.axis2.om.OMElement;
+import org.apache.axis2.om.OMNamespace;
+import org.apache.axis2.soap.SOAPFactory;
+import org.apache.kandula.Constants;
+
+import javax.xml.namespace.QName;
+import java.util.Iterator;
+
+/**
+ * @author <a href="mailto:thilina@opensource.lk"> Thilina Gunarathne </a>
+ */
+public class SimpleCoordinationContext implements CoordinationContext {
+    private String activityID;
+
+    private String coordinationType;
+
+    private long expires;
+
+    private EndpointReference registrationServiceEpr;
+
+    private OMElement contextElement = null;
+
+    public SimpleCoordinationContext(String activityID,String coordinationType, EndpointReference epr) {
+        this.activityID = activityID;
+        this.coordinationType  = coordinationType;
+        this.registrationServiceEpr = epr;
+    }
+
+    public SimpleCoordinationContext(OMElement contextElement) {
+        super();
+        this.contextElement = contextElement;
+        activityID = contextElement.getFirstChildWithName(
+                new QName("Identifier")).getText();
+        coordinationType = contextElement.getFirstChildWithName(
+                new QName("CoordinationType")).getText();
+        OMElement registrationElement = contextElement.getFirstChildWithName(
+                new QName("RegistrationService"));
+        registrationServiceEpr = new EndpointReference(registrationElement
+                .getFirstChildWithName(new QName("Address")).getText());
+        AnyContentType referenceProperties = new AnyContentType();
+        OMElement referencePropertiesElement = registrationElement
+                .getFirstChildWithName(new QName("ReferenceProperties"));
+        Iterator propertyIter = referencePropertiesElement.getChildElements();
+        while (propertyIter.hasNext()) {
+            OMElement element = (OMElement) propertyIter.next();
+            referenceProperties.addReferenceValue(element.getQName(), element
+                    .getText());
+        }
+        registrationServiceEpr.setReferenceProperties(referenceProperties);
+    }
+
+    public String getActivityID() {
+        return activityID;
+    }
+
+    public String getCoordinationType() {
+        return coordinationType;
+    }
+
+    public EndpointReference getRegistrationService() {
+        return this.registrationServiceEpr;
+    }
+
+    public long getExpires() {
+        return expires;
+    }
+
+    public void setActivityID(String value) {
+        this.activityID = value;
+
+    }
+
+    public void setCoordinationType(String value) {
+        this.coordinationType = value;
+
+    }
+
+    public void setRegistrationService(EndpointReference epr) {
+        this.registrationServiceEpr = epr;
+    }
+
+    public void setExpires(long value) {
+        this.expires = value;
+    }
+
+    public Object getCoordinationContextType() {
+        return this;
+    }
+
+    public OMElement toOM() {
+        if (contextElement != null) {
+            return contextElement;
+        } else {
+            SOAPFactory factory = OMAbstractFactory.getSOAP12Factory();
+            OMNamespace wsCoor = factory.createOMNamespace(Constants.WS_COOR,
+                    "wscoor");
+            OMElement contextElement = factory.createOMElement(
+                    "CoordinationContext", wsCoor);
+            if (this.expires != 0) {
+                OMElement expiresElement = factory.createOMElement("Expires",
+                        wsCoor);
+                expiresElement.setText(Long.toString(this.expires));
+                contextElement.addChild(expiresElement);
+            }
+            OMElement identifierElement = factory.createOMElement("Identifier",
+                    wsCoor);
+            identifierElement.setText(this.activityID);
+            contextElement.addChild(identifierElement);
+            OMElement coorTypeElement = factory.createOMElement(
+                    "CoordinationType", wsCoor);
+            coorTypeElement.setText(this.coordinationType);
+            contextElement.addChild(coorTypeElement);
+            OMElement registrationServiceElement = factory.createOMElement(
+                    "RegistrationService", wsCoor);
+            OMNamespace wsAddressing = factory.createOMNamespace(
+                    AddressingConstants.Submission.WSA_NAMESPACE,
+                    AddressingConstants.WSA_DEFAULT_PRFIX);
+            OMElement addressElement = factory.createOMElement("Address",
+                    wsAddressing);
+            addressElement.setText(registrationServiceEpr.getAddress());
+            registrationServiceElement.addChild(addressElement);
+            AnyContentType referenceValues = registrationServiceEpr
+                    .getReferenceProperties();
+            if (referenceValues != null) {
+                OMElement refPropertyElement = factory.createOMElement(
+                        "ReferenceProperties", wsAddressing);
+                registrationServiceElement.addChild(refPropertyElement);
+                Iterator iterator = referenceValues.getKeys();
+                while (iterator.hasNext()) {
+                    QName key = (QName) iterator.next();
+                    String value = referenceValues.getReferenceValue(key);
+                    OMElement omElement = factory.createOMElement(key,
+                            refPropertyElement);
+                    refPropertyElement.addChild(omElement);
+                    if (Final.WSA_NAMESPACE.equals(wsAddressing)) {
+                        omElement.addAttribute(
+                                Final.WSA_IS_REFERENCE_PARAMETER_ATTRIBUTE,
+                                Final.WSA_TYPE_ATTRIBUTE_VALUE, wsAddressing);
+                    }
+                    omElement.setText(value);
+                }
+            }
+            contextElement.addChild(registrationServiceElement);
+            return contextElement;
+        }
+    }
+}
\ No newline at end of file

Modified: webservices/kandula/trunk/java/src/org/apache/kandula/coordinator/Coordinator.java
URL: http://svn.apache.org/viewcvs/webservices/kandula/trunk/java/src/org/apache/kandula/coordinator/Coordinator.java?rev=290684&r1=290683&r2=290684&view=diff
==============================================================================
--- webservices/kandula/trunk/java/src/org/apache/kandula/coordinator/Coordinator.java (original)
+++ webservices/kandula/trunk/java/src/org/apache/kandula/coordinator/Coordinator.java Wed Sep 21 04:55:49 2005
@@ -17,13 +17,12 @@
 package org.apache.kandula.coordinator;
 
 import org.apache.axis2.addressing.EndpointReference;
-import org.apache.kandula.KandulaException;
-import org.apache.kandula.context.ActivityContext;
+import org.apache.kandula.context.AbstractContext;
 import org.apache.kandula.context.ContextFactory;
-import org.apache.kandula.coordinator.at.ATCoordinator;
+import org.apache.kandula.context.coordination.CoordinationContext;
+import org.apache.kandula.faults.AbstractKandulaException;
 import org.apache.kandula.storage.StorageFactory;
 import org.apache.kandula.storage.Store;
-import org.apache.kandula.context.coordination.CoordinationContext;
 
 /**
  * @author <a href="mailto:thilina@opensource.lk"> Thilina Gunarathne </a>
@@ -31,6 +30,7 @@
 
 public class Coordinator {
     private Store store;
+
     //till we be able to use reference properties correctly
     public static String ACTIVITY_ID;
 
@@ -40,42 +40,41 @@
     }
 
     /**
-     * @param Coordination Type
-     * @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 ActivityContext. The Coordination Context created by this can
-     *         be used to convey the information about the transaction between
+     * @param Coordination
+     *            Type
+     * @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
+     *         ActivityContext. The Coordination Context created by this can be
+     *         used to convey the information about the transaction between
      *         initiator,Participants and coordinator
-     * @throws KandulaException
+     * @throws AbstractKandulaException
      */
-    public ActivityContext createCoordinationContext(String coordinationType,
-                                                     long expires) throws KandulaException {
+    public AbstractContext createCoordinationContext(String coordinationType,
+            long expires) throws AbstractKandulaException {
         ContextFactory factory = ContextFactory.getInstance();
-        ActivityContext context = factory.createActivity(coordinationType);
+        AbstractContext context = factory.createActivity(coordinationType);
         context.getCoordinationContext().setExpires(expires);
         ACTIVITY_ID = context.getCoordinationContext().getActivityID();
-        store.putContext(context.getCoordinationContext().getActivityID(),
+        store.put(context.getCoordinationContext().getActivityID(),
                 context);
         return context;
     }
 
     /**
      * @param CoordinationContext
-     * @return the interposed Coordination Context created
-     *         <p/>
-     *         Participants decided to use this Coordinator as a interposed
-     *         sub-coordinator.The newly created CoordinationContext will contain the
-     *         same ActivityIdentifier & Protocol type. Registration EPR of the earlier
-     *         CoordinationContext will be replaced by the RegistrationEPR of this
-     *         Coordinator.
+     * @return the interposed Coordination Context created <p/>Participants
+     *         decided to use this Coordinator as a interposed
+     *         sub-coordinator.The newly created CoordinationContext will
+     *         contain the same ActivityIdentifier & Protocol type. Registration
+     *         EPR of the earlier CoordinationContext will be replaced by the
+     *         RegistrationEPR of this Coordinator.
      */
-    public ActivityContext createCoordinationContext(
-            CoordinationContext coorContext) throws KandulaException {
+    public AbstractContext createCoordinationContext(
+            CoordinationContext coorContext) throws AbstractKandulaException {
         ContextFactory factory = ContextFactory.getInstance();
-        ActivityContext context = factory.createActivity(coorContext);
-        store.putContext(context.getCoordinationContext().getActivityID(),
+        AbstractContext context = factory.createActivity(coorContext);
+        store.put(context.getCoordinationContext().getActivityID(),
                 context);
         return context;
     }
@@ -84,28 +83,29 @@
      * @param coordinationProtocol
      * @param participantEPR
      * @param Activity-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 by a initiator.
-     *         Registration request will be forwarded to repective protocol
-     *         coordinators.
-     * @throws KandulaException
+     * @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
+     *         by a initiator. Registration request will be forwarded to
+     *         repective protocol coordinators.
+     * @throws AbstractKandulaException
      */
     public EndpointReference registerParticipant(String id, String protocol,
-                                                 EndpointReference participantEPR) throws KandulaException {
+            EndpointReference participantEPR) throws AbstractKandulaException {
 
-        ActivityContext context = getCoordinationContext(id);
+        AbstractContext context = getCoordinationContext(id);
         if (context == null) {
             throw new IllegalStateException(
                     "No Activity Found for this Activity ID");
         }
-        //TODO use "switch case" when BA is present
-        Registerable activityCoordinator = new ATCoordinator();
-        return activityCoordinator.register(context, protocol, participantEPR);
+
+        Registerable registerableCoordinator = Registerable.Factory
+                .newRegisterable(context.getCoordinationType());
+        return registerableCoordinator.register(context, protocol,
+                participantEPR);
     }
 
-    private ActivityContext getCoordinationContext(String id) {
-        return store.getContext(id);
+    private AbstractContext getCoordinationContext(String id) {
+        return (AbstractContext)store.get(id);
     }
 }

Modified: webservices/kandula/trunk/java/src/org/apache/kandula/coordinator/CoordinatorUtils.java
URL: http://svn.apache.org/viewcvs/webservices/kandula/trunk/java/src/org/apache/kandula/coordinator/CoordinatorUtils.java?rev=290684&r1=290683&r2=290684&view=diff
==============================================================================
--- webservices/kandula/trunk/java/src/org/apache/kandula/coordinator/CoordinatorUtils.java (original)
+++ webservices/kandula/trunk/java/src/org/apache/kandula/coordinator/CoordinatorUtils.java Wed Sep 21 04:55:49 2005
@@ -16,21 +16,17 @@
  */
 package org.apache.kandula.coordinator;
 
-import org.apache.kandula.context.ActivityContext;
-
-import java.net.InetAddress;
-import java.net.UnknownHostException;
-import java.security.MessageDigest;
-import java.security.NoSuchAlgorithmException;
 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 ActivityContext getActivityContext(String id) {
+    public static AbstractContext getActivityContext(String id) {
         return null;
     }
 }

Modified: webservices/kandula/trunk/java/src/org/apache/kandula/coordinator/Registerable.java
URL: http://svn.apache.org/viewcvs/webservices/kandula/trunk/java/src/org/apache/kandula/coordinator/Registerable.java?rev=290684&r1=290683&r2=290684&view=diff
==============================================================================
--- webservices/kandula/trunk/java/src/org/apache/kandula/coordinator/Registerable.java (original)
+++ webservices/kandula/trunk/java/src/org/apache/kandula/coordinator/Registerable.java Wed Sep 21 04:55:49 2005
@@ -17,13 +17,32 @@
 package org.apache.kandula.coordinator;
 
 import org.apache.axis2.addressing.EndpointReference;
-import org.apache.kandula.KandulaException;
-import org.apache.kandula.context.ActivityContext;
+import org.apache.kandula.Constants;
+import org.apache.kandula.context.AbstractContext;
+import org.apache.kandula.coordinator.at.ATCoordinator;
+import org.apache.kandula.faults.AbstractKandulaException;
+import org.apache.kandula.faults.InvalidProtocolException;
 
 /**
  * @author <a href="mailto:thilina@opensource.lk"> Thilina Gunarathne </a>
  */
 public interface Registerable {
-    public EndpointReference register(ActivityContext context, String protocol,
-                                      EndpointReference participantEPR) throws KandulaException;
-}
+    public EndpointReference register(AbstractContext context, String protocol,
+            EndpointReference participantEPR) throws AbstractKandulaException;
+
+    public static final class Factory {
+        public static Registerable newRegisterable(String coordinationType)
+                throws InvalidProtocolException {
+            if (Constants.WS_AT.equals(coordinationType)) {
+
+                return new ATCoordinator();
+
+            } else {
+                throw new InvalidProtocolException("Unsupported Coordination Type");
+            }
+        }
+
+        private Factory() {
+        }
+    }
+}
\ No newline at end of file

Modified: webservices/kandula/trunk/java/src/org/apache/kandula/coordinator/at/ATCoordinator.java
URL: http://svn.apache.org/viewcvs/webservices/kandula/trunk/java/src/org/apache/kandula/coordinator/at/ATCoordinator.java?rev=290684&r1=290683&r2=290684&view=diff
==============================================================================
--- webservices/kandula/trunk/java/src/org/apache/kandula/coordinator/at/ATCoordinator.java (original)
+++ webservices/kandula/trunk/java/src/org/apache/kandula/coordinator/at/ATCoordinator.java Wed Sep 21 04:55:49 2005
@@ -16,49 +16,51 @@
  */
 package org.apache.kandula.coordinator.at;
 
+import java.util.Iterator;
+
 import org.apache.axis2.addressing.EndpointReference;
 import org.apache.kandula.Constants;
-import org.apache.kandula.KandulaException;
 import org.apache.kandula.Status;
 import org.apache.kandula.Status.CoordinatorStatus;
-import org.apache.kandula.context.ActivityContext;
+import org.apache.kandula.context.AbstractContext;
 import org.apache.kandula.context.at.ATActivityContext;
 import org.apache.kandula.coordinator.CoordinatorUtils;
 import org.apache.kandula.coordinator.Registerable;
-
-import java.util.Iterator;
+import org.apache.kandula.faults.AbstractKandulaException;
+import org.apache.kandula.faults.InvalidProtocolException;
+import org.apache.kandula.faults.InvalidStateException;
 
 /**
  * @author <a href="mailto:thilina@opensource.lk"> Thilina Gunarathne </a>
  */
 public class ATCoordinator implements Registerable {
 
-    public EndpointReference register(ActivityContext context, String protocol,
-                                      EndpointReference participantEPR) throws KandulaException {
+    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 IllegalStateException(
+                throw new InvalidStateException(
                         "Coordinator is in preparing state - Durable ");
             case CoordinatorStatus.STATUS_PREPARED_SUCCESS:
                 context.unlock();
-                throw new IllegalStateException(
+                throw new InvalidStateException(
                         "Coordinator is in prepared success state");
             case CoordinatorStatus.STATUS_COMMITTING:
                 context.unlock();
-                throw new IllegalStateException(
+                throw new InvalidStateException(
                         "Coordinator is in committing state");
             case CoordinatorStatus.STATUS_ABORTING:
-                throw new IllegalStateException("Coordinator is in Aborting state");
+                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 IllegalStateException();
+                throw new InvalidStateException();
         }
     }
 
@@ -68,7 +70,7 @@
      *         in Ws-AtomicTransaction specification.
      */
     public String commitOperation(String id) throws IllegalAccessException {
-        ActivityContext context = CoordinatorUtils.getActivityContext(id);
+        AbstractContext context = CoordinatorUtils.getActivityContext(id);
         // if store throws a Exception capture it
         if (context == null) {
             throw new IllegalStateException(
@@ -114,7 +116,7 @@
     }
 
     public String rollbackOperation(String id) throws IllegalAccessException {
-        ActivityContext context = CoordinatorUtils.getActivityContext(id);
+        AbstractContext context = CoordinatorUtils.getActivityContext(id);
         // if store throws a Exception capture it
         if (context == null) {
             throw new IllegalStateException(
@@ -163,7 +165,7 @@
      *      check if there are any more participants to be responded by checking
      *      the hasMorePreparing() methode of the context.
      */
-    public int volatilePrepare(ActivityContext context) {
+    public int volatilePrepare(AbstractContext context) {
         ATActivityContext atContext = (ATActivityContext) context;
         Iterator volatilePartipantIterator = atContext
                 .getRegisteredParticipants(Constants.WS_AT_VOLATILE2PC);
@@ -189,7 +191,7 @@
      *      check if there are any more participants to be responded by checking
      *      the hasMorePreparing() methode of the context.
      */
-    public int durablePrepare(ActivityContext context) {
+    public int durablePrepare(AbstractContext context) {
         ATActivityContext atContext = (ATActivityContext) context;
         Iterator durablePartipantIterator = atContext
                 .getRegisteredParticipants(Constants.WS_AT_DURABLE2PC);
@@ -218,7 +220,7 @@
      *      registered for the Transaction Must check whether all the
      *      participants have replied to the prepare()
      */
-    public int commit(ActivityContext context) {
+    public int commit(AbstractContext context) {
         // check whether all participants are prepared
         ATActivityContext atContext = (ATActivityContext) context;
         while (atContext.hasMorePreparing()) {
@@ -243,12 +245,12 @@
      *      registered for the Transaction Do not have to check whether all the
      *      participants have replied to the prepare()
      */
-    public int abort(ActivityContext context) {
-        // check whether all participants are prepared
-        context.lock();
-        context.setStatus(Status.CoordinatorStatus.STATUS_ABORTING);
-        context.unlock();
-        Iterator participants = context.getAllParticipants();
+    public int abort(AbstractContext context) {
+        ATActivityContext atContext = (ATActivityContext) context;
+        atContext.lock();
+        atContext.setStatus(Status.CoordinatorStatus.STATUS_ABORTING);
+        atContext.unlock();
+        Iterator participants = atContext.getAllParticipants();
 
         while (participants.hasNext()) {
             //port.rollback(participant)
@@ -256,8 +258,8 @@
         return Status.CoordinatorStatus.STATUS_ABORTING;
     }
 
-    public EndpointReference addParticipant(ActivityContext context, String protocol,
-                                            EndpointReference participantEPR) throws KandulaException {
+    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);
@@ -266,7 +268,6 @@
         else if (protocol.equals(Constants.WS_AT_COMPLETION))
             return atContext.addParticipant(participantEPR, protocol);
         else
-            throw new KandulaException(new IllegalArgumentException(
-                    "Unsupported Protocol"));
+            throw new InvalidProtocolException();
     }
 }

Modified: webservices/kandula/trunk/java/src/org/apache/kandula/coordinator/at/ATSubCoordinator.java
URL: http://svn.apache.org/viewcvs/webservices/kandula/trunk/java/src/org/apache/kandula/coordinator/at/ATSubCoordinator.java?rev=290684&r1=290683&r2=290684&view=diff
==============================================================================
--- webservices/kandula/trunk/java/src/org/apache/kandula/coordinator/at/ATSubCoordinator.java (original)
+++ webservices/kandula/trunk/java/src/org/apache/kandula/coordinator/at/ATSubCoordinator.java Wed Sep 21 04:55:49 2005
@@ -18,9 +18,10 @@
 
 import org.apache.axis2.addressing.EndpointReference;
 import org.apache.kandula.Constants;
-import org.apache.kandula.KandulaException;
-import org.apache.kandula.context.ActivityContext;
+import org.apache.kandula.context.AbstractContext;
 import org.apache.kandula.context.at.ATActivityContext;
+import org.apache.kandula.faults.AbstractKandulaException;
+import org.apache.kandula.faults.InvalidProtocolException;
 
 /**
  * @author <a href="mailto:thilina@opensource.lk"> Thilina Gunarathne </a>
@@ -37,8 +38,8 @@
                 "This activity is a Sub Ordinate activity. Completion Protocol not supported.");
     }
 
-    public EndpointReference addParticipant(ActivityContext context, String protocol,
-                                            EndpointReference participantEPR) throws KandulaException {
+    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()) {
@@ -55,8 +56,7 @@
             }
             return atContext.addParticipant(participantEPR, protocol);
         } else
-            throw new KandulaException(new IllegalArgumentException(
-                    "Unsupported Protocol"));
+            throw new InvalidProtocolException();
     }
 
 }

Modified: webservices/kandula/trunk/java/src/org/apache/kandula/coordinator/ba/BACoordinator.java
URL: http://svn.apache.org/viewcvs/webservices/kandula/trunk/java/src/org/apache/kandula/coordinator/ba/BACoordinator.java?rev=290684&r1=290683&r2=290684&view=diff
==============================================================================
--- webservices/kandula/trunk/java/src/org/apache/kandula/coordinator/ba/BACoordinator.java (original)
+++ webservices/kandula/trunk/java/src/org/apache/kandula/coordinator/ba/BACoordinator.java Wed Sep 21 04:55:49 2005
@@ -17,16 +17,16 @@
 package org.apache.kandula.coordinator.ba;
 
 import org.apache.axis2.addressing.EndpointReference;
-import org.apache.kandula.KandulaException;
-import org.apache.kandula.context.ActivityContext;
+import org.apache.kandula.context.AbstractContext;
 import org.apache.kandula.coordinator.Registerable;
+import org.apache.kandula.faults.AbstractKandulaException;
 
 /**
  * @author <a href="mailto:thilina@opensource.lk"> Thilina Gunarathne </a>
  */
 public class BACoordinator implements Registerable {
 
-    public EndpointReference register(ActivityContext context, String protocol, EndpointReference participantEPR) throws KandulaException {
+    public EndpointReference register(AbstractContext context, String protocol, EndpointReference participantEPR) throws AbstractKandulaException {
         return null;  //To change body of implemented methods use File | Settings | File Templates.
     }
 }

Added: webservices/kandula/trunk/java/src/org/apache/kandula/faults/AbstractKandulaException.java
URL: http://svn.apache.org/viewcvs/webservices/kandula/trunk/java/src/org/apache/kandula/faults/AbstractKandulaException.java?rev=290684&view=auto
==============================================================================
--- webservices/kandula/trunk/java/src/org/apache/kandula/faults/AbstractKandulaException.java (added)
+++ webservices/kandula/trunk/java/src/org/apache/kandula/faults/AbstractKandulaException.java Wed Sep 21 04:55:49 2005
@@ -0,0 +1,61 @@
+/*
+ * 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.faults;
+
+/**
+ * @author <a href="mailto:thilina@opensource.lk"> Thilina Gunarathne </a>
+ */
+public abstract class AbstractKandulaException extends Exception{
+    
+    public AbstractKandulaException() {
+        super();
+    }
+
+    /**
+     * @param arg0 - String
+     */
+    public AbstractKandulaException(String arg0) {
+        super(arg0);
+    }
+
+    /**
+     * @param arg0 - Throwable
+     */
+    public AbstractKandulaException(Throwable arg0) {
+        super(arg0);
+    }
+
+    /**
+     * @param arg0 - String
+     * @param arg1 - Throwable
+     */
+    public AbstractKandulaException(String arg0, Throwable arg1) {
+        super(arg0, arg1);
+    }
+
+    public abstract String getFaultCode();
+
+    public abstract String getFaultSubcode();
+
+    public abstract String getFaultReason();
+
+    public String getFaultDetail()
+    {
+        return this.toString();
+    }
+
+}
\ No newline at end of file

Added: webservices/kandula/trunk/java/src/org/apache/kandula/faults/AlreadyRegisteredException.java
URL: http://svn.apache.org/viewcvs/webservices/kandula/trunk/java/src/org/apache/kandula/faults/AlreadyRegisteredException.java?rev=290684&view=auto
==============================================================================
--- webservices/kandula/trunk/java/src/org/apache/kandula/faults/AlreadyRegisteredException.java (added)
+++ webservices/kandula/trunk/java/src/org/apache/kandula/faults/AlreadyRegisteredException.java Wed Sep 21 04:55:49 2005
@@ -0,0 +1,79 @@
+/*
+ * 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.faults;
+
+/**
+ * @author <a href="mailto:thilina@opensource.lk"> Thilina Gunarathne </a>
+ */
+public class AlreadyRegisteredException extends AbstractKandulaException {
+
+    /**
+     *  
+     */
+    public AlreadyRegisteredException() {
+        super();
+    }
+
+    /**
+     * @param arg0
+     */
+    public AlreadyRegisteredException(String arg0) {
+        super(arg0);
+    }
+
+    /**
+     * @param arg0
+     */
+    public AlreadyRegisteredException(Throwable arg0) {
+        super(arg0);
+    }
+
+    /**
+     * @param arg0
+     * @param arg1
+     */
+    public AlreadyRegisteredException(String arg0, Throwable arg1) {
+        super(arg0, arg1);
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see org.apache.kandula.faults.KandulaFault#getFaultCode()
+     */
+    public String getFaultCode() {
+        return "Sender";
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see org.apache.kandula.faults.KandulaFault#getFaultSubcode()
+     */
+    public String getFaultSubcode() {
+        return "wscoor:AlreadyRegistered";
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see org.apache.kandula.faults.KandulaFault#getFaultReason()
+     */
+    public String getFaultReason() {
+        return "The participant has already registered for the same protocol.";
+    }
+}
\ No newline at end of file

Added: webservices/kandula/trunk/java/src/org/apache/kandula/faults/ContextRefusedException.java
URL: http://svn.apache.org/viewcvs/webservices/kandula/trunk/java/src/org/apache/kandula/faults/ContextRefusedException.java?rev=290684&view=auto
==============================================================================
--- webservices/kandula/trunk/java/src/org/apache/kandula/faults/ContextRefusedException.java (added)
+++ webservices/kandula/trunk/java/src/org/apache/kandula/faults/ContextRefusedException.java Wed Sep 21 04:55:49 2005
@@ -0,0 +1,79 @@
+/*
+ * 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.faults;
+
+/**
+ * @author <a href="mailto:thilina@opensource.lk"> Thilina Gunarathne </a>
+ */
+public class ContextRefusedException extends AbstractKandulaException {
+
+    /**
+     *  
+     */
+    public ContextRefusedException() {
+        super();
+    }
+
+    /**
+     * @param arg0
+     */
+    public ContextRefusedException(String arg0) {
+        super(arg0);
+    }
+
+    /**
+     * @param arg0
+     */
+    public ContextRefusedException(Throwable arg0) {
+        super(arg0);
+    }
+
+    /**
+     * @param arg0
+     * @param arg1
+     */
+    public ContextRefusedException(String arg0, Throwable arg1) {
+        super(arg0, arg1);
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see org.apache.kandula.faults.KandulaFault#getFaultCode()
+     */
+    public String getFaultCode() {
+        return "Sender";
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see org.apache.kandula.faults.KandulaFault#getFaultSubcode()
+     */
+    public String getFaultSubcode() {
+        return "wscoor:ContextRefused";
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see org.apache.kandula.faults.KandulaFault#getFaultReason()
+     */
+    public String getFaultReason() {
+        return "The coordination context that was provided could not be accepted.";
+    }
+}
\ No newline at end of file

Added: webservices/kandula/trunk/java/src/org/apache/kandula/faults/InvalidParameterException.java
URL: http://svn.apache.org/viewcvs/webservices/kandula/trunk/java/src/org/apache/kandula/faults/InvalidParameterException.java?rev=290684&view=auto
==============================================================================
--- webservices/kandula/trunk/java/src/org/apache/kandula/faults/InvalidParameterException.java (added)
+++ webservices/kandula/trunk/java/src/org/apache/kandula/faults/InvalidParameterException.java Wed Sep 21 04:55:49 2005
@@ -0,0 +1,74 @@
+/*
+ * 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.faults;
+
+/**
+ * @author <a href="mailto:thilina@opensource.lk"> Thilina Gunarathne </a>
+ */
+public class InvalidParameterException extends AbstractKandulaException {
+
+    /**
+     * 
+     */
+    public InvalidParameterException() {
+        super();
+    }
+
+    /**
+     * @param arg0
+     */
+    public InvalidParameterException(String arg0) {
+        super(arg0);
+    }
+
+    /**
+     * @param arg0
+     */
+    public InvalidParameterException(Throwable arg0) {
+        super(arg0);
+    }
+
+    /**
+     * @param arg0
+     * @param arg1
+     */
+    public InvalidParameterException(String arg0, Throwable arg1) {
+        super(arg0, arg1);
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.kandula.faults.KandulaFault#getFaultCode()
+     */
+    public String getFaultCode() {
+        return "Sender";
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.kandula.faults.KandulaFault#getFaultSubcode()
+     */
+    public String getFaultSubcode() {
+        return "wscoor:InvalidParameters";
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.kandula.faults.KandulaFault#getFaultReason()
+     */
+    public String getFaultReason() {
+
+        return "The message contained invalid parameters and could not be processed.x";
+    }
+}
\ No newline at end of file

Added: webservices/kandula/trunk/java/src/org/apache/kandula/faults/InvalidProtocolException.java
URL: http://svn.apache.org/viewcvs/webservices/kandula/trunk/java/src/org/apache/kandula/faults/InvalidProtocolException.java?rev=290684&view=auto
==============================================================================
--- webservices/kandula/trunk/java/src/org/apache/kandula/faults/InvalidProtocolException.java (added)
+++ webservices/kandula/trunk/java/src/org/apache/kandula/faults/InvalidProtocolException.java Wed Sep 21 04:55:49 2005
@@ -0,0 +1,73 @@
+/*
+ * 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.faults;
+
+/**
+ * @author <a href="mailto:thilina@opensource.lk"> Thilina Gunarathne </a>
+ */
+public class InvalidProtocolException extends AbstractKandulaException {
+
+    /**
+     * 
+     */
+    public InvalidProtocolException() {
+        super();
+    }
+
+    /**
+     * @param arg0
+     */
+    public InvalidProtocolException(String arg0) {
+        super(arg0);
+    }
+
+    /**
+     * @param arg0
+     */
+    public InvalidProtocolException(Throwable arg0) {
+        super(arg0);
+    }
+
+    /**
+     * @param arg0
+     * @param arg1
+     */
+    public InvalidProtocolException(String arg0, Throwable arg1) {
+        super(arg0, arg1);
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.kandula.faults.KandulaFault#getFaultCode()
+     */
+    public String getFaultCode() {
+        return "Sender";
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.kandula.faults.KandulaFault#getFaultSubcode()
+     */
+    public String getFaultSubcode() {
+        return "wscoor:InvalidProtocol";
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.kandula.faults.KandulaFault#getFaultReason()
+     */
+    public String getFaultReason() {
+        return "The protocol is invalid or is not supported by the coordinator.";
+    }
+}

Added: webservices/kandula/trunk/java/src/org/apache/kandula/faults/InvalidStateException.java
URL: http://svn.apache.org/viewcvs/webservices/kandula/trunk/java/src/org/apache/kandula/faults/InvalidStateException.java?rev=290684&view=auto
==============================================================================
--- webservices/kandula/trunk/java/src/org/apache/kandula/faults/InvalidStateException.java (added)
+++ webservices/kandula/trunk/java/src/org/apache/kandula/faults/InvalidStateException.java Wed Sep 21 04:55:49 2005
@@ -0,0 +1,73 @@
+/*
+ * 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.faults;
+
+/**
+ * @author <a href="mailto:thilina@opensource.lk"> Thilina Gunarathne </a>
+ */
+public class InvalidStateException extends AbstractKandulaException {
+
+    /**
+     * 
+     */
+    public InvalidStateException() {
+        super();
+    }
+
+    /**
+     * @param arg0
+     */
+    public InvalidStateException(String arg0) {
+        super(arg0);
+    }
+
+    /**
+     * @param arg0
+     */
+    public InvalidStateException(Throwable arg0) {
+        super(arg0);
+    }
+
+    /**
+     * @param arg0
+     * @param arg1
+     */
+    public InvalidStateException(String arg0, Throwable arg1) {
+        super(arg0, arg1);
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.kandula.faults.KandulaFault#getFaultCode()
+     */
+    public String getFaultCode() {
+        return "Sender";
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.kandula.faults.KandulaFault#getFaultSubcode()
+     */
+    public String getFaultSubcode() {
+        return "wscoor:InvalidState";
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.kandula.faults.KandulaFault#getFaultReason()
+     */
+    public String getFaultReason() {
+        return "The message was invalid for the current state of the activity.";
+    }
+}
\ No newline at end of file

Added: webservices/kandula/trunk/java/src/org/apache/kandula/faults/NoActivityException.java
URL: http://svn.apache.org/viewcvs/webservices/kandula/trunk/java/src/org/apache/kandula/faults/NoActivityException.java?rev=290684&view=auto
==============================================================================
--- webservices/kandula/trunk/java/src/org/apache/kandula/faults/NoActivityException.java (added)
+++ webservices/kandula/trunk/java/src/org/apache/kandula/faults/NoActivityException.java Wed Sep 21 04:55:49 2005
@@ -0,0 +1,74 @@
+/*
+ * 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.faults;
+
+/**
+ * @author <a href="mailto:thilina@opensource.lk"> Thilina Gunarathne </a>
+ */
+public class NoActivityException extends AbstractKandulaException {
+
+    /**
+     * 
+     */
+    public NoActivityException() {
+        super();
+    }
+
+    /**
+     * @param arg0
+     */
+    public NoActivityException(String arg0) {
+        super(arg0);
+    }
+
+    /**
+     * @param arg0
+     */
+    public NoActivityException(Throwable arg0) {
+        super(arg0);
+    }
+
+    /**
+     * @param arg0
+     * @param arg1
+     */
+    public NoActivityException(String arg0, Throwable arg1) {
+        super(arg0, arg1);
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.kandula.faults.KandulaFault#getFaultCode()
+     */
+    public String getFaultCode() {
+        return "Sender";
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.kandula.faults.KandulaFault#getFaultSubcode()
+     */
+    public String getFaultSubcode() {
+        return "wscoor:NoActivity";
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.kandula.faults.KandulaFault#getFaultReason()
+     */
+    public String getFaultReason() {
+
+        return "The participant is not responding and is presumed to have ended.";
+    }
+}
\ No newline at end of file

Added: webservices/kandula/trunk/java/src/org/apache/kandula/initiator/ATInitiatorTransaction.java
URL: http://svn.apache.org/viewcvs/webservices/kandula/trunk/java/src/org/apache/kandula/initiator/ATInitiatorTransaction.java?rev=290684&view=auto
==============================================================================
--- webservices/kandula/trunk/java/src/org/apache/kandula/initiator/ATInitiatorTransaction.java (added)
+++ webservices/kandula/trunk/java/src/org/apache/kandula/initiator/ATInitiatorTransaction.java Wed Sep 21 04:55:49 2005
@@ -0,0 +1,64 @@
+/*
+ * 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;
+
+import org.apache.axis2.addressing.EndpointReference;
+import org.apache.kandula.context.coordination.CoordinationContext;
+
+/**
+ * @author <a href="mailto:thilina@opensource.lk"> Thilina Gunarathne </a>
+ */
+public class ATInitiatorTransaction {
+
+    private EndpointReference coordinationEPR;
+
+    private CoordinationContext coordinationContext;
+
+    public ATInitiatorTransaction(EndpointReference coordinationEPR) {
+        this.coordinationEPR = coordinationEPR;
+    }
+
+    /**
+     * @return Returns the coordinationEPR.
+     */
+    public EndpointReference getCoordinationEPR() {
+        return coordinationEPR;
+    }
+
+    /**
+     * @param coordinationEPR
+     *            The coordinationEPR to set.
+     */
+    public void setCoordinationEPR(EndpointReference coordinationEPR) {
+        this.coordinationEPR = coordinationEPR;
+    }
+
+    /**
+     * @return Returns the coordinationContext.
+     */
+    public CoordinationContext getCoordinationContext() {
+        return coordinationContext;
+    }
+
+    /**
+     * @param coordinationContext
+     *            The coordinationContext to set.
+     */
+    public void setCoordinationContext(CoordinationContext coordinationContext) {
+        this.coordinationContext = coordinationContext;
+    }
+}
\ No newline at end of file

Modified: webservices/kandula/trunk/java/src/org/apache/kandula/initiator/TransactionManager.java
URL: http://svn.apache.org/viewcvs/webservices/kandula/trunk/java/src/org/apache/kandula/initiator/TransactionManager.java?rev=290684&r1=290683&r2=290684&view=diff
==============================================================================
--- webservices/kandula/trunk/java/src/org/apache/kandula/initiator/TransactionManager.java (original)
+++ webservices/kandula/trunk/java/src/org/apache/kandula/initiator/TransactionManager.java Wed Sep 21 04:55:49 2005
@@ -16,19 +16,20 @@
  */
 package org.apache.kandula.initiator;
 
+import java.rmi.RemoteException;
+
 import org.apache.axis2.addressing.EndpointReference;
-import org.apache.kandula.KandulaException;
-import org.apache.kandula.context.ActivityContext;
+import org.apache.kandula.context.AbstractContext;
 import org.apache.kandula.context.ContextFactory;
 import org.apache.kandula.context.at.ATActivityContext;
+import org.apache.kandula.faults.AbstractKandulaException;
+import org.apache.kandula.faults.InvalidStateException;
 import org.apache.kandula.storage.StorageFactory;
 import org.apache.kandula.storage.Store;
 import org.apache.kandula.utility.EndpointReferenceFactory;
 import org.apache.kandula.wscoor.ActivationCoordinatorPortTypeRawXMLStub;
 import org.apache.kandula.wscoor.RegistrationCoordinatorPortTypeRawXMLStub;
 
-import java.rmi.RemoteException;
-
 /**
  * @author Dasarath Weeratunge
  * @author <a href="mailto:thilina@apache.org"> Thilina Gunarathne </a>
@@ -42,17 +43,18 @@
     public static String tempID;
 
     public TransactionManager(String coordinationType,
-                              EndpointReference coordEPR) throws KandulaException {
+                              EndpointReference coordinatorEPR) throws AbstractKandulaException {
         threadInfo = new ThreadLocal();
-        ActivityContext context = ContextFactory.getInstance().createActivity(
-                coordinationType, coordEPR);
+        ATInitiatorTransaction transaction = new ATInitiatorTransaction(coordinatorEPR);
+        AbstractContext context = ContextFactory.getInstance().createActivity(
+                coordinationType, coordinatorEPR);
         if (threadInfo.get() != null)
             throw new IllegalStateException();
-        threadInfo.set(context.getProperty(ATActivityContext.REQUESTER_ID));
+        threadInfo.set(transaction);
         //TODO remove this when we get replyTo reference properties correctly
         tempID = (String) context.getProperty(ATActivityContext.REQUESTER_ID);
         Store store = StorageFactory.getInstance().getStore();
-        store.putContext(context.getProperty(ATActivityContext.REQUESTER_ID),
+        store.put(context.getProperty(ATActivityContext.REQUESTER_ID),
                 context);
     }
 
@@ -60,7 +62,7 @@
      * @throws Exception
      */
     public void begin() throws Exception {
-        ActivityContext context = getTransaction();
+        AbstractContext context = getTransaction();
         String id = (String) context
                 .getProperty(ATActivityContext.REQUESTER_ID);
         threadInfo.set(id);
@@ -118,12 +120,12 @@
     //		threadInfo.set(null);
     //	}
 
-    public ActivityContext getTransaction() throws KandulaException {
+    public AbstractContext getTransaction() throws AbstractKandulaException {
         Object key = threadInfo.get();
-        ActivityContext context = StorageFactory.getInstance().getStore()
-                .getContext(key);
+        AbstractContext context = (AbstractContext) StorageFactory.getInstance().getStore()
+                .get(key);
         if (context == null) {
-            throw new KandulaException("IllegalState");
+            throw new InvalidStateException("No Activity Found");
         }
         return context;
     }

Added: webservices/kandula/trunk/java/src/org/apache/kandula/initiator/TransactionOutHandler.java
URL: http://svn.apache.org/viewcvs/webservices/kandula/trunk/java/src/org/apache/kandula/initiator/TransactionOutHandler.java?rev=290684&view=auto
==============================================================================
--- webservices/kandula/trunk/java/src/org/apache/kandula/initiator/TransactionOutHandler.java (added)
+++ webservices/kandula/trunk/java/src/org/apache/kandula/initiator/TransactionOutHandler.java Wed Sep 21 04:55:49 2005
@@ -0,0 +1,49 @@
+/*
+ * 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;
+
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.addressing.MessageInformationHeaders;
+import org.apache.axis2.context.MessageContext;
+import org.apache.axis2.handlers.AbstractHandler;
+import org.apache.axis2.soap.SOAPHeader;
+import org.apache.kandula.context.AbstractContext;
+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);
+            if (context == null) {
+                throw new AxisFault("IllegalState");
+            }
+
+            MessageInformationHeaders messageInformationHeaders =
+                    msgContext.getMessageInformationHeaders();
+            SOAPHeader soapHeader = msgContext.getEnvelope().getHeader();
+            CoordinationContext coorContext = context.getCoordinationContext();
+            soapHeader.addChild(coorContext.toOM());
+        }
+    }
+}
+

Added: webservices/kandula/trunk/java/src/org/apache/kandula/participant/KandulaResource.java
URL: http://svn.apache.org/viewcvs/webservices/kandula/trunk/java/src/org/apache/kandula/participant/KandulaResource.java?rev=290684&view=auto
==============================================================================
--- webservices/kandula/trunk/java/src/org/apache/kandula/participant/KandulaResource.java (added)
+++ webservices/kandula/trunk/java/src/org/apache/kandula/participant/KandulaResource.java Wed Sep 21 04:55:49 2005
@@ -0,0 +1,26 @@
+/*
+ * Copyright  2004 The Apache Software Foundation.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ */
+package org.apache.kandula.participant;
+
+/**
+ * @author <a href="mailto:thilina@opensource.lk"> Thilina Gunarathne </a>
+ */
+public interface KandulaResource {
+    public void commit();
+    public void rollback();
+    public Vote prepare();
+}

Added: webservices/kandula/trunk/java/src/org/apache/kandula/participant/ParticipantTransactionManager.java
URL: http://svn.apache.org/viewcvs/webservices/kandula/trunk/java/src/org/apache/kandula/participant/ParticipantTransactionManager.java?rev=290684&view=auto
==============================================================================
--- webservices/kandula/trunk/java/src/org/apache/kandula/participant/ParticipantTransactionManager.java (added)
+++ webservices/kandula/trunk/java/src/org/apache/kandula/participant/ParticipantTransactionManager.java Wed Sep 21 04:55:49 2005
@@ -0,0 +1,57 @@
+/*
+ * Copyright  2004 The Apache Software Foundation.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ */
+package org.apache.kandula.participant;
+
+import org.apache.kandula.Status;
+import org.apache.kandula.context.AbstractContext;
+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;
+        atContext.lock();
+        switch (context.getStatus())
+        {
+        case (Status.CoordinatorStatus.STATUS_NONE):
+            //TODO send aborted
+            atContext.unlock();
+            return Vote.ABORT;
+        case (Status.CoordinatorStatus.STATUS_PREPARING):
+        case (Status.CoordinatorStatus.STATUS_PREPARED):
+        case (Status.CoordinatorStatus.STATUS_COMMITTING):
+            //Ignore the message
+            atContext.unlock();
+            return Vote.NONE;
+        case (Status.CoordinatorStatus.STATUS_PREPARED_SUCCESS):
+            atContext.unlock();
+        	return Vote.PREPARED;
+        case (Status.CoordinatorStatus.STATUS_ACTIVE):
+            atContext.setStatus(Status.CoordinatorStatus.STATUS_PREPARING);
+        	KandulaResource resource = atContext.getResource();
+        	return resource.prepare();
+        default:
+            context.unlock();
+            throw new InvalidStateException();
+        }
+    }
+}

Added: webservices/kandula/trunk/java/src/org/apache/kandula/participant/Vote.java
URL: http://svn.apache.org/viewcvs/webservices/kandula/trunk/java/src/org/apache/kandula/participant/Vote.java?rev=290684&view=auto
==============================================================================
--- webservices/kandula/trunk/java/src/org/apache/kandula/participant/Vote.java (added)
+++ webservices/kandula/trunk/java/src/org/apache/kandula/participant/Vote.java Wed Sep 21 04:55:49 2005
@@ -0,0 +1,43 @@
+/*
+ * Copyright  2004 The Apache Software Foundation.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ */
+package org.apache.kandula.participant;
+
+
+/**
+ * @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)
+    {
+        this.state = outcome;
+    }
+    public String getOutcome()
+    {
+        return state;
+    }
+}



---------------------------------------------------------------------
To unsubscribe, e-mail: kandula-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: kandula-dev-help@ws.apache.org