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)
diff --git a/maven.xml b/maven.xml
index d72e047..5a0b993 100644
--- a/maven.xml
+++ b/maven.xml
@@ -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>
diff --git a/project.xml b/project.xml
index cc22ecc..1d3d5d0 100644
--- a/project.xml
+++ b/project.xml
@@ -125,7 +125,7 @@
<dependency>
<groupId>axis</groupId>
<artifactId>axis2</artifactId>
- <version>0.9</version>
+ <version>0.91</version>
</dependency>
<!--
diff --git a/src/org/apache/kandula/KandulaException.java b/src/org/apache/kandula/KandulaException.java
deleted file mode 100644
index 4c738f5..0000000
--- a/src/org/apache/kandula/KandulaException.java
+++ /dev/null
@@ -1,57 +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;
-
-/**
- * @author <a href="mailto:thilina@opensource.lk"> Thilina Gunarathne </a>
- */
-public class KandulaException extends Exception {
-
- /**
- *
- */
- public KandulaException() {
- super();
- // TODO Auto-generated constructor stub
- }
-
- /**
- * @param arg0
- */
- public KandulaException(String arg0) {
- super(arg0);
- // TODO Auto-generated constructor stub
- }
-
- /**
- * @param arg0
- */
- public KandulaException(Throwable arg0) {
- super(arg0);
- // TODO Auto-generated constructor stub
- }
-
- /**
- * @param arg0
- * @param arg1
- */
- public KandulaException(String arg0, Throwable arg1) {
- super(arg0, arg1);
- // TODO Auto-generated constructor stub
- }
-
-}
diff --git a/src/org/apache/kandula/Status.java b/src/org/apache/kandula/Status.java
index 3e36216..c04ae5c 100644
--- a/src/org/apache/kandula/Status.java
+++ b/src/org/apache/kandula/Status.java
@@ -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 = 22;
- public static final int STATUS_ABORTED = 23;
-
- 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;
diff --git a/src/org/apache/kandula/context/ActivityContextImpl.java b/src/org/apache/kandula/context/AbstractContext.java
similarity index 81%
rename from src/org/apache/kandula/context/ActivityContextImpl.java
rename to src/org/apache/kandula/context/AbstractContext.java
index a873ea4..607334a 100644
--- a/src/org/apache/kandula/context/ActivityContextImpl.java
+++ b/src/org/apache/kandula/context/AbstractContext.java
@@ -16,20 +16,21 @@
*/
package org.apache.kandula.context;
-import org.apache.axis2.addressing.AnyContentType;
-import org.apache.axis2.addressing.EndpointReference;
-import org.apache.kandula.context.coordination.CoordinationContext;
-import org.apache.kandula.Status.CoordinatorStatus;
-import org.apache.kandula.utility.EndpointReferenceFactory;
-import org.apache.kandula.utility.KandulaUtils;
+import java.util.HashMap;
import javax.xml.namespace.QName;
-import java.util.HashMap;
+
+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 ActivityContextImpl implements ActivityContext {
+public abstract class AbstractContext {
private HashMap propertyBag;
@@ -41,15 +42,13 @@
protected CoordinationContext coordinationContext = null;
- protected ActivityContextImpl() {
+ protected AbstractContext() {
propertyBag = new HashMap();
}
- public ActivityContextImpl(String coordinationType) {
+ public AbstractContext(String coordinationType) {
propertyBag = new HashMap();
activityID = KandulaUtils.getRandomStringOf18Characters();
- coordinationContext = CoordinationContext.Factory.newInstance();
- coordinationContext.setActivityID(activityID);
EndpointReference registrationEpr = EndpointReferenceFactory
.getInstance().getRegistrationEndpoint(activityID);
AnyContentType referenceProp = new AnyContentType();
@@ -57,8 +56,8 @@
"http://webservice.apache.org/~thilina", "myapp", "ID"),
activityID);
registrationEpr.setReferenceProperties(referenceProp);
- coordinationContext.setRegistrationService(registrationEpr);
- coordinationContext.setCoordinationType(coordinationType);
+ coordinationContext = CoordinationContext.Factory.newContext(
+ activityID, coordinationType, registrationEpr);
}
public CoordinationContext getCoordinationContext() {
@@ -69,12 +68,6 @@
this.coordinationContext = context;
}
-// public abstract EndpointReference addParticipant(EndpointReference participantEPR, String protocol) throws KandulaException;
-//
-// public abstract Iterator getRegisteredParticipants(String protocol);
-//
-// public abstract Iterator getAllParticipants();
-
public int getStatus() {
return status;
}
@@ -114,4 +107,5 @@
public 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/ActivityContext.java b/src/org/apache/kandula/context/ActivityContext.java
deleted file mode 100644
index 290dc03..0000000
--- a/src/org/apache/kandula/context/ActivityContext.java
+++ /dev/null
@@ -1,52 +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.context;
-
-import org.apache.axis2.addressing.EndpointReference;
-import org.apache.kandula.KandulaException;
-import org.apache.kandula.context.coordination.CoordinationContext;
-
-import java.util.Iterator;
-
-/**
- * @author <a href="mailto:thilina@opensource.lk"> Thilina Gunarathne </a>
- */
-public interface ActivityContext {
-
- public abstract EndpointReference addParticipant(EndpointReference participantEPR, String protocol) throws KandulaException;
-
- public abstract Iterator getRegisteredParticipants(String protocol);
-
- public abstract Iterator getAllParticipants();
-
- public abstract int getStatus();
-
- public abstract void setStatus(int value);
-
- public abstract void lock();
-
- public abstract void unlock();
-
- public abstract void setProperty(Object key, Object value);
-
- public abstract Object getProperty(Object key);
-
- public abstract CoordinationContext getCoordinationContext();
-
- public abstract void setCoordinationContext(CoordinationContext context);
-
-}
\ 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 e9bc834..a96514b 100644
--- a/src/org/apache/kandula/context/ContextFactory.java
+++ b/src/org/apache/kandula/context/ContextFactory.java
@@ -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");
}
}
}
\ 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 1fcf1f6..43b9fc5 100644
--- a/src/org/apache/kandula/context/at/ATActivityContext.java
+++ b/src/org/apache/kandula/context/at/ATActivityContext.java
@@ -16,26 +16,26 @@
*/
package org.apache.kandula.context.at;
-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.Participant;
-import org.apache.kandula.context.coordination.CoordinationContext;
-import org.apache.kandula.utility.EndpointReferenceFactory;
-import org.apache.kandula.utility.KandulaUtils;
-
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.Status;
+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;
+
/**
* @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));
@@ -177,4 +177,9 @@
// }
// }
+
+ public String getCoordinationType() {
+ return Constants.WS_AT;
+ }
+
}
\ No newline at end of file
diff --git a/src/org/apache/kandula/context/at/ATParticipantContext.java b/src/org/apache/kandula/context/at/ATParticipantContext.java
new file mode 100644
index 0000000..21254f1
--- /dev/null
+++ b/src/org/apache/kandula/context/at/ATParticipantContext.java
@@ -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
diff --git a/src/org/apache/kandula/context/coordination/CoordinationContext.java b/src/org/apache/kandula/context/coordination/CoordinationContext.java
index 98fb1fd..dc21655 100644
--- a/src/org/apache/kandula/context/coordination/CoordinationContext.java
+++ b/src/org/apache/kandula/context/coordination/CoordinationContext.java
@@ -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
diff --git a/src/org/apache/kandula/context/coordination/simple/SimpleCoordinationContext.java b/src/org/apache/kandula/context/coordination/SimpleCoordinationContext.java
similarity index 95%
rename from src/org/apache/kandula/context/coordination/simple/SimpleCoordinationContext.java
rename to src/org/apache/kandula/context/coordination/SimpleCoordinationContext.java
index 6f529e0..495e409 100644
--- a/src/org/apache/kandula/context/coordination/simple/SimpleCoordinationContext.java
+++ b/src/org/apache/kandula/context/coordination/SimpleCoordinationContext.java
@@ -14,7 +14,7 @@
* limitations under the License.
*
*/
-package org.apache.kandula.context.coordination.simple;
+package org.apache.kandula.context.coordination;
import org.apache.axis2.addressing.AddressingConstants;
import org.apache.axis2.addressing.AddressingConstants.Final;
@@ -25,7 +25,6 @@
import org.apache.axis2.om.OMNamespace;
import org.apache.axis2.soap.SOAPFactory;
import org.apache.kandula.Constants;
-import org.apache.kandula.context.coordination.CoordinationContext;
import javax.xml.namespace.QName;
import java.util.Iterator;
@@ -44,8 +43,10 @@
private OMElement contextElement = null;
- public SimpleCoordinationContext() {
- super();
+ public SimpleCoordinationContext(String activityID,String coordinationType, EndpointReference epr) {
+ this.activityID = activityID;
+ this.coordinationType = coordinationType;
+ this.registrationServiceEpr = epr;
}
public SimpleCoordinationContext(OMElement contextElement) {
diff --git a/src/org/apache/kandula/coordinator/Coordinator.java b/src/org/apache/kandula/coordinator/Coordinator.java
index 74c8f1a..0f7f5b3 100644
--- a/src/org/apache/kandula/coordinator/Coordinator.java
+++ b/src/org/apache/kandula/coordinator/Coordinator.java
@@ -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);
}
}
\ No newline at end of file
diff --git a/src/org/apache/kandula/coordinator/CoordinatorUtils.java b/src/org/apache/kandula/coordinator/CoordinatorUtils.java
index 92821dd..ac461fa 100644
--- a/src/org/apache/kandula/coordinator/CoordinatorUtils.java
+++ b/src/org/apache/kandula/coordinator/CoordinatorUtils.java
@@ -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;
}
}
\ 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 5072582..3fcb218 100644
--- a/src/org/apache/kandula/coordinator/Registerable.java
+++ b/src/org/apache/kandula/coordinator/Registerable.java
@@ -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
diff --git a/src/org/apache/kandula/coordinator/at/ATCoordinator.java b/src/org/apache/kandula/coordinator/at/ATCoordinator.java
index 6fcc5bb..f9ba140 100644
--- a/src/org/apache/kandula/coordinator/at/ATCoordinator.java
+++ b/src/org/apache/kandula/coordinator/at/ATCoordinator.java
@@ -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();
}
}
\ 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 0804bd2..ec1bca1 100644
--- a/src/org/apache/kandula/coordinator/at/ATSubCoordinator.java
+++ b/src/org/apache/kandula/coordinator/at/ATSubCoordinator.java
@@ -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();
}
}
\ No newline at end of file
diff --git a/src/org/apache/kandula/coordinator/ba/BACoordinator.java b/src/org/apache/kandula/coordinator/ba/BACoordinator.java
index f018786..01aef46 100644
--- a/src/org/apache/kandula/coordinator/ba/BACoordinator.java
+++ b/src/org/apache/kandula/coordinator/ba/BACoordinator.java
@@ -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.
}
}
\ No newline at end of file
diff --git a/src/org/apache/kandula/faults/AbstractKandulaException.java b/src/org/apache/kandula/faults/AbstractKandulaException.java
new file mode 100644
index 0000000..1c09edb
--- /dev/null
+++ b/src/org/apache/kandula/faults/AbstractKandulaException.java
@@ -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
diff --git a/src/org/apache/kandula/faults/AlreadyRegisteredException.java b/src/org/apache/kandula/faults/AlreadyRegisteredException.java
new file mode 100644
index 0000000..19e6858
--- /dev/null
+++ b/src/org/apache/kandula/faults/AlreadyRegisteredException.java
@@ -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
diff --git a/src/org/apache/kandula/faults/ContextRefusedException.java b/src/org/apache/kandula/faults/ContextRefusedException.java
new file mode 100644
index 0000000..6d6079b
--- /dev/null
+++ b/src/org/apache/kandula/faults/ContextRefusedException.java
@@ -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
diff --git a/src/org/apache/kandula/faults/InvalidParameterException.java b/src/org/apache/kandula/faults/InvalidParameterException.java
new file mode 100644
index 0000000..28fa137
--- /dev/null
+++ b/src/org/apache/kandula/faults/InvalidParameterException.java
@@ -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
diff --git a/src/org/apache/kandula/faults/InvalidProtocolException.java b/src/org/apache/kandula/faults/InvalidProtocolException.java
new file mode 100644
index 0000000..61c6ccf
--- /dev/null
+++ b/src/org/apache/kandula/faults/InvalidProtocolException.java
@@ -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.";
+ }
+}
diff --git a/src/org/apache/kandula/faults/InvalidStateException.java b/src/org/apache/kandula/faults/InvalidStateException.java
new file mode 100644
index 0000000..4fb0d07
--- /dev/null
+++ b/src/org/apache/kandula/faults/InvalidStateException.java
@@ -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
diff --git a/src/org/apache/kandula/faults/NoActivityException.java b/src/org/apache/kandula/faults/NoActivityException.java
new file mode 100644
index 0000000..26c2151
--- /dev/null
+++ b/src/org/apache/kandula/faults/NoActivityException.java
@@ -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
diff --git a/src/org/apache/kandula/initiator/ATInitiatorTransaction.java b/src/org/apache/kandula/initiator/ATInitiatorTransaction.java
new file mode 100644
index 0000000..c02857b
--- /dev/null
+++ b/src/org/apache/kandula/initiator/ATInitiatorTransaction.java
@@ -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
diff --git a/src/org/apache/kandula/initiator/TransactionManager.java b/src/org/apache/kandula/initiator/TransactionManager.java
index 6436b58..6d692cb 100644
--- a/src/org/apache/kandula/initiator/TransactionManager.java
+++ b/src/org/apache/kandula/initiator/TransactionManager.java
@@ -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;
}
diff --git a/src/org/apache/kandula/initiator/handler/TransactionOutHandler.java b/src/org/apache/kandula/initiator/TransactionOutHandler.java
similarity index 88%
rename from src/org/apache/kandula/initiator/handler/TransactionOutHandler.java
rename to src/org/apache/kandula/initiator/TransactionOutHandler.java
index 79c4727..878e9d6 100644
--- a/src/org/apache/kandula/initiator/handler/TransactionOutHandler.java
+++ b/src/org/apache/kandula/initiator/TransactionOutHandler.java
@@ -14,14 +14,14 @@
* limitations under the License.
*
*/
-package org.apache.kandula.initiator.handler;
+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.ActivityContext;
+import org.apache.kandula.context.AbstractContext;
import org.apache.kandula.context.coordination.CoordinationContext;
import org.apache.kandula.storage.StorageFactory;
@@ -32,8 +32,8 @@
public void invoke(MessageContext msgContext) throws AxisFault {
Object key = threadInfo.get();
if (null != key) {
- ActivityContext context = StorageFactory.getInstance().getStore()
- .getContext(key);
+ AbstractContext context = (AbstractContext)StorageFactory.getInstance().getStore()
+ .get(key);
if (context == null) {
throw new AxisFault("IllegalState");
}
diff --git a/src/org/apache/kandula/participant/simple/SimpleResource.java b/src/org/apache/kandula/participant/KandulaResource.java
similarity index 87%
rename from src/org/apache/kandula/participant/simple/SimpleResource.java
rename to src/org/apache/kandula/participant/KandulaResource.java
index 9ffc443..3d7bfc9 100644
--- a/src/org/apache/kandula/participant/simple/SimpleResource.java
+++ b/src/org/apache/kandula/participant/KandulaResource.java
@@ -14,13 +14,13 @@
* limitations under the License.
*
*/
-package org.apache.kandula.participant.simple;
+package org.apache.kandula.participant;
/**
* @author <a href="mailto:thilina@opensource.lk"> Thilina Gunarathne </a>
*/
-public interface SimpleResource {
+public interface KandulaResource {
public void commit();
public void rollback();
- public boolean prepare();
+ public Vote prepare();
}
diff --git a/src/org/apache/kandula/participant/ParticipantTransactionManager.java b/src/org/apache/kandula/participant/ParticipantTransactionManager.java
new file mode 100644
index 0000000..cdf174b
--- /dev/null
+++ b/src/org/apache/kandula/participant/ParticipantTransactionManager.java
@@ -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();
+ }
+ }
+}
diff --git a/src/org/apache/kandula/participant/Vote.java b/src/org/apache/kandula/participant/Vote.java
new file mode 100644
index 0000000..f0ef0d8
--- /dev/null
+++ b/src/org/apache/kandula/participant/Vote.java
@@ -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;
+ }
+}
diff --git a/src/org/apache/kandula/storage/Axis1Store.java b/src/org/apache/kandula/storage/Axis1Store.java
index 24852de..f4e00b8 100644
--- a/src/org/apache/kandula/storage/Axis1Store.java
+++ b/src/org/apache/kandula/storage/Axis1Store.java
@@ -16,7 +16,6 @@
*/
package org.apache.kandula.storage;
-import org.apache.kandula.context.ActivityContext;
/**
* @author <a href="mailto:thilina@opensource.lk"> Thilina Gunarathne </a>
@@ -26,7 +25,7 @@
/* (non-Javadoc)
* @see org.apache.kandula.storage.Store#putContext(java.lang.String, org.apache.kandula.context.coordination.CoordinationContext)
*/
- public void putContext(Object id, ActivityContext context) {
+ public void put(Object id, Object context) {
// TODO Auto-generated method stub
}
@@ -34,7 +33,7 @@
/* (non-Javadoc)
* @see org.apache.kandula.storage.Store#getContext(java.lang.String)
*/
- public ActivityContext getContext(Object id) {
+ public Object get(Object id) {
return null;
}
@@ -42,7 +41,7 @@
/* (non-Javadoc)
* @see org.apache.kandula.storage.Store#forgetContext(java.lang.String)
*/
- public void forgetContext(Object id) {
+ public void forget(Object id) {
// TODO Auto-generated method stub
}
diff --git a/src/org/apache/kandula/storage/Axis2Store.java b/src/org/apache/kandula/storage/Axis2Store.java
index 807cb37..b2b5fc1 100644
--- a/src/org/apache/kandula/storage/Axis2Store.java
+++ b/src/org/apache/kandula/storage/Axis2Store.java
@@ -16,7 +16,6 @@
*/
package org.apache.kandula.storage;
-import org.apache.kandula.context.ActivityContext;
/**
* @author <a href="mailto:thilina@opensource.lk"> Thilina Gunarathne </a>
@@ -26,7 +25,7 @@
/* (non-Javadoc)
* @see org.apache.kandula.storage.Store#putContext(java.lang.String, org.apache.kandula.context.coordination.CoordinationContext)
*/
- public void putContext(Object id, ActivityContext context) {
+ public void put(Object id, Object context) {
// TODO Auto-generated method stub
}
@@ -34,12 +33,12 @@
/* (non-Javadoc)
* @see org.apache.kandula.storage.Store#getContext(java.lang.String)
*/
- public ActivityContext getContext(Object id) {
+ public Object get(Object id) {
return null;
}
- public void forgetContext(Object id) {
+ public void forget(Object id) {
}
}
diff --git a/src/org/apache/kandula/storage/SimpleStore.java b/src/org/apache/kandula/storage/SimpleStore.java
index 0220f13..5041955 100644
--- a/src/org/apache/kandula/storage/SimpleStore.java
+++ b/src/org/apache/kandula/storage/SimpleStore.java
@@ -16,7 +16,7 @@
*/
package org.apache.kandula.storage;
-import org.apache.kandula.context.ActivityContext;
+import org.apache.kandula.context.AbstractContext;
import java.util.HashMap;
@@ -34,21 +34,21 @@
contextMap = new HashMap();
}
- public void putContext(Object id, ActivityContext context) {
+ public void put(Object id, Object context) {
contextMap.put(id, context);
}
/* (non-Javadoc)
* @see org.apache.kandula.storage.Store#getContext(java.lang.String)
*/
- public ActivityContext getContext(Object id) {
- return (ActivityContext) contextMap.get(id);
+ public Object get(Object id) {
+ return (AbstractContext) contextMap.get(id);
}
/* (non-Javadoc)
* @see org.apache.kandula.storage.Store#forgetContext(java.lang.String)
*/
- public void forgetContext(Object id) {
+ public void forget(Object id) {
contextMap.remove(id);
}
diff --git a/src/org/apache/kandula/storage/Store.java b/src/org/apache/kandula/storage/Store.java
index 95b3d5e..8aa029b 100644
--- a/src/org/apache/kandula/storage/Store.java
+++ b/src/org/apache/kandula/storage/Store.java
@@ -16,15 +16,14 @@
*/
package org.apache.kandula.storage;
-import org.apache.kandula.context.ActivityContext;
/**
* @author <a href="mailto:thilina@opensource.lk"> Thilina Gunarathne </a>
*/
public interface Store {
- void putContext(Object id, ActivityContext context);
+ void put(Object id, Object context);
- ActivityContext getContext(Object id);
+ Object get(Object id);
- void forgetContext(Object id);
+ void forget(Object id);
}
diff --git a/src/org/apache/kandula/typemapping/xmlbeansimpl/XmlBeansTypeCoordinationContext.java b/src/org/apache/kandula/typemapping/xmlbeansimpl/XmlBeansTypeCoordinationContext.java
deleted file mode 100644
index 47c173b..0000000
--- a/src/org/apache/kandula/typemapping/xmlbeansimpl/XmlBeansTypeCoordinationContext.java
+++ /dev/null
@@ -1,99 +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.typemapping.xmlbeansimpl;
-
-import org.apache.axis2.addressing.EndpointReference;
-import org.apache.axis2.om.OMElement;
-import org.apache.kandula.context.coordination.CoordinationContext;
-import org.apache.kandula.typemapping.EndPointReference;
-import org.xmlsoap.schemas.ws.x2002.x07.utility.AttributedDateTime;
-import org.xmlsoap.schemas.ws.x2002.x07.utility.AttributedURI;
-import org.xmlsoap.schemas.ws.x2003.x09.wscoor.CoordinationContextType;
-import org.xmlsoap.schemas.ws.x2004.x03.addressing.EndpointReferenceType;
-
-/**
- * @author <a href="mailto:thilina@opensource.lk"> Thilina Gunarathne </a>
- */
-public class XmlBeansTypeCoordinationContext implements CoordinationContext {
- private CoordinationContextType contextType;
-
- public XmlBeansTypeCoordinationContext() {
- super();
- EndpointReferenceType epr = EndpointReferenceType.Factory.newInstance();
- contextType = CoordinationContextType.Factory.newInstance();
- }
-
- /**
- * @param contextType
- */
- public XmlBeansTypeCoordinationContext(Object contextType) {
- super();
- this.contextType = (CoordinationContextType) contextType;
- }
-
- public String getActivityID() {
- return contextType.getIdentifier().getId();
- }
-
- public String getCoordinationType() {
- return contextType.getCoordinationType();
- }
-
- public EndpointReference getRegistrationService() {
- return null;//contextType.getRegistrationService().
- }
-
- public long getExpires() {
- return Long.parseLong(contextType.getExpires().getId());
- }
-
- public void setActivityID(String value) {
- AttributedURI uri = AttributedURI.Factory.newInstance();
- uri.setId(value);
- contextType.setIdentifier(uri);
-
- }
-
- public void setCoordinationType(String value) {
- contextType.setCoordinationType(value);
-
- }
-
- public void setRegistrationService(EndpointReference value) {
- // contextType.setRegistrationService((EndpointReferenceType)value.getEndPointReferenceType());
-
- }
-
- public void setExpires(long value) {
- AttributedDateTime dateTime = AttributedDateTime.Factory.newInstance();
- dateTime.setId(new Long(value).toString());
- contextType.setExpires(dateTime);
- }
-
- public Object getCoordinationContextType() {
- return contextType;
- }
-
- /* (non-Javadoc)
- * @see org.apache.kandula.context.coordination.CoordinationContext#toOM()
- */
- public OMElement toOM() {
- // TODO Auto-generated method stub
- return null;
- }
-
-}
diff --git a/src/org/apache/kandula/typemapping/xmlbeansimpl/XmlBeansTypeEndPointReference.java b/src/org/apache/kandula/typemapping/xmlbeansimpl/XmlBeansTypeEndPointReference.java
deleted file mode 100644
index 4b100ba..0000000
--- a/src/org/apache/kandula/typemapping/xmlbeansimpl/XmlBeansTypeEndPointReference.java
+++ /dev/null
@@ -1,53 +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.typemapping.xmlbeansimpl;
-
-import org.apache.kandula.typemapping.EndPointReference;
-import org.xmlsoap.schemas.ws.x2004.x03.addressing.EndpointReferenceType;
-
-/**
- * @author <a href="mailto:thilina@opensource.lk"> Thilina Gunarathne </a>
- */
-public class XmlBeansTypeEndPointReference implements EndPointReference {
-
- EndpointReferenceType eprType;
-
- /**
- *
- */
- public XmlBeansTypeEndPointReference() {
- super();
- eprType = EndpointReferenceType.Factory.newInstance();
- }
-
- /**
- * @param eprType
- */
- public XmlBeansTypeEndPointReference(Object eprType) {
- super();
- this.eprType = (EndpointReferenceType) eprType;
- }
-
- public Object getEndPointReferenceType() {
- return eprType;
- }
-
- public String getPortTypeLocalPart() {
- return eprType.getPortType().getQNameValue().getLocalPart();
- }
-
-}
diff --git a/src/org/apache/kandula/utility/KandulaListener.java b/src/org/apache/kandula/utility/KandulaListener.java
index ac4a1a9..9258aa5 100644
--- a/src/org/apache/kandula/utility/KandulaListener.java
+++ b/src/org/apache/kandula/utility/KandulaListener.java
@@ -107,7 +107,7 @@
}
public String getHost() throws UnknownHostException {
- return "http://" + InetAddress.getLocalHost().getHostAddress() + ":" + SERVER_PORT
+ return "http://" + InetAddress.getLocalHost().getHostAddress() + ":" + 5060
+ "/axis2/services/";
}
}
\ No newline at end of file
diff --git a/src/org/apache/kandula/wscoor/ActivationPortTypeRawXMLSkeleton.java b/src/org/apache/kandula/wscoor/ActivationPortTypeRawXMLSkeleton.java
index 931987d..726ef46 100644
--- a/src/org/apache/kandula/wscoor/ActivationPortTypeRawXMLSkeleton.java
+++ b/src/org/apache/kandula/wscoor/ActivationPortTypeRawXMLSkeleton.java
@@ -1,12 +1,13 @@
package org.apache.kandula.wscoor;
-import org.apache.axis2.om.OMElement;
-import org.apache.kandula.KandulaException;
-import org.apache.kandula.context.ActivityContext;
-import org.apache.kandula.coordinator.Coordinator;
-
import javax.xml.namespace.QName;
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.om.OMElement;
+import org.apache.kandula.context.AbstractContext;
+import org.apache.kandula.coordinator.Coordinator;
+import org.apache.kandula.faults.AbstractKandulaException;
+
/**
* Auto generated java skeleton for the service by the Axis code generator
*/
@@ -15,26 +16,21 @@
/**
* Auto generated method signature
- *
+ *
* @param requestElement
- * @throws KandulaException
+ * @throws AbstractKandulaException
*/
- public OMElement CreateCoordinationContextOperation(
- OMElement requestElement)
- throws KandulaException {
- ActivityContext context;
- Coordinator coordinator = new Coordinator();
+ public OMElement CreateCoordinationContextOperation(OMElement requestElement)
+ throws AxisFault {
+ AbstractContext context;
-// ActivityContext context;
-// Coordinator coordinator = new Coordinator();
-// if (requestDoc.getCreateCoordinationContext().getCurrentContext() != null) {
-// CoordinationContext coorContext = CoordinationContext.Factory.newInstance(requestDoc
-// .getCreateCoordinationContext().getCurrentContext());
-// context = coordinator.createCoordinationContext(coorContext);
-// }else
-// {
- String coordinationType = requestElement.getFirstChildWithName(new QName("CoordinationType")).getText();
- OMElement expiresElement = requestElement.getFirstChildWithName(new QName("Expires"));
+ /*
+ * 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) {
@@ -43,38 +39,20 @@
expiresL = Long.parseLong(expires);
}
}
- context = coordinator.createCoordinationContext(coordinationType, expiresL);
- return context.getCoordinationContext().toOM();
- // context(coordinationType, expiresL);
- // }
-// CreateCoordinationContextResponseDocument responseDoc = CreateCoordinationContextResponseDocument.Factory
-// .newInstance();
-// CreateCoordinationContextResponseType responseType = CreateCoordinationContextResponseType.Factory
-// .newInstance();
-// responseType.setCoordinationContext((CoordinationContextType)context.getCoordinationContext().getCoordinationContextType());
-// responseDoc.setCreateCoordinationContextResponse(responseType);
- // return new OMElementImpl("Thilina",new OMNamespaceImpl("pre","http://www.thilina.org"));
-
-// if (requestDoc.getCreateCoordinationContext().getCurrentContext() != null) {
-// CoordinationContext coorContext = CoordinationContext.Factory.newInstance(requestDoc
-// .getCreateCoordinationContext().getCurrentContext());
-// context = coordinator.createCoordinationContext(coorContext);
-// }else
-// {
-// context = coordinator.createCoordinationContext(requestDoc
-// .getCreateCoordinationContext().getCoordinationType(), Long
-// .parseLong(requestDoc.getCreateCoordinationContext()
-// .getExpires().getId()));
-// }
-// CreateCoordinationContextResponseDocument responseDoc = CreateCoordinationContextResponseDocument.Factory
-// .newInstance();
-// CreateCoordinationContextResponseType responseType = CreateCoordinationContextResponseType.Factory
-// .newInstance();
-// responseType.setCoordinationContext((CoordinationContextType)context.getCoordinationContext().getCoordinationContextType());
-// responseDoc.setCreateCoordinationContextResponse(responseType);
-// return responseDoc;
-
+ /*
+ * 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;
+ }
}
diff --git a/src/org/apache/kandula/wscoor/ActivationRequesterPortTypeRawXMLSkeleton.java b/src/org/apache/kandula/wscoor/ActivationRequesterPortTypeRawXMLSkeleton.java
index 2e74089..4049e83 100644
--- a/src/org/apache/kandula/wscoor/ActivationRequesterPortTypeRawXMLSkeleton.java
+++ b/src/org/apache/kandula/wscoor/ActivationRequesterPortTypeRawXMLSkeleton.java
@@ -2,7 +2,7 @@
import org.apache.axis2.context.MessageContext;
import org.apache.axis2.om.OMElement;
-import org.apache.kandula.context.ActivityContext;
+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;
@@ -37,12 +37,10 @@
}
public OMElement CreateCoordinationContextOperation(OMElement requestElement) {
-// OMElement coordinationContextElement = requestElement
-// .getFirstChildWithName(new QName("CoordinationContext"));
if ("CoordinationContext".equals(requestElement.getLocalName())) {
msgContext.getMessageInformationHeaders().getReferenceParameters();
- CoordinationContext coordinationContext = CoordinationContext.Factory.newInstance(requestElement);
- ActivityContext context = StorageFactory.getInstance().getStore().getContext(TransactionManager.tempID);
+ CoordinationContext coordinationContext = CoordinationContext.Factory.newContext(requestElement);
+ AbstractContext context = (AbstractContext)StorageFactory.getInstance().getStore().get(TransactionManager.tempID);
context.setCoordinationContext(coordinationContext);
}
return null;
diff --git a/src/org/apache/kandula/wscoor/RegistrationPortTypeRawXMLAsyncMessageReceiver.java b/src/org/apache/kandula/wscoor/RegistrationPortTypeRawXMLAsyncMessageReceiver.java
new file mode 100644
index 0000000..78903d5
--- /dev/null
+++ b/src/org/apache/kandula/wscoor/RegistrationPortTypeRawXMLAsyncMessageReceiver.java
@@ -0,0 +1,77 @@
+/*
+ * Copyright 2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+package org.apache.kandula.wscoor;
+
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.engine.DependencyManager;
+import org.apache.axis2.om.OMElement;
+
+/**
+ * @author <a href="mailto:thilina@opensource.lk"> Thilina Gunarathne </a>
+ */
+public class RegistrationPortTypeRawXMLAsyncMessageReceiver extends
+ org.apache.axis2.receivers.AbstractInOutSyncMessageReceiver {
+
+ public void invokeBusinessLogic(
+ org.apache.axis2.context.MessageContext msgContext,
+ 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);
+
+ RegistrationPortTypeRawXMLSkeleton skel = (RegistrationPortTypeRawXMLSkeleton) obj;
+ //Out Envelop
+ org.apache.axis2.soap.SOAPEnvelope envelope = null;
+ //Find the operation that has been set by the Dispatch phase.
+ org.apache.axis2.description.OperationDescription op = msgContext
+ .getOperationContext().getAxisOperation();
+
+ String methodName;
+ if (op.getName() != null
+ & (methodName = op.getName().getLocalPart()) != null) {
+ if (methodName.equals("RegisterOperation")) {
+ OMElement response = null;
+
+ //doc style
+ response = skel
+ .RegisterOperation((org.apache.axis2.om.OMElement) msgContext
+ .getEnvelope().getBody().getFirstChild()
+ .detach());
+
+ //Create a default envelop
+ envelope = getSOAPFactory().getDefaultEnvelope();
+ //Create a Omelement of the result if a result exist
+
+ envelope.getBody().setFirstChild(response);
+ }
+ newMsgContext.setEnvelope(envelope);
+ newMsgContext.setSoapAction("RegisterOperation");
+ // callback.handleResult(newMsgContext);
+ }
+ } catch (Exception e) {
+ throw AxisFault.makeFault(e);
+ }
+
+ }
+
+}
\ No newline at end of file
diff --git a/src/org/apache/kandula/wscoor/RegistrationPortTypeRawXMLSkeleton.java b/src/org/apache/kandula/wscoor/RegistrationPortTypeRawXMLSkeleton.java
index bc78b84..d0592b8 100644
--- a/src/org/apache/kandula/wscoor/RegistrationPortTypeRawXMLSkeleton.java
+++ b/src/org/apache/kandula/wscoor/RegistrationPortTypeRawXMLSkeleton.java
@@ -16,6 +16,12 @@
*/
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;
@@ -23,14 +29,10 @@
import org.apache.axis2.om.OMElement;
import org.apache.axis2.om.OMNamespace;
import org.apache.axis2.soap.SOAPFactory;
-import org.apache.kandula.KandulaException;
import org.apache.kandula.coordinator.Coordinator;
+import org.apache.kandula.faults.AbstractKandulaException;
import org.apache.kandula.utility.KandulaUtils;
-import javax.xml.namespace.QName;
-import java.util.ArrayList;
-import java.util.Iterator;
-
/**
* @author <a href="mailto:thilina@apache.org"> Thilina Gunarathne </a>
*/
@@ -43,15 +45,22 @@
}
public OMElement RegisterOperation(OMElement request)
- throws KandulaException {
+ throws AxisFault {
- String protocolIdentifier = request.getFirstChildWithName(
+ String protocolIdentifier;
+ EndpointReference participantEPR;
+ String activityId;
+
+ /*
+ * Extracting data from the received message
+ */
+ protocolIdentifier = request.getFirstChildWithName(
new QName("ProtocolIdentifier")).getText();
OMElement participantEPRElement = request
.getFirstChildWithName(new QName("ParticipantProtocolService"));
- EndpointReference participantEPR = new EndpointReference(
- participantEPRElement.getFirstChildWithName(
- new QName("Address")).getText());
+ //Extracting the participant EPR
+ participantEPR = new EndpointReference(participantEPRElement
+ .getFirstChildWithName(new QName("Address")).getText());
AnyContentType referenceProperties = new AnyContentType();
OMElement referencePropertiesElement = participantEPRElement
.getFirstChildWithName(new QName("ReferenceProperties"));
@@ -66,14 +75,27 @@
//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
+ activityId = Coordinator.ACTIVITY_ID;
+ /*
+ * Registering the participant for the activity for the given protocol
+ */
+ try{
Coordinator coordinator = new Coordinator();
- EndpointReference epr = coordinator.registerParticipant(
- Coordinator.ACTIVITY_ID, protocolIdentifier, participantEPR);
- System.out.println("visited registration skeleton");
+ EndpointReference epr = coordinator.registerParticipant(activityId,
+ protocolIdentifier, participantEPR);
return toOM(epr);
+ } catch (AbstractKandulaException e) {
+ AxisFault fault = new AxisFault(e);
+ fault.setFaultCode(e.getFaultCode());
+ throw fault;
+ }
}
+ /**
+ * Serializes an EndpointRefrence to OM Nodes
+ */
private OMElement toOM(EndpointReference epr) {
SOAPFactory factory = OMAbstractFactory.getSOAP12Factory();
OMNamespace wsCoor = factory.createOMNamespace(
diff --git a/test-resources/testing-repository/services/RegistrationCoordinator.jar b/test-resources/testing-repository/services/RegistrationCoordinator.jar
index 5a412e7..625edd2 100644
--- a/test-resources/testing-repository/services/RegistrationCoordinator.jar
+++ b/test-resources/testing-repository/services/RegistrationCoordinator.jar
Binary files differ
diff --git a/test/org/apache/kandula/coordinator/CoordinatorImplTest.java b/test/org/apache/kandula/coordinator/CoordinatorImplTest.java
index 837c80b..ab992a9 100644
--- a/test/org/apache/kandula/coordinator/CoordinatorImplTest.java
+++ b/test/org/apache/kandula/coordinator/CoordinatorImplTest.java
@@ -17,12 +17,14 @@
package org.apache.kandula.coordinator;
import junit.framework.TestCase;
+
+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.coordination.CoordinationContext;
+import org.apache.kandula.context.AbstractContext;
import org.apache.kandula.context.at.ATActivityContext;
+import org.apache.kandula.context.coordination.CoordinationContext;
+import org.apache.kandula.faults.AbstractKandulaException;
/**
* @author <a href="mailto:thilina@opensource.lk"> Thilina Gunarathne </a>
@@ -46,9 +48,9 @@
/*
* Class under test for ActivityContext createCoordinationContext(String, long)
*/
- public void testCreateCoordinationContextStringlong() throws KandulaException {
+ public void testCreateCoordinationContextStringlong() throws AbstractKandulaException {
Coordinator coordinator = new Coordinator();
- ActivityContext 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);
@@ -57,14 +59,12 @@
/*
* Class under test for ActivityContext createCoordinationContext(CoordinationContext)
*/
- public void testCreateCoordinationContextCoordinationContext() throws KandulaException {
+ public void testCreateCoordinationContextCoordinationContext() throws AbstractKandulaException {
Coordinator coordinator = new Coordinator();
- CoordinationContext coorContext = CoordinationContext.Factory.newInstance();
- coorContext.setCoordinationType(Constants.WS_AT);
+ CoordinationContext coorContext = CoordinationContext.Factory.newContext("uuid:29919219jdk02102021",Constants.WS_AT,new EndpointReference(""));
coorContext.setExpires(3000);
- coorContext.setActivityID("uuid:29919219jdk02102021");
// coorContext.setRegistrationService()
- ActivityContext context = coordinator.createCoordinationContext(coorContext);
+ AbstractContext context = coordinator.createCoordinationContext(coorContext);
assertTrue(ATActivityContext.class.isInstance(context));
assertNotNull(context.getCoordinationContext());
assertTrue(context.getStatus() == Status.CoordinatorStatus.STATUS_ACTIVE);
diff --git a/test/org/apache/kandula/integration/CreateCoordinationContextTest.java b/test/org/apache/kandula/integration/CreateCoordinationContextTest.java
index 688a90c..b4595be 100644
--- a/test/org/apache/kandula/integration/CreateCoordinationContextTest.java
+++ b/test/org/apache/kandula/integration/CreateCoordinationContextTest.java
@@ -85,7 +85,7 @@
public void testEchoXMLSync() throws Exception {
- TransactionManager tm = new TransactionManager(Constants.WS_AT, new EndpointReference("http://localhost:8081/axis/services/ActivationCoordinator"));
+ TransactionManager tm = new TransactionManager(Constants.WS_AT, new EndpointReference("http://localhost:8082/axis/services/ActivationCoordinator"));
//Thread.sleep(100000);
tm.begin();
}