Commiting the initial WS-BA implementation for Kandula2...
Some contributions in this commit are from Bimalee, Thimali & Nisansala
git-svn-id: https://svn.apache.org/repos/asf/webservices/kandula/trunk/java@507487 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/src/org/apache/kandula/Constants.java b/src/org/apache/kandula/Constants.java
index 50b57ff..c9c736b 100644
--- a/src/org/apache/kandula/Constants.java
+++ b/src/org/apache/kandula/Constants.java
@@ -18,96 +18,106 @@
import javax.xml.namespace.QName;
-public interface Constants {
+public class Constants {
// WS-Coordination URI's
- static final String WS_COOR = "http://docs.oasis-open.org/ws-tx/wscoor/2006/06";
+ public static final String WS_COOR = "http://docs.oasis-open.org/ws-tx/wscoor/2006/06";
- static final String WS_COOR_CREATE_COORDINATIONCONTEXT = WS_COOR+ "/CreateCoordinationContext";
+ public static final String WS_COOR_CREATE_COORDINATIONCONTEXT = WS_COOR+ "/CreateCoordinationContext";
- static final String WS_COOR_CREATE_COORDINATIONCONTEXT_RESPONSE = WS_COOR+ "/CreateCoordinationContextResponse";
+ public static final String WS_COOR_CREATE_COORDINATIONCONTEXT_RESPONSE = WS_COOR+ "/CreateCoordinationContextResponse";
- static final String WS_COOR_REGISTER = WS_COOR+ "/Register";
+ public static final String WS_COOR_REGISTER = WS_COOR+ "/Register";
- static final String WS_COOR_REGISTER_RESPONSE = WS_COOR+ "/RegisterResponse";
+ public static final String WS_COOR_REGISTER_RESPONSE = WS_COOR+ "/RegisterResponse";
// WS-AT URI's
- static final String WS_AT = "http://docs.oasis-open.org/ws-tx/wsat/2006/03";
+ public static final String WS_AT = "http://docs.oasis-open.org/ws-tx/wsat/2006/03";
- static final String WS_AT_COMPLETION = WS_AT+ "/Completion";
+ public static final String WS_AT_COMPLETION = WS_AT+ "/Completion";
- static final String WS_AT_COMMIT = WS_AT+ "/Commit";
+ public static final String WS_AT_COMMIT = WS_AT+ "/Commit";
- static final String WS_AT_COMMITTED = WS_AT+ "/Committed";
+ public static final String WS_AT_COMMITTED = WS_AT+ "/Committed";
- static final String WS_AT_ROLLBACK = WS_AT+ "/Rollback";
+ public static final String WS_AT_ROLLBACK = WS_AT+ "/Rollback";
- static final String WS_AT_ABORTED = WS_AT+ "/Aborted";
+ public static final String WS_AT_ABORTED = WS_AT+ "/Aborted";
- static final String WS_AT_DURABLE2PC = WS_AT+ "/Durable2PC";
+ public static final String WS_AT_DURABLE2PC = WS_AT+ "/Durable2PC";
- static final String WS_AT_VOLATILE2PC = WS_AT+ "/Volatile2PC";
+ public static final String WS_AT_VOLATILE2PC = WS_AT+ "/Volatile2PC";
- static final String WS_AT_PREPARE = WS_AT+ "/Prepare";
+ public static final String WS_AT_PREPARE = WS_AT+ "/Prepare";
- static final String WS_AT_PREPARED = WS_AT+ "/Prepared";
+ public static final String WS_AT_PREPARED = WS_AT+ "/Prepared";
- static final String WS_AT_REPLAY = WS_AT+ "/Replay";
+ public static final String WS_AT_REPLAY = WS_AT+ "/Replay";
- static final String WS_AT_READONLY = WS_AT+ "/ReadOnly";
+ public static final String WS_AT_READONLY = WS_AT+ "/ReadOnly";
- static final String SUB_VOLATILE_REGISTERED = "registered for volatile 2PC";
+ public static final String SUB_VOLATILE_REGISTERED = "registered for volatile 2PC";
- static final String SUB_DURABLE_REGISTERED = "registered for durable 2PC";
+ public static final String SUB_DURABLE_REGISTERED = "registered for durable 2PC";
// WS-BA URI's
- static final String WS_BA = "http://docs.oasis-open.org/ws-tx/wsba/2006/03";
+ public static final String WS_BA = "http://docs.oasis-open.org/ws-tx/wsba/2006/03";
- static final String WS_BA_ATOMIC = WS_BA+ "/AtomicOutcome";
+ public static final String WS_BA_ATOMIC = WS_BA+ "/AtomicOutcome";
- static final String WS_BA_MIXED = WS_BA+"/MixedOutcome";
+ public static final String WS_BA_MIXED = WS_BA+"/MixedOutcome";
//bims
- static final String WS_BA_PC = WS_BA+ "/ParticipantCompletion";
+ public static final String WS_BA_PC = WS_BA+ "/ParticipantCompletion";
- static final String WS_BA_CC = WS_BA+ "/CoordinatorCompletion";
+ public static final String WS_BA_CC = WS_BA+ "/CoordinatorCompletion";
// Kandula Specific
- // Constants----------------------------------------------------------------------------------------------------
- static String TRANSACTION_CONTEXT = "TransactionContext";
+ // Constants-------------------------------------------------------------
- static String KANDULA_URI = "http://ws.apache.org/kandula";
+ public static final String KANDULA_URI = "http://ws.apache.org/kandula";
- static String KANDULA_RESOURCE = "KandulaResource";
+ public static final String KANDULA_RESOURCE = "KandulaResource";
- static String KANDULA_PRE = "kand";
+ public static final String KANDULA_PRE = "kand";
- static String KANDULA_STORE = "KandulaStore";
+ public static final String KANDULA_STORE = "KandulaStore";
// For the coordinator to identify seperate distributed
// activities(transactions)
// Common to all the parties participating in a single distributed tx.
- static final QName TRANSACTION_ID_PARAMETER = new QName(KANDULA_URI,
+ public static final QName TRANSACTION_ID_PARAMETER = new QName(KANDULA_URI,
"TransactionID", KANDULA_PRE);
// Used by the Initiator Transaction Manager & participant TM to track the
// seperate transactions
- static final QName REQUESTER_ID_PARAMETER = new QName(KANDULA_URI,
+ public static final QName REQUESTER_ID_PARAMETER = new QName(KANDULA_URI,
"RequesterID", KANDULA_PRE);
+
+ public static final QName PARTICIPANT_ID_PARAMETER = new QName(KANDULA_URI,
+ Configuration.PARTICIPANT_IDENTIFIER, KANDULA_PRE);
+
// For the coordinator to identify each and every registered participant
// whithing a transaction
// This + Tx_ID will be unique for a participant
- static final QName ENLISTMENT_ID_PARAMETER = new QName(KANDULA_URI,
+ public static final QName ENLISTMENT_ID_PARAMETER = new QName(KANDULA_URI,
"EnlistmentID", KANDULA_PRE);
//bims
//For the coordinator to identify seperate business
// activities
// Common to all the parties participating in a single distributed tx.
- static final QName BA_ID_PARAMETER = new QName(KANDULA_URI,
+ public static final QName BA_ID_PARAMETER = new QName(KANDULA_URI,
"BusinessActivityID", KANDULA_PRE);
+
+ public static interface Configuration {
+
+ public static final String TRANSACTION_CONTEXT = "TransactionContext";
+
+ public static final String PARTICIPANT_IDENTIFIER = "ParticipantID";
+ }
}
diff --git a/src/org/apache/kandula/Status.java b/src/org/apache/kandula/Status.java
index eaf7abf..66ce9d0 100644
--- a/src/org/apache/kandula/Status.java
+++ b/src/org/apache/kandula/Status.java
@@ -16,8 +16,8 @@
*/
package org.apache.kandula;
-public abstract interface Status {
- interface CoordinatorStatus {
+public class Status {
+ public static interface CoordinatorStatus {
static final int STATUS_ABORTING = 9;
@@ -42,7 +42,7 @@
}
// TODO remove the inner interfaces..
- interface ParticipantStatus {
+ public static interface ParticipantStatus {
static final int STATUS_ABORTED = 22;
@@ -55,13 +55,13 @@
static final int STATUS_VOLATILE_PREPARING = 20;
}
- interface BACoordinatorStatus {
+ public static interface BACoordinatorStatus {
static final int STATUS_CLOSING = 30;
static final int STATUS_COMPENSATING = 31;
- static final int STATUS_ACTIVE = 32;
+ static final int STATUS_ACTIVE = 0;
static final int STATUS_CANCELLING = 33;
@@ -81,18 +81,20 @@
static final int STATUS_COMPLETING = 41;
- static final int STATUS_CANCELING_COMPLETING = 42;
+ static final int STATUS_CANCELLING_COMPLETING = 42;
static final int STATUS_FAULTING_COMPLETED = 43;
+
+ static final int STATUS_FAULTING_COMPLETING = 44;
}
- interface BAParticipantStatus {
+ public static interface BAParticipantStatus {
- static final int STATUS_CLOSING = 44;
+ static final int STATUS_CLOSING = 45;
- static final int STATUS_COMPENSATING = 45;
+ static final int STATUS_COMPENSATING = 46;
- static final int STATUS_ACTIVE = 46;
+ static final int STATUS_ACTIVE = 0;
static final int STATUS_CANCELLING = 47;
@@ -100,7 +102,9 @@
static final int STATUS_FAULTING_COMPENSATING = 49;
- static final int STATUS_FAULTING_ACTIVE_COMPLETED = 50;
+ static final int STATUS_FAULTING_ACTIVE = 150;
+
+ static final int STATUS_FAULTING_COMPLETED = 151;
static final int STATUS_EXITING = 51;
@@ -111,5 +115,8 @@
static final int STATUS_COMPLETING = 55;
static final int STATUS_FAULTING = 56;
+
+ // Additional state to use within Kandula
+ static final int STATUS_WORK_DONE = 100;
}
}
diff --git a/src/org/apache/kandula/ba/AtomicBusinessActivity.java b/src/org/apache/kandula/ba/AtomicBusinessActivity.java
new file mode 100644
index 0000000..a5b0c21
--- /dev/null
+++ b/src/org/apache/kandula/ba/AtomicBusinessActivity.java
@@ -0,0 +1,29 @@
+package org.apache.kandula.ba;
+
+
+import org.apache.kandula.Constants;
+import org.apache.kandula.context.impl.BAActivityContext;
+import org.apache.kandula.coordinator.Coordinator;
+import org.apache.kandula.coordinator.ba.BACoordinator;
+import org.apache.kandula.faults.AbstractKandulaException;
+
+public class AtomicBusinessActivity extends BusinessActivity{
+
+ public AtomicBusinessActivity(long expires ) throws AbstractKandulaException {
+ Coordinator coordinator = new Coordinator();
+ context = (BAActivityContext)coordinator.createCoordinationContext(Constants.WS_BA_ATOMIC,
+ expires);
+ }
+
+ public void closeActivity() throws AbstractKandulaException
+ {
+ BACoordinator atomicBACoordinator = new BACoordinator();
+ atomicBACoordinator.closeAllOperation(context);
+ }
+
+ public void compensateActivity() throws AbstractKandulaException
+ {
+ BACoordinator atomicBACoordinator = new BACoordinator();
+ atomicBACoordinator.compensateAllOperation(context);
+ }
+}
diff --git a/src/org/apache/kandula/ba/BusinessActivity.java b/src/org/apache/kandula/ba/BusinessActivity.java
new file mode 100644
index 0000000..7b67f04
--- /dev/null
+++ b/src/org/apache/kandula/ba/BusinessActivity.java
@@ -0,0 +1,79 @@
+package org.apache.kandula.ba;
+
+import java.util.Iterator;
+
+import org.apache.kandula.Status;
+import org.apache.kandula.context.impl.BAActivityContext;
+import org.apache.kandula.coordinator.ba.BACoordinator;
+import org.apache.kandula.coordinator.ba.BAParticipantInformation;
+import org.apache.kandula.faults.AbstractKandulaException;
+import org.apache.kandula.faults.KandulaGeneralException;
+
+public class BusinessActivity {
+
+ protected BAActivityContext context;
+
+ public void complete() throws AbstractKandulaException {
+ BACoordinator coordinator = new BACoordinator();
+ coordinator.completeOperation(context);
+ while (context.getStatus()!=Status.BACoordinatorStatus.STATUS_ENDED){
+ try {
+ Thread.sleep(10);
+ } catch (InterruptedException e) {
+ throw new KandulaGeneralException(e);
+ }
+ }
+ }
+
+ public void cancelParticipant(String participantID) throws AbstractKandulaException {
+ BAParticipantInformation participantInformation;
+ participantInformation = context.getParticipant(participantID);
+ if (participantInformation==null)
+ {
+ //participant registration might be still on the wire.. So let's wait an retry..
+ try {
+ Thread.sleep(200);
+ } catch (InterruptedException e) {
+ throw new KandulaGeneralException(e);
+ }
+ participantInformation = context.getParticipant(participantID);
+ if (participantInformation==null)
+ {
+ throw new KandulaGeneralException("No registered participant found by the ID :"+participantID);
+ }
+ }
+ BACoordinator coordinator = new BACoordinator();
+ coordinator.cancelOperation(context,participantInformation);
+ }
+
+ public BAActivityContext getContext() {
+ return (BAActivityContext)context;
+ }
+
+ public BusinessActivityCallBack getCallBack() {
+ return context.getCallBack();
+ }
+
+ public void setCallBack(BusinessActivityCallBack callBack) {
+ callBack.setBusinessActivity(this);
+ this.context.setCallBack(callBack);
+ }
+
+ public int getStatus() {
+ return context.getStatus();
+ }
+
+ public Iterator getAllParticipants() {
+ return context.getAllParticipants();
+ }
+
+ public BAParticipantInformation getParticipant(String participantID) {
+
+ return context.getParticipant(participantID);
+ }
+
+ public void addParticipantActivity(AtomicBusinessActivity businessActivity) {
+ //TODO
+ }
+
+}
diff --git a/src/org/apache/kandula/ba/BusinessActivityCallBack.java b/src/org/apache/kandula/ba/BusinessActivityCallBack.java
new file mode 100644
index 0000000..e4696e5
--- /dev/null
+++ b/src/org/apache/kandula/ba/BusinessActivityCallBack.java
@@ -0,0 +1,14 @@
+package org.apache.kandula.ba;
+
+import org.apache.kandula.context.impl.BAActivityContext;
+
+public abstract class BusinessActivityCallBack {
+
+ protected BusinessActivity businessActivity;
+
+ public abstract void onComplete();
+
+ protected void setBusinessActivity(BusinessActivity businessActivity){
+ this.businessActivity = businessActivity;
+ }
+}
diff --git a/src/org/apache/kandula/ba/MixedBusinessActivity.java b/src/org/apache/kandula/ba/MixedBusinessActivity.java
new file mode 100644
index 0000000..d6c70d8
--- /dev/null
+++ b/src/org/apache/kandula/ba/MixedBusinessActivity.java
@@ -0,0 +1,54 @@
+package org.apache.kandula.ba;
+
+import java.util.ArrayList;
+
+import org.apache.kandula.Constants;
+import org.apache.kandula.context.impl.BAActivityContext;
+import org.apache.kandula.coordinator.Coordinator;
+import org.apache.kandula.coordinator.ba.BACoordinator;
+import org.apache.kandula.coordinator.ba.BAParticipantInformation;
+import org.apache.kandula.faults.AbstractKandulaException;
+
+public class MixedBusinessActivity extends BusinessActivity {
+
+ private ArrayList closeParticipantsList;
+
+ private ArrayList compensateParticipantsList;
+
+ public MixedBusinessActivity(long expires ) throws AbstractKandulaException {
+ closeParticipantsList = new ArrayList();
+ compensateParticipantsList = new ArrayList();
+ Coordinator coordinator = new Coordinator();
+ context = (BAActivityContext)coordinator.createCoordinationContext(Constants.WS_BA_ATOMIC,
+ expires);
+ }
+
+ public void addParticipantToCloseList(BAParticipantInformation participantInformation)
+ {
+ closeParticipantsList.add(participantInformation);
+ }
+
+ public void addParticipantToCompensateList(BAParticipantInformation participantInformation)
+ {
+ if (participantInformation!=null)
+ compensateParticipantsList.add(participantInformation);
+ }
+
+ public void addParticipantToCloseList(String participantID)
+ {
+ BAParticipantInformation participantInformation = context.getParticipant(participantID);
+ closeParticipantsList.add(participantInformation);
+ }
+
+ public void addParticipantToCompensateList(String participantID)
+ {
+ BAParticipantInformation participantInformation = context.getParticipant(participantID);
+ compensateParticipantsList.add(participantInformation);
+ }
+
+ public void finalizeActivity() throws AbstractKandulaException
+ {
+ BACoordinator coordinator = new BACoordinator();
+ coordinator.finalizeMixedOutcomeActivity(context,closeParticipantsList,compensateParticipantsList);
+ }
+}
diff --git a/src/org/apache/kandula/context/ContextFactory.java b/src/org/apache/kandula/context/ContextFactory.java
index b7f367b..8847c01 100644
--- a/src/org/apache/kandula/context/ContextFactory.java
+++ b/src/org/apache/kandula/context/ContextFactory.java
@@ -16,7 +16,9 @@
*/
package org.apache.kandula.context;
+import org.apache.kandula.Constants;
import org.apache.kandula.context.impl.ATActivityContext;
+import org.apache.kandula.context.impl.BAActivityContext;
import org.apache.kandula.faults.InvalidProtocolException;
public class ContextFactory {
@@ -31,10 +33,10 @@
if (org.apache.kandula.Constants.WS_AT.equalsIgnoreCase(context
.getCoordinationType())) {
return new ATActivityContext(context);
-// }else if(org.apache.kandula.Constants.WS_BA_ATOMIC.equalsIgnoreCase(context
-// .getCoordinationType()))
-// {
-// return new BAActivityContext(context);
+ }else if(org.apache.kandula.Constants.WS_BA_ATOMIC.equalsIgnoreCase(context
+ .getCoordinationType()))
+ {
+ return new BAActivityContext(context);
} else {
throw new InvalidProtocolException("Unsupported Protocol Type");
}
@@ -44,10 +46,10 @@
throws InvalidProtocolException {
if (org.apache.kandula.Constants.WS_AT.equalsIgnoreCase(protocol)) {
return new ATActivityContext();
-// }else if (org.apache.kandula.Constants.WS_BA_ATOMIC.equalsIgnoreCase(protocol)) {
-// return new BAActivityContext(Constants.WS_BA_ATOMIC);
-// }else if (org.apache.kandula.Constants.WS_BA_MIXED.equalsIgnoreCase(protocol)) {
-// return new BAActivityContext(Constants.WS_BA_MIXED);
+ }else if (org.apache.kandula.Constants.WS_BA_ATOMIC.equalsIgnoreCase(protocol)) {
+ return new BAActivityContext(Constants.WS_BA_ATOMIC);
+ }else if (org.apache.kandula.Constants.WS_BA_MIXED.equalsIgnoreCase(protocol)) {
+ return new BAActivityContext(Constants.WS_BA_MIXED);
}
else {
throw new InvalidProtocolException("Unsupported Protocol Type");
diff --git a/src/org/apache/kandula/context/CoordinationContext.java b/src/org/apache/kandula/context/CoordinationContext.java
index c5e875c..e1ed65d 100644
--- a/src/org/apache/kandula/context/CoordinationContext.java
+++ b/src/org/apache/kandula/context/CoordinationContext.java
@@ -38,10 +38,6 @@
return new ADBCoordinationContext(context_type3);
}
- // 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/impl/ADBCoordinationContext.java b/src/org/apache/kandula/context/impl/ADBCoordinationContext.java
index 08d97dd..c24aa16 100644
--- a/src/org/apache/kandula/context/impl/ADBCoordinationContext.java
+++ b/src/org/apache/kandula/context/impl/ADBCoordinationContext.java
@@ -41,7 +41,7 @@
return element.getText();
}
public Object getCoordinationContextType() {
- return this;
+ return context_type3;
}
public String getCoordinationType() {
return context_type3.getCoordinationType().getPath();
diff --git a/src/org/apache/kandula/context/impl/ATActivityContext.java b/src/org/apache/kandula/context/impl/ATActivityContext.java
index c954b85..a20211c 100644
--- a/src/org/apache/kandula/context/impl/ATActivityContext.java
+++ b/src/org/apache/kandula/context/impl/ATActivityContext.java
@@ -87,9 +87,10 @@
* @throws AbstractKandulaException
*/
public EndpointReference addParticipant(EndpointReference participantEPR,
- String protocol) throws AbstractKandulaException {
- String enlistmentID = EndpointReferenceFactory
- .getRandomStringOf18Characters();
+ String protocol,String enlistmentID) throws AbstractKandulaException {
+ if (enlistmentID == null) {
+ enlistmentID = EndpointReferenceFactory.getRandomStringOf18Characters();
+ }
if (Constants.WS_AT_VOLATILE2PC.equals(protocol)) {
addVolatileParticipant(participantEPR, enlistmentID);
return EndpointReferenceFactory.getInstance()
diff --git a/src/org/apache/kandula/context/impl/BAActivityContext.java b/src/org/apache/kandula/context/impl/BAActivityContext.java
new file mode 100644
index 0000000..cbb82fa
--- /dev/null
+++ b/src/org/apache/kandula/context/impl/BAActivityContext.java
@@ -0,0 +1,174 @@
+ package org.apache.kandula.context.impl;
+
+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.ba.BusinessActivityCallBack;
+import org.apache.kandula.context.AbstractContext;
+import org.apache.kandula.context.CoordinationContext;
+import org.apache.kandula.coordinator.ba.BAParticipantInformation;
+import org.apache.kandula.faults.AbstractKandulaException;
+import org.apache.kandula.faults.AlreadyRegisteredException;
+import org.apache.kandula.faults.InvalidProtocolException;
+import org.apache.kandula.utility.EndpointReferenceFactory;
+
+public class BAActivityContext extends AbstractContext {
+
+ private String coordinationType;
+ private Hashtable participantCompletionParticipantsTable;
+ private Hashtable coordinatorCompletionParticipantsTable;
+ private int completingParticipantCount = 0;
+ private BusinessActivityCallBack callBack;
+
+ public BAActivityContext() {
+ }
+
+ public BAActivityContext(String coorType) {
+ super(coorType);
+ this.coordinationType = coorType;
+ this.setStatus(Status.CoordinatorStatus.STATUS_ACTIVE);
+ participantCompletionParticipantsTable = new Hashtable();
+ coordinatorCompletionParticipantsTable = new Hashtable();
+ }
+
+ public BAActivityContext(CoordinationContext context) {
+ this.setStatus(Status.CoordinatorStatus.STATUS_ACTIVE);
+ // TODO do we need the following
+ participantCompletionParticipantsTable = new Hashtable();
+ coordinatorCompletionParticipantsTable = new Hashtable();
+ setCoordinationContext(context);
+ }
+
+ /**
+ * @param participantEPR
+ * @param protocol
+ * @return Coordinator protocol service.
+ * @throws AbstractKandulaException
+ */
+ public EndpointReference addParticipant(EndpointReference participantEPR, String protocol,
+ String enlistmentID) throws AbstractKandulaException {
+ if (enlistmentID == null) {
+ enlistmentID = EndpointReferenceFactory.getRandomStringOf18Characters();
+ }
+ if (Constants.WS_BA_CC.equals(protocol)) {
+ addCoordinatorCompletionParticipants(participantEPR, enlistmentID);
+ if (this.coordinationType.equals(Constants.WS_BA_ATOMIC)) {
+ return EndpointReferenceFactory.getInstance().getAtomicOutcomeCCCoordinatorEndpoint(
+ activityID, enlistmentID);
+ } else if (this.coordinationType.equals(Constants.WS_BA_MIXED)) {
+ return EndpointReferenceFactory.getInstance().getMixedOutcomeCCCoordinatorEndpoint(
+ activityID, enlistmentID);
+ }
+ } else if (Constants.WS_BA_PC.equals(protocol)) {
+ addParticipantCompletionParticipants(participantEPR, enlistmentID);
+ incrementCompletingParticipantCount();
+ if (this.coordinationType.equals(Constants.WS_BA_ATOMIC)) {
+ return EndpointReferenceFactory.getInstance().getAtomicOutcomePCCoordinatorEndpoint(
+ activityID, enlistmentID);
+ } else if (this.coordinationType.equals(Constants.WS_BA_MIXED)) {
+ return EndpointReferenceFactory.getInstance().getMixedOutcomePCCoordinatorEndpoint(
+ activityID, enlistmentID);
+ }
+ } else {
+ throw new InvalidProtocolException();
+ }
+ return null;
+ }
+
+ public void removeParticipant(String enlistmentID) {
+ // TODO: what to do if the participant is not found
+ if (participantCompletionParticipantsTable.containsKey(enlistmentID)) {
+ participantCompletionParticipantsTable.remove(enlistmentID);
+ } else if (coordinatorCompletionParticipantsTable.containsKey(enlistmentID)) {
+ coordinatorCompletionParticipantsTable.remove(enlistmentID);
+ }
+ }
+
+ protected void addParticipantCompletionParticipants(EndpointReference participantEPR,
+ String enlistmentID) throws AlreadyRegisteredException {
+ if (participantCompletionParticipantsTable.contains(participantEPR)) {
+ throw new AlreadyRegisteredException();
+ }
+ BAParticipantInformation participant = new BAParticipantInformation(
+ participantEPR, Constants.WS_BA_PC, enlistmentID);
+ participantCompletionParticipantsTable.put(enlistmentID, participant);
+ }
+
+ protected void addCoordinatorCompletionParticipants(EndpointReference participantEPR,
+ String enlistmentID) throws AbstractKandulaException {
+ if (coordinatorCompletionParticipantsTable.contains(participantEPR))
+ throw new AlreadyRegisteredException();
+ BAParticipantInformation participant = new BAParticipantInformation(
+ participantEPR, Constants.WS_BA_CC, enlistmentID);
+ coordinatorCompletionParticipantsTable.put(enlistmentID, participant);
+ }
+
+ public int getcoordinatorCompletionParticipantsCount() {
+ return coordinatorCompletionParticipantsTable.size();
+ }
+
+ public int getparticipantCompletionParticipantCount() {
+ return participantCompletionParticipantsTable.size();
+ }
+
+ public Iterator getAllParticipants() {
+ LinkedList list = new LinkedList(participantCompletionParticipantsTable.values());
+ list.addAll(coordinatorCompletionParticipantsTable.values());
+ return list.iterator();
+ }
+
+
+ public BAParticipantInformation getParticipant(String enlistmentId) {
+ if (participantCompletionParticipantsTable.containsKey(enlistmentId)) {
+ return (BAParticipantInformation) participantCompletionParticipantsTable
+ .get(enlistmentId);
+ } else if (coordinatorCompletionParticipantsTable.containsKey(enlistmentId)) {
+ return (BAParticipantInformation) coordinatorCompletionParticipantsTable
+ .get(enlistmentId);
+ } else {
+ return null;
+ }
+ }
+ public String getCoordinationType() {
+ return this.coordinationType;
+ }
+ public String getRegistrationProtocol() {
+ return null;
+ }
+
+ public Hashtable getCoordinatorCompletionParticipants(){
+ return coordinatorCompletionParticipantsTable;
+ }
+
+ public Hashtable getparticipantCompletionParticipants() {
+ return participantCompletionParticipantsTable;
+ }
+
+ public synchronized void incrementCompletingParticipantCount() {
+ completingParticipantCount++;
+ }
+
+ public synchronized void incrementCompletingParticipantCount(int number) {
+ completingParticipantCount+=number;
+ }
+
+ public synchronized void decrementCompletingParticipantCount() {
+ completingParticipantCount--;
+ }
+
+ public synchronized boolean hasMoreCompleting() {
+ return (completingParticipantCount > 0);
+ }
+
+ public BusinessActivityCallBack getCallBack() {
+ return callBack;
+ }
+
+ public void setCallBack(BusinessActivityCallBack callBack) {
+ this.callBack = callBack;
+ }
+}
diff --git a/src/org/apache/kandula/context/impl/ATParticipantContext.java b/src/org/apache/kandula/context/impl/ParticipantContext.java
similarity index 70%
rename from src/org/apache/kandula/context/impl/ATParticipantContext.java
rename to src/org/apache/kandula/context/impl/ParticipantContext.java
index 1d3f50f..59f8be7 100644
--- a/src/org/apache/kandula/context/impl/ATParticipantContext.java
+++ b/src/org/apache/kandula/context/impl/ParticipantContext.java
@@ -20,15 +20,18 @@
import org.apache.kandula.Constants;
import org.apache.kandula.Status;
import org.apache.kandula.context.AbstractContext;
+import org.apache.kandula.faults.KandulaGeneralException;
import org.apache.kandula.participant.KandulaResource;
+import org.apache.kandula.participant.at.KandulaAtomicResource;
+import org.apache.kandula.participant.ba.KandulaBusinessActivityResource;
import org.apache.kandula.utility.EndpointReferenceFactory;
-public class ATParticipantContext extends AbstractContext {
+public class ParticipantContext extends AbstractContext {
KandulaResource resource;
String ID;
EndpointReference coordinationEPR;
- public ATParticipantContext() {
+ public ParticipantContext() {
this.setStatus(Status.CoordinatorStatus.STATUS_ACTIVE);
ID = EndpointReferenceFactory.getRandomStringOf18Characters();
}
@@ -60,9 +63,17 @@
/**
* @param setting
* the transaction participant resource
+ * @throws KandulaGeneralException
*/
- public void setResource(KandulaResource resource) {
- this.resource = resource;
+ public void setResource(KandulaResource resource) throws KandulaGeneralException {
+ if (((this.getCoordinationContext().getCoordinationType().equals(Constants.WS_AT)) & (resource instanceof KandulaAtomicResource)) |((this.getCoordinationContext().getCoordinationType().equals(Constants.WS_BA_ATOMIC)) & (resource instanceof KandulaBusinessActivityResource)) )
+ {
+ resource.init(this);
+ this.resource = resource;
+ }else
+ {
+ throw new KandulaGeneralException("Invalid Resource");
+ }
}
public String getRegistrationProtocol() {
@@ -76,5 +87,4 @@
public void setID(String id) {
ID = id;
}
-
}
diff --git a/src/org/apache/kandula/coordinator/Coordinator.java b/src/org/apache/kandula/coordinator/Coordinator.java
index 7b4f48d..1bc6532 100644
--- a/src/org/apache/kandula/coordinator/Coordinator.java
+++ b/src/org/apache/kandula/coordinator/Coordinator.java
@@ -21,9 +21,12 @@
import org.apache.kandula.context.ContextFactory;
import org.apache.kandula.context.CoordinationContext;
import org.apache.kandula.faults.AbstractKandulaException;
+import org.apache.kandula.storage.SimpleStore;
+import org.apache.kandula.storage.Store;
public class Coordinator {
+ public static Store store= new SimpleStore();
public Coordinator() {
}
@@ -41,6 +44,7 @@
CoordinationContext coorContext) throws AbstractKandulaException {
ContextFactory factory = ContextFactory.getInstance();
AbstractContext context = factory.createActivity(coorContext);
+ store.put(context.getCoordinationContext().getActivityID(),context);
return context;
}
@@ -59,6 +63,7 @@
ContextFactory factory = ContextFactory.getInstance();
AbstractContext context = factory.createActivity(coordinationType);
context.getCoordinationContext().setExpires(expires);
+ store.put(context.getCoordinationContext().getActivityID(),context);
return context;
}
@@ -74,10 +79,10 @@
* @throws AbstractKandulaException
*/
public EndpointReference registerParticipant(AbstractContext context, String protocol,
- EndpointReference participantEPR) throws AbstractKandulaException {
+ EndpointReference participantEPR, String participantID) throws AbstractKandulaException {
Registerable registerableCoordinator = Registerable.Factory
.newRegisterable(context.getCoordinationType());
return registerableCoordinator.register(context, protocol,
- participantEPR);
+ participantEPR,participantID);
}
}
\ 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 40c6094..4f8dbf0 100644
--- a/src/org/apache/kandula/coordinator/Registerable.java
+++ b/src/org/apache/kandula/coordinator/Registerable.java
@@ -44,5 +44,5 @@
}
public EndpointReference register(AbstractContext context, String protocol,
- EndpointReference participantEPR) throws AbstractKandulaException;
+ EndpointReference participantEPR, String enlistmentID) throws AbstractKandulaException;
}
\ 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 dcfb8d6..28245ff 100644
--- a/src/org/apache/kandula/coordinator/at/ATCoordinator.java
+++ b/src/org/apache/kandula/coordinator/at/ATCoordinator.java
@@ -29,7 +29,7 @@
import org.apache.kandula.faults.AbstractKandulaException;
import org.apache.kandula.faults.InvalidStateException;
import org.apache.kandula.faults.KandulaGeneralException;
-import org.apache.kandula.participant.Vote;
+import org.apache.kandula.participant.at.Vote;
import org.apache.kandula.wsat.completion.CompletionInitiatorPortTypeRawXMLStub;
import org.apache.kandula.wsat.twopc.ParticipantPortTypeRawXMLStub;
@@ -45,7 +45,7 @@
* java.lang.String, org.apache.axis2.addressing.EndpointReference)
*/
public EndpointReference register(AbstractContext context, String protocol,
- EndpointReference participantEPR) throws AbstractKandulaException {
+ EndpointReference participantEPR,String enlistmentID) throws AbstractKandulaException {
ATActivityContext atContext = (ATActivityContext) context;
atContext.lock();
switch (atContext.getStatus()) {
@@ -72,7 +72,7 @@
case CoordinatorStatus.STATUS_ACTIVE:
case CoordinatorStatus.STATUS_PREPARING_VOLATILE:
EndpointReference epr = atContext.addParticipant(participantEPR,
- protocol);
+ protocol,enlistmentID);
atContext.unlock();
return epr;
case CoordinatorStatus.STATUS_NONE:
diff --git a/src/org/apache/kandula/coordinator/at/ATSubCoordinator.java b/src/org/apache/kandula/coordinator/at/ATSubCoordinator.java
index 7611c0a..160680e 100644
--- a/src/org/apache/kandula/coordinator/at/ATSubCoordinator.java
+++ b/src/org/apache/kandula/coordinator/at/ATSubCoordinator.java
@@ -34,7 +34,7 @@
// have to register with the parent coordinator
atContext.setSubDurableRegistered(true);
}
- return atContext.addParticipant(participantEPR, protocol);
+ return atContext.addParticipant(participantEPR, protocol,null);
}
else if (protocol.equals(Constants.WS_AT_VOLATILE2PC)) {
@@ -42,7 +42,8 @@
// have to register with the parent coordinator
atContext.setSubDurableRegistered(true);
}
- return atContext.addParticipant(participantEPR, protocol);
+ //FIXME null
+ return atContext.addParticipant(participantEPR, protocol,null);
} else
throw new InvalidProtocolException();
}
diff --git a/src/org/apache/kandula/coordinator/ba/BACoordinator.java b/src/org/apache/kandula/coordinator/ba/BACoordinator.java
index 178f699..38df208 100644
--- a/src/org/apache/kandula/coordinator/ba/BACoordinator.java
+++ b/src/org/apache/kandula/coordinator/ba/BACoordinator.java
@@ -16,1782 +16,698 @@
*/
package org.apache.kandula.coordinator.ba;
+import java.rmi.RemoteException;
+import java.util.ArrayList;
+import java.util.Hashtable;
+import java.util.Iterator;
import org.apache.axis2.addressing.EndpointReference;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.kandula.Constants;
+import org.apache.kandula.Status;
+import org.apache.kandula.Status.BACoordinatorStatus;
+import org.apache.kandula.ba.BusinessActivityCallBack;
import org.apache.kandula.context.AbstractContext;
+import org.apache.kandula.context.impl.BAActivityContext;
import org.apache.kandula.coordinator.Registerable;
import org.apache.kandula.faults.AbstractKandulaException;
+import org.apache.kandula.faults.InvalidStateException;
+import org.apache.kandula.faults.KandulaGeneralException;
+import org.apache.kandula.storage.StorageUtils;
+import org.apache.kandula.utility.KandulaConfiguration;
+import org.apache.kandula.wsba.BACoordinatorCompletionParticipantServiceStub;
+import org.oasis_open.docs.ws_tx.wsba._2006._06.Cancel;
+import org.oasis_open.docs.ws_tx.wsba._2006._06.Close;
+import org.oasis_open.docs.ws_tx.wsba._2006._06.Compensate;
+import org.oasis_open.docs.ws_tx.wsba._2006._06.Complete;
+import org.oasis_open.docs.ws_tx.wsba._2006._06.Exited;
+import org.oasis_open.docs.ws_tx.wsba._2006._06.Failed;
+import org.oasis_open.docs.ws_tx.wsba._2006._06.NotificationType;
-public class BACoordinator implements Registerable
-{
- public BACoordinator()
- {
- }
-
- //Start - Register
- /*public EndpointReference register(AbstractContext context, String protocol,
- EndpointReference participantEPR) throws AbstractKandulaException
- {
- EndpointReference registeredParticipantEPR = null;
- BAActivityContext baContext = (BAActivityContext) context;
- if(baContext.getCoordinationType().equals(Constants.WS_BA_ATOMIC))
- {
- AtomicBACoordinator atomicBACoordinator = new AtomicBACoordinator();
- registeredParticipantEPR = atomicBACoordinator.registerBAAtomicParticipants(baContext,protocol,participantEPR);
- }
- if(baContext.getCoordinationType().equals(Constants.WS_BA_MIXED))
- {
- MixedBACoordinator mixedBACoordinator = new MixedBACoordinator();
- registeredParticipantEPR = mixedBACoordinator.registerBAMixedParticipants(baContext,protocol,participantEPR);
- }
- return registeredParticipantEPR;
- }*/
- //End -Register
-
+public class BACoordinator implements Registerable {
+
+ private static final Log log = LogFactory.getLog(BACoordinator.class);
+
public EndpointReference register(AbstractContext context, String protocol,
- EndpointReference participantEPR)throws AbstractKandulaException
- {
-// BAActivityContext baContext = (BAActivityContext) context;
-// baContext.lock();
-// int coordinatorStatus = baContext.getStatus();
-// if(coordinatorStatus ==(BACoordinatorStatus.STATUS_CLOSING))
-// {
-// baContext.unlock();
-// throw new InvalidStateException ("Coordinator is in closing status ");
-// }else if(coordinatorStatus ==(BACoordinatorStatus.STATUS_COMPENSATING))
-// {
-// baContext.unlock();
-// throw new InvalidStateException ("Coordinator is in compensating status ");
-// }
-// else
-// {
-// EndpointReference epr = baContext.addParticipant(participantEPR,
-// protocol);
-// baContext.unlock();
-// return epr;
-// }
- return null;
+ EndpointReference participantEPR, String registrationID)
+ throws AbstractKandulaException {
+ BAActivityContext baContext = (BAActivityContext) context;
+ baContext.lock();
+ int coordinatorStatus = baContext.getStatus();
+ if (coordinatorStatus == (BACoordinatorStatus.STATUS_CLOSING)) {
+ baContext.unlock();
+ throw new InvalidStateException("Coordinator is in closing status ");
+ } else if (coordinatorStatus == (BACoordinatorStatus.STATUS_COMPENSATING)) {
+ baContext.unlock();
+ throw new InvalidStateException("Coordinator is in compensating status ");
+ } else {
+ EndpointReference epr = baContext.addParticipant(participantEPR, protocol,
+ registrationID);
+ baContext.unlock();
+ return epr;
+ }
+ }
+
+ /**
+ * See Coordinator View of BusinessAgreement with Coordinator Completion
+ *
+ * @param context
+ * @param enlishmentID
+ * @throws AbstractKandulaException
+ */
+ public void completeOperation(BAActivityContext baContext) throws AbstractKandulaException {
+ baContext.lock();
+ switch (baContext.getStatus()) {
+ case BACoordinatorStatus.STATUS_ACTIVE:
+ case BACoordinatorStatus.STATUS_COMPLETING:
+ baContext.unlock();
+ baContext.setStatus(BACoordinatorStatus.STATUS_COMPLETING);
+ Hashtable coordinatorCompletionParticipants = baContext
+ .getCoordinatorCompletionParticipants();
+ Iterator participantIterator = coordinatorCompletionParticipants.values().iterator();
+ baContext.incrementCompletingParticipantCount(coordinatorCompletionParticipants.size());
+ BACoordinatorCompletionParticipantServiceStub participantServiceStub;
+ try {
+ participantServiceStub = new BACoordinatorCompletionParticipantServiceStub(
+ KandulaConfiguration.getInstance()
+ .getCoordinatorAxis2ConfigurationContext(), null);
+ } catch (Exception e1) {
+ log.fatal("WS_BA : " + baContext.getCoordinationContext().getActivityID()
+ + " : completeOperation : " + e1);
+ throw new KandulaGeneralException(e1);
+ }
+ while (participantIterator.hasNext()) {
+ Object object = (participantIterator.next());
+ BAParticipantInformation participant = (BAParticipantInformation) object;
+ try {
+ participantServiceStub._getServiceClient().getOptions().setTo(
+ participant.getEpr());
+ Complete completeParam = new Complete();
+ completeParam.setComplete(new NotificationType());
+ participant.setStatus(BACoordinatorStatus.STATUS_COMPLETING);
+ participantServiceStub.CompleteOperation(completeParam);
+ } catch (Exception e) {
+ log.fatal("WS_BA : " + baContext.getCoordinationContext().getActivityID()
+ + " : completeOperation :" + participant.getEnlistmentId() + " : " + e);
+ throw new KandulaGeneralException(e);
+ }
+ }
+ break;
+ case BACoordinatorStatus.STATUS_CANCELLING:
+ case BACoordinatorStatus.STATUS_COMPLETED:
+ case BACoordinatorStatus.STATUS_CLOSING:
+ case BACoordinatorStatus.STATUS_COMPENSATING:
+ case BACoordinatorStatus.STATUS_FAULTING:
+ case BACoordinatorStatus.STATUS_EXITING:
+ case BACoordinatorStatus.STATUS_ENDED:
+ baContext.unlock();
+ log.fatal("WS_BA : " + baContext.getCoordinationContext().getActivityID()
+ + " : completeOperation : Coordinator is in" + baContext.getStatus()
+ + " (invalid) state");
+ throw new InvalidStateException("Coordinator is in" + baContext.getStatus() + "state");
+ default:
+ log.fatal("WS_BA : " + baContext.getCoordinationContext().getActivityID()
+ + " : completeOperation : Coordinator is in" + baContext.getStatus()
+ + " (invalid) state, Defaulting");
+ throw new InvalidStateException("Coordinator is in" + baContext.getStatus() + "state");
+ }
+ }
+
+ protected void closeOperation(BAActivityContext baContext, String enlistmentID)
+ throws AbstractKandulaException {
+ BAParticipantInformation baParticipantInformation = baContext.getParticipant(enlistmentID);
+ BACoordinatorCompletionParticipantServiceStub participantServiceStub;
+ switch (baParticipantInformation.getStatus()) {
+ case BACoordinatorStatus.STATUS_ACTIVE:
+ case BACoordinatorStatus.STATUS_CANCELLING:
+ case BACoordinatorStatus.STATUS_COMPENSATING:
+ case BACoordinatorStatus.STATUS_FAULTING:
+ case BACoordinatorStatus.STATUS_EXITING:
+ case BACoordinatorStatus.STATUS_ENDED:
+ case BACoordinatorStatus.STATUS_COMPLETING:
+ log.fatal("WS_BA : " + baContext.getCoordinationContext().getActivityID()
+ + " : closeOperation : Coordinator is in" + baContext.getStatus()
+ + " (invalid) state");
+ throw new InvalidStateException("Coordinator is in" + baContext.getStatus() + "state");
+ case BACoordinatorStatus.STATUS_COMPLETED:
+ case BACoordinatorStatus.STATUS_CLOSING:
+ try {
+ participantServiceStub = new BACoordinatorCompletionParticipantServiceStub(
+ KandulaConfiguration.getInstance()
+ .getCoordinatorAxis2ConfigurationContext(), null);
+ participantServiceStub._getServiceClient().getOptions().setTo(
+ baParticipantInformation.getEpr());
+ Close closeParam = new Close();
+ closeParam.setClose(new NotificationType());
+ baParticipantInformation.setStatus(BACoordinatorStatus.STATUS_CLOSING);
+ participantServiceStub.CloseOperation(closeParam);
+ } catch (Exception e) {
+ log.fatal("WS_BA : " + baContext.getCoordinationContext().getActivityID()
+ + " : close Operation :" + baParticipantInformation + " : " + e);
+ throw new KandulaGeneralException(e);
+ }
+ break;
+ default:
+ log.fatal("WS_BA : " + baContext.getCoordinationContext().getActivityID()
+ + " : closeOperation : Coordinator is in" + baContext.getStatus()
+ + " (invalid) state, Defaulting");
+ throw new InvalidStateException("Coordinator is in" + baContext.getStatus() + "state");
+ }
}
- /**
- * Coordinator View of BusinessAgreement with Participant Completion
- */
- //*********************************************************************************
- /*
- * Handling Protocol Messages recieved by the Coordinator[sent by participant] </a>
- */
+
+ protected void compensateOperation(BAActivityContext baContext, String enlistmentID)
+ throws AbstractKandulaException {
+ BAParticipantInformation baParticipantInformation = baContext.getParticipant(enlistmentID);
+ BACoordinatorCompletionParticipantServiceStub participantServiceStub;
+ switch (baParticipantInformation.getStatus()) {
+ case BACoordinatorStatus.STATUS_ACTIVE:
+ case BACoordinatorStatus.STATUS_CANCELLING:
+ case BACoordinatorStatus.STATUS_CLOSING:
+ case BACoordinatorStatus.STATUS_FAULTING:
+ case BACoordinatorStatus.STATUS_EXITING:
+ case BACoordinatorStatus.STATUS_ENDED:
+ case BACoordinatorStatus.STATUS_COMPLETING:
+ log.fatal("WS_BA : " + baContext.getCoordinationContext().getActivityID()
+ + " : compensateOperation : Coordinator is in" + baContext.getStatus()
+ + " (invalid) state");
+ throw new InvalidStateException("Coordinator is in" + baContext.getStatus() + "state");
+ case BACoordinatorStatus.STATUS_COMPLETED:
+ case BACoordinatorStatus.STATUS_COMPENSATING:
+ try {
+ participantServiceStub = new BACoordinatorCompletionParticipantServiceStub(
+ KandulaConfiguration.getInstance()
+ .getCoordinatorAxis2ConfigurationContext(), null);
+ participantServiceStub._getServiceClient().getOptions().setTo(
+ baParticipantInformation.getEpr());
+ Compensate compensate = new Compensate();
+ compensate.setCompensate(new NotificationType());
+ baParticipantInformation.setStatus(BACoordinatorStatus.STATUS_COMPENSATING);
+ participantServiceStub.CompensateOperation(compensate);
+ } catch (Exception e) {
+ log.fatal("WS_BA : " + baContext.getCoordinationContext().getActivityID()
+ + " : compensateOperation :" + baParticipantInformation + " : " + e);
+ throw new KandulaGeneralException(e);
+ }
+ break;
+ default:
+ log.fatal("WS_BA : " + baContext.getCoordinationContext().getActivityID()
+ + " : compensateOperation : Coordinator is in" + baContext.getStatus()
+ + " (invalid) state, Defaulting");
+ throw new InvalidStateException("Coordinator is in" + baContext.getStatus() + "state");
+ }
+ }
-// 1. Start Exit
-// If a exit is recieved the the coordinator removes that participant from the list
-// public void PCExitOperation(AbstractContext context, String enlishmentID)
-// throws AbstractKandulaException
-// {
-// BAActivityContext baContext = (BAActivityContext) context;
-// baContext.lock();
-// BAParticipantInformation baParticipantInfo = baContext.getParticipant(enlishmentID);
-// switch(baContext.getStatus())
-// {
-//
-// case BACoordinatorStatus.STATUS_ACTIVE:
-// try{
-// baContext.removeParticipant(enlishmentID);
-// int existingCount = baContext.getParticipantCount();
-// baContext.setParticipantCount(existingCount--);
-// baParticipantInfo.setStatus(Status.BACoordinatorStatus.STATUS_EXITING);
-// baContext.setStatus(BACoordinatorStatus.STATUS_EXITING);
-// baContext.unlock();
-// this.PCExitedOperation(baContext,enlishmentID);
-// }
-// catch(Exception e)
-// {
-// throw new KandulaGeneralException(e);
-// }
-//
-// case BACoordinatorStatus.STATUS_CANCELLING:
-// try{
-// baContext.removeParticipant(enlishmentID);
-// int existingCount = baContext.getParticipantCount();
-// baContext.setParticipantCount(existingCount--);
-// // Take an iterator
-// baParticipantInfo.setStatus(Status.BACoordinatorStatus.STATUS_EXITING);
-// baContext.setStatus(BACoordinatorStatus.STATUS_EXITING);
-// baContext.unlock();
-// this.PCExitedOperation(baContext,enlishmentID);
-//
-// }
-// catch(Exception e)
-// {
-// throw new KandulaGeneralException(e);
-// }
-//
-// case BACoordinatorStatus.STATUS_ENDED:
-// try{
-// baContext.unlock();
-// this.PCExitedOperation(baContext,enlishmentID);
-// }
-// catch(Exception e)
-// {
-// throw new KandulaGeneralException(e);
-// }
-//
-// case BACoordinatorStatus.STATUS_COMPLETED:
-// baContext.unlock();
-// throw new InvalidStateException(
-// "Coordinator is in completed state");
-//
-// case BACoordinatorStatus.STATUS_CLOSING:
-// baContext.unlock();
-// throw new InvalidStateException(
-// "Coordinator is in closing state");
-//
-// case BACoordinatorStatus.STATUS_COMPENSATING:
-// baContext.unlock();
-// throw new InvalidStateException(
-// "Coordinator is in compensating state");
-//
-// case BACoordinatorStatus.STATUS_FAULTING_COMPENSATING:
-// baContext.unlock();
-// throw new InvalidStateException(
-// "Coordinator is in faulting compensatingstate");
-//
-// case BACoordinatorStatus.STATUS_FAULTING_ACTIVE:
-// baContext.unlock();
-// throw new InvalidStateException(
-// "Coordinator is in faulting active state");
-//
-// case BACoordinatorStatus.STATUS_EXITING:
-// baContext.unlock();
-// }
-// }
-// //End Exit
-//
-// //2. start Completed
-// public void PCCompletedOperation(BAActivityContext baContext, String enlishmentID)
-// throws AbstractKandulaException
-// {
-// switch(baContext.getStatus())
-// {
-// case BACoordinatorStatus.STATUS_COMPLETED:
-// baContext.unlock();
-//
-// case BACoordinatorStatus.STATUS_FAULTING_ACTIVE:
-// baContext.unlock();
-// throw new InvalidStateException(
-// "Coordinator is in faulting active state");
-//
-// case BACoordinatorStatus.STATUS_EXITING:
-// baContext.unlock();
-// throw new InvalidStateException(
-// "Coordinator is in exiting active state");
-//
-// case BACoordinatorStatus.STATUS_ENDED:
-// baContext.unlock();
-// }
-// }
-// //EndCompleted
-//
-// // 3. Start - Fault
-// public void PCFaultOperation(AbstractContext context, String enlishmentID)
-// throws AbstractKandulaException
-// {
-// BAActivityContext baContext = (BAActivityContext) context;
-// baContext.lock();
-// BAParticipantInformation baParticipantInformation= baContext.getParticipant(enlishmentID);
-// switch(baContext.getStatus())
-// {
-// case BACoordinatorStatus.STATUS_ACTIVE:
-// try{
-// baParticipantInformation.setStatus(Status.BACoordinatorStatus.STATUS_FAULTING_ACTIVE);
-// baContext.setStatus(Status.BACoordinatorStatus.STATUS_FAULTING_ACTIVE);
-// baContext.unlock();
-// }
-// catch(Exception e)
-// {
-// throw new KandulaGeneralException(e);
-// }
-//
-// case BACoordinatorStatus.STATUS_CANCELLING:
-// try{
-// baParticipantInformation.setStatus(Status.BACoordinatorStatus.STATUS_FAULTING_ACTIVE);
-// baContext.setStatus(Status.BACoordinatorStatus.STATUS_FAULTING_ACTIVE);
-// baContext.unlock();
-// }
-// catch(Exception e)
-// {
-// throw new KandulaGeneralException(e);
-// }
-//
-// case BACoordinatorStatus.STATUS_COMPENSATING:
-// try{
-//
-// baParticipantInformation.setStatus(Status.BACoordinatorStatus.STATUS_FAULTING_COMPENSATING);
-// baContext.setStatus(Status.BACoordinatorStatus.STATUS_FAULTING_COMPENSATING);
-// baContext.unlock();
-// }
-// catch(Exception e)
-// {
-// throw new KandulaGeneralException(e);
-// }
-//
-//
-// case BACoordinatorStatus.STATUS_COMPLETED:
-// baContext.unlock();
-// throw new InvalidStateException(
-// "Coordinator is in completed state");
-//
-// case BACoordinatorStatus.STATUS_CLOSING:
-// baContext.unlock();
-// throw new InvalidStateException(
-// "Coordinator is in closing state");
-//
-// case BACoordinatorStatus.STATUS_FAULTING_COMPENSATING:
-// baContext.setStatus(BACoordinatorStatus.STATUS_FAULTING);
-// baParticipantInformation.setStatus(Status.BACoordinatorStatus.STATUS_FAULTING);
-// baContext.unlock();
-// this.PCFaultedOperation(baContext,enlishmentID);
-//
-//
-// case BACoordinatorStatus.STATUS_FAULTING_ACTIVE:
-// baContext.setStatus(BACoordinatorStatus.STATUS_FAULTING);
-// baParticipantInformation.setStatus(Status.BACoordinatorStatus.STATUS_FAULTING);
-// baContext.unlock();
-// this.PCFaultedOperation(baContext,enlishmentID);
-//
-//
-// case BACoordinatorStatus.STATUS_ENDED:
-// baContext.unlock();
-// this.PCFaultedOperation(baContext,enlishmentID);
-//
-// }
-// }
-// //End - Fault
-//
-// //4. Canceled
-// public void PCCanceledOperation(BAActivityContext baContext,String enlishmentID)
-// throws AbstractKandulaException
-// {
-// switch(baContext.getStatus())
-// {
-// case BACoordinatorStatus.STATUS_ACTIVE:
-// baContext.unlock();
-// throw new InvalidStateException(
-// "Coordinator is in Active state");
-//
-// case BACoordinatorStatus.STATUS_COMPLETED:
-// baContext.unlock();
-// throw new InvalidStateException(
-// "Coordinator is in completed state");
-//
-// case BACoordinatorStatus.STATUS_CLOSING:
-// baContext.unlock();
-// throw new InvalidStateException(
-// "Coordinator is in cLOSING state");
-//
-// case BACoordinatorStatus.STATUS_COMPENSATING:
-// baContext.unlock();
-// throw new InvalidStateException(
-// "Coordinator is in compensating state");
-//
-// case BACoordinatorStatus.STATUS_FAULTING_COMPENSATING:
-// baContext.unlock();
-// throw new InvalidStateException(
-// "Coordinator is in faulting Compensating state");
-//
-// case BACoordinatorStatus.STATUS_FAULTING_ACTIVE:
-// baContext.unlock();
-// throw new InvalidStateException(
-// "Coordinator is in faulting active state");
-//
-// case BACoordinatorStatus.STATUS_EXITING:
-// baContext.unlock();
-// throw new InvalidStateException(
-// "Coordinator is in exiting state");
-//
-// case BACoordinatorStatus.STATUS_ENDED:
-// baContext.unlock();
-// }
-// }
-// //End Canceled
-//
-// //5.Start -Closed
-// public void PCClosedOperation(BAActivityContext baContext,String enlishmentID)
-// throws AbstractKandulaException
-// {
-// BAParticipantInformation baPaticipantInformation = baContext.getParticipant(enlishmentID);
-// switch(baContext.getStatus())
-// {
-// case BACoordinatorStatus.STATUS_ACTIVE:
-// baContext.unlock();
-// throw new InvalidStateException(
-// "Coordinator is in Active state");
-//
-// case BACoordinatorStatus.STATUS_CANCELLING:
-// baContext.unlock();
-// throw new InvalidStateException(
-// "Coordinator is in canceling state");
-//
-// case BACoordinatorStatus.STATUS_COMPLETED:
-// baContext.unlock();
-// throw new InvalidStateException(
-// "Coordinator is in completed state");
-//
-// case BACoordinatorStatus.STATUS_CLOSING:
-// baPaticipantInformation.setStatus(BACoordinatorStatus.STATUS_ENDED);
-// baContext.setStatus(BACoordinatorStatus.STATUS_ENDED);
-// baContext.unlock();
-//
-// case BACoordinatorStatus.STATUS_COMPENSATING:
-// baContext.unlock();
-// throw new InvalidStateException(
-// "Coordinator is in compensating state");
-//
-// case BACoordinatorStatus.STATUS_FAULTING_COMPENSATING:
-// baContext.unlock();
-// throw new InvalidStateException(
-// "Coordinator is in faulting Compensating state");
-//
-// case BACoordinatorStatus.STATUS_FAULTING_ACTIVE:
-// baContext.unlock();
-// throw new InvalidStateException(
-// "Coordinator is in faulting active state");
-//
-// case BACoordinatorStatus.STATUS_EXITING:
-// baContext.unlock();
-// throw new InvalidStateException(
-// "Coordinator is in exiting state");
-//
-// case BACoordinatorStatus.STATUS_ENDED:
-// baContext.unlock();
-// }
-// }
-// //End Closed
-//
-// // Start - Compensated
-// public void PCCompensatedOperation(BAActivityContext baContext,String enlishmentID)
-// throws AbstractKandulaException
-// {
-// BAParticipantInformation baPaticipantInformation = baContext.getParticipant(enlishmentID);
-// switch(baContext.getStatus())
-// {
-// case BACoordinatorStatus.STATUS_ACTIVE:
-// baContext.unlock();
-// throw new InvalidStateException(
-// "Coordinator is in Active state");
-//
-// case BACoordinatorStatus.STATUS_CANCELLING:
-// baContext.unlock();
-// throw new InvalidStateException(
-// "Coordinator is in canceling state");
-//
-// case BACoordinatorStatus.STATUS_COMPLETED:
-// baContext.unlock();
-// throw new InvalidStateException(
-// "Coordinator is in completed state");
-//
-// case BACoordinatorStatus.STATUS_CLOSING:
-// baContext.unlock();
-// throw new InvalidStateException(
-// "Coordinator is in closing state");
-//
-// case BACoordinatorStatus.STATUS_COMPENSATING:
-// baPaticipantInformation.setStatus(BACoordinatorStatus.STATUS_ENDED);
-// baContext.setStatus(BACoordinatorStatus.STATUS_ENDED);
-// baContext.unlock();
-//
-// case BACoordinatorStatus.STATUS_FAULTING_COMPENSATING:
-// baContext.unlock();
-// throw new InvalidStateException(
-// "Coordinator is in faulting Compensating state");
-//
-// case BACoordinatorStatus.STATUS_FAULTING_ACTIVE:
-// baContext.unlock();
-// throw new InvalidStateException(
-// "Coordinator is in faulting active state");
-//
-// case BACoordinatorStatus.STATUS_EXITING:
-// baContext.unlock();
-// throw new InvalidStateException(
-// "Coordinator is in exiting state");
-//
-// case BACoordinatorStatus.STATUS_ENDED:
-// baContext.unlock();
-// }
-// }
-// //End -Compensated
-//
-///**
-// * Handling Protocol Messages sent by the Coordinator[recieved by participant] </a>
-// */
-//
-////start - Cancel
-//public void PCCancelOperation(AbstractContext context,String enlishmentID)
-//throws AbstractKandulaException
-//{
-// BAActivityContext baContext = (BAActivityContext) context;
-// baContext.lock();
-// BAParticipantInformation cancelingParticipant = baContext.getParticipant(enlishmentID);
-// BAParticipantCompletionParticipantServiceStub pcpsStub;
-// switch(baContext.getStatus())
-// {
-// case BACoordinatorStatus.STATUS_ACTIVE:
-// try{
-// pcpsStub = new BAParticipantCompletionParticipantServiceStub(((cancelingParticipant.getEpr()).toString()));
-// Cancel cancelParam = new Cancel();
-// pcpsStub.CancelOperation(cancelParam);
-// baContext.setStatus(BACoordinatorStatus.STATUS_CANCELLING_ACTIVE);
-// cancelingParticipant.setStatus(BACoordinatorStatus.STATUS_CANCELLING_ACTIVE);
-// baContext.unlock();
-// }
-// catch(AxisFault e)
-// {
-// throw new KandulaGeneralException(e);
-// }
-// catch(Exception e)
-// {
-// //TODO
-// }
-//
-// case BACoordinatorStatus.STATUS_CANCELLING:
-// try{
-//
-// pcpsStub = new BAParticipantCompletionParticipantServiceStub(((cancelingParticipant.getEpr()).toString()));
-// Cancel cancelParam = new Cancel();
-// pcpsStub.CancelOperation(cancelParam);
-// baContext.unlock();
-// }
-// catch(AxisFault e)
-// {
-// throw new KandulaGeneralException(e);
-// }
-// catch(Exception e)
-// {
-// //TODO
-// }
-//
-// case BACoordinatorStatus.STATUS_COMPLETED:
-// baContext.unlock();
-// throw new InvalidStateException(
-// "Coordinator is in completed state");
-//
-// case BACoordinatorStatus.STATUS_CLOSING:
-// baContext.unlock();
-// throw new InvalidStateException(
-// "Coordinator is in closing state");
-//
-// case BACoordinatorStatus.STATUS_COMPENSATING:
-// baContext.unlock();
-// throw new InvalidStateException(
-// "Coordinator is in compensated state");
-//
-// case BACoordinatorStatus.STATUS_FAULTING:
-// baContext.unlock();
-// throw new InvalidStateException(
-// "Coordinator is in faulting state");
-//
-// case BACoordinatorStatus.STATUS_EXITING:
-// baContext.unlock();
-// throw new InvalidStateException(
-// "Coordinator is in exiting state");
-//
-// case BACoordinatorStatus.STATUS_ENDED:
-// baContext.unlock();
-// throw new InvalidStateException(
-// "Coordinator is in ended state");
-// }
-//}//End Cancel
-//
-////Start Colse
-//public void PCCloseOperation(BAActivityContext baContext, String enlishmentID)
-//throws AbstractKandulaException
-//{
-// BAParticipantInformation baParticipantInformation = baContext.getParticipant(enlishmentID);
-// baContext.lock();
-// BAParticipantCompletionParticipantServiceStub pcpsStub;
-// switch(baContext.getStatus())
-// {
-// case BACoordinatorStatus.STATUS_ACTIVE:
-// baContext.unlock();
-// throw new InvalidStateException(
-// "Coordinator is in active state");
-//
-// case BACoordinatorStatus.STATUS_CANCELLING:
-// baContext.unlock();
-// throw new InvalidStateException(
-// "Coordinator is in cancelling state");
-//
-// case BACoordinatorStatus.STATUS_COMPLETED:
-// try{
-// String participantEndpointReference = baParticipantInformation.getEpr().toString();
-// pcpsStub = new BAParticipantCompletionParticipantServiceStub(participantEndpointReference);
-// Close closeParam = new Close();
-// pcpsStub.CloseOperation(closeParam);
-// baParticipantInformation.setStatus(BACoordinatorStatus.STATUS_CLOSING);
-// baContext.unlock();
-// }
-// catch(AxisFault e)
-// {
-// throw new KandulaGeneralException(e);
-// }
-// catch(Exception e)
-// {
-// //TODO
-// }
-//
-// case BACoordinatorStatus.STATUS_CLOSING:
-// try{
-//
-// String participantEndpointReference = baParticipantInformation.getEpr().toString();
-// pcpsStub = new BAParticipantCompletionParticipantServiceStub(participantEndpointReference);
-// Close closeParam = new Close();
-// pcpsStub.CloseOperation(closeParam);
-// baParticipantInformation.setStatus(BACoordinatorStatus.STATUS_CLOSING);
-// baContext.unlock();
-// }
-// catch(AxisFault e)
-// {
-// throw new KandulaGeneralException(e);
-// }
-// catch(Exception e)
-// {
-// //TODO
-// }
-//
-// case BACoordinatorStatus.STATUS_COMPENSATING:
-// baContext.unlock();
-// throw new InvalidStateException(
-// "Coordinator is in compensating state");
-//
-// case BACoordinatorStatus.STATUS_FAULTING:
-// baContext.unlock();
-// throw new InvalidStateException(
-// "Coordinator is in faulting state");
-//
-// case BACoordinatorStatus.STATUS_EXITING:
-// baContext.unlock();
-// throw new InvalidStateException(
-// "Coordinator is in exiting state");
-//
-// case BACoordinatorStatus.STATUS_ENDED:
-// baContext.unlock();
-// throw new InvalidStateException(
-// "Coordinator is in exiting state");
-// }
-//}//End - Close
-//
-////Start - Compensate
-//public void PCCompensateOperation(BAActivityContext baContext, String enlishmentID)
-//throws AbstractKandulaException
-//{
-// BAParticipantInformation baParticipantInformation = baContext.getParticipant(enlishmentID);
-// baContext.lock();
-// BAParticipantCompletionParticipantServiceStub pcpsStub;
-// switch(baContext.getStatus())
-// {
-// case BACoordinatorStatus.STATUS_ACTIVE:
-// baContext.unlock();
-// throw new InvalidStateException(
-// "Coordinator is in active state");
-//
-// case BACoordinatorStatus.STATUS_CANCELLING:
-// baContext.unlock();
-// throw new InvalidStateException(
-// "Coordinator is in cancelling state");
-//
-// case BACoordinatorStatus.STATUS_COMPLETED:
-// try{
-// String participantEndpointReference = baParticipantInformation.getEpr().toString();
-// pcpsStub = new BAParticipantCompletionParticipantServiceStub(participantEndpointReference);
-// Compensate compensateParam = new Compensate();
-// pcpsStub.CompensateOperation(compensateParam);
-// baParticipantInformation.setStatus(BACoordinatorStatus.STATUS_COMPENSATING);
-// baContext.unlock();
-// }
-// catch(AxisFault e)
-// {
-// throw new KandulaGeneralException(e);
-// }
-// catch(Exception e)
-// {
-// //TODO
-// }
-//
-// case BACoordinatorStatus.STATUS_CLOSING:
-// baContext.unlock();
-// throw new InvalidStateException(
-// "Coordinator is in cancelling state");
-//
-// case BACoordinatorStatus.STATUS_COMPENSATING:
-// try{
-// String participantEndpointReference = baParticipantInformation.getEpr().toString();
-// pcpsStub = new BAParticipantCompletionParticipantServiceStub(participantEndpointReference);
-// Compensate compensateParam = new Compensate();
-// pcpsStub.CompensateOperation(compensateParam);
-// baParticipantInformation.setStatus(BACoordinatorStatus.STATUS_COMPENSATING);
-// baContext.unlock();
-// }
-// catch(AxisFault e)
-// {
-// throw new KandulaGeneralException(e);
-// }
-// catch(Exception e)
-// {
-// //TODO
-// }
-//
-// case BACoordinatorStatus.STATUS_FAULTING:
-// baContext.unlock();
-// throw new InvalidStateException(
-// "Coordinator is in faulting state");
-//
-// case BACoordinatorStatus.STATUS_EXITING:
-// baContext.unlock();
-// throw new InvalidStateException(
-// "Coordinator is in exiting state");
-//
-// case BACoordinatorStatus.STATUS_ENDED:
-// baContext.unlock();
-// throw new InvalidStateException(
-// "Coordinator is in exiting state");
-// }
-//}//End - Compensate
-//
-////Start Faulted
-//public void PCFaultedOperation(BAActivityContext baContext, String enlishmentID)
-//throws AbstractKandulaException
-//{
-// baContext.lock();
-// BAParticipantInformation baParticipantInformation = baContext.getParticipant(enlishmentID);
-// BAParticipantCompletionParticipantServiceStub pcpsStub;
-// switch(baContext.getStatus())
-// {
-// case BACoordinatorStatus.STATUS_ACTIVE:
-// baContext.unlock();
-// throw new InvalidStateException(
-// "Coordinator is in active state");
-//
-// case BACoordinatorStatus.STATUS_CANCELLING:
-// baContext.unlock();
-// throw new InvalidStateException(
-// "Coordinator is in cancelling state");
-//
-// case BACoordinatorStatus.STATUS_COMPLETED:
-// baContext.unlock();
-// throw new InvalidStateException(
-// "Coordinator is in completed state");
-//
-// case BACoordinatorStatus.STATUS_CLOSING:
-// baContext.unlock();
-// throw new InvalidStateException(
-// "Coordinator is in closing state");
-//
-// case BACoordinatorStatus.STATUS_COMPENSATING:
-// baContext.unlock();
-// throw new InvalidStateException(
-// "Coordinator is in compensating state");
-//
-// case BACoordinatorStatus.STATUS_FAULTING:
-// try{
-// String participantEndpointReference = baParticipantInformation.getEpr().toString();
-// pcpsStub = new BAParticipantCompletionParticipantServiceStub(participantEndpointReference);
-// Failed failedParam = new Failed();
-// pcpsStub.FailedOperation(failedParam);
-// baContext.setStatus(BACoordinatorStatus.STATUS_ENDED);
-// baParticipantInformation.setStatus(Status.BACoordinatorStatus.STATUS_ENDED);
-// baContext.unlock();
-// }
-// catch(AxisFault e)
-// {
-// throw new KandulaGeneralException(e);
-// }
-// catch(Exception e)
-// {
-// //TODO
-// }
-//
-// case BACoordinatorStatus.STATUS_EXITING:
-// baContext.unlock();
-// throw new InvalidStateException(
-// "Coordinator is in exiting state");
-//
-// case BACoordinatorStatus.STATUS_ENDED:
-// try{
-// String participantEndpointReference = baParticipantInformation.getEpr().toString();
-// pcpsStub = new BAParticipantCompletionParticipantServiceStub(participantEndpointReference);
-// Failed failedParam = new Failed();
-// pcpsStub.FailedOperation(failedParam);
-// baContext.unlock();
-// }
-// catch(AxisFault e)
-// {
-// throw new KandulaGeneralException(e);
-// }
-// catch(Exception e)
-// {
-// //TODO
-// }
-// }
-//}
-////End Faulted
-//
-////Start - Exited
-//public void PCExitedOperation(AbstractContext context, String enlishmentID)
-//throws AbstractKandulaException
-//{
-// BAParticipantCompletionParticipantServiceStub pcpsStub;
-// BAActivityContext baContext = (BAActivityContext) context;
-// baContext.lock();
-// BAParticipantInformation exitingParticipant = baContext.getParticipant(enlishmentID);
-//
-// switch(baContext.getStatus())
-// {
-// case BACoordinatorStatus.STATUS_ACTIVE:
-// baContext.unlock();
-// throw new InvalidStateException(
-// "Coordinator is in active state");
-//
-// case BACoordinatorStatus.STATUS_CANCELLING:
-// baContext.unlock();
-// throw new InvalidStateException(
-// "Coordinator is in canceling state");
-//
-// case BACoordinatorStatus.STATUS_COMPLETED:
-// baContext.unlock();
-// throw new InvalidStateException(
-// "Coordinator is in completed state");
-//
-// case BACoordinatorStatus.STATUS_CLOSING:
-// baContext.unlock();
-// throw new InvalidStateException(
-// "Coordinator is in closing state");
-//
-// case BACoordinatorStatus.STATUS_COMPENSATING:
-// baContext.unlock();
-// throw new InvalidStateException(
-// "Coordinator is in compensating state");
-//
-// case BACoordinatorStatus.STATUS_FAULTING:
-// baContext.unlock();
-// throw new InvalidStateException(
-// "Coordinator is in faulting state");
-//
-// case BACoordinatorStatus.STATUS_EXITING:
-// try{
-// pcpsStub = new BAParticipantCompletionParticipantServiceStub(((exitingParticipant.getEpr()).toString()));
-// Exited exitedParam = new Exited();
-// pcpsStub.ExitedOperation(exitedParam);
-// exitingParticipant.setStatus(Status.BACoordinatorStatus.STATUS_ENDED);
-// baContext.setStatus(BACoordinatorStatus.STATUS_ENDED);
-// baContext.unlock();
-// }
-// catch(AxisFault e)
-// {
-// throw new KandulaGeneralException(e);
-// }
-// catch(Exception e)
-// {
-// //TODO
-// }
-// case BACoordinatorStatus.STATUS_ENDED:
-// try{
-// pcpsStub = new BAParticipantCompletionParticipantServiceStub(((exitingParticipant.getEpr()).toString()));
-// Exited exitedParam = new Exited();
-// pcpsStub.ExitedOperation(exitedParam);
-// baContext.setStatus(Status.BACoordinatorStatus.STATUS_ENDED);
-// baContext.unlock();
-// }
-// catch(AxisFault e)
-// {
-// throw new KandulaGeneralException(e);
-// }
-// catch(Exception e)
-// {
-// //TODO
-// }
-// }
-//}
-////End Exited
-//
-////***********************************************************************************
-///**
-// * Coordinator View of BusinessAgreement with Coordinator Completion
-// */
-//
-///**
-// * Handling Protocol Messages recieved by the Coordinator[sent by participant] </a>
-// */
-////1. Start CCExit
-//public void CCExitOperation(AbstractContext context, String enlishmentID)
-//throws AbstractKandulaException
-//{
-// BAActivityContext baContext = (BAActivityContext) context;
-// baContext.lock();
-// BAParticipantInformation baParticipantInfo = baContext.getParticipant(enlishmentID);
-// switch(baContext.getStatus())
-// {
-//
-// case BACoordinatorStatus.STATUS_ACTIVE:
-// try{
-// baContext.removeParticipant(enlishmentID);
-// int existingCount = baContext.getParticipantCount();
-// baContext.setParticipantCount(existingCount--);
-// baParticipantInfo.setStatus(Status.BACoordinatorStatus.STATUS_EXITING);
-// baContext.setStatus(BACoordinatorStatus.STATUS_EXITING);
-// baContext.unlock();
-// this.CCExitedOperation(baContext,enlishmentID);
-//
-// }
-// catch(Exception e)
-// {
-// throw new KandulaGeneralException(e);
-// }
-//
-// case BACoordinatorStatus.STATUS_CANCELLING:
-// try{
-// baContext.removeParticipant(enlishmentID);
-// int existingCount = baContext.getParticipantCount();
-// baContext.setParticipantCount(existingCount--);
-// baParticipantInfo.setStatus(Status.BACoordinatorStatus.STATUS_EXITING);
-// baContext.setStatus(BACoordinatorStatus.STATUS_EXITING);
-// baContext.unlock();
-// this.CCExitedOperation(baContext,enlishmentID);
-// }
-// catch(Exception e)
-// {
-// throw new KandulaGeneralException(e);
-// }
-//
-// case BACoordinatorStatus.STATUS_CANCELING_COMPLETING:
-// try{
-// baContext.removeParticipant(enlishmentID);
-// int existingCount = baContext.getParticipantCount();
-// baContext.setParticipantCount(existingCount--);
-// baParticipantInfo.setStatus(Status.BACoordinatorStatus.STATUS_EXITING);
-// baContext.setStatus(BACoordinatorStatus.STATUS_EXITING);
-// baContext.unlock();
-// this.CCExitedOperation(baContext,enlishmentID);
-//
-// }
-// catch(Exception e)
-// {
-// throw new KandulaGeneralException(e);
-// }
-//
-// case BACoordinatorStatus.STATUS_COMPLETED:
-// baContext.unlock();
-// throw new InvalidStateException(
-// "Coordinator is in completed state");
-//
-// case BACoordinatorStatus.STATUS_CLOSING:
-// baContext.unlock();
-// throw new InvalidStateException(
-// "Coordinator is in closing state");
-//
-// case BACoordinatorStatus.STATUS_COMPENSATING:
-// baContext.unlock();
-// throw new InvalidStateException(
-// "Coordinator is in compensating state");
-//
-// case BACoordinatorStatus.STATUS_FAULTING_COMPENSATING:
-// baContext.unlock();
-// throw new InvalidStateException(
-// "Coordinator is in faulting compensatingstate");
-//
-// case BACoordinatorStatus.STATUS_FAULTING_ACTIVE:
-// baContext.unlock();
-// throw new InvalidStateException(
-// "Coordinator is in faulting active state");
-//
-// case BACoordinatorStatus.STATUS_EXITING:
-// baContext.unlock();
-//
-// case BACoordinatorStatus.STATUS_ENDED:
-// try{
-// baContext.unlock();
-// this.CCExitedOperation(baContext,enlishmentID);
-// }
-// catch(Exception e)
-// {
-// throw new KandulaGeneralException(e);
-// }
-// }
-// }
-////End CCExit
-//
-////2. start CCCompleted
-//public void CCCompletedOperation(BAActivityContext baContext, String enlishmentID)
-//throws AbstractKandulaException
-//{
-// BAParticipantInformation baParticipantInformation= baContext.getParticipant(enlishmentID);
-// switch(baContext.getStatus())
-// {
-// case BACoordinatorStatus.STATUS_ACTIVE:
-// baContext.unlock();
-// throw new InvalidStateException(
-// "Coordinator is in active state");
-//
-// case BACoordinatorStatus.STATUS_CANCELLING_ACTIVE:
-// baContext.setStatus(BACoordinatorStatus.STATUS_CANCELLING);
-// baParticipantInformation.setStatus(Status.BACoordinatorStatus.STATUS_CANCELLING);
-// baContext.unlock();
-// throw new InvalidStateException(
-// "Coordinator is in canceling active state");
-//
-// case BACoordinatorStatus.STATUS_COMPLETED:
-// baContext.unlock();
-//
-// case BACoordinatorStatus.STATUS_CLOSING:
-// baContext.unlock();
-// CCCloseOperation(baContext,enlishmentID);
-// throw new InvalidStateException(
-// "Coordinator is in faulting active state");
-//
-// case BACoordinatorStatus.STATUS_COMPENSATING:
-// baContext.unlock();
-// throw new InvalidStateException(
-// "Coordinator is in compensating state");
-//
-// case BACoordinatorStatus.STATUS_FAULTING_COMPENSATING:
-// baContext.setStatus(BACoordinatorStatus.STATUS_FAULTING);
-// baParticipantInformation.setStatus(Status.BACoordinatorStatus.STATUS_FAULTING);
-// baContext.unlock();
-// throw new InvalidStateException(
-// "Coordinator is in faulting compensating state");
-//
-// case BACoordinatorStatus.STATUS_FAULTING_ACTIVE:
-// baContext.setStatus(BACoordinatorStatus.STATUS_FAULTING);
-// baParticipantInformation.setStatus(Status.BACoordinatorStatus.STATUS_FAULTING);
-// baContext.unlock();
-// throw new InvalidStateException(
-// "Coordinator is in faulting compensating state");
-//
-// case BACoordinatorStatus.STATUS_EXITING:
-// baContext.unlock();
-//
-// case BACoordinatorStatus.STATUS_ENDED:
-// baContext.unlock();
-// }
-//}
-////End - CCCompleted
-//
-//// 3. Start - Fault
-//public void CCFaultOperation(AbstractContext context, String enlishmentID)
-//throws AbstractKandulaException
-//{
-// BAActivityContext baContext = (BAActivityContext) context;
-// baContext.lock();
-// BAParticipantInformation baParticipantInformation= baContext.getParticipant(enlishmentID);
-// switch(baContext.getStatus())
-// {
-// case BACoordinatorStatus.STATUS_ACTIVE:
-// try{
-// baContext.setStatus(BACoordinatorStatus.STATUS_FAULTING_ACTIVE);
-// baParticipantInformation.setStatus(Status.BACoordinatorStatus.STATUS_FAULTING_ACTIVE);
-// baContext.unlock();
-// this.CCFaultedOperation(baContext,enlishmentID);
-//
-// }
-// catch(Exception e)
-// {
-// throw new KandulaGeneralException(e);
-// }
-//
-// case BACoordinatorStatus.STATUS_CANCELLING_ACTIVE:
-// try{
-// baContext.setStatus(BACoordinatorStatus.STATUS_FAULTING_ACTIVE);
-// baParticipantInformation.setStatus(Status.BACoordinatorStatus.STATUS_FAULTING_ACTIVE);
-// baContext.unlock();
-// this.CCFaultedOperation(baContext,enlishmentID);
-//
-// }
-// catch(Exception e)
-// {
-// throw new KandulaGeneralException(e);
-// }
-//
-// case BACoordinatorStatus.STATUS_CANCELING_COMPLETING:
-// try{
-// baContext.setStatus(BACoordinatorStatus.STATUS_FAULTING_ACTIVE);
-// baParticipantInformation.setStatus(Status.BACoordinatorStatus.STATUS_FAULTING_ACTIVE);
-// baContext.unlock();
-// this.CCFaultedOperation(baContext,enlishmentID);
-//
-// }
-// catch(Exception e)
-// {
-// throw new KandulaGeneralException(e);
-// }
-//
-// case BACoordinatorStatus.STATUS_COMPLETING:
-// try{
-// baContext.setStatus(BACoordinatorStatus.STATUS_FAULTING_ACTIVE);
-// baParticipantInformation.setStatus(Status.BACoordinatorStatus.STATUS_FAULTING_ACTIVE);
-// baContext.unlock();
-// this.CCFaultedOperation(baContext,enlishmentID);
-// }
-// catch(Exception e)
-// {
-// throw new KandulaGeneralException(e);
-// }
-//
-// case BACoordinatorStatus.STATUS_COMPLETED:
-// baContext.unlock();
-// throw new InvalidStateException(
-// "Coordinator is in completed state");
-//
-// case BACoordinatorStatus.STATUS_CLOSING:
-// baContext.unlock();
-// throw new InvalidStateException(
-// "Coordinator is in closing state");
-//
-// case BACoordinatorStatus.STATUS_COMPENSATING:
-// try{
-// baContext.setStatus(BACoordinatorStatus.STATUS_FAULTING_COMPENSATING);
-// baParticipantInformation.setStatus(Status.BACoordinatorStatus.STATUS_FAULTING_COMPENSATING);
-// this.CCFaultedOperation(baContext,enlishmentID);
-// baContext.unlock();
-// }
-// catch(Exception e)
-// {
-// throw new KandulaGeneralException(e);
-// }
-//
-// case BACoordinatorStatus.STATUS_FAULTING_COMPENSATING:
-// baContext.setStatus(BACoordinatorStatus.STATUS_FAULTING);
-// baParticipantInformation.setStatus(Status.BACoordinatorStatus.STATUS_FAULTING);
-// baContext.unlock();
-//
-// case BACoordinatorStatus.STATUS_FAULTING_ACTIVE:
-// baContext.setStatus(BACoordinatorStatus.STATUS_FAULTING);
-// baParticipantInformation.setStatus(Status.BACoordinatorStatus.STATUS_FAULTING);
-// baContext.unlock();
-// this.PCFaultedOperation(baContext,enlishmentID);
-//
-// case BACoordinatorStatus.STATUS_ENDED:
-// baContext.unlock();
-//
-// case BACoordinatorStatus.STATUS_EXITING:
-// baContext.unlock();
-// throw new InvalidStateException(
-// "Coordinator is in exiting state");
-//
-// }
-//}
-////End - Fault
-//
-////4. Canceled
-//public void CCCanceledOperation(BAActivityContext baContext,String enlishmentID)
-//throws AbstractKandulaException
-//{
-// BAParticipantInformation baParticipantInformation = baContext.getParticipant(enlishmentID);
-// switch(baContext.getStatus())
-// {
-// case BACoordinatorStatus.STATUS_ACTIVE:
-// baContext.unlock();
-// throw new InvalidStateException(
-// "Coordinator is in Active state");
-//
-// case BACoordinatorStatus.STATUS_COMPLETING:
-// baContext.unlock();
-// throw new InvalidStateException(
-// "Coordinator is in completing state");
-//
-// case BACoordinatorStatus.STATUS_COMPLETED:
-// baContext.unlock();
-// throw new InvalidStateException(
-// "Coordinator is in completed state");
-//
-// case BACoordinatorStatus.STATUS_CLOSING:
-// baContext.unlock();
-// throw new InvalidStateException(
-// "Coordinator is in closing state");
-//
-// case BACoordinatorStatus.STATUS_COMPENSATING:
-// baContext.unlock();
-// throw new InvalidStateException(
-// "Coordinator is in compensating state");
-//
-// case BACoordinatorStatus.STATUS_FAULTING_COMPENSATING:
-// baContext.setStatus(BACoordinatorStatus.STATUS_FAULTING);
-// baParticipantInformation.setStatus(Status.BACoordinatorStatus.STATUS_FAULTING);
-// baContext.unlock();
-// throw new InvalidStateException(
-// "Coordinator is in faulting Compensating state");
-//
-// case BACoordinatorStatus.STATUS_FAULTING_ACTIVE:
-// baContext.setStatus(BACoordinatorStatus.STATUS_FAULTING);
-// baParticipantInformation.setStatus(Status.BACoordinatorStatus.STATUS_FAULTING);
-// baContext.unlock();
-// throw new InvalidStateException(
-// "Coordinator is in faulting active state");
-//
-// case BACoordinatorStatus.STATUS_EXITING:
-// baContext.unlock();
-// throw new InvalidStateException(
-// "Coordinator is in exiting state");
-//
-// case BACoordinatorStatus.STATUS_ENDED:
-// baContext.unlock();
-// }
-// }
-////End Canceled
-//
-////5.Start -Closed
-//public void CCClosedOperation(BAActivityContext baContext,String enlishmentID)
-//throws AbstractKandulaException
-//{
-// BAParticipantInformation baPaticipantInformation = baContext.getParticipant(enlishmentID);
-// switch(baContext.getStatus())
-// {
-// case BACoordinatorStatus.STATUS_ACTIVE:
-// baContext.unlock();
-// throw new InvalidStateException(
-// "Coordinator is in Active state");
-//
-// case BACoordinatorStatus.STATUS_CANCELLING_ACTIVE:
-// baPaticipantInformation.setStatus(BACoordinatorStatus.STATUS_CANCELLING);
-// baContext.setStatus(BACoordinatorStatus.STATUS_CANCELLING);
-// baContext.unlock();
-// throw new InvalidStateException(
-// "Coordinator is in canceling active state");
-//
-// case BACoordinatorStatus.STATUS_CANCELING_COMPLETING:
-// baPaticipantInformation.setStatus(BACoordinatorStatus.STATUS_CANCELLING);
-// baContext.setStatus(BACoordinatorStatus.STATUS_CANCELLING);
-// baContext.unlock();
-// throw new InvalidStateException(
-// "Coordinator is in canceling completing state");
-//
-// case BACoordinatorStatus.STATUS_COMPLETING:
-// baContext.unlock();
-// throw new InvalidStateException(
-// "Coordinator is in completing state");
-//
-// case BACoordinatorStatus.STATUS_COMPLETED:
-// baContext.unlock();
-// throw new InvalidStateException(
-// "Coordinator is in completed state");
-//
-// case BACoordinatorStatus.STATUS_CLOSING:
-// baPaticipantInformation.setStatus(BACoordinatorStatus.STATUS_ENDED);
-// baContext.setStatus(BACoordinatorStatus.STATUS_ENDED);
-// baContext.unlock();
-//
-// case BACoordinatorStatus.STATUS_COMPENSATING:
-// baContext.unlock();
-// throw new InvalidStateException(
-// "Coordinator is in compensating state");
-//
-// case BACoordinatorStatus.STATUS_FAULTING_COMPENSATING:
-// baPaticipantInformation.setStatus(BACoordinatorStatus.STATUS_FAULTING);
-// baContext.setStatus(BACoordinatorStatus.STATUS_FAULTING);
-// baContext.unlock();
-// throw new InvalidStateException(
-// "Coordinator is in faulting Compensating state");
-//
-// case BACoordinatorStatus.STATUS_FAULTING_ACTIVE:
-// baPaticipantInformation.setStatus(BACoordinatorStatus.STATUS_FAULTING);
-// baContext.setStatus(BACoordinatorStatus.STATUS_FAULTING);
-// baContext.unlock();
-// throw new InvalidStateException(
-// "Coordinator is in faulting active state");
-//
-// case BACoordinatorStatus.STATUS_EXITING:
-// baContext.unlock();
-// throw new InvalidStateException(
-// "Coordinator is in exiting state");
-//
-// case BACoordinatorStatus.STATUS_ENDED:
-// baContext.unlock();
-// }
-// }
-////End Closed
-//
-//// Start - Compensated
-//public void CCCompensatedOperation(BAActivityContext baContext,String enlishmentID)
-//throws AbstractKandulaException
-//{
-// BAParticipantInformation baPaticipantInformation = baContext.getParticipant(enlishmentID);
-// switch(baContext.getStatus())
-// {
-// case BACoordinatorStatus.STATUS_ACTIVE:
-// baContext.unlock();
-// throw new InvalidStateException(
-// "Coordinator is in Active state");
-//
-// case BACoordinatorStatus.STATUS_CANCELLING_ACTIVE:
-// baPaticipantInformation.setStatus(BACoordinatorStatus.STATUS_CANCELLING);
-// baContext.setStatus(BACoordinatorStatus.STATUS_CANCELLING);
-// baContext.unlock();
-// throw new InvalidStateException(
-// "Coordinator is in canceling active state");
-//
-// case BACoordinatorStatus.STATUS_CANCELING_COMPLETING:
-// baPaticipantInformation.setStatus(BACoordinatorStatus.STATUS_CANCELLING);
-// baContext.setStatus(BACoordinatorStatus.STATUS_CANCELLING);
-// baContext.unlock();
-// throw new InvalidStateException(
-// "Coordinator is in canceling completing state");
-//
-// case BACoordinatorStatus.STATUS_COMPLETING:
-// baContext.unlock();
-// throw new InvalidStateException(
-// "Coordinator is in completing state");
-//
-// case BACoordinatorStatus.STATUS_COMPLETED:
-// baContext.unlock();
-// throw new InvalidStateException(
-// "Coordinator is in completed state");
-//
-// case BACoordinatorStatus.STATUS_CLOSING:
-// baContext.unlock();
-// throw new InvalidStateException(
-// "Coordinator is in closing state");
-//
-// case BACoordinatorStatus.STATUS_COMPENSATING:
-// baPaticipantInformation.setStatus(BACoordinatorStatus.STATUS_ENDED);
-// baContext.setStatus(BACoordinatorStatus.STATUS_ENDED);
-// baContext.unlock();
-//
-// case BACoordinatorStatus.STATUS_FAULTING_COMPENSATING:
-// baPaticipantInformation.setStatus(BACoordinatorStatus.STATUS_FAULTING);
-// baContext.setStatus(BACoordinatorStatus.STATUS_FAULTING);
-// baContext.unlock();
-// throw new InvalidStateException(
-// "Coordinator is in faulting Compensating state");
-//
-// case BACoordinatorStatus.STATUS_FAULTING_ACTIVE:
-// baPaticipantInformation.setStatus(BACoordinatorStatus.STATUS_FAULTING);
-// baContext.setStatus(BACoordinatorStatus.STATUS_FAULTING);
-// baContext.unlock();
-// throw new InvalidStateException(
-// "Coordinator is in faulting active state");
-//
-// case BACoordinatorStatus.STATUS_EXITING:
-// baContext.unlock();
-// throw new InvalidStateException(
-// "Coordinator is in exiting state");
-//
-// case BACoordinatorStatus.STATUS_ENDED:
-// baContext.unlock();
-// }
-// }
-////End -Compensated
-//
-///**
-// * Handling Protocol Messages sent by the Coordinator[sent by participant] </a>
-// */
-//
-//public void CCCancelOperation(AbstractContext context,String enlishmentID)
-//throws AbstractKandulaException
-//{
-// BAActivityContext baContext = (BAActivityContext) context;
-// baContext.lock();
-// BAParticipantInformation cancelingParticipant = baContext.getParticipant(enlishmentID);
-// BACoordinatorCompletionParticipantServiceStub ccpsStub;
-// switch(baContext.getStatus())
-// {
-// case BACoordinatorStatus.STATUS_ACTIVE:
-// try{
-// ccpsStub = new BACoordinatorCompletionParticipantServiceStub(((cancelingParticipant.getEpr()).toString()));
-// Cancel cancelParam = new Cancel();
-// ccpsStub.CancelOperation(cancelParam);
-// baContext.setStatus(BACoordinatorStatus.STATUS_CANCELLING_ACTIVE);
-// cancelingParticipant.setStatus(BACoordinatorStatus.STATUS_CANCELLING_ACTIVE);
-// baContext.unlock();
-// }
-// catch(AxisFault e)
-// {
-// throw new KandulaGeneralException(e);
-// }
-// catch(Exception e)
-// {
-// //TODO
-// }
-// case BACoordinatorStatus.STATUS_CANCELLING:
-// try{
-//
-// ccpsStub = new BACoordinatorCompletionParticipantServiceStub(((cancelingParticipant.getEpr()).toString()));
-// Cancel cancelParam = new Cancel();
-// ccpsStub.CancelOperation(cancelParam);
-// baContext.unlock();
-// }
-// catch(AxisFault e)
-// {
-// throw new KandulaGeneralException(e);
-// }
-// catch(Exception e)
-// {
-// //TODO
-// }
-//
-//
-// case BACoordinatorStatus.STATUS_COMPLETING:
-// try{
-//
-// ccpsStub = new BACoordinatorCompletionParticipantServiceStub(((cancelingParticipant.getEpr()).toString()));
-// Cancel cancelParam = new Cancel();
-// ccpsStub.CancelOperation(cancelParam);
-// baContext.setStatus(BACoordinatorStatus.STATUS_CANCELING_COMPLETING);
-// cancelingParticipant.setStatus(BACoordinatorStatus.STATUS_CANCELING_COMPLETING);
-// baContext.unlock();
-// }
-// catch(AxisFault e)
-// {
-// throw new KandulaGeneralException(e);
-// }
-// catch(Exception e)
-// {
-// //TODO
-// }
-//
-// case BACoordinatorStatus.STATUS_COMPLETED:
-// baContext.unlock();
-// throw new InvalidStateException(
-// "Coordinator is in completed state");
-//
-// case BACoordinatorStatus.STATUS_CLOSING:
-// baContext.unlock();
-// throw new InvalidStateException(
-// "Coordinator is in closing state");
-//
-// case BACoordinatorStatus.STATUS_COMPENSATING:
-// baContext.unlock();
-// throw new InvalidStateException(
-// "Coordinator is in compensated state");
-//
-// case BACoordinatorStatus.STATUS_FAULTING:
-// baContext.unlock();
-// throw new InvalidStateException(
-// "Coordinator is in faulting state");
-//
-// case BACoordinatorStatus.STATUS_EXITING:
-// baContext.unlock();
-// throw new InvalidStateException(
-// "Coordinator is in exiting state");
-//
-// case BACoordinatorStatus.STATUS_ENDED:
-// baContext.unlock();
-// throw new InvalidStateException(
-// "Coordinator is in ended state");
-// }
-//}//End Cancel
-//
-////Start - Complete
-//public void CCCompleteOperation(AbstractContext context,String enlishmentID)
-//throws AbstractKandulaException
-//{
-// BAActivityContext baContext = (BAActivityContext) context;
-// baContext.lock();
-// BAParticipantInformation cancelingParticipant = baContext.getParticipant(enlishmentID);
-// BACoordinatorCompletionParticipantServiceStub ccpsStub;
-// switch(baContext.getStatus())
-// {
-// case BACoordinatorStatus.STATUS_ACTIVE:
-// try{
-// ccpsStub = new BACoordinatorCompletionParticipantServiceStub(((cancelingParticipant.getEpr()).toString()));
-// Complete completeParam = new Complete();
-// ccpsStub.CompleteOperation(completeParam);
-// baContext.setStatus(BACoordinatorStatus.STATUS_COMPLETING);
-// cancelingParticipant.setStatus(BACoordinatorStatus.STATUS_COMPLETING);
-// baContext.unlock();
-// }
-// catch(AxisFault e)
-// {
-// throw new KandulaGeneralException(e);
-// }
-// catch(Exception e)
-// {
-// //TODO
-// }
-// case BACoordinatorStatus.STATUS_CANCELLING:
-// baContext.unlock();
-// throw new InvalidStateException(
-// "Coordinator is in cancelling state");
-//
-// case BACoordinatorStatus.STATUS_COMPLETING:
-// try{
-// ccpsStub = new BACoordinatorCompletionParticipantServiceStub(((cancelingParticipant.getEpr()).toString()));
-// Complete completeParam = new Complete();
-// ccpsStub.CompleteOperation(completeParam);
-// baContext.setStatus(BACoordinatorStatus.STATUS_COMPLETING);
-// cancelingParticipant.setStatus(BACoordinatorStatus.STATUS_COMPLETING);
-// baContext.unlock();
-// }
-// catch(AxisFault e)
-// {
-// throw new KandulaGeneralException(e);
-// }
-// catch(Exception e)
-// {
-// //TODO
-// }
-// case BACoordinatorStatus.STATUS_COMPLETED:
-// baContext.unlock();
-// throw new InvalidStateException(
-// "Coordinator is in completed state");
-//
-// case BACoordinatorStatus.STATUS_CLOSING:
-// baContext.unlock();
-// throw new InvalidStateException(
-// "Coordinator is in closing state");
-//
-// case BACoordinatorStatus.STATUS_COMPENSATING:
-// baContext.unlock();
-// throw new InvalidStateException(
-// "Coordinator is in compensating state");
-//
-// case BACoordinatorStatus.STATUS_FAULTING:
-// baContext.unlock();
-// throw new InvalidStateException(
-// "Coordinator is in faulting state");
-//
-// case BACoordinatorStatus.STATUS_EXITING:
-// baContext.unlock();
-// throw new InvalidStateException(
-// "Coordinator is in exiting state");
-//
-// case BACoordinatorStatus.STATUS_ENDED:
-// baContext.unlock();
-// throw new InvalidStateException(
-// "Coordinator is in ended state");
-// }
-//}
-////End - Complete
-//
-////Start - Close
-//public void CCCloseOperation(BAActivityContext baContext,String enlishmentID)
-//throws AbstractKandulaException
-//{
-// BAParticipantInformation baParticipantInformation = baContext.getParticipant(enlishmentID);
-// baContext.lock();
-// BACoordinatorCompletionParticipantServiceStub ccpsStub;
-// switch(baContext.getStatus())
-// {
-// case BACoordinatorStatus.STATUS_ACTIVE:
-// baContext.unlock();
-// throw new InvalidStateException(
-// "Coordinator is in active state");
-//
-// case BACoordinatorStatus.STATUS_CANCELLING:
-// baContext.unlock();
-// throw new InvalidStateException(
-// "Coordinator is in cancelling state");
-//
-// case BACoordinatorStatus.STATUS_COMPLETING:
-// baContext.unlock();
-// throw new InvalidStateException(
-// "Coordinator is in completing state");
-//
-// case BACoordinatorStatus.STATUS_COMPLETED:
-// try{
-// String participantEndpointReference = baParticipantInformation.getEpr().toString();
-// ccpsStub = new BACoordinatorCompletionParticipantServiceStub(participantEndpointReference);
-// Close closeParam = new Close();
-// ccpsStub.CloseOperation(closeParam);
-// baParticipantInformation.setStatus(BACoordinatorStatus.STATUS_CLOSING);
-// baContext.unlock();
-// }
-// catch(AxisFault e)
-// {
-// throw new KandulaGeneralException(e);
-// }
-// catch(Exception e)
-// {
-// //TODO
-// }
-//
-// case BACoordinatorStatus.STATUS_CLOSING:
-// try{
-//
-// String participantEndpointReference = baParticipantInformation.getEpr().toString();
-// ccpsStub = new BACoordinatorCompletionParticipantServiceStub(participantEndpointReference);
-// Close closeParam = new Close();
-// ccpsStub.CloseOperation(closeParam);
-// baParticipantInformation.setStatus(BACoordinatorStatus.STATUS_CLOSING);
-// baContext.unlock();
-// }
-// catch(AxisFault e)
-// {
-// throw new KandulaGeneralException(e);
-// }
-// catch(Exception e)
-// {
-// //TODO
-// }
-//
-// case BACoordinatorStatus.STATUS_COMPENSATING:
-// baContext.unlock();
-// throw new InvalidStateException(
-// "Coordinator is in compensating state");
-//
-// case BACoordinatorStatus.STATUS_FAULTING:
-// baContext.unlock();
-// throw new InvalidStateException(
-// "Coordinator is in faulting state");
-//
-// case BACoordinatorStatus.STATUS_EXITING:
-// baContext.unlock();
-// throw new InvalidStateException(
-// "Coordinator is in exiting state");
-//
-// case BACoordinatorStatus.STATUS_ENDED:
-// baContext.unlock();
-// throw new InvalidStateException(
-// "Coordinator is in exiting state");
-// }
-//}
-////End - Close
-//
-////Start - Compensate
-//public void CCCompensateOperation(BAActivityContext baContext,String enlishmentID)
-//throws AbstractKandulaException
-//{
-// BAParticipantInformation baParticipantInformation = baContext.getParticipant(enlishmentID);
-// baContext.lock();
-// BACoordinatorCompletionParticipantServiceStub ccpsStub;
-// switch(baContext.getStatus())
-// {
-// case BACoordinatorStatus.STATUS_ACTIVE:
-// baContext.unlock();
-// throw new InvalidStateException(
-// "Coordinator is in active state");
-//
-// case BACoordinatorStatus.STATUS_CANCELLING:
-// baContext.unlock();
-// throw new InvalidStateException(
-// "Coordinator is in cancelling state");
-//
-// case BACoordinatorStatus.STATUS_COMPLETING:
-// baContext.unlock();
-// throw new InvalidStateException(
-// "Coordinator is in completing state");
-//
-// case BACoordinatorStatus.STATUS_COMPLETED:
-// try{
-// String participantEndpointReference = baParticipantInformation.getEpr().toString();
-// ccpsStub = new BACoordinatorCompletionParticipantServiceStub(participantEndpointReference);
-// Compensate compensateParam = new Compensate();
-// ccpsStub.CompensateOperation(compensateParam);
-// baParticipantInformation.setStatus(BACoordinatorStatus.STATUS_COMPENSATING);
-// baContext.unlock();
-// }
-// catch(AxisFault e)
-// {
-// throw new KandulaGeneralException(e);
-// }
-// catch(Exception e)
-// {
-// //TODO
-// }
-//
-// case BACoordinatorStatus.STATUS_CLOSING:
-// baContext.unlock();
-// throw new InvalidStateException(
-// "Coordinator is in cancelling state");
-//
-// case BACoordinatorStatus.STATUS_COMPENSATING:
-// try{
-// String participantEndpointReference = baParticipantInformation.getEpr().toString();
-// ccpsStub = new BACoordinatorCompletionParticipantServiceStub(participantEndpointReference);
-// Compensate compensateParam = new Compensate();
-// ccpsStub.CompensateOperation(compensateParam);
-// baParticipantInformation.setStatus(BACoordinatorStatus.STATUS_COMPENSATING);
-// baContext.unlock();
-// }
-// catch(AxisFault e)
-// {
-// throw new KandulaGeneralException(e);
-// }
-// catch(Exception e)
-// {
-// //TODO
-// }
-//
-// case BACoordinatorStatus.STATUS_FAULTING:
-// baContext.unlock();
-// throw new InvalidStateException(
-// "Coordinator is in faulting state");
-//
-// case BACoordinatorStatus.STATUS_EXITING:
-// baContext.unlock();
-// throw new InvalidStateException(
-// "Coordinator is in exiting state");
-//
-// case BACoordinatorStatus.STATUS_ENDED:
-// baContext.unlock();
-// throw new InvalidStateException(
-// "Coordinator is in exiting state");
-// }
-//}
-////End - compensate
-////Start -Failed
-//public void CCFaultedOperation(BAActivityContext baContext, String enlishmentID)
-//throws AbstractKandulaException
-//{
-// baContext.lock();
-// BAParticipantInformation baParticipantInformation = baContext.getParticipant(enlishmentID);
-// BACoordinatorCompletionParticipantServiceStub ccpsStub;
-// switch(baContext.getStatus())
-// {
-// case BACoordinatorStatus.STATUS_ACTIVE:
-// baContext.unlock();
-// throw new InvalidStateException(
-// "Coordinator is in active state");
-//
-// case BACoordinatorStatus.STATUS_CANCELLING:
-// baContext.unlock();
-// throw new InvalidStateException(
-// "Coordinator is in cancelling state");
-//
-// case BACoordinatorStatus.STATUS_COMPLETING:
-// baContext.unlock();
-// throw new InvalidStateException(
-// "Coordinator is in completing state");
-//
-// case BACoordinatorStatus.STATUS_COMPLETED:
-// baContext.unlock();
-// throw new InvalidStateException(
-// "Coordinator is in completed state");
-//
-// case BACoordinatorStatus.STATUS_CLOSING:
-// baContext.unlock();
-// throw new InvalidStateException(
-// "Coordinator is in closing state");
-//
-// case BACoordinatorStatus.STATUS_COMPENSATING:
-// baContext.unlock();
-// throw new InvalidStateException(
-// "Coordinator is in compensating state");
-//
-// case BACoordinatorStatus.STATUS_FAULTING:
-// try{
-// String participantEndpointReference = baParticipantInformation.getEpr().toString();
-// ccpsStub = new BACoordinatorCompletionParticipantServiceStub(participantEndpointReference);
-// Failed failedParam = new Failed();
-// ccpsStub.FailedOperation(failedParam);
-// baContext.setStatus(BACoordinatorStatus.STATUS_ENDED);
-// baParticipantInformation.setStatus(Status.BACoordinatorStatus.STATUS_ENDED);
-// baContext.unlock();
-// }
-// catch(AxisFault e)
-// {
-// throw new KandulaGeneralException(e);
-// }
-// catch(Exception e)
-// {
-// //TODO
-// }
-//
-// case BACoordinatorStatus.STATUS_EXITING:
-// baContext.unlock();
-// throw new InvalidStateException(
-// "Coordinator is in exiting state");
-//
-// case BACoordinatorStatus.STATUS_ENDED:
-// try{
-// String participantEndpointReference = baParticipantInformation.getEpr().toString();
-// ccpsStub = new BACoordinatorCompletionParticipantServiceStub(participantEndpointReference);
-// Failed failedParam = new Failed();
-// ccpsStub.FailedOperation(failedParam);
-// baContext.unlock();
-// }
-// catch(AxisFault e)
-// {
-// throw new KandulaGeneralException(e);
-// }
-// catch(Exception e)
-// {
-// //TODO
-// }
-// }
-//
-//}
-////End - Failed
-////Start - Exited
-//public void CCExitedOperation(AbstractContext context,String enlishmentID)
-//throws AbstractKandulaException
-//{
-// BACoordinatorCompletionParticipantServiceStub ccpsStub;
-// BAActivityContext baContext = (BAActivityContext) context;
-// baContext.lock();
-// BAParticipantInformation exitingParticipant = baContext.getParticipant(enlishmentID);
-//
-// switch(baContext.getStatus())
-// {
-// case BACoordinatorStatus.STATUS_ACTIVE:
-// baContext.unlock();
-// throw new InvalidStateException(
-// "Coordinator is in active state");
-//
-// case BACoordinatorStatus.STATUS_CANCELLING:
-// baContext.unlock();
-// throw new InvalidStateException(
-// "Coordinator is in canceling state");
-//
-// case BACoordinatorStatus.STATUS_COMPLETING:
-// baContext.unlock();
-// throw new InvalidStateException(
-// "Coordinator is in canceling state");
-//
-// case BACoordinatorStatus.STATUS_COMPLETED:
-// baContext.unlock();
-// throw new InvalidStateException(
-// "Coordinator is in completed state");
-//
-// case BACoordinatorStatus.STATUS_CLOSING:
-// baContext.unlock();
-// throw new InvalidStateException(
-// "Coordinator is in closing state");
-//
-// case BACoordinatorStatus.STATUS_COMPENSATING:
-// baContext.unlock();
-// throw new InvalidStateException(
-// "Coordinator is in compensating state");
-//
-// case BACoordinatorStatus.STATUS_FAULTING:
-// baContext.unlock();
-// throw new InvalidStateException(
-// "Coordinator is in faulting state");
-//
-// case BACoordinatorStatus.STATUS_EXITING:
-// try{
-// ccpsStub = new BACoordinatorCompletionParticipantServiceStub(((exitingParticipant.getEpr()).toString()));
-// Exited exitedParam = new Exited();
-// ccpsStub.ExitedOperation(exitedParam);
-// exitingParticipant.setStatus(Status.BACoordinatorStatus.STATUS_ENDED);
-// baContext.setStatus(BACoordinatorStatus.STATUS_ENDED);
-// baContext.unlock();
-// }
-// catch(AxisFault e)
-// {
-// throw new KandulaGeneralException(e);
-// }
-// catch(Exception e)
-// {
-// //TODO
-// }
-// case BACoordinatorStatus.STATUS_ENDED:
-// try{
-// ccpsStub = new BACoordinatorCompletionParticipantServiceStub(((exitingParticipant.getEpr()).toString()));
-// Exited exitedParam = new Exited();
-// ccpsStub.ExitedOperation(exitedParam);
-// baContext.setStatus(Status.BACoordinatorStatus.STATUS_ENDED);
-// baContext.unlock();
-// }
-// catch(AxisFault e)
-// {
-// throw new KandulaGeneralException(e);
-// }
-// catch(Exception e)
-// {
-// //TODO
-// }
-// }
+ public void compensatedOperation(BAActivityContext baContext, String enlistmentID) throws AbstractKandulaException {
+ BAParticipantInformation baPaticipantInformation = baContext.getParticipant(enlistmentID);
+ switch (baPaticipantInformation.getStatus()) {
+ case BACoordinatorStatus.STATUS_ACTIVE:
+ case BACoordinatorStatus.STATUS_COMPLETED:
+ case BACoordinatorStatus.STATUS_CLOSING:
+ case BACoordinatorStatus.STATUS_FAULTING_COMPENSATING:
+ case BACoordinatorStatus.STATUS_FAULTING_ACTIVE:
+ case BACoordinatorStatus.STATUS_EXITING:
+ case BACoordinatorStatus.STATUS_CANCELLING:
+ case BACoordinatorStatus.STATUS_CANCELLING_ACTIVE:
+ case BACoordinatorStatus.STATUS_CANCELLING_COMPLETING:
+ case BACoordinatorStatus.STATUS_COMPLETING:
+ case BACoordinatorStatus.STATUS_FAULTING_COMPLETING:
+ log.fatal("WS_BA : " + baContext.getCoordinationContext().getActivityID()
+ + " : compensatedOperation : Coordinator is in" + baContext.getStatus()
+ + " (invalid) state");
+ throw new InvalidStateException("Coordinator is in" + baContext.getStatus() + "state");
-//}
-//End - Exited
+ case BACoordinatorStatus.STATUS_COMPENSATING:
+ baPaticipantInformation.setStatus(BACoordinatorStatus.STATUS_ENDED);
+ baContext.removeParticipant(baPaticipantInformation.getEnlistmentId());
+ if ((baContext.getcoordinatorCompletionParticipantsCount() == 0)
+ && (baContext.getparticipantCompletionParticipantCount() == 0)) {
+ baContext.setStatus(BACoordinatorStatus.STATUS_ENDED);
+ StorageUtils.forgetContext(baContext.getCoordinationContext().getActivityID());
+ }
+ break;
+ case BACoordinatorStatus.STATUS_ENDED:
+ break;
+ default:
+ log.fatal("WS_BA : " + baContext.getCoordinationContext().getActivityID()
+ + " : compensatedOperation : Coordinator is in" + baContext.getStatus()
+ + " (invalid) state, Defaulting");
+ throw new InvalidStateException("Coordinator is in" + baContext.getStatus() + "state");
+ }
+ }
+
+ /**
+ * Send the wsba:cancel message to the given participant
+ *
+ * @param baContext
+ * @param cancelingParticipant
+ * @throws AbstractKandulaException
+ */
+ public void cancelOperation(BAActivityContext baContext,
+ BAParticipantInformation cancelingParticipant) throws AbstractKandulaException {
+ baContext.lock();
+ switch (baContext.getStatus()) {
+ case BACoordinatorStatus.STATUS_COMPLETED:
+ case BACoordinatorStatus.STATUS_CLOSING:
+ case BACoordinatorStatus.STATUS_COMPENSATING:
+ case BACoordinatorStatus.STATUS_FAULTING:
+ case BACoordinatorStatus.STATUS_EXITING:
+ case BACoordinatorStatus.STATUS_ENDED:
+ baContext.unlock();
+ log.fatal("WS_BA : " + baContext.getCoordinationContext().getActivityID()
+ + " : cancelOperation : Coordinator is in" + baContext.getStatus()
+ + " (invalid) state");
+ throw new InvalidStateException("Coordinator is in" + baContext.getStatus() + "state");
+ case BACoordinatorStatus.STATUS_ACTIVE:
+ case BACoordinatorStatus.STATUS_CANCELLING:
+ baContext.unlock();
+ cancelingParticipant.setStatus(BACoordinatorStatus.STATUS_CANCELLING_ACTIVE);
+ try {
+ sendCancelMessage(cancelingParticipant);
+ } catch (Exception e) {
+ log.fatal("WS_BA : " + baContext.getCoordinationContext().getActivityID()
+ + " : cancelOperation :" + cancelingParticipant + " : " + e);
+ throw new KandulaGeneralException(e);
+ }
+ break;
+ case BACoordinatorStatus.STATUS_COMPLETING:
+ baContext.unlock();
+ cancelingParticipant.setStatus(BACoordinatorStatus.STATUS_CANCELLING_COMPLETING);
+ try {
+ sendCancelMessage(cancelingParticipant);
+ } catch (Exception e) {
+ log.fatal("WS_BA : " + baContext.getCoordinationContext().getActivityID()
+ + " : cancelOperation :" + cancelingParticipant + " : " + e);
+ throw new KandulaGeneralException(e);
+ }
+ break;
+ default:
+ log.fatal("WS_BA : " + baContext.getCoordinationContext().getActivityID()
+ + " : cancelOperation : Coordinator is in" + baContext.getStatus()
+ + " (invalid) state, Defaulting");
+ throw new InvalidStateException("Coordinator is in" + baContext.getStatus() + "state");
+ }
+
+ }
+
+ private void sendCancelMessage(BAParticipantInformation participantInformation)
+ throws AbstractKandulaException, RemoteException {
+ BACoordinatorCompletionParticipantServiceStub participantServiceStub;
+ participantServiceStub = new BACoordinatorCompletionParticipantServiceStub(
+ KandulaConfiguration.getInstance().getCoordinatorAxis2ConfigurationContext(), null);
+ participantServiceStub._getServiceClient().getOptions().setTo(
+ participantInformation.getEpr());
+ Cancel cancel = new Cancel();
+ cancel.setCancel(new NotificationType());
+ participantServiceStub.CancelOperation(cancel);
+ }
+
+ public void canceledOperation(BAActivityContext baContext, String enlistmentID)
+ throws AbstractKandulaException {
+ BAParticipantInformation cancelingParticipant = baContext.getParticipant(enlistmentID);
+ switch (cancelingParticipant.getStatus()) {
+ case BACoordinatorStatus.STATUS_ACTIVE:
+ case BACoordinatorStatus.STATUS_COMPLETED:
+ case BACoordinatorStatus.STATUS_COMPLETING:
+ case BACoordinatorStatus.STATUS_CLOSING:
+ case BACoordinatorStatus.STATUS_COMPENSATING:
+ case BACoordinatorStatus.STATUS_FAULTING_COMPENSATING:
+ case BACoordinatorStatus.STATUS_FAULTING_ACTIVE:
+ case BACoordinatorStatus.STATUS_FAULTING_COMPLETING:
+ case BACoordinatorStatus.STATUS_EXITING:
+ log.fatal("WS_BA : " + baContext.getCoordinationContext().getActivityID()
+ + " : canceledOperation : Coordinator is in" + baContext.getStatus()
+ + " (invalid) state");
+ throw new InvalidStateException("Coordinator is in" + baContext.getStatus() + "state");
+ case BACoordinatorStatus.STATUS_ENDED:
+ break;
+ case BACoordinatorStatus.STATUS_CANCELLING:
+ case BACoordinatorStatus.STATUS_CANCELLING_ACTIVE:
+ cancelingParticipant.setStatus(BACoordinatorStatus.STATUS_ENDED);
+ baContext.removeParticipant(enlistmentID);
+ break;
+ case BACoordinatorStatus.STATUS_CANCELLING_COMPLETING:
+ baContext.decrementCompletingParticipantCount();
+ cancelingParticipant.setStatus(BACoordinatorStatus.STATUS_ENDED);
+ baContext.removeParticipant(enlistmentID);
+ break;
+ default:
+ log.fatal("WS_BA : " + baContext.getCoordinationContext().getActivityID()
+ + " : canceledOperation : Coordinator is in" + baContext.getStatus()
+ + " (invalid) state, Defaulting");
+ throw new InvalidStateException("Coordinator is in" + baContext.getStatus() + "state");
+ }
+ }
+
+
+ public void exitOperation(BAActivityContext baContext, String enlistmentID)
+ throws AbstractKandulaException {
+ BAParticipantInformation cancelingParticipant = baContext.getParticipant(enlistmentID);
+ switch (cancelingParticipant.getStatus()) {
+ case BACoordinatorStatus.STATUS_COMPLETED:
+ case BACoordinatorStatus.STATUS_CLOSING:
+ case BACoordinatorStatus.STATUS_COMPENSATING:
+ case BACoordinatorStatus.STATUS_FAULTING_COMPENSATING:
+ case BACoordinatorStatus.STATUS_FAULTING_ACTIVE:
+ case BACoordinatorStatus.STATUS_FAULTING_COMPLETING:
+ log.fatal("WS_BA : " + baContext.getCoordinationContext().getActivityID()
+ + " : exitOperation : Coordinator is in" + baContext.getStatus()
+ + " (invalid) state");
+ throw new InvalidStateException("Coordinator is in" + baContext.getStatus() + "state");
+ case BACoordinatorStatus.STATUS_EXITING:
+ break;
+ case BACoordinatorStatus.STATUS_ENDED:
+ //resend exited
+ break;
+ case BACoordinatorStatus.STATUS_ACTIVE:
+ case BACoordinatorStatus.STATUS_CANCELLING_ACTIVE:
+ case BACoordinatorStatus.STATUS_CANCELLING_COMPLETING:
+ case BACoordinatorStatus.STATUS_COMPLETING:
+ case BACoordinatorStatus.STATUS_CANCELLING:
+ cancelingParticipant.setStatus(BACoordinatorStatus.STATUS_EXITING);
+ exited(baContext,cancelingParticipant);
+ baContext.removeParticipant(enlistmentID);
+
+ break;
+ default:
+ log.fatal("WS_BA : " + baContext.getCoordinationContext().getActivityID()
+ + " : exitOperation : Coordinator is in" + baContext.getStatus()
+ + " (invalid) state, Defaulting");
+ throw new InvalidStateException("Coordinator is in" + baContext.getStatus() + "state");
+ }
+ }
+
+ protected void exited(BAActivityContext baContext, BAParticipantInformation baParticipantInformation) throws AbstractKandulaException {
+ BACoordinatorCompletionParticipantServiceStub participantServiceStub;
+ switch (baParticipantInformation.getStatus()) {
+ case BACoordinatorStatus.STATUS_ACTIVE:
+ case BACoordinatorStatus.STATUS_CANCELLING:
+ case BACoordinatorStatus.STATUS_COMPENSATING:
+ case BACoordinatorStatus.STATUS_FAULTING:
+ case BACoordinatorStatus.STATUS_COMPLETED:
+ case BACoordinatorStatus.STATUS_CLOSING:
+ case BACoordinatorStatus.STATUS_COMPLETING:
+ log.fatal("WS_BA : " + baContext.getCoordinationContext().getActivityID()
+ + " : exited Operation : Coordinator is in" + baContext.getStatus()
+ + " (invalid) state");
+ throw new InvalidStateException("Coordinator is in" + baContext.getStatus() + "state");
+
+ case BACoordinatorStatus.STATUS_EXITING:
+ case BACoordinatorStatus.STATUS_ENDED:
+ try {
+ participantServiceStub = new BACoordinatorCompletionParticipantServiceStub(
+ KandulaConfiguration.getInstance()
+ .getCoordinatorAxis2ConfigurationContext(), null);
+ participantServiceStub._getServiceClient().getOptions().setTo(
+ baParticipantInformation.getEpr());
+ Exited exited = new Exited();
+ exited.setExited(new NotificationType());
+ baParticipantInformation.setStatus(BACoordinatorStatus.STATUS_ENDED);
+ participantServiceStub.ExitedOperation(exited);
+ } catch (Exception e) {
+ log.fatal("WS_BA : " + baContext.getCoordinationContext().getActivityID()
+ + " : exited Operation :" + baParticipantInformation + " : " + e);
+ throw new KandulaGeneralException(e);
+ }
+ break;
+ default:
+ log.fatal("WS_BA : " + baContext.getCoordinationContext().getActivityID()
+ + " : exited operation : Coordinator is in" + baContext.getStatus()
+ + " (invalid) state, Defaulting");
+ throw new InvalidStateException("Coordinator is in" + baContext.getStatus() + "state");
+ }
+ }
+ public void closedOperation(BAActivityContext baContext, String enlistmentID)
+ throws AbstractKandulaException {
+ BAParticipantInformation baPaticipantInformation = baContext.getParticipant(enlistmentID);
+ switch (baPaticipantInformation.getStatus()) {
+ case BACoordinatorStatus.STATUS_ACTIVE:
+ case BACoordinatorStatus.STATUS_COMPLETED:
+ case BACoordinatorStatus.STATUS_COMPENSATING:
+ case BACoordinatorStatus.STATUS_FAULTING_COMPENSATING:
+ case BACoordinatorStatus.STATUS_FAULTING_ACTIVE:
+ case BACoordinatorStatus.STATUS_EXITING:
+ case BACoordinatorStatus.STATUS_CANCELLING_ACTIVE:
+ case BACoordinatorStatus.STATUS_CANCELLING_COMPLETING:
+ case BACoordinatorStatus.STATUS_COMPLETING:
+ case BACoordinatorStatus.STATUS_FAULTING_COMPLETING:
+ case BACoordinatorStatus.STATUS_CANCELLING:
+ log.fatal("WS_BA : " + baContext.getCoordinationContext().getActivityID()
+ + " : closedOperation : Coordinator is in" + baContext.getStatus()
+ + " (invalid) state");
+ throw new InvalidStateException("Coordinator is in" + baContext.getStatus() + "state");
+ case BACoordinatorStatus.STATUS_ENDED:
+ break;
+ case BACoordinatorStatus.STATUS_CLOSING:
+ baPaticipantInformation.setStatus(BACoordinatorStatus.STATUS_ENDED);
+ baContext.removeParticipant(enlistmentID);
+ if ((baContext.getcoordinatorCompletionParticipantsCount() == 0)
+ && (baContext.getparticipantCompletionParticipantCount() == 0)) {
+ baContext.setStatus(BACoordinatorStatus.STATUS_ENDED);
+ StorageUtils.forgetContext(baContext.getCoordinationContext().getActivityID());
+ }
+ break;
+ }
+ }
+ // 3. Start - Fault
+ public void faultOperation(BAActivityContext baContext, String enlistmentID)
+ throws AbstractKandulaException {
+ BAParticipantInformation cancelingParticipant = baContext.getParticipant(enlistmentID);
+ switch (cancelingParticipant.getStatus()) {
+ case BACoordinatorStatus.STATUS_COMPLETED:
+ case BACoordinatorStatus.STATUS_CLOSING:
+ case BACoordinatorStatus.STATUS_EXITING:
+ log.fatal("WS_BA : " + baContext.getCoordinationContext().getActivityID()
+ + " : faultOperation : Coordinator is in" + baContext.getStatus()
+ + " (invalid) state");
+ throw new InvalidStateException("Coordinator is in" + baContext.getStatus() + "state");
+
+ case BACoordinatorStatus.STATUS_ENDED:
+ faultedOperation(baContext,cancelingParticipant);
+ break;
+ case BACoordinatorStatus.STATUS_COMPENSATING:
+ cancelingParticipant.setStatus(BACoordinatorStatus.STATUS_FAULTING_COMPENSATING);
+ faultedOperation(baContext,cancelingParticipant);
+ break;
+ case BACoordinatorStatus.STATUS_ACTIVE:
+ case BACoordinatorStatus.STATUS_CANCELLING_ACTIVE:
+ case BACoordinatorStatus.STATUS_CANCELLING_COMPLETING:
+ case BACoordinatorStatus.STATUS_COMPLETING:
+ case BACoordinatorStatus.STATUS_CANCELLING:
+ cancelingParticipant.setStatus(BACoordinatorStatus.STATUS_FAULTING_ACTIVE);
+ faultedOperation(baContext,cancelingParticipant);
+ break;
+ case BACoordinatorStatus.STATUS_FAULTING:
+ case BACoordinatorStatus.STATUS_FAULTING_ACTIVE:
+ case BACoordinatorStatus.STATUS_FAULTING_COMPENSATING:
+ case BACoordinatorStatus.STATUS_FAULTING_COMPLETING:
+ break;
+ default:
+ log.fatal("WS_BA : " + baContext.getCoordinationContext().getActivityID()
+ + " : faultOperation : Coordinator is in" + baContext.getStatus()
+ + " (invalid) state, Defaulting");
+ throw new InvalidStateException("Coordinator is in" + baContext.getStatus() + "state");
+ }
+ }
-}
\ No newline at end of file
+ protected void faultedOperation(BAActivityContext baContext,BAParticipantInformation baParticipantInformation) throws AbstractKandulaException {
+ BACoordinatorCompletionParticipantServiceStub participantServiceStub;
+ switch (baParticipantInformation.getStatus()) {
+ case BACoordinatorStatus.STATUS_ACTIVE:
+ case BACoordinatorStatus.STATUS_CANCELLING:
+ case BACoordinatorStatus.STATUS_COMPLETING:
+ case BACoordinatorStatus.STATUS_COMPLETED:
+ case BACoordinatorStatus.STATUS_CLOSING:
+ case BACoordinatorStatus.STATUS_COMPENSATING:
+ case BACoordinatorStatus.STATUS_EXITING:
+ log.fatal("WS_BA : " + baContext.getCoordinationContext().getActivityID()
+ + " : faultedOperation : Coordinator is in" + baContext.getStatus()
+ + " (invalid) state");
+ throw new InvalidStateException("Coordinator is in" + baContext.getStatus() + "state");
+ case BACoordinatorStatus.STATUS_ENDED:
+ case BACoordinatorStatus.STATUS_FAULTING:
+ case BACoordinatorStatus.STATUS_FAULTING_ACTIVE:
+ case BACoordinatorStatus.STATUS_FAULTING_COMPENSATING:
+ case BACoordinatorStatus.STATUS_FAULTING_COMPLETING:
+ case BACoordinatorStatus.STATUS_FAULTING_COMPLETED:
+ try {
+ participantServiceStub = new BACoordinatorCompletionParticipantServiceStub(
+ KandulaConfiguration.getInstance()
+ .getCoordinatorAxis2ConfigurationContext(), null);
+ participantServiceStub._getServiceClient().getOptions().setTo(
+ baParticipantInformation.getEpr());
+ Failed failed = new Failed();
+ failed.setFailed(new NotificationType());
+ baParticipantInformation.setStatus(BACoordinatorStatus.STATUS_ENDED);
+ baContext.removeParticipant(baParticipantInformation.getEnlistmentId());
+ participantServiceStub.FailedOperation(failed);
+ } catch (Exception e) {
+ log.fatal("WS_BA : " + baContext.getCoordinationContext().getActivityID()
+ + " : faultedOperation :" + baParticipantInformation + " : " + e);
+ throw new KandulaGeneralException(e);
+ }
+ break;
+ default:
+ log.fatal("WS_BA : " + baContext.getCoordinationContext().getActivityID()
+ + " : faultedOperation : Coordinator is in" + baParticipantInformation.getStatus()
+ + " (invalid) state, Defaulting");
+ throw new InvalidStateException("Coordinator is in" + baParticipantInformation.getStatus() + "state");
+ }
+ }
+
+ /**
+ * If the coordinator received a Completed message - then it checks whether
+ * all the participants have finished. This is done by checking whether
+ * allparticipantcount is equal to the failed + completed
+ * participants.(Since cancelled and exited participant are removed from the
+ * list). If all have finished If all are completed - send close to all If
+ * even one is faulted - send compensate for all
+ *
+ * @param baContext
+ * @param enlistmentID
+ * @throws AbstractKandulaException
+ */
+ public void completedOperation(final BAActivityContext baContext, String enlistmentID) throws AbstractKandulaException {
+ if (baContext == null) {
+ throw new IllegalStateException("No Activity Found for this Activity ID");
+ }
+ BAParticipantInformation baParticipantInformation = baContext.getParticipant(enlistmentID);
+
+ if (baParticipantInformation.getProtocol().equals(Constants.WS_BA_PC)) {
+ switch (baParticipantInformation.getStatus()) {
+ case BACoordinatorStatus.STATUS_COMPLETED:
+ case BACoordinatorStatus.STATUS_FAULTING_COMPENSATING:
+ case BACoordinatorStatus.STATUS_ENDED:
+ break;
+ case BACoordinatorStatus.STATUS_ACTIVE:
+ case BACoordinatorStatus.STATUS_CANCELLING:
+ baParticipantInformation.setStatus(BACoordinatorStatus.STATUS_COMPLETED);
+ baContext.decrementCompletingParticipantCount();
+ if (!baContext.hasMoreCompleting()) {
+ baContext.setStatus(BACoordinatorStatus.STATUS_COMPLETED);
+ log.debug("WS_BA : " + baContext.getCoordinationContext().getActivityID()
+ + " : " + "Decision to close.");
+ BusinessActivityCallBack callBack = baContext.getCallBack();
+ callBack.onComplete();
+ }
+ break;
+ case BACoordinatorStatus.STATUS_CLOSING:
+ closeOperation(baContext, baParticipantInformation.getEnlistmentId());
+ break;
+ case BACoordinatorStatus.STATUS_COMPENSATING:
+ compensateOperation(baContext, baParticipantInformation.getEnlistmentId());
+ break;
+ case BACoordinatorStatus.STATUS_FAULTING_ACTIVE:
+ case BACoordinatorStatus.STATUS_EXITING:
+ log.fatal("WS_BA : " + baContext.getCoordinationContext().getActivityID()
+ + " : atCompleted : Coordinator is in" + baContext.getStatus()
+ + " (invalid) state");
+ throw new InvalidStateException("Coordinator is in" + baContext.getStatus()
+ + "state");
+ default:
+ log.fatal("WS_BA : " + baContext.getCoordinationContext().getActivityID()
+ + " : atCompleted : Coordinator is in" + baContext.getStatus()
+ + " (invalid) state, Defaulting");
+ throw new InvalidStateException("Coordinator is in" + baContext.getStatus()
+ + "state");
+ }
+ } else if (baParticipantInformation.getProtocol().equals(Constants.WS_BA_CC)) {
+ switch (baParticipantInformation.getStatus()) {
+ case BACoordinatorStatus.STATUS_COMPLETED:
+ case BACoordinatorStatus.STATUS_FAULTING:
+ case BACoordinatorStatus.STATUS_ENDED:
+ break;
+
+ case BACoordinatorStatus.STATUS_CANCELLING_COMPLETING:
+ case BACoordinatorStatus.STATUS_COMPLETING:
+ baParticipantInformation.setStatus(BACoordinatorStatus.STATUS_COMPLETED);
+ baContext.decrementCompletingParticipantCount();
+ if (!baContext.hasMoreCompleting()) {
+ baContext.setStatus(BACoordinatorStatus.STATUS_COMPLETED);
+ log.debug("WS_BA : " + baContext.getCoordinationContext().getActivityID()
+ + " : " + "Decision to close.");
+ Runnable threadedTask = new Runnable() {
+ public void run() {
+ BusinessActivityCallBack callBack = baContext.getCallBack();
+ callBack.onComplete();
+ }
+ };
+ Thread thread = new Thread(threadedTask);
+ thread.start();
+ }
+ break;
+ case BACoordinatorStatus.STATUS_CLOSING:
+ closeOperation(baContext, baParticipantInformation.getEnlistmentId());
+ break;
+ case BACoordinatorStatus.STATUS_COMPENSATING:
+ compensateOperation(baContext, baParticipantInformation.getEnlistmentId());
+ break;
+ case BACoordinatorStatus.STATUS_FAULTING_ACTIVE:
+ case BACoordinatorStatus.STATUS_FAULTING_COMPLETING:
+ case BACoordinatorStatus.STATUS_EXITING:
+ case BACoordinatorStatus.STATUS_ACTIVE:
+ case BACoordinatorStatus.STATUS_CANCELLING_ACTIVE:
+ log.fatal("WS_BA : " + baContext.getCoordinationContext().getActivityID()
+ + " : atCompleted : Coordinator is in" + baContext.getStatus()
+ + " (invalid) state");
+ throw new InvalidStateException("Coordinator is in" + baContext.getStatus()
+ + "state");
+ default:
+ log.fatal("WS_BA : " + baContext.getCoordinationContext().getActivityID()
+ + " : atCompleted : Coordinator is in" + baContext.getStatus()
+ + " (invalid) state, Defaulting");
+ throw new InvalidStateException("Coordinator is in" + baContext.getStatus()
+ + "state");
+
+ }
+ }
+ }
+ /**
+ * After all the participants have completed sucessfully send close to all
+ *
+ * @param baContext
+ * @throws AbstractKandulaException
+ */
+ public void closeAllOperation(BAActivityContext baContext) throws AbstractKandulaException {
+ Iterator allParticipants = baContext.getAllParticipants();
+ baContext.setStatus(Status.BACoordinatorStatus.STATUS_CLOSING);
+ while (allParticipants.hasNext()) {
+ BAParticipantInformation participantInformation = (BAParticipantInformation) allParticipants
+ .next();
+ String enlistmentId = participantInformation.getEnlistmentId();
+ closeOperation(baContext, enlistmentId);
+ }
+ }
+
+ // After all the cparticipants have finished and if a even one faulted
+ // occured send compensate to all
+ public void compensateAllOperation(BAActivityContext baContext) throws AbstractKandulaException {
+ baContext.lock();
+ Iterator allparticipants = baContext.getAllParticipants();
+ baContext.setStatus(Status.BACoordinatorStatus.STATUS_COMPENSATING);
+ while (allparticipants.hasNext()) {
+ BAParticipantInformation pInformation = (BAParticipantInformation) allparticipants
+ .next();
+ String nextEnlistmentId = pInformation.getEnlistmentId();
+ compensateOperation(baContext, nextEnlistmentId);
+ }
+ }
+
+ public void finalizeMixedOutcomeActivity(BAActivityContext context, ArrayList closeParticipantsList,ArrayList compensateParticipantsList) throws AbstractKandulaException
+ {
+ Iterator iterator1 = compensateParticipantsList.iterator();
+ while (iterator1.hasNext()) {
+ BAParticipantInformation participantInformation = (BAParticipantInformation) iterator1.next();
+ compensateOperation(context,participantInformation.getEnlistmentId());
+ }
+ Iterator iterator = closeParticipantsList.iterator();
+ while (iterator.hasNext()) {
+ BAParticipantInformation participantInformation = (BAParticipantInformation) iterator.next();
+ closeOperation(context,participantInformation.getEnlistmentId());
+ }
+ }
+}
diff --git a/src/org/apache/kandula/coordinator/ba/BAParticipantInformation.java b/src/org/apache/kandula/coordinator/ba/BAParticipantInformation.java
new file mode 100644
index 0000000..a189396
--- /dev/null
+++ b/src/org/apache/kandula/coordinator/ba/BAParticipantInformation.java
@@ -0,0 +1,73 @@
+package org.apache.kandula.coordinator.ba;
+
+import org.apache.axis2.addressing.EndpointReference;
+import org.apache.kandula.Status;
+
+public class BAParticipantInformation {
+
+ private String enlistmentId;
+
+ private EndpointReference epr;
+
+ private String protocol;
+
+ private int status;
+
+ boolean criticalParticipant;
+
+ public BAParticipantInformation(EndpointReference epr, String protocol,
+ String enlistmentId) {
+ super();
+ this.epr = epr;
+ this.protocol = protocol;
+ this.enlistmentId = enlistmentId;
+ this.status = Status.BACoordinatorStatus.STATUS_ACTIVE;
+ }
+
+
+
+ /**
+ * @return Returns the Id which this participant is registered with the
+ * coordinator
+ */
+ public String getEnlistmentId() {
+ return enlistmentId;
+ }
+
+ /**
+ * @return Returns the epr of the participant
+ */
+ public EndpointReference getEpr() {
+ return epr;
+ }
+
+ /**
+ * @return Returns the protocol of the participant (Eg: WS-AT, WS-BA)
+ */
+ public String getProtocol() {
+ return protocol;
+ }
+
+ /**
+ * @return Returns the status of the participant
+ */
+ public int getStatus() {
+ return status;
+ }
+
+ public void setEpr(EndpointReference epr) {
+ this.epr = epr;
+ }
+
+ public void setStatus(int status) {
+ this.status = status;
+ }
+
+ public boolean setCriticality(boolean criticality) {
+ return criticalParticipant;
+ }
+
+ public boolean getCriticality() {
+ return criticalParticipant;
+ }
+}
diff --git a/src/org/apache/kandula/initiator/TransactionManager.java b/src/org/apache/kandula/initiator/TransactionManager.java
index 0ff67d8..5bb7dfb 100644
--- a/src/org/apache/kandula/initiator/TransactionManager.java
+++ b/src/org/apache/kandula/initiator/TransactionManager.java
@@ -1,18 +1,16 @@
/*
- * Copyright 2004 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
+ * Copyright 2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the License
+ * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
+ * or implied. See the License for the specific language governing permissions and limitations under
+ * the License.
+ *
*/
package org.apache.kandula.initiator;
@@ -37,6 +35,7 @@
import org.apache.kandula.wsat.completion.CompletionInitiatorServiceListener;
import org.apache.kandula.wscoor.ActivationServiceStub;
import org.apache.kandula.wscoor.RegistrationServiceStub;
+import org.oasis_open.docs.ws_tx.wscoor._2006._06.CoordinationContext_type3;
import org.oasis_open.docs.ws_tx.wscoor._2006._06.CreateCoordinationContext;
import org.oasis_open.docs.ws_tx.wscoor._2006._06.CreateCoordinationContextResponse;
import org.oasis_open.docs.ws_tx.wscoor._2006._06.CreateCoordinationContextResponseType;
@@ -46,16 +45,15 @@
import org.oasis_open.docs.ws_tx.wscoor._2006._06.RegisterType;
public class TransactionManager {
-
+
private static ThreadLocal threadInfo = new ThreadLocal();
+
private ConfigurationContext configurationContext;
- public TransactionManager(String axis2Home, String axis2Xml)
- throws AbstractKandulaException {
+ public TransactionManager(String axis2Home, String axis2Xml) throws AbstractKandulaException {
try {
configurationContext = ConfigurationContextFactory
- .createConfigurationContextFromFileSystem(axis2Home,
- axis2Xml);
+ .createConfigurationContextFromFileSystem(axis2Home, axis2Xml);
} catch (DeploymentException e) {
throw new KandulaGeneralException(e);
} catch (AxisFault e1) {
@@ -68,31 +66,30 @@
*/
public void begin(String coordinatorAddress) throws Exception {
- if (threadInfo.get()!=null)
- {
+ if (threadInfo.get() != null) {
throw new IllegalStateException();
}
- InitiatorContext initiatorTransaction = new InitiatorContext(Constants.WS_AT,coordinatorAddress);
+ InitiatorContext initiatorTransaction = new InitiatorContext(Constants.WS_AT,
+ coordinatorAddress);
CoordinationContext coordinationContext = createTransaction(initiatorTransaction);
initiatorTransaction.setCoordinationContext(coordinationContext);
threadInfo.set(initiatorTransaction);
}
-
-
public void commit() throws Exception {
InitiatorContext initiatorTransaction = getTransaction();
CompletionCallback completionCallback = new CompletionCallback(initiatorTransaction);
// Register for completion
- EndpointReference coordinationEPR = registerForCompletion(initiatorTransaction,completionCallback);
- initiatorTransaction.setCoordinationEPR(coordinationEPR);
+ EndpointReference coordinationEPR = registerForCompletion(initiatorTransaction,
+ completionCallback);
+ initiatorTransaction.setCoordinationEPR(coordinationEPR);
CompletionCoordinatorPortTypeRawXMLStub stub = new CompletionCoordinatorPortTypeRawXMLStub(
configurationContext, coordinationEPR);
stub.commitOperation();
while (!completionCallback.isComplete())
Thread.sleep(10);
-
+
if ((completionCallback.getResult() == Status.CoordinatorStatus.STATUS_ABORTING)) {
forgetTransaction();
throw new Exception("Aborted");
@@ -101,12 +98,13 @@
}
public void rollback() throws Exception {
- InitiatorContext initiatorTransaction = getTransaction();
+ InitiatorContext initiatorTransaction = getTransaction();
// Register for completion
CompletionCallback completionCallback = new CompletionCallback(initiatorTransaction);
// Register for completion
- EndpointReference coordinationEPR = registerForCompletion(initiatorTransaction,completionCallback);
- initiatorTransaction.setCoordinationEPR(coordinationEPR);
+ EndpointReference coordinationEPR = registerForCompletion(initiatorTransaction,
+ completionCallback);
+ initiatorTransaction.setCoordinationEPR(coordinationEPR);
CompletionCoordinatorPortTypeRawXMLStub stub = new CompletionCoordinatorPortTypeRawXMLStub(
configurationContext, coordinationEPR);
stub.rollbackOperation();
@@ -132,12 +130,10 @@
// threadInfo.set(null);
// }
- private static InitiatorContext getTransaction()
- throws AbstractKandulaException {
+ public static InitiatorContext getTransaction() throws AbstractKandulaException {
Object key = threadInfo.get();
- if (key!= null)
- {
- return (InitiatorContext)key;
+ if (key != null) {
+ return (InitiatorContext) key;
}
return null;
}
@@ -145,40 +141,48 @@
public static void forgetTransaction() {
threadInfo.set(null);
}
-
- private EndpointReference registerForCompletion(InitiatorContext initiatorTransaction, CompletionCallback completionCallback) throws AxisFault, IOException, MalformedURIException, RemoteException {
+
+ private EndpointReference registerForCompletion(InitiatorContext initiatorTransaction,
+ CompletionCallback completionCallback) throws AxisFault, IOException,
+ MalformedURIException, RemoteException {
RegistrationServiceStub registrationCoordinator = new RegistrationServiceStub(
- configurationContext,null);
- registrationCoordinator._getServiceClient().setTargetEPR(initiatorTransaction
- .getCoordinationContext().getRegistrationService());
- //setup the listener
+ configurationContext, null);
+ registrationCoordinator._getServiceClient().setTargetEPR(
+ initiatorTransaction.getCoordinationContext().getRegistrationService());
+ // setup the listener
CompletionInitiatorServiceListener listener = new CompletionInitiatorServiceListener();
- EndpointReference registrationRequeterPortEPR =listener.getEpr(completionCallback);
-
+ EndpointReference registrationRequeterPortEPR = listener.getEpr(completionCallback);
+
Register register = new Register();
RegisterType registerType = new RegisterType();
registerType.setProtocolIdentifier(new URI(Constants.WS_AT_COMPLETION));
- registerType.setParticipantProtocolService(EndpointReferenceFactory.getADBEPRTypeFromEPR(registrationRequeterPortEPR));
+ registerType.setParticipantProtocolService(EndpointReferenceFactory
+ .getEPRTypeFromEPR(registrationRequeterPortEPR));
register.setRegister(registerType);
- //Actual WS call for registeration
- RegisterResponse registerResponse = registrationCoordinator
- .RegisterOperation(register);
- EndpointReference coordinationEPR = EndpointReferenceFactory
- .getEPR(registerResponse.getRegisterResponse()
- .getCoordinatorProtocolService());
+ // Actual WS call for registeration
+ RegisterResponse registerResponse = registrationCoordinator.RegisterOperation(register);
+ EndpointReference coordinationEPR = EndpointReferenceFactory.getEPR(registerResponse
+ .getRegisterResponse().getCoordinatorProtocolService());
return coordinationEPR;
}
- private CoordinationContext createTransaction(InitiatorContext initiatorTransaction) throws AxisFault, MalformedURIException, RemoteException {
+ private CoordinationContext createTransaction(InitiatorContext initiatorTransaction)
+ throws AxisFault, MalformedURIException, RemoteException {
ActivationServiceStub activationCoordinator = new ActivationServiceStub(
- configurationContext,initiatorTransaction.getActivationEPR());
+ configurationContext, initiatorTransaction.getActivationEPR());
CreateCoordinationContext context = new CreateCoordinationContext();
CreateCoordinationContextType createCoordinationContextType = new CreateCoordinationContextType();
- createCoordinationContextType.setCoordinationType(new URI(initiatorTransaction.getCoordinationType()));
+ createCoordinationContextType.setCoordinationType(new URI(initiatorTransaction
+ .getCoordinationType()));
context.setCreateCoordinationContext(createCoordinationContextType);
- CreateCoordinationContextResponse response = activationCoordinator.CreateCoordinationContextOperation(context);
- CreateCoordinationContextResponseType createCoordinationContextResponse = response.getCreateCoordinationContextResponse();
- CoordinationContext coordinationContext = new ADBCoordinationContext(createCoordinationContextResponse.getCoordinationContext());
+ CreateCoordinationContextResponse response = activationCoordinator
+ .CreateCoordinationContextOperation(context);
+ CreateCoordinationContextResponseType createCoordinationContextResponse = response
+ .getCreateCoordinationContextResponse();
+ CoordinationContext_type3 coordinationContextType = createCoordinationContextResponse.getCoordinationContext();
+ coordinationContextType.setExtraAttributes(null);
+ CoordinationContext coordinationContext = new ADBCoordinationContext(
+ coordinationContextType);
return coordinationContext;
}
}
diff --git a/src/org/apache/kandula/initiator/TransactionOutHandler.java b/src/org/apache/kandula/initiator/TransactionOutHandler.java
index 337a737..39d693f 100644
--- a/src/org/apache/kandula/initiator/TransactionOutHandler.java
+++ b/src/org/apache/kandula/initiator/TransactionOutHandler.java
@@ -18,11 +18,8 @@
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
-import java.util.Iterator;
import javax.xml.namespace.QName;
-import javax.xml.stream.XMLStreamException;
-import javax.xml.stream.XMLStreamReader;
import org.apache.axiom.om.OMElement;
import org.apache.axiom.om.util.StAXUtils;
@@ -36,7 +33,6 @@
import org.apache.kandula.context.AbstractContext;
import org.apache.kandula.context.CoordinationContext;
import org.apache.kandula.faults.AbstractKandulaException;
-import org.apache.kandula.faults.KandulaGeneralException;
import org.oasis_open.docs.ws_tx.wscoor._2006._06.CoordinationContext_type3;
import org.xmlsoap.schemas.ws._2004._08.addressing.ReferenceParametersType;
@@ -47,13 +43,10 @@
*/
private static final Log log = LogFactory.getLog(TransactionOutHandler.class);
- private static ThreadLocal threadInfo = new ThreadLocal();
-
private static final long serialVersionUID = 4133392345837905499L;
public InvocationResponse invoke(MessageContext msgContext) throws AxisFault {
- InitiatorContext initiatorTransaction;
String wsaAction = msgContext.getWSAAction();
if ((wsaAction != Constants.WS_COOR_CREATE_COORDINATIONCONTEXT)
&& (wsaAction != Constants.WS_COOR_REGISTER)
@@ -62,8 +55,7 @@
try {
context = TransactionManager.getTransaction();
} catch (AbstractKandulaException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
+ throw new AxisFault(e);
}
if (context == null) {
context = msgContext.getProperty(Constants.Configuration.TRANSACTION_CONTEXT);
@@ -98,8 +90,11 @@
referenceParametersType.addExtraElement(omElement);
soapHeader.addChild(context_type32.getOMElement(new QName(Constants.WS_COOR,
"CoordinationContext"), soapHeader.getOMFactory()));
+ log.info("Transaction Context found for message ID" + msgContext.getMessageID()
+ + ". Participant ID :" + registrationID);
} else {
soapHeader.addChild(coorContext.toOM());
+ log.info("Transaction Context found for message ID" + msgContext.getMessageID());
}
} else {
@@ -109,17 +104,4 @@
}
return InvocationResponse.CONTINUE;
}
-
- private static void addParticipantIdentifier(OMElement coorContext, String participantID) {
- // Opps.. OMSourcedElementImpl.build() is broken
- coorContext.getFirstOMChild();
- OMElement registrationEPRElement = coorContext.getFirstChildWithName(new QName(
- "RegistrationService", Constants.WS_COOR));
- OMElement refParameters = registrationEPRElement.getFirstChildWithName(new QName(
- "ReferenceParameters", "http://schemas.xmlsoap.org/ws/2004/08/addressing"));
- OMElement omElement = registrationEPRElement.getOMFactory().createOMElement(
- Constants.PARTICIPANT_ID_PARAMETER, null);
- omElement.setText(participantID);
- refParameters.addChild(omElement);
- }
}
diff --git a/src/org/apache/kandula/participant/KandulaResource.java b/src/org/apache/kandula/participant/KandulaResource.java
index 35e6234..a214791 100644
--- a/src/org/apache/kandula/participant/KandulaResource.java
+++ b/src/org/apache/kandula/participant/KandulaResource.java
@@ -16,13 +16,10 @@
*/
package org.apache.kandula.participant;
+import org.apache.kandula.context.impl.ParticipantContext;
+
public interface KandulaResource {
- public boolean commit();
-
- public void rollback();
-
- public Vote prepare();
-
- public String getProtocol();
+ public void init(ParticipantContext context);
+ public String getProtocol();
}
\ No newline at end of file
diff --git a/src/org/apache/kandula/participant/ParticipantUtility.java b/src/org/apache/kandula/participant/ParticipantUtility.java
index a208e06..15ea25d 100644
--- a/src/org/apache/kandula/participant/ParticipantUtility.java
+++ b/src/org/apache/kandula/participant/ParticipantUtility.java
@@ -26,7 +26,7 @@
import org.apache.axis2.context.MessageContext;
import org.apache.axis2.databinding.types.URI;
import org.apache.kandula.Constants;
-import org.apache.kandula.context.impl.ATParticipantContext;
+import org.apache.kandula.context.impl.ParticipantContext;
import org.apache.kandula.faults.AbstractKandulaException;
import org.apache.kandula.utility.EndpointReferenceFactory;
import org.apache.kandula.utility.KandulaConfiguration;
@@ -40,7 +40,7 @@
public class ParticipantUtility {
public static void registerParticipant(
- ATParticipantContext participantContext,
+ ParticipantContext participantContext,
MessageContext messageContext) throws AxisFault {
try {
ConfigurationContext axis2ConfigurationContext = KandulaConfiguration
@@ -50,8 +50,8 @@
.getConfigurationContext();
}
EndpointReference participantProtocolService = EndpointReferenceFactory
- .getInstance().get2PCParticipantEndpoint(
- participantContext.getID());
+ .getInstance().getParticipantEndpoint(
+ participantContext.getID(),participantContext.getRegistrationProtocol());
RegistrationServiceStub registrationCoordinator = new RegistrationServiceStub(
axis2ConfigurationContext, null);
diff --git a/src/org/apache/kandula/participant/TransactionInHandler.java b/src/org/apache/kandula/participant/TransactionInHandler.java
index fd5a7f7..1137825 100644
--- a/src/org/apache/kandula/participant/TransactionInHandler.java
+++ b/src/org/apache/kandula/participant/TransactionInHandler.java
@@ -24,14 +24,22 @@
import org.apache.axis2.context.MessageContext;
import org.apache.axis2.description.Parameter;
import org.apache.axis2.handlers.AbstractHandler;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
import org.apache.kandula.Constants;
import org.apache.kandula.context.AbstractContext;
import org.apache.kandula.context.CoordinationContext;
-import org.apache.kandula.context.impl.ATParticipantContext;
+import org.apache.kandula.context.impl.ParticipantContext;
import org.apache.kandula.context.impl.SimpleCoordinationContext;
+import org.apache.kandula.participant.ba.ParticipantOutHandler;
import org.apache.kandula.storage.StorageUtils;
public class TransactionInHandler extends AbstractHandler {
+ /**
+ * Field log
+ */
+ private static final Log log = LogFactory.getLog(ParticipantOutHandler.class);
+
private static final long serialVersionUID = 2098581248112968550L;
@@ -42,7 +50,7 @@
&& (wsaAction != Constants.WS_COOR_REGISTER)
&& (wsaAction != Constants.WS_AT_COMMIT)
&& (wsaAction != Constants.WS_AT_ROLLBACK)) {
- ATParticipantContext context = new ATParticipantContext();
+ ParticipantContext context = new ParticipantContext();
SOAPHeader header = msgContext.getEnvelope().getHeader();
OMElement coordinationElement = header
.getFirstChildWithName(new QName(Constants.WS_COOR,
@@ -57,18 +65,19 @@
StorageUtils.putContext(context,context.getID(),msgContext);
msgContext.setProperty(AbstractContext.REQUESTER_ID,context.getID());
- Parameter resourceFile = msgContext.getParameter(
- Constants.KANDULA_RESOURCE);
+ msgContext.getOperationContext().setProperty(AbstractContext.REQUESTER_ID,context.getID());
+ Parameter resourceFile = msgContext.getParameter(Constants.KANDULA_RESOURCE);
//Resource not given. Registration delayed to the business logic
if (resourceFile != null) {
try {
- resource = (KandulaResource) Class.forName((String)resourceFile.getValue())
+ resource = (KandulaResource) Class.forName((String) resourceFile.getValue())
.newInstance();
+ context.setResource(resource);
} catch (Exception e) {
+ log.fatal("TransactionInHandler: Activity ID :"+context.getCoordinationContext().getActivityID()+" : "+e);
throw new AxisFault(e);
}
- context.setResource(resource);
ParticipantUtility.registerParticipant(context,msgContext);
}
}
diff --git a/src/org/apache/kandula/participant/at/KandulaAtomicResource.java b/src/org/apache/kandula/participant/at/KandulaAtomicResource.java
new file mode 100644
index 0000000..7351934
--- /dev/null
+++ b/src/org/apache/kandula/participant/at/KandulaAtomicResource.java
@@ -0,0 +1,19 @@
+package org.apache.kandula.participant.at;
+
+import org.apache.kandula.context.impl.ParticipantContext;
+import org.apache.kandula.participant.KandulaResource;
+
+public abstract class KandulaAtomicResource implements KandulaResource{
+
+ protected ParticipantContext context=null;
+
+ public void init(ParticipantContext context)
+ {
+ this.context = context;
+ }
+ public abstract boolean commit();
+
+ public abstract void rollback();
+
+ public abstract Vote prepare();
+}
\ No newline at end of file
diff --git a/src/org/apache/kandula/participant/ParticipantTransactionCoordinator.java b/src/org/apache/kandula/participant/at/ParticipantTransactionCoordinator.java
similarity index 87%
rename from src/org/apache/kandula/participant/ParticipantTransactionCoordinator.java
rename to src/org/apache/kandula/participant/at/ParticipantTransactionCoordinator.java
index 0aed77b..df6a7a8 100644
--- a/src/org/apache/kandula/participant/ParticipantTransactionCoordinator.java
+++ b/src/org/apache/kandula/participant/at/ParticipantTransactionCoordinator.java
@@ -14,11 +14,11 @@
* limitations under the License.
*
*/
-package org.apache.kandula.participant;
+package org.apache.kandula.participant.at;
import org.apache.kandula.Status;
import org.apache.kandula.context.AbstractContext;
-import org.apache.kandula.context.impl.ATParticipantContext;
+import org.apache.kandula.context.impl.ParticipantContext;
import org.apache.kandula.faults.AbstractKandulaException;
import org.apache.kandula.faults.InvalidStateException;
import org.apache.kandula.wsat.twopc.CoordinatorPortTypeRawXMLStub;
@@ -28,7 +28,7 @@
public void prepare(AbstractContext context)
throws AbstractKandulaException {
CoordinatorPortTypeRawXMLStub stub;
- ATParticipantContext atContext = (ATParticipantContext) context;
+ ParticipantContext atContext = (ParticipantContext) context;
atContext.lock();
switch (context.getStatus()) {
case (Status.CoordinatorStatus.STATUS_NONE):
@@ -52,7 +52,7 @@
case (Status.CoordinatorStatus.STATUS_ACTIVE):
atContext.setStatus(Status.CoordinatorStatus.STATUS_PREPARING);
atContext.unlock();
- KandulaResource resource = atContext.getResource();
+ KandulaAtomicResource resource = (KandulaAtomicResource)atContext.getResource();
Vote vote = resource.prepare();
stub = new CoordinatorPortTypeRawXMLStub(atContext
.getCoordinationEPR());
@@ -71,8 +71,8 @@
}
public void commit(AbstractContext context) throws AbstractKandulaException {
- ATParticipantContext atContext = (ATParticipantContext) context;
- boolean outcome = atContext.getResource().commit();
+ ParticipantContext atContext = (ParticipantContext) context;
+ boolean outcome = ((KandulaAtomicResource)atContext.getResource()).commit();
CoordinatorPortTypeRawXMLStub stub = new CoordinatorPortTypeRawXMLStub(
atContext.getCoordinationEPR());
if (outcome) {
@@ -107,8 +107,8 @@
}
public void rollback(AbstractContext context) throws AbstractKandulaException {
- ATParticipantContext atContext = (ATParticipantContext) context;
- atContext.getResource().rollback();
+ ParticipantContext atContext = (ParticipantContext) context;
+ ((KandulaAtomicResource)atContext.getResource()).rollback();
CoordinatorPortTypeRawXMLStub stub = new CoordinatorPortTypeRawXMLStub(
atContext.getCoordinationEPR());
stub.abortedOperation();
diff --git a/src/org/apache/kandula/participant/Vote.java b/src/org/apache/kandula/participant/at/Vote.java
similarity index 95%
rename from src/org/apache/kandula/participant/Vote.java
rename to src/org/apache/kandula/participant/at/Vote.java
index f4b182e..0d4eb1f 100644
--- a/src/org/apache/kandula/participant/Vote.java
+++ b/src/org/apache/kandula/participant/at/Vote.java
@@ -14,7 +14,7 @@
* limitations under the License.
*
*/
-package org.apache.kandula.participant;
+package org.apache.kandula.participant.at;
public class Vote {
diff --git a/src/org/apache/kandula/participant/ba/BAParticipantTransactionCoordinator.java b/src/org/apache/kandula/participant/ba/BAParticipantTransactionCoordinator.java
new file mode 100644
index 0000000..9330d2f
--- /dev/null
+++ b/src/org/apache/kandula/participant/ba/BAParticipantTransactionCoordinator.java
@@ -0,0 +1,224 @@
+package org.apache.kandula.participant.ba;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.kandula.Constants;
+import org.apache.kandula.Status;
+import org.apache.kandula.context.AbstractContext;
+import org.apache.kandula.context.impl.ParticipantContext;
+import org.apache.kandula.faults.AbstractKandulaException;
+import org.apache.kandula.faults.InvalidStateException;
+import org.apache.kandula.storage.StorageUtils;
+import org.apache.kandula.wsba.BACoordinatorCompletionParticipantServiceStub;
+import org.apache.kandula.wsba.BAParticipantCompletionCoordinatorServiceStub;
+
+public class BAParticipantTransactionCoordinator {
+
+ private static final Log log = LogFactory.getLog(BAParticipantTransactionCoordinator.class);
+
+ public void complete(ParticipantContext context) throws AbstractKandulaException {
+ BAParticipantTransactionSentCoordinator sentCoordinator;
+ switch (context.getStatus()) {
+ case (Status.BAParticipantStatus.STATUS_ACTIVE):
+ KandulaBusinessActivityResource resource = (KandulaBusinessActivityResource) context
+ .getResource();
+ context.setStatus(Status.BAParticipantStatus.STATUS_COMPLETING);
+ resource.complete();
+ sentCoordinator = new BAParticipantTransactionSentCoordinator();
+ sentCoordinator.completed(context);
+ break;
+ case (Status.BAParticipantStatus.STATUS_COMPLETED):
+ sentCoordinator = new BAParticipantTransactionSentCoordinator();
+ sentCoordinator.completed(context);
+ break;
+ case (Status.BAParticipantStatus.STATUS_WORK_DONE):
+ context.setStatus(Status.BAParticipantStatus.STATUS_COMPLETING);
+ sentCoordinator = new BAParticipantTransactionSentCoordinator();
+ sentCoordinator.completed(context);
+ break;
+ case (Status.BAParticipantStatus.STATUS_CANCELLING):
+ case (Status.BAParticipantStatus.STATUS_COMPLETING):
+ case (Status.BAParticipantStatus.STATUS_CLOSING):
+ case (Status.BAParticipantStatus.STATUS_COMPENSATING):
+ case (Status.BAParticipantStatus.STATUS_FAULTING_COMPENSATING):
+ case (Status.BAParticipantStatus.STATUS_ENDED):
+ break;
+
+ case (Status.BAParticipantStatus.STATUS_FAULTING_ACTIVE):
+ case (Status.BAParticipantStatus.STATUS_FAULTING_COMPLETED):
+ // TODO resend fault
+ // try{
+ // CCPStub = new BACoordinatorCompletionParticipantServiceStub();
+ // Failed failed= new Failed();
+ // CCPStub.FailedOperation(failed);
+ // context.setStatus(Status.BAParticipantStatus.STATUS_FAULTING_ACTIVE_COMPLETED);
+ // }catch(Exception e){
+ //
+ // }
+ break;
+
+ case (Status.BAParticipantStatus.STATUS_EXITING):
+ sentCoordinator = new BAParticipantTransactionSentCoordinator();
+ sentCoordinator.exit(context);
+ break;
+ }
+ }
+
+ public void close(ParticipantContext context) throws AbstractKandulaException {
+
+ switch (context.getStatus()) {
+ case (Status.BAParticipantStatus.STATUS_ACTIVE):
+ case (Status.BAParticipantStatus.STATUS_CANCELLING):
+ case (Status.BAParticipantStatus.STATUS_COMPLETING):
+ case (Status.BAParticipantStatus.STATUS_COMPENSATING):
+ case (Status.BAParticipantStatus.STATUS_FAULTING_ACTIVE):
+ case (Status.BAParticipantStatus.STATUS_FAULTING_COMPLETED):
+ case (Status.BAParticipantStatus.STATUS_FAULTING_COMPENSATING):
+ case (Status.BAParticipantStatus.STATUS_EXITING):
+ log.fatal("WS_BA : " + context.getCoordinationContext().getActivityID()
+ + " : completeOperation :" + context.getID() + " : " + " Coordinator is in"
+ + context.getStatus() + " (invalid) state");
+ throw new InvalidStateException();
+
+ case (Status.BAParticipantStatus.STATUS_COMPLETED):
+ KandulaBusinessActivityResource resource = (KandulaBusinessActivityResource) context
+ .getResource();
+
+ context.setStatus(Status.BAParticipantStatus.STATUS_CLOSING);
+ resource.close();
+ BAParticipantTransactionSentCoordinator sentCoordinator = new BAParticipantTransactionSentCoordinator();
+ sentCoordinator.closed(context);
+ break;
+
+ case (Status.BAParticipantStatus.STATUS_ENDED):
+ BAParticipantTransactionSentCoordinator sentCoordinator1 = new BAParticipantTransactionSentCoordinator();
+ sentCoordinator1.closed(context);
+ break;
+ case (Status.BAParticipantStatus.STATUS_CLOSING):
+ break;
+ }
+
+ }
+
+ public void cancel(ParticipantContext context) throws AbstractKandulaException {
+ BAParticipantTransactionSentCoordinator coordinator;
+ switch (context.getStatus()) {
+ case (Status.BAParticipantStatus.STATUS_CANCELLING):
+ case (Status.BAParticipantStatus.STATUS_CLOSING):
+ case (Status.BAParticipantStatus.STATUS_COMPENSATING):
+ case (Status.BAParticipantStatus.STATUS_FAULTING_COMPENSATING):
+ break;
+
+ case (Status.BAParticipantStatus.STATUS_ACTIVE):
+ case (Status.BAParticipantStatus.STATUS_COMPLETING):
+ case (Status.BAParticipantStatus.STATUS_WORK_DONE):
+ KandulaBusinessActivityResource resource = (KandulaBusinessActivityResource) context
+ .getResource();
+ context.setStatus(Status.BAParticipantStatus.STATUS_CANCELLING);
+ resource.cancel();
+ BAParticipantTransactionSentCoordinator sentCoordinator = new BAParticipantTransactionSentCoordinator();
+ sentCoordinator.canceled(context);
+ break;
+
+ case (Status.BAParticipantStatus.STATUS_COMPLETED):
+ coordinator = new BAParticipantTransactionSentCoordinator();
+ coordinator.completed(context);
+ break;
+ case (Status.BAParticipantStatus.STATUS_FAULTING_ACTIVE):
+ case (Status.BAParticipantStatus.STATUS_FAULTING_COMPLETED):
+ // resend fault
+ break;
+
+ case (Status.BAParticipantStatus.STATUS_EXITING):
+ coordinator = new BAParticipantTransactionSentCoordinator();
+ coordinator.exit(context);
+ break;
+ case (Status.BAParticipantStatus.STATUS_ENDED):
+ coordinator = new BAParticipantTransactionSentCoordinator();
+ coordinator.canceled(context);
+ break;
+ }
+ }
+
+ public void exited(ParticipantContext context) throws AbstractKandulaException {
+
+ BACoordinatorCompletionParticipantServiceStub CCPStub;
+ switch (context.getStatus()) {
+ case (Status.BAParticipantStatus.STATUS_ACTIVE):
+ case (Status.BAParticipantStatus.STATUS_CANCELLING):
+ case (Status.BAParticipantStatus.STATUS_COMPLETING):
+ case (Status.BAParticipantStatus.STATUS_COMPLETED):
+ case (Status.BAParticipantStatus.STATUS_CLOSING):
+ case (Status.BAParticipantStatus.STATUS_COMPENSATING):
+ case (Status.BAParticipantStatus.STATUS_FAULTING_ACTIVE):
+ case (Status.BAParticipantStatus.STATUS_FAULTING_COMPLETED):
+ case (Status.BAParticipantStatus.STATUS_FAULTING_COMPENSATING):
+ log.fatal("WS_BA : " + context.getCoordinationContext().getActivityID() + " : exited :"
+ + context.getID() + " : " + " Coordinator is in" + context.getStatus()
+ + " (invalid) state");
+ throw new InvalidStateException();
+ case (Status.BAParticipantStatus.STATUS_EXITING):
+ case (Status.BAParticipantStatus.STATUS_ENDED):
+ context.setStatus(Status.BAParticipantStatus.STATUS_ENDED);
+ StorageUtils.forgetContext(context.getID());
+ break;
+ }
+
+ }
+
+ public void compensate(ParticipantContext context) throws AbstractKandulaException {
+ BAParticipantTransactionSentCoordinator sentCoordinator;
+ switch (context.getStatus()) {
+ case (Status.BAParticipantStatus.STATUS_ACTIVE):
+ case (Status.BAParticipantStatus.STATUS_CANCELLING):
+ case (Status.BAParticipantStatus.STATUS_COMPLETING):
+ case (Status.BAParticipantStatus.STATUS_CLOSING):
+ case (Status.BAParticipantStatus.STATUS_FAULTING_ACTIVE):
+ case (Status.BAParticipantStatus.STATUS_FAULTING_COMPLETED):
+ case (Status.BAParticipantStatus.STATUS_EXITING):
+ throw new InvalidStateException();
+
+ case (Status.BAParticipantStatus.STATUS_COMPLETED):
+ KandulaBusinessActivityResource resource = (KandulaBusinessActivityResource) context
+ .getResource();
+ context.setStatus(Status.BAParticipantStatus.STATUS_COMPENSATING);
+ resource.compensate();
+ sentCoordinator = new BAParticipantTransactionSentCoordinator();
+ sentCoordinator.compensated(context);
+ case (Status.BAParticipantStatus.STATUS_COMPENSATING):
+ break;
+ case (Status.BAParticipantStatus.STATUS_FAULTING_COMPENSATING):
+ //resend fault
+ break;
+ case (Status.BAParticipantStatus.STATUS_ENDED):
+ sentCoordinator = new BAParticipantTransactionSentCoordinator();
+ sentCoordinator.compensated(context);
+ break;
+ }
+ }
+
+ public void Faulted(ParticipantContext context) throws AbstractKandulaException {
+ BACoordinatorCompletionParticipantServiceStub CCPStub;
+ switch (context.getStatus()) {
+ case (Status.BAParticipantStatus.STATUS_ACTIVE):
+ case (Status.BAParticipantStatus.STATUS_CANCELLING):
+ case (Status.BAParticipantStatus.STATUS_COMPLETING):
+ case (Status.BAParticipantStatus.STATUS_COMPLETED):
+ case (Status.BAParticipantStatus.STATUS_CLOSING):
+ case (Status.BAParticipantStatus.STATUS_COMPENSATING):
+ case (Status.BAParticipantStatus.STATUS_EXITING):
+ log.fatal("WS_BA : " + context.getCoordinationContext().getActivityID()
+ + " : Faulted :" + context.getID() + " : " + " Coordinator is in"
+ + context.getStatus() + " (invalid) state");
+ throw new InvalidStateException();
+ case (Status.BAParticipantStatus.STATUS_FAULTING_ACTIVE):
+ case (Status.BAParticipantStatus.STATUS_FAULTING_COMPLETED):
+ case (Status.BAParticipantStatus.STATUS_FAULTING_COMPENSATING):
+ context.setStatus(Status.BAParticipantStatus.STATUS_ENDED);
+ StorageUtils.forgetContext(context.getID());
+ break;
+ case (Status.BAParticipantStatus.STATUS_ENDED):
+ break;
+ }
+ }
+}
diff --git a/src/org/apache/kandula/participant/ba/BAParticipantTransactionSentCoordinator.java b/src/org/apache/kandula/participant/ba/BAParticipantTransactionSentCoordinator.java
new file mode 100644
index 0000000..07d0dcd
--- /dev/null
+++ b/src/org/apache/kandula/participant/ba/BAParticipantTransactionSentCoordinator.java
@@ -0,0 +1,261 @@
+package org.apache.kandula.participant.ba;
+
+import javax.xml.namespace.QName;
+
+import org.apache.axis2.context.MessageContext;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.kandula.Constants;
+import org.apache.kandula.Status;
+import org.apache.kandula.context.AbstractContext;
+import org.apache.kandula.context.impl.BAActivityContext;
+import org.apache.kandula.context.impl.ParticipantContext;
+import org.apache.kandula.faults.AbstractKandulaException;
+import org.apache.kandula.faults.InvalidStateException;
+import org.apache.kandula.faults.KandulaGeneralException;
+import org.apache.kandula.storage.StorageUtils;
+import org.apache.kandula.utility.KandulaConfiguration;
+import org.apache.kandula.wsba.BACoordinatorCompletionCoordinatorServiceStub;
+import org.apache.kandula.wsba.BACoordinatorCompletionParticipantServiceStub;
+import org.apache.kandula.wsba.BAParticipantCompletionCoordinatorServiceStub;
+import org.apache.kandula.wsba.BAParticipantCompletionParticipantServiceStub;
+import org.oasis_open.docs.ws_tx.wsba._2006._06.Canceled;
+import org.oasis_open.docs.ws_tx.wsba._2006._06.Closed;
+import org.oasis_open.docs.ws_tx.wsba._2006._06.Compensated;
+import org.oasis_open.docs.ws_tx.wsba._2006._06.Completed;
+import org.oasis_open.docs.ws_tx.wsba._2006._06.ExceptionType;
+import org.oasis_open.docs.ws_tx.wsba._2006._06.Exit;
+import org.oasis_open.docs.ws_tx.wsba._2006._06.Fail;
+import org.oasis_open.docs.ws_tx.wsba._2006._06.NotificationType;
+
+public class BAParticipantTransactionSentCoordinator {
+
+ private static final Log log = LogFactory.getLog(BAParticipantTransactionSentCoordinator.class);
+
+ public void completed(ParticipantContext context) throws AbstractKandulaException {
+
+ context.lock();
+ switch (context.getStatus()) {
+ case (Status.BAParticipantStatus.STATUS_COMPLETING):
+ case (Status.BAParticipantStatus.STATUS_COMPLETED):
+ context.unlock();
+ try {
+ BAParticipantCompletionCoordinatorServiceStub serviceStub = new BAParticipantCompletionCoordinatorServiceStub(
+ MessageContext.getCurrentMessageContext().getConfigurationContext(), null);
+ serviceStub._getServiceClient().getOptions().setTo(context.getCoordinationEPR());
+ Completed completed = new Completed();
+ completed.setCompleted(new NotificationType());
+ context.setStatus(Status.BAParticipantStatus.STATUS_COMPLETED);
+ serviceStub.CompletedOperation(completed);
+ } catch (Exception e) {
+ log.fatal("WS_BA : " + context.getCoordinationContext().getActivityID()
+ + " : completed :" + context.getID() + " : " + e);
+ throw new KandulaGeneralException(e);
+ }
+ break;
+ case (Status.BAParticipantStatus.STATUS_CANCELLING):
+ case (Status.BAParticipantStatus.STATUS_COMPENSATING):
+ case (Status.BAParticipantStatus.STATUS_ACTIVE):
+ case (Status.BAParticipantStatus.STATUS_CLOSING):
+ case (Status.BAParticipantStatus.STATUS_FAULTING):
+ case (Status.BAParticipantStatus.STATUS_EXITING):
+ case (Status.BAParticipantStatus.STATUS_ENDED):
+ log.fatal("WS_BA : " + context.getCoordinationContext().getActivityID()
+ + " : completed :" + context.getID() + " : " + " Participant is in"
+ + context.getStatus() + " (invalid) state");
+ throw new InvalidStateException(" Participant is in" + context.getStatus()
+ + " (invalid) state");
+ }
+ }
+
+ public void closed(ParticipantContext context) throws AbstractKandulaException {
+ BACoordinatorCompletionCoordinatorServiceStub coordinatorStub;
+ switch (context.getStatus()) {
+ case (Status.BAParticipantStatus.STATUS_ACTIVE):
+ case (Status.BAParticipantStatus.STATUS_CANCELLING):
+ case (Status.BAParticipantStatus.STATUS_COMPLETING):
+ case (Status.BAParticipantStatus.STATUS_COMPLETED):
+ case (Status.BAParticipantStatus.STATUS_COMPENSATING):
+ case (Status.BAParticipantStatus.STATUS_FAULTING):
+ case (Status.BAParticipantStatus.STATUS_EXITING):
+ log.fatal("WS_BA : " + context.getCoordinationContext().getActivityID() + " : closed :"
+ + context.getID() + " : " + " Participant is in" + context.getStatus()
+ + " (invalid) state");
+ throw new InvalidStateException(" Participant is in" + context.getStatus()
+ + " (invalid) state");
+ case (Status.BAParticipantStatus.STATUS_CLOSING):
+ case (Status.BAParticipantStatus.STATUS_ENDED):
+ try {
+ coordinatorStub = new BACoordinatorCompletionCoordinatorServiceStub(MessageContext
+ .getCurrentMessageContext().getConfigurationContext(), null);
+ coordinatorStub._getServiceClient().getOptions()
+ .setTo(context.getCoordinationEPR());
+ Closed closed = new Closed();
+ closed.setClosed(new NotificationType());
+ coordinatorStub.ClosedOperation(closed);
+ context.setStatus(Status.BAParticipantStatus.STATUS_ENDED);
+ StorageUtils.forgetContext(context.getID());
+ } catch (Exception e) {
+ log.fatal("WS_BA : " + context.getCoordinationContext().getActivityID()
+ + " : closed :" + context.getID() + " : " + e);
+ throw new KandulaGeneralException(e);
+ }
+ break;
+ }
+ }
+
+ public void canceled(ParticipantContext context) throws AbstractKandulaException {
+ switch (context.getStatus()) {
+ case (Status.BAParticipantStatus.STATUS_ACTIVE):
+ case (Status.BAParticipantStatus.STATUS_COMPLETING):
+ case (Status.BAParticipantStatus.STATUS_COMPLETED):
+ case (Status.BAParticipantStatus.STATUS_CLOSING):
+ case (Status.BAParticipantStatus.STATUS_COMPENSATING):
+ case (Status.BAParticipantStatus.STATUS_FAULTING):
+ case (Status.BAParticipantStatus.STATUS_EXITING):
+ log.fatal("WS_BA : " + context.getCoordinationContext().getActivityID()
+ + " : canceled :" + context.getID() + " : " + " Participant is in"
+ + context.getStatus() + " (invalid) state");
+ throw new InvalidStateException(" Participant is in" + context.getStatus()
+ + " (invalid) state");
+
+ case (Status.BAParticipantStatus.STATUS_CANCELLING):
+ case (Status.BAParticipantStatus.STATUS_ENDED):
+ try {
+ BACoordinatorCompletionCoordinatorServiceStub coordinatorServiceStub;
+ coordinatorServiceStub = new BACoordinatorCompletionCoordinatorServiceStub(
+ MessageContext.getCurrentMessageContext().getConfigurationContext(), null);
+ coordinatorServiceStub._getServiceClient().getOptions().setTo(
+ context.getCoordinationEPR());
+ Canceled canceled = new Canceled();
+ canceled.setCanceled(new NotificationType());
+ coordinatorServiceStub.CanceledOperation(canceled);
+ context.setStatus(Status.BAParticipantStatus.STATUS_ENDED);
+ StorageUtils.forgetContext(context.getID());
+ } catch (Exception e) {
+ log.fatal("WS_BA : " + context.getCoordinationContext().getActivityID()
+ + " : canceled :" + context.getID() + " : " + e);
+ throw new KandulaGeneralException(e);
+ }
+ break;
+ }
+ }
+
+ public void exit(ParticipantContext context) throws AbstractKandulaException {
+ BACoordinatorCompletionCoordinatorServiceStub coordinatorStub;
+ switch (context.getStatus()) {
+ case (Status.BAParticipantStatus.STATUS_ACTIVE):
+ case (Status.BAParticipantStatus.STATUS_COMPLETING):
+ case (Status.BAParticipantStatus.STATUS_EXITING):
+ try {
+ coordinatorStub = new BACoordinatorCompletionCoordinatorServiceStub(MessageContext
+ .getCurrentMessageContext().getConfigurationContext(), null);
+ coordinatorStub._getServiceClient().getOptions()
+ .setTo(context.getCoordinationEPR());
+ Exit exit = new Exit();
+ exit.setExit(new NotificationType());
+ context.setStatus(Status.BAParticipantStatus.STATUS_EXITING);
+ coordinatorStub.ExitOperation(exit);
+ } catch (Exception e) {
+ log.fatal("WS_BA : " + context.getCoordinationContext().getActivityID()
+ + " : closed :" + context.getID() + " : " + e);
+ throw new KandulaGeneralException(e);
+ }
+ break;
+ case (Status.BAParticipantStatus.STATUS_CANCELLING):
+ case (Status.BAParticipantStatus.STATUS_COMPLETED):
+ case (Status.BAParticipantStatus.STATUS_CLOSING):
+ case (Status.BAParticipantStatus.STATUS_COMPENSATING):
+ case (Status.BAParticipantStatus.STATUS_FAULTING):
+ case (Status.BAParticipantStatus.STATUS_ENDED):
+ log.fatal("WS_BA : " + context.getCoordinationContext().getActivityID() + " : exit :"
+ + context.getID() + " : " + " Participant is in" + context.getStatus()
+ + " (invalid) state");
+ throw new InvalidStateException(" Participant is in" + context.getStatus()
+ + " (invalid) state");
+ }
+ }
+
+ public void compensated(ParticipantContext context) throws AbstractKandulaException {
+ BACoordinatorCompletionCoordinatorServiceStub coordinatorStub;
+ switch (context.getStatus()) {
+ case (Status.BAParticipantStatus.STATUS_ACTIVE):
+ case (Status.BAParticipantStatus.STATUS_CANCELLING):
+ case (Status.BAParticipantStatus.STATUS_COMPLETING):
+ case (Status.BAParticipantStatus.STATUS_COMPLETED):
+ case (Status.BAParticipantStatus.STATUS_CLOSING):
+ case (Status.BAParticipantStatus.STATUS_FAULTING):
+ case (Status.BAParticipantStatus.STATUS_EXITING):
+ log.fatal("WS_BA : " + context.getCoordinationContext().getActivityID()
+ + " : compensated :" + context.getID() + " : " + " Participant is in"
+ + context.getStatus() + " (invalid) state");
+ throw new InvalidStateException(" Participant is in" + context.getStatus()
+ + " (invalid) state");
+ case (Status.BAParticipantStatus.STATUS_COMPENSATING):
+ case (Status.BAParticipantStatus.STATUS_ENDED):
+ try {
+ coordinatorStub = new BACoordinatorCompletionCoordinatorServiceStub(MessageContext
+ .getCurrentMessageContext().getConfigurationContext(), null);
+ coordinatorStub._getServiceClient().getOptions()
+ .setTo(context.getCoordinationEPR());
+ Compensated compensated = new Compensated();
+ compensated.setCompensated(new NotificationType());
+ context.setStatus(Status.BAParticipantStatus.STATUS_ENDED);
+ coordinatorStub.CompensatedOperation(compensated);
+ } catch (Exception e) {
+ log.fatal("WS_BA : " + context.getCoordinationContext().getActivityID()
+ + " : compensated :" + context.getID() + " : " + e);
+ throw new KandulaGeneralException(e);
+ }
+ break;
+ }
+ }
+
+ public void fault(ParticipantContext context) throws AbstractKandulaException {
+ switch (context.getStatus()) {
+ case (Status.BAParticipantStatus.STATUS_ACTIVE):
+ case (Status.BAParticipantStatus.STATUS_COMPLETING):
+ context.setStatus(Status.BAParticipantStatus.STATUS_FAULTING_ACTIVE);
+ sendFaultMessage(context);
+ break;
+ case (Status.BAParticipantStatus.STATUS_CANCELLING):
+ case (Status.BAParticipantStatus.STATUS_COMPLETED):
+ case (Status.BAParticipantStatus.STATUS_CLOSING):
+ case (Status.BAParticipantStatus.STATUS_EXITING):
+ case (Status.BAParticipantStatus.STATUS_ENDED):
+ log.fatal("WS_BA : " + context.getCoordinationContext().getActivityID() + " : Fault :"
+ + context.getID() + " : " + " Participant is in" + context.getStatus()
+ + " (invalid) state");
+ throw new InvalidStateException(" Participant is in" + context.getStatus()
+ + " (invalid) state");
+ case (Status.BAParticipantStatus.STATUS_COMPENSATING):
+ context.setStatus(Status.BAParticipantStatus.STATUS_FAULTING_COMPENSATING);
+ sendFaultMessage(context);
+ break;
+ case (Status.BAParticipantStatus.STATUS_FAULTING):
+ context.setStatus(Status.BAParticipantStatus.STATUS_FAULTING);
+ sendFaultMessage(context);
+ break;
+ }
+ }
+
+ private void sendFaultMessage(ParticipantContext context) throws AbstractKandulaException {
+ BACoordinatorCompletionCoordinatorServiceStub coordinatorStub;
+ try {
+ coordinatorStub = new BACoordinatorCompletionCoordinatorServiceStub(
+ KandulaConfiguration.getInstance().getPariticipantAxis2ConfigurationContext(),
+ null);
+ coordinatorStub._getServiceClient().getOptions().setTo(context.getCoordinationEPR());
+ Fail fail = new Fail();
+ ExceptionType exceptionType = new ExceptionType();
+ exceptionType.setExceptionIdentifier(new QName("Bimalee"));
+ fail.setFail(exceptionType);
+ context.setStatus(Status.BAParticipantStatus.STATUS_ENDED);
+ coordinatorStub.FailOperation(fail);
+ } catch (Exception e) {
+ log.fatal("WS_BA : " + context.getCoordinationContext().getActivityID()
+ + " : compensated :" + context.getID() + " : " + e);
+ throw new KandulaGeneralException(e);
+ }
+ }
+}
diff --git a/src/org/apache/kandula/participant/ba/KandulaBusinessActivityResource.java b/src/org/apache/kandula/participant/ba/KandulaBusinessActivityResource.java
new file mode 100644
index 0000000..b40c643
--- /dev/null
+++ b/src/org/apache/kandula/participant/ba/KandulaBusinessActivityResource.java
@@ -0,0 +1,29 @@
+package org.apache.kandula.participant.ba;
+
+import org.apache.kandula.context.impl.ParticipantContext;
+import org.apache.kandula.faults.AbstractKandulaException;
+import org.apache.kandula.participant.KandulaResource;
+
+public abstract class KandulaBusinessActivityResource implements KandulaResource{
+
+ protected ParticipantContext context= null;
+
+ public void init(ParticipantContext context)
+ {
+ this.context =context;
+ }
+ public abstract boolean compensate();
+
+ public abstract void complete() throws AbstractKandulaException;
+
+ public abstract void close();
+
+ public abstract void cancel();
+
+ public void exit() throws AbstractKandulaException
+ {
+ BAParticipantTransactionSentCoordinator coordinator = new BAParticipantTransactionSentCoordinator();
+ coordinator.exit(context);
+ }
+
+}
\ No newline at end of file
diff --git a/src/org/apache/kandula/participant/ba/ParticipantOutFaultHandler.java b/src/org/apache/kandula/participant/ba/ParticipantOutFaultHandler.java
new file mode 100644
index 0000000..08725a6
--- /dev/null
+++ b/src/org/apache/kandula/participant/ba/ParticipantOutFaultHandler.java
@@ -0,0 +1,45 @@
+package org.apache.kandula.participant.ba;
+
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.context.MessageContext;
+import org.apache.axis2.handlers.AbstractHandler;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.kandula.Constants;
+import org.apache.kandula.Status;
+import org.apache.kandula.context.AbstractContext;
+import org.apache.kandula.context.impl.ParticipantContext;
+import org.apache.kandula.faults.AbstractKandulaException;
+import org.apache.kandula.storage.StorageUtils;
+
+public class ParticipantOutFaultHandler extends AbstractHandler {
+
+ /**
+ * Field log
+ */
+ private static final Log log = LogFactory.getLog(ParticipantOutFaultHandler.class);
+
+ public InvocationResponse invoke(MessageContext msgContext) throws AxisFault {
+
+ Object property = msgContext.getOperationContext()
+ .getProperty(AbstractContext.REQUESTER_ID);
+ if (property != null) {
+ String reqID = (String) property;
+ AbstractContext context = StorageUtils.getContext(msgContext, reqID);
+ if (context != null) {
+ ParticipantContext participantContext = (ParticipantContext) context;
+ if (participantContext.getRegistrationProtocol().equals(Constants.WS_BA_CC)
+ || participantContext.getRegistrationProtocol().equals(Constants.WS_BA_PC)) {
+ // Notify the coordinator if the participant is wsba-pc
+ BAParticipantTransactionSentCoordinator coordinator = new BAParticipantTransactionSentCoordinator();
+ try {
+ coordinator.fault(participantContext);
+ } catch (AbstractKandulaException e) {
+ throw new AxisFault(e);
+ }
+ }
+ }
+ }
+ return InvocationResponse.CONTINUE;
+ }
+}
diff --git a/src/org/apache/kandula/participant/ba/ParticipantOutHandler.java b/src/org/apache/kandula/participant/ba/ParticipantOutHandler.java
new file mode 100644
index 0000000..2547230
--- /dev/null
+++ b/src/org/apache/kandula/participant/ba/ParticipantOutHandler.java
@@ -0,0 +1,48 @@
+package org.apache.kandula.participant.ba;
+
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.context.MessageContext;
+import org.apache.axis2.handlers.AbstractHandler;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.kandula.Constants;
+import org.apache.kandula.Status;
+import org.apache.kandula.context.AbstractContext;
+import org.apache.kandula.context.impl.ParticipantContext;
+import org.apache.kandula.faults.AbstractKandulaException;
+import org.apache.kandula.storage.StorageUtils;
+
+public class ParticipantOutHandler extends AbstractHandler {
+
+ /**
+ * Field log
+ */
+ private static final Log log = LogFactory.getLog(ParticipantOutHandler.class);
+
+ public InvocationResponse invoke(MessageContext msgContext) throws AxisFault {
+
+ String wsaAction = msgContext.getWSAAction();
+ Object property = msgContext.getOperationContext()
+ .getProperty(AbstractContext.REQUESTER_ID);
+ if (property != null) {
+ String reqID = (String) property;
+ AbstractContext context = StorageUtils.getContext(msgContext, reqID);
+ if (context != null) {
+ ParticipantContext participantContext = (ParticipantContext) context;
+ if (participantContext.getRegistrationProtocol().equals(Constants.WS_BA_CC)) {
+ participantContext.setStatus(Status.BAParticipantStatus.STATUS_WORK_DONE);
+ } else if (participantContext.getRegistrationProtocol().equals(Constants.WS_BA_PC)) {
+ // Notify the coordinator if the participant is wsba-pc
+ BAParticipantTransactionSentCoordinator coordinator = new BAParticipantTransactionSentCoordinator();
+ try {
+ participantContext.setStatus(Status.BAParticipantStatus.STATUS_COMPLETING);
+ coordinator.completed(participantContext);
+ } catch (AbstractKandulaException e) {
+ throw new AxisFault(e);
+ }
+ }
+ }
+ }
+ return InvocationResponse.CONTINUE;
+ }
+}
diff --git a/src/org/apache/kandula/storage/StorageUtils.java b/src/org/apache/kandula/storage/StorageUtils.java
index 2c16f5c..a41a67e 100644
--- a/src/org/apache/kandula/storage/StorageUtils.java
+++ b/src/org/apache/kandula/storage/StorageUtils.java
@@ -16,34 +16,59 @@
import org.apache.axis2.context.ConfigurationContext;
import org.apache.axis2.context.MessageContext;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
import org.apache.kandula.Constants;
import org.apache.kandula.context.AbstractContext;
+import org.apache.kandula.coordinator.Coordinator;
public class StorageUtils {
+
+ private static final Log log = LogFactory.getLog(StorageUtils.class);
+
+ public static AbstractContext getContext(MessageContext messageContext, String id) {
+ log.info("Kandula : Retrieved Context " + id + " from the store.");
+ Store store = getStore(messageContext.getServiceContext().getConfigurationContext());
+ return (AbstractContext) store.get(id);
+ }
+
public static AbstractContext getContext(String id) {
+ log.info("Kandula : Retrieved Context " + id + " from the store.");
Store store = getStore(MessageContext.getCurrentMessageContext().getServiceContext()
.getConfigurationContext());
return (AbstractContext) store.get(id);
}
public static void putContext(AbstractContext context) {
+ log.info("Kandula : Stored Context " + context.getCoordinationContext().getActivityID()
+ + " on the store.");
Store store = getStore(MessageContext.getCurrentMessageContext().getServiceContext()
.getConfigurationContext());
store.put(context.getCoordinationContext().getActivityID(), context);
}
public static void putContext(AbstractContext context, String id, MessageContext messageContext) {
+ log.info("Kandula : Stored Context " + context.getCoordinationContext().getActivityID()
+ + " on the store.");
Store store = getStore(messageContext.getServiceContext().getConfigurationContext());
store.put(id, context);
}
+ public static void forgetContext(String id) {
+ log.info("Kandula : Forgot Context " + id + " from the store.");
+ Store store = getStore(MessageContext.getCurrentMessageContext().getServiceContext()
+ .getConfigurationContext());
+ store.forget(id);
+ }
+
public static Store getStore(ConfigurationContext configurationContext) {
if (configurationContext == null)
return null;
Store store;
Object storeObect = configurationContext.getProperty(Constants.KANDULA_STORE);
if (storeObect == null) {
- store = new SimpleStore();
+ store = Coordinator.store;
+ // store = new SimpleStore();
configurationContext.setProperty(Constants.KANDULA_STORE, store);
} else {
store = (Store) storeObect;
diff --git a/src/org/apache/kandula/utility/EndpointReferenceFactory.java b/src/org/apache/kandula/utility/EndpointReferenceFactory.java
index 2b503f9..16dbaf6 100644
--- a/src/org/apache/kandula/utility/EndpointReferenceFactory.java
+++ b/src/org/apache/kandula/utility/EndpointReferenceFactory.java
@@ -68,10 +68,10 @@
}
public EndpointReference getCompletionEndpoint(String id) {
-
EndpointReference epr = new EndpointReference(configuration.getLocationForEPR()
+ "/axis2/services/CompletionCoordinator");
EndpointReferenceFactory.addReferenceProperty(epr, Constants.TRANSACTION_ID_PARAMETER, id);
+
return epr;
}
@@ -87,11 +87,25 @@
return epr;
}
- public EndpointReference get2PCParticipantEndpoint(String id) {
-
- EndpointReference epr = new EndpointReference(configuration.getLocationForEPR()
- + "/axis2/services/AtomicTransactionParticipant");
- EndpointReferenceFactory.addReferenceProperty(epr, Constants.REQUESTER_ID_PARAMETER, id);
+ public EndpointReference getParticipantEndpoint(String id, String protocol) {
+ EndpointReference epr = null;
+ if (protocol.equals(Constants.WS_AT_VOLATILE2PC)
+ || protocol.equals(Constants.WS_AT_DURABLE2PC)) {
+ epr = new EndpointReference(configuration.getLocationForEPR()
+ + "/axis2/services/AtomicTransactionParticipant");
+ EndpointReferenceFactory
+ .addReferenceProperty(epr, Constants.REQUESTER_ID_PARAMETER, id);
+ } else if (protocol.equals(Constants.WS_BA_CC)) {
+ epr = new EndpointReference(configuration.getLocationForEPR()
+ + "/axis2/services/BACoordinatorCompletionParticipantService");
+ EndpointReferenceFactory
+ .addReferenceProperty(epr, Constants.REQUESTER_ID_PARAMETER, id);
+ } else if (protocol.equals(Constants.WS_BA_CC)) {
+ epr = new EndpointReference(configuration.getLocationForEPR()
+ + "/axis2/services/BAParticipantCompletionParticipantService");
+ EndpointReferenceFactory
+ .addReferenceProperty(epr, Constants.REQUESTER_ID_PARAMETER, id);
+ }
return epr;
}
@@ -138,7 +152,7 @@
return new String(sb2.toString().substring(begin, begin + 18)).toUpperCase();
}
- public static void addReferenceProperty(EndpointReference epr, QName key, String Value) {
+ public static void addReferenceProperty(EndpointReference epr, QName key, String value) {
// We'll have to live with reference parameters for the moment
// Since Axis2 Addressing does not support ref properties well
HashMap refProperties;
@@ -147,7 +161,7 @@
}
OMLinkedListImplFactory factory = new OMLinkedListImplFactory();
OMElement omElement = factory.createOMElement(key, null);
- omElement.setText(Value);
+ omElement.setText(value);
refProperties.put(key, omElement);
epr.setReferenceParameters(refProperties);
}
@@ -175,18 +189,18 @@
return epr;
}
- public static void endpointToOM(EndpointReference epr, OMElement parentEPR, SOAPFactory factory) {
+ public static void endpointToOM(EndpointReference epr, OMElement parentElement, SOAPFactory factory) {
OMNamespace wsAddressing = factory.createOMNamespace(
AddressingConstants.Submission.WSA_NAMESPACE,
AddressingConstants.WSA_DEFAULT_PREFIX);
OMElement addressElement = factory.createOMElement("Address", wsAddressing);
addressElement.setText(epr.getAddress());
- parentEPR.addChild(addressElement);
+ parentElement.addChild(addressElement);
Map referenceValues = epr.getAllReferenceParameters();
if (referenceValues != null) {
OMElement refPropertyElement = factory.createOMElement("ReferenceParameters",
wsAddressing);
- parentEPR.addChild(refPropertyElement);
+ parentElement.addChild(refPropertyElement);
Iterator iterator = referenceValues.keySet().iterator();
while (iterator.hasNext()) {
QName key = (QName) iterator.next();
@@ -200,7 +214,7 @@
}
}
- public static OMElement endpointToOM(EndpointReference epr) {
+ public static OMElement endpointAddressToOM(EndpointReference epr) {
OMFactory factory = OMAbstractFactory.getOMFactory();
OMNamespace wsAddressing = factory.createOMNamespace(
AddressingConstants.Submission.WSA_NAMESPACE,
@@ -211,32 +225,59 @@
return addressElement;
}
- // bims
- public EndpointReference getAtoimcOutcomeCoordinatorEndpoint(String activityId,
+ public EndpointReference getAtomicOutcomePCCoordinatorEndpoint(String activityId,
String enlistmentId) {
// Activity ID to find Activity Context , EnlistmentID to find
// participant in activity
EndpointReference epr = new EndpointReference(configuration.getLocationForEPR()
- + "/axis2/services/AtomicBACoordinator");
+ + "/axis2/services/BAParticipantCompletionCoordinatorService");
+ EndpointReferenceFactory.addReferenceProperty(epr, Constants.TRANSACTION_ID_PARAMETER, activityId);
+ EndpointReferenceFactory.addReferenceProperty(epr, Constants.ENLISTMENT_ID_PARAMETER,
+ enlistmentId);
+ return epr;
+ }
+
+ public EndpointReference getMixedOutcomePCCoordinatorEndpoint(String activityId,
+ String enlistmentId) {
+ // Activity ID to find Activity Context , EnlistmentID to find
+ // participant in activity
+ EndpointReference epr = new EndpointReference(configuration.getLocationForEPR()
+ + "/axis2/services/BAParticipantCompletionCoordinatorService");
+ EndpointReferenceFactory.addReferenceProperty(epr, Constants.BA_ID_PARAMETER, activityId);
+ EndpointReferenceFactory.addReferenceProperty(epr, Constants.ENLISTMENT_ID_PARAMETER,
+ enlistmentId);
+ return epr;
+ }
+
+ public EndpointReference getAtomicOutcomeCCCoordinatorEndpoint(String activityId,
+ String enlistmentId) {
+ // Activity ID to find Activity Context , EnlistmentID to find
+ // participant in activity
+ EndpointReference epr = new EndpointReference(configuration.getLocationForEPR()
+ + "/axis2/services/BACoordinatorCompletionCoordinatorService");
+ EndpointReferenceFactory.addReferenceProperty(epr, Constants.TRANSACTION_ID_PARAMETER, activityId);
+ EndpointReferenceFactory.addReferenceProperty(epr, Constants.ENLISTMENT_ID_PARAMETER,
+ enlistmentId);
+ return epr;
+ }
+
+ public EndpointReference getMixedOutcomeCCCoordinatorEndpoint(String activityId,
+ String enlistmentId) {
+ // Activity ID to find Activity Context , EnlistmentID to find
+ // participant in activity
+ EndpointReference epr = new EndpointReference(configuration.getLocationForEPR()
+ + "/axis2/services/BACoordinatorCompletionCoordinatorService");
EndpointReferenceFactory.addReferenceProperty(epr, Constants.BA_ID_PARAMETER, activityId);
EndpointReferenceFactory.addReferenceProperty(epr, Constants.ENLISTMENT_ID_PARAMETER,
enlistmentId);
return epr;
}
- // bims
- public EndpointReference getMixedOutcomeCoordinatorEndpoint(String activityId,
- String enlistmentId) {
- // Activity ID to find Activity Context , EnlistmentID to find
- // participant in activity
- EndpointReference epr = new EndpointReference(configuration.getLocationForEPR()
- + "/axis2/services/MixedBACoordinator");
- EndpointReferenceFactory.addReferenceProperty(epr, Constants.BA_ID_PARAMETER, activityId);
- EndpointReferenceFactory.addReferenceProperty(epr, Constants.ENLISTMENT_ID_PARAMETER,
- enlistmentId);
- return epr;
- }
-
+ /**
+ * Util method to convert ADB generated EPR to a org.apache.axis2.addressing.EndpointReference
+ * @param endpointReferenceType
+ * @return
+ */
public static EndpointReference getEPR(EndpointReferenceType endpointReferenceType) {
EndpointReference endpointReference = new EndpointReference(endpointReferenceType
.getAddress().getAnyURI().toString());
@@ -257,7 +298,7 @@
* @return
* @throws MalformedURIException
*/
- public static EndpointReferenceType getADBEPRTypeFromEPR(EndpointReference endpointReference)
+ public static EndpointReferenceType getEPRTypeFromEPR(EndpointReference endpointReference)
throws MalformedURIException {
EndpointReferenceType endpointReferenceType = new EndpointReferenceType();
AttributedURI attributedURI = new AttributedURI();
diff --git a/src/org/apache/kandula/utility/KandulaConfiguration.java b/src/org/apache/kandula/utility/KandulaConfiguration.java
index 6b55245..043ed2d 100644
--- a/src/org/apache/kandula/utility/KandulaConfiguration.java
+++ b/src/org/apache/kandula/utility/KandulaConfiguration.java
@@ -74,13 +74,16 @@
String debug = "false";
+ private ConfigurationContext coordinatorConfigurationContext = null;
+
+ private ConfigurationContext participantConfigurationContext = null;
+
private KandulaConfiguration() {
String port = null;
String host = null;
- InputStream in = getClass().getClassLoader().getResourceAsStream(
- PROPERTY_FILE);
+ InputStream in = getClass().getClassLoader().getResourceAsStream(PROPERTY_FILE);
properties = new Properties();
try {
properties.load(in);
@@ -96,19 +99,16 @@
debug = "true";
}
- participantAxis2Xml = properties
- .getProperty(PARTICIPANT_AXIS2_CONF);
+ participantAxis2Xml = properties.getProperty(PARTICIPANT_AXIS2_CONF);
// if (participantAxis2Xml == null) {
// participantAxis2Xml = "axis2.xml";
// }
- kandulaListenerRepository = properties
- .getProperty(KANDULA_LISTENER_REPO);
+ kandulaListenerRepository = properties.getProperty(KANDULA_LISTENER_REPO);
// if (kandulaListenerRepository == null) {
// kandulaListenerRepository = ".";
// }
- kandulaListenerAxis2Xml = properties
- .getProperty(KANDULA_LISTENER_AXIS2XML);
+ kandulaListenerAxis2Xml = properties.getProperty(KANDULA_LISTENER_AXIS2XML);
// if (kandulaListenerAxis2Xml == null) {
// kandulaListenerRepository += "/axis2.xml";
// }
@@ -153,27 +153,28 @@
return instance;
}
-
/**
* @return a ConfigurationContext according to the coordinator Axis2.xml & repository configured.
* @throws AbstractKandulaException
*/
public ConfigurationContext getPariticipantAxis2ConfigurationContext()
throws AbstractKandulaException {
- try {
- if (coordinatorAxis2Conf != null && coordinatorAxis2Conf != "")
- {
- return ConfigurationContextFactory
- .createConfigurationContextFromFileSystem(
- participantRepository, participantAxis2Xml);
+ if (participantConfigurationContext == null) {
+ try {
+ if (coordinatorAxis2Conf != null && coordinatorAxis2Conf != "") {
+
+ participantConfigurationContext = ConfigurationContextFactory
+ .createConfigurationContextFromFileSystem(participantRepository,
+ participantAxis2Xml);
+ }
+
+ } catch (DeploymentException e) {
+ throw new KandulaGeneralException(e);
+ } catch (AxisFault e1) {
+ throw new KandulaGeneralException(e1);
}
-
- } catch (DeploymentException e) {
- throw new KandulaGeneralException(e);
- } catch (AxisFault e1) {
- throw new KandulaGeneralException(e1);
}
- return null;
+ return participantConfigurationContext;
}
public String getParticipantRepository() {
@@ -186,19 +187,20 @@
public ConfigurationContext getCoordinatorAxis2ConfigurationContext()
throws AbstractKandulaException {
- try {
- if (coordinatorAxis2Conf != null && coordinatorAxis2Conf != "")
- {
- return ConfigurationContextFactory
- .createConfigurationContextFromFileSystem(
- coordinatorRepo, coordinatorAxis2Conf);
+ if (coordinatorConfigurationContext == null) {
+ try {
+ if (coordinatorAxis2Conf != null && coordinatorAxis2Conf != "") {
+ coordinatorConfigurationContext = ConfigurationContextFactory
+ .createConfigurationContextFromFileSystem(coordinatorRepo,
+ coordinatorAxis2Conf);
+ }
+ } catch (DeploymentException e) {
+ throw new KandulaGeneralException(e);
+ } catch (AxisFault e1) {
+ throw new KandulaGeneralException(e1);
}
- } catch (DeploymentException e) {
- throw new KandulaGeneralException(e);
- } catch (AxisFault e1) {
- throw new KandulaGeneralException(e1);
}
- return null;
+ return coordinatorConfigurationContext;
}
public String getCoordinatorRepo() {
diff --git a/src/org/apache/kandula/wsat/twopc/CoordinatorPortTypeRawXMLSkeleton.java b/src/org/apache/kandula/wsat/twopc/CoordinatorPortTypeRawXMLSkeleton.java
index 63475d5..ed04210 100644
--- a/src/org/apache/kandula/wsat/twopc/CoordinatorPortTypeRawXMLSkeleton.java
+++ b/src/org/apache/kandula/wsat/twopc/CoordinatorPortTypeRawXMLSkeleton.java
@@ -23,7 +23,7 @@
import org.apache.kandula.context.impl.ATActivityContext;
import org.apache.kandula.coordinator.at.ATCoordinator;
import org.apache.kandula.faults.AbstractKandulaException;
-import org.apache.kandula.participant.Vote;
+import org.apache.kandula.participant.at.Vote;
import org.apache.kandula.storage.StorageUtils;
/**
diff --git a/src/org/apache/kandula/wsat/twopc/ParticipantPortTypeRawXMLSkeleton.java b/src/org/apache/kandula/wsat/twopc/ParticipantPortTypeRawXMLSkeleton.java
index 044ba2a..ee467a9 100644
--- a/src/org/apache/kandula/wsat/twopc/ParticipantPortTypeRawXMLSkeleton.java
+++ b/src/org/apache/kandula/wsat/twopc/ParticipantPortTypeRawXMLSkeleton.java
@@ -22,7 +22,7 @@
import org.apache.kandula.Constants;
import org.apache.kandula.context.AbstractContext;
import org.apache.kandula.faults.AbstractKandulaException;
-import org.apache.kandula.participant.ParticipantTransactionCoordinator;
+import org.apache.kandula.participant.at.ParticipantTransactionCoordinator;
import org.apache.kandula.storage.StorageUtils;
/**
diff --git a/src/org/apache/kandula/wsba/BACoordinatorCompletionCoordinatorServiceSkeleton.java b/src/org/apache/kandula/wsba/BACoordinatorCompletionCoordinatorServiceSkeleton.java
new file mode 100644
index 0000000..5a86223
--- /dev/null
+++ b/src/org/apache/kandula/wsba/BACoordinatorCompletionCoordinatorServiceSkeleton.java
@@ -0,0 +1,273 @@
+/*
+ * 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.wsba;
+
+import org.apache.axiom.om.OMElement;
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.context.MessageContext;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.kandula.Constants;
+import org.apache.kandula.context.AbstractContext;
+import org.apache.kandula.context.impl.BAActivityContext;
+import org.apache.kandula.coordinator.ba.BACoordinator;
+import org.apache.kandula.faults.AbstractKandulaException;
+import org.apache.kandula.faults.NoActivityException;
+import org.apache.kandula.storage.StorageUtils;
+
+/**
+ * BACoordinatorCompletionCoordinatorServiceSkeleton java skeleton for the
+ * axisService
+ */
+public class BACoordinatorCompletionCoordinatorServiceSkeleton {
+
+ private static final Log log = LogFactory
+ .getLog(BACoordinatorCompletionCoordinatorServiceSkeleton.class);
+
+ public void CompensatedOperation(org.oasis_open.docs.ws_tx.wsba._2006._06.Compensated param0)
+ throws AxisFault {
+ OMElement header = MessageContext.getCurrentMessageContext().getEnvelope().getHeader();
+ String activityId = header.getFirstChildWithName(Constants.TRANSACTION_ID_PARAMETER)
+ .getText();
+ String enlistmentId = header.getFirstChildWithName(Constants.ENLISTMENT_ID_PARAMETER)
+ .getText();
+ try {
+ AbstractContext context = StorageUtils.getContext(activityId);
+ if (context != null) {
+ BAActivityContext baContext = (BAActivityContext) context;
+ BACoordinator atomicBACoordinator = new BACoordinator();
+ atomicBACoordinator.compensatedOperation(baContext, enlistmentId);
+ } else {
+ log.fatal("WS_BA : message "
+ + MessageContext.getCurrentMessageContext().getMessageID()
+ + " : CompensatedOperation : Business Activity Not Found");
+ throw new NoActivityException("CompensatedOperation : Business Activity Not Found");
+ }
+ } catch (AbstractKandulaException e) {
+ log.fatal("WS_BA : message " + MessageContext.getCurrentMessageContext().getMessageID()
+ + " : CompensatedOperation :" + e);
+ throw new AxisFault(e);
+ }
+ }
+
+ /**
+ * Auto generated method signature
+ *
+ * @param param1
+ * @throws AxisFault
+ *
+ */
+ public void ClosedOperation(org.oasis_open.docs.ws_tx.wsba._2006._06.Closed param1)
+ throws AxisFault {
+ OMElement header = MessageContext.getCurrentMessageContext().getEnvelope().getHeader();
+ String activityId = header.getFirstChildWithName(Constants.TRANSACTION_ID_PARAMETER)
+ .getText();
+ String enlistmentId = header.getFirstChildWithName(Constants.ENLISTMENT_ID_PARAMETER)
+ .getText();
+ try {
+ AbstractContext context = StorageUtils.getContext(activityId);
+ if (context != null) {
+ BAActivityContext baContext = (BAActivityContext) context;
+ BACoordinator atomicBACoordinator = new BACoordinator();
+ atomicBACoordinator.closedOperation(baContext, enlistmentId);
+ } else {
+ log.fatal("WS_BA : message "
+ + MessageContext.getCurrentMessageContext().getMessageID()
+ + " : ClosedOperation : Business Activity Not Found");
+ throw new NoActivityException("ClosedOperation : Business Activity Not Found");
+ }
+ } catch (AbstractKandulaException e) {
+ log.fatal("WS_BA : message " + MessageContext.getCurrentMessageContext().getMessageID()
+ + " : ClosedOperation :" + e);
+ throw new AxisFault(e);
+ }
+ }
+
+ /**
+ * Auto generated method signature
+ *
+ * @param param2
+ * @throws AxisFault
+ *
+ */
+ public void ExitOperation(org.oasis_open.docs.ws_tx.wsba._2006._06.Exit param2)
+ throws AxisFault
+
+ {
+ OMElement header = MessageContext.getCurrentMessageContext().getEnvelope().getHeader();
+ String activityId = header.getFirstChildWithName(Constants.TRANSACTION_ID_PARAMETER)
+ .getText();
+ String enlistmentId = header.getFirstChildWithName(Constants.ENLISTMENT_ID_PARAMETER)
+ .getText();
+ try {
+ AbstractContext context = StorageUtils.getContext(activityId);
+ if (context != null) {
+ BAActivityContext baContext = (BAActivityContext) context;
+ BACoordinator atomicBACoordinator = new BACoordinator();
+ atomicBACoordinator.exitOperation(baContext, enlistmentId);
+ } else {
+ log.fatal("WS_BA : message "
+ + MessageContext.getCurrentMessageContext().getMessageID()
+ + " : ExitOperation : Business Activity Not Found");
+ throw new NoActivityException("ClosedOperation : Business Activity Not Found");
+ }
+ } catch (AbstractKandulaException e) {
+ log.fatal("WS_BA : message " + MessageContext.getCurrentMessageContext().getMessageID()
+ + " : ExitOperation :" + e);
+ throw new AxisFault(e);
+ }
+ }
+
+ /**
+ * Auto generated method signature
+ *
+ * @param param3
+ * @throws AxisFault
+ *
+ */
+ public void CompletedOperation(org.oasis_open.docs.ws_tx.wsba._2006._06.Completed param3)
+ throws AxisFault {
+ OMElement header = MessageContext.getCurrentMessageContext().getEnvelope().getHeader();
+ String activityId = header.getFirstChildWithName(Constants.TRANSACTION_ID_PARAMETER)
+ .getText();
+ String enlistmentId = header.getFirstChildWithName(Constants.ENLISTMENT_ID_PARAMETER)
+ .getText();
+ try {
+ AbstractContext context = StorageUtils.getContext(activityId);
+ if (context != null) {
+ BAActivityContext baContext = (BAActivityContext) context;
+ BACoordinator atomicBACoordinator = new BACoordinator();
+ atomicBACoordinator.completedOperation(baContext, enlistmentId);
+ } else {
+ log.fatal("WS_BA : message "
+ + MessageContext.getCurrentMessageContext().getMessageID()
+ + " : CompletedOperation : Business Activity Not Found");
+ throw new NoActivityException("ClosedOperation : Business Activity Not Found");
+ }
+ } catch (AbstractKandulaException e) {
+ log.fatal("WS_BA : message " + MessageContext.getCurrentMessageContext().getMessageID()
+ + " : CompletedOperation :" + e);
+ throw new AxisFault(e);
+ }
+ }
+
+ /**
+ * Auto generated method signature
+ *
+ * @param param4
+ *
+ */
+ public void CannotComplete(org.oasis_open.docs.ws_tx.wsba._2006._06.CannotComplete param4)
+
+ {
+ // Todo fill this with the necessary business logic
+
+ }
+
+ /**
+ * Auto generated method signature
+ *
+ * @param param5
+ *
+ */
+ public void GetStatusOperation(org.oasis_open.docs.ws_tx.wsba._2006._06.GetStatus param5)
+
+ {
+ // Todo fill this with the necessary business logic
+
+ }
+
+ /**
+ * Auto generated method signature
+ *
+ * @param param6
+ * @throws AxisFault
+ *
+ */
+ public void FailOperation(org.oasis_open.docs.ws_tx.wsba._2006._06.Fail param6)
+ throws AxisFault
+
+ {
+ OMElement header = MessageContext.getCurrentMessageContext().getEnvelope().getHeader();
+ String activityId = header.getFirstChildWithName(Constants.TRANSACTION_ID_PARAMETER)
+ .getText();
+ String enlistmentId = header.getFirstChildWithName(Constants.ENLISTMENT_ID_PARAMETER)
+ .getText();
+ try {
+ AbstractContext context = StorageUtils.getContext(activityId);
+ if (context != null) {
+ BAActivityContext baContext = (BAActivityContext) context;
+ BACoordinator atomicBACoordinator = new BACoordinator();
+ atomicBACoordinator.faultOperation(baContext, enlistmentId);
+ } else {
+ log.fatal("WS_BA : message "
+ + MessageContext.getCurrentMessageContext().getMessageID()
+ + " : FailOperation : Business Activity Not Found");
+ throw new NoActivityException("ClosedOperation : Business Activity Not Found");
+ }
+ } catch (AbstractKandulaException e) {
+ log.fatal("WS_BA : message " + MessageContext.getCurrentMessageContext().getMessageID()
+ + " : FailOperation :" + e);
+ throw new AxisFault(e);
+ }
+
+ }
+
+ /**
+ * Auto generated method signature
+ *
+ * @param param7
+ *
+ */
+ public void StatusOperation(org.oasis_open.docs.ws_tx.wsba._2006._06.Status param7)
+
+ {
+ // Todo fill this with the necessary business logic
+
+ }
+
+ /**
+ * Auto generated method signature
+ *
+ * @param param8
+ * @throws AxisFault
+ *
+ */
+ public void CanceledOperation(org.oasis_open.docs.ws_tx.wsba._2006._06.Canceled param8)
+ throws AxisFault
+
+ {
+ OMElement header = MessageContext.getCurrentMessageContext().getEnvelope().getHeader();
+ String activityId = header.getFirstChildWithName(Constants.TRANSACTION_ID_PARAMETER)
+ .getText();
+ String enlistmentId = header.getFirstChildWithName(Constants.ENLISTMENT_ID_PARAMETER)
+ .getText();
+ try {
+ AbstractContext context = StorageUtils.getContext(activityId);
+ if (context != null) {
+ BAActivityContext baContext = (BAActivityContext) context;
+ BACoordinator atomicBACoordinator = new BACoordinator();
+ atomicBACoordinator.canceledOperation(baContext, enlistmentId);
+ }
+ } catch (AbstractKandulaException e) {
+ log.fatal("WS_BA : message " + MessageContext.getCurrentMessageContext().getMessageID()
+ + " : CanceledOperation :" + e);
+ throw new AxisFault(e);
+ }
+ }
+
+}
diff --git a/src/org/apache/kandula/wsba/BACoordinatorCompletionParticipantServiceSkeleton.java b/src/org/apache/kandula/wsba/BACoordinatorCompletionParticipantServiceSkeleton.java
new file mode 100644
index 0000000..a09ca85
--- /dev/null
+++ b/src/org/apache/kandula/wsba/BACoordinatorCompletionParticipantServiceSkeleton.java
@@ -0,0 +1,289 @@
+/*
+ * 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.wsba;
+
+import org.apache.axiom.om.OMElement;
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.context.MessageContext;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.kandula.Constants;
+import org.apache.kandula.context.AbstractContext;
+import org.apache.kandula.context.impl.ParticipantContext;
+import org.apache.kandula.faults.AbstractKandulaException;
+import org.apache.kandula.faults.NoActivityException;
+import org.apache.kandula.participant.ba.BAParticipantTransactionCoordinator;
+import org.apache.kandula.storage.StorageUtils;
+
+/**
+ * BACoordinatorCompletionParticipantServiceSkeleton java skeleton for the
+ * axisService
+ */
+public class BACoordinatorCompletionParticipantServiceSkeleton {
+
+ private static final Log log = LogFactory
+ .getLog(BACoordinatorCompletionParticipantServiceSkeleton.class);
+
+ public void CloseOperation(org.oasis_open.docs.ws_tx.wsba._2006._06.Close param1)
+ throws AxisFault {
+ OMElement header = MessageContext.getCurrentMessageContext().getEnvelope().getHeader();
+ OMElement firstChildWithName = header
+ .getFirstChildWithName(Constants.REQUESTER_ID_PARAMETER);
+ if (firstChildWithName != null) {
+ String requesterID = firstChildWithName.getText();
+ AbstractContext context2 = StorageUtils.getContext(requesterID);
+ try {
+ if (context2!=null)
+ {
+ ParticipantContext context = (ParticipantContext) context2;
+ BAParticipantTransactionCoordinator participantCoordinator = new BAParticipantTransactionCoordinator();
+ participantCoordinator.close(context);
+ }else {
+ log.fatal("WS_BA : message "+ MessageContext.getCurrentMessageContext().getMessageID()
+ + " : CompensatedOperation : Business Activity Not Found");
+ throw new NoActivityException("CompensateOperation : Business Activity Not Found");
+ }
+ } catch (AbstractKandulaException e) {
+ log.fatal("WS_BA : Message ID : " + MessageContext.getCurrentMessageContext().getMessageID()
+ + " : close Operation :" + e);
+ throw new AxisFault(e);
+ }
+ } else {
+ AxisFault e = new AxisFault(
+ "Requester ID header is not found in the message. Please check whether ws-addressing is enabled in the coordinator.");
+ log.fatal("WS_BA : Message ID "
+ + MessageContext.getCurrentMessageContext().getMessageID()
+ + " : CloseOperation :" + e);
+ throw e;
+ }
+ }
+
+ public void CompleteOperation(org.oasis_open.docs.ws_tx.wsba._2006._06.Complete param4)
+ throws AxisFault {
+ OMElement header = MessageContext.getCurrentMessageContext().getEnvelope().getHeader();
+ OMElement firstChildWithName = header
+ .getFirstChildWithName(Constants.REQUESTER_ID_PARAMETER);
+ if (firstChildWithName != null) {
+ String requesterID = firstChildWithName.getText();
+ AbstractContext context2 = StorageUtils.getContext(requesterID);
+ if (context2 != null) {
+ ParticipantContext context = (ParticipantContext) context2;
+ BAParticipantTransactionCoordinator participantCoordinator = new BAParticipantTransactionCoordinator();
+ try {
+ participantCoordinator.complete(context);
+ } catch (AbstractKandulaException e) {
+ log.fatal("WS_BA : " + context.getCoordinationContext().getActivityID()
+ + " : Complete Operation :" + e);
+ throw new AxisFault(e);
+ }
+ } else {
+ log.fatal("WS_BA : Message ID "
+ + MessageContext.getCurrentMessageContext().getMessageID()
+ + " : CompleteOperation : Participant Context Not Found.");
+ throw new AxisFault("CompleteOperation : Participant Context Not Found.");
+ }
+ } else {
+ AxisFault e = new AxisFault(
+ "Requester ID header is not found in the message. Please check whether ws-addressing is enabled in the coordinator.");
+ log.fatal("WS_BA : Message ID "
+ + MessageContext.getCurrentMessageContext().getMessageID()
+ + " : Complete Operation :" + e);
+ throw e;
+ }
+ }
+
+ public void CancelOperation(org.oasis_open.docs.ws_tx.wsba._2006._06.Cancel param3)
+ throws AxisFault {
+ OMElement header = MessageContext.getCurrentMessageContext().getEnvelope().getHeader();
+ OMElement firstChildWithName = header
+ .getFirstChildWithName(Constants.REQUESTER_ID_PARAMETER);
+ if (firstChildWithName != null) {
+ String requesterID = firstChildWithName.getText();
+ AbstractContext context2 = StorageUtils.getContext(requesterID);
+ if (context2 != null) {
+ ParticipantContext context = (ParticipantContext) context2;
+ BAParticipantTransactionCoordinator participantCoordinator = new BAParticipantTransactionCoordinator();
+ try {
+ participantCoordinator.cancel(context);
+ } catch (AbstractKandulaException e) {
+ log.fatal("WS_BA : " + context.getCoordinationContext().getActivityID()
+ + " : CancelOperation :" + e);
+ throw new AxisFault(e);
+ }
+ } else
+ // participant context migt have been already removed by an earlier
+ // cancel
+ {
+ log.info("WS_BA : Message ID "
+ + MessageContext.getCurrentMessageContext().getMessageID()
+ + " : CancelOperation : Participant Context Not Found.");
+ }
+ } else {
+ AxisFault e = new AxisFault(
+ "Requester ID header is not found in the message. Please check whether ws-addressing is enabled in the coordinator.");
+ log.fatal("WS_BA : Message ID "
+ + MessageContext.getCurrentMessageContext().getMessageID()
+ + " : CancelOperation :" + e);
+ throw e;
+ }
+ }
+
+ public void ExitedOperation(org.oasis_open.docs.ws_tx.wsba._2006._06.Exited param8)
+ throws AxisFault
+ {
+ OMElement header = MessageContext.getCurrentMessageContext().getEnvelope().getHeader();
+ OMElement firstChildWithName = header
+ .getFirstChildWithName(Constants.REQUESTER_ID_PARAMETER);
+ if (firstChildWithName != null) {
+ String requesterID = firstChildWithName.getText();
+ AbstractContext context2 = StorageUtils.getContext(requesterID);
+ if (context2 != null) {
+ ParticipantContext context = (ParticipantContext) context2;
+ BAParticipantTransactionCoordinator participantCoordinator = new BAParticipantTransactionCoordinator();
+ try {
+ participantCoordinator.exited(context);
+ } catch (AbstractKandulaException e) {
+ log.fatal("WS_BA : " + context.getCoordinationContext().getActivityID()
+ + " : ExitedOperation :" + e);
+ throw new AxisFault(e);
+ }
+ } else
+ // participant context migt have been already removed by an earlier
+ // exited
+ {
+ log.info("WS_BA : Message ID "
+ + MessageContext.getCurrentMessageContext().getMessageID()
+ + " : ExitedOperation : Participant Context Not Found.");
+ }
+ } else {
+ AxisFault e = new AxisFault(
+ "Requester ID header is not found in the message. Please check whether ws-addressing is enabled in the coordinator.");
+ log.fatal("WS_BA : Message ID "
+ + MessageContext.getCurrentMessageContext().getMessageID()
+ + " : ExitedOperation :" + e);
+ throw e;
+ }
+ }
+
+ public void CompensateOperation(org.oasis_open.docs.ws_tx.wsba._2006._06.Compensate param2) throws AxisFault
+
+ {
+ OMElement header = MessageContext.getCurrentMessageContext().getEnvelope().getHeader();
+ OMElement firstChildWithName = header
+ .getFirstChildWithName(Constants.REQUESTER_ID_PARAMETER);
+ if (firstChildWithName != null) {
+ String requesterID = firstChildWithName.getText();
+ AbstractContext context2 = StorageUtils.getContext(requesterID);
+ try {
+ if (context2 != null) {
+ ParticipantContext context = (ParticipantContext) context2;
+ BAParticipantTransactionCoordinator participantCoordinator = new BAParticipantTransactionCoordinator();
+ participantCoordinator.compensate(context);
+ } else {
+ log.fatal("WS_BA : message "+ MessageContext.getCurrentMessageContext().getMessageID()
+ + " : CompensatedOperation : Business Activity Not Found");
+ throw new NoActivityException("CompensateOperation : Business Activity Not Found");
+ }
+ } catch (AbstractKandulaException e) {
+ log.fatal("WS_BA : Message ID : " + MessageContext.getCurrentMessageContext().getMessageID()
+ + " : CompensateOperation :" + e);
+ throw new AxisFault(e);
+ }
+ } else {
+ AxisFault e = new AxisFault(
+ "Requester ID header is not found in the message. Please check whether ws-addressing is enabled in the coordinator.");
+ log.fatal("WS_BA : Message ID "
+ + MessageContext.getCurrentMessageContext().getMessageID()
+ + " : CompensateOperation :" + e);
+ throw e;
+ }
+ }
+
+ public void FailedOperation(org.oasis_open.docs.ws_tx.wsba._2006._06.Failed param0) throws AxisFault
+
+ {
+ OMElement header = MessageContext.getCurrentMessageContext().getEnvelope().getHeader();
+ OMElement firstChildWithName = header
+ .getFirstChildWithName(Constants.REQUESTER_ID_PARAMETER);
+ if (firstChildWithName != null) {
+ String requesterID = firstChildWithName.getText();
+ AbstractContext context2 = StorageUtils.getContext(requesterID);
+ if (context2 != null) {
+ ParticipantContext context = (ParticipantContext) context2;
+ BAParticipantTransactionCoordinator participantCoordinator = new BAParticipantTransactionCoordinator();
+ try {
+ participantCoordinator.Faulted(context);
+ } catch (AbstractKandulaException e) {
+ log.fatal("WS_BA : " + context.getCoordinationContext().getActivityID()
+ + " : FailedOperation :" + e);
+ throw new AxisFault(e);
+ }
+ } else
+ // participant context migt have been already removed by an earlier
+ // exited
+ {
+ log.info("WS_BA : Message ID "
+ + MessageContext.getCurrentMessageContext().getMessageID()
+ + " : FailedOperation : Participant Context Not Found.");
+ }
+ } else {
+ AxisFault e = new AxisFault(
+ "Requester ID header is not found in the message. Please check whether ws-addressing is enabled in the coordinator.");
+ log.fatal("WS_BA : Message ID "
+ + MessageContext.getCurrentMessageContext().getMessageID()
+ + " : FailedOperation :" + e);
+ throw e;
+ }
+ }
+
+ /**
+ * Auto generated method signature
+ *
+ * @param param5
+ *
+ */
+ public void GetStatusOperation(org.oasis_open.docs.ws_tx.wsba._2006._06.GetStatus param5) {
+ // Todo fill this with the necessary business logic
+ }
+
+ /**
+ * Auto generated method signature
+ *
+ * @param param6
+ *
+ */
+ public void NotCompleted(org.oasis_open.docs.ws_tx.wsba._2006._06.NotCompleted param6)
+
+ {
+ // Todo fill this with the necessary business logic
+
+ }
+
+ /**
+ * Auto generated method signature
+ *
+ * @param param7
+ *
+ */
+ public void StatusOperation(org.oasis_open.docs.ws_tx.wsba._2006._06.Status param7)
+
+ {
+ // Todo fill this with the necessary business logic
+
+ }
+}
diff --git a/src/org/apache/kandula/wsba/BAParticipantCompletionCoordinatorServiceSkeleton.java b/src/org/apache/kandula/wsba/BAParticipantCompletionCoordinatorServiceSkeleton.java
new file mode 100644
index 0000000..77fd584
--- /dev/null
+++ b/src/org/apache/kandula/wsba/BAParticipantCompletionCoordinatorServiceSkeleton.java
@@ -0,0 +1,180 @@
+package org.apache.kandula.wsba;
+
+import org.apache.axiom.om.OMElement;
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.context.MessageContext;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.kandula.Constants;
+import org.apache.kandula.context.AbstractContext;
+import org.apache.kandula.context.impl.BAActivityContext;
+import org.apache.kandula.coordinator.ba.BACoordinator;
+import org.apache.kandula.faults.AbstractKandulaException;
+import org.apache.kandula.storage.StorageUtils;
+
+/**
+ * BAParticipantCompletionCoordinatorServiceSkeleton java skeleton for the
+ * axisService
+ */
+public class BAParticipantCompletionCoordinatorServiceSkeleton {
+
+ private static final Log log = LogFactory
+ .getLog(BAParticipantCompletionCoordinatorServiceSkeleton.class);
+
+ public void CompletedOperation(org.oasis_open.docs.ws_tx.wsba._2006._06.Completed param3)
+ throws AxisFault
+
+ {
+ OMElement header = MessageContext.getCurrentMessageContext().getEnvelope().getHeader();
+ String activityId = header.getFirstChildWithName(Constants.TRANSACTION_ID_PARAMETER)
+ .getText();
+ String enlistmentId = header.getFirstChildWithName(Constants.ENLISTMENT_ID_PARAMETER)
+ .getText();
+ try {
+ BAActivityContext baContext = (BAActivityContext) StorageUtils.getContext(activityId);
+ BACoordinator atomicBACoordinator = new BACoordinator();
+ atomicBACoordinator.completedOperation(baContext, enlistmentId);
+ } catch (AbstractKandulaException e) {
+ log.fatal("WS_BA : message " + MessageContext.getCurrentMessageContext().getMessageID()
+ + " : CompletedOperation :" + e);
+ throw new AxisFault(e);
+ }
+ }
+
+ public void ClosedOperation(org.oasis_open.docs.ws_tx.wsba._2006._06.Closed param1)
+ throws AxisFault
+
+ {
+ OMElement header = MessageContext.getCurrentMessageContext().getEnvelope().getHeader();
+ String activityId = header.getFirstChildWithName(Constants.TRANSACTION_ID_PARAMETER)
+ .getText();
+ String enlistmentId = header.getFirstChildWithName(Constants.ENLISTMENT_ID_PARAMETER)
+ .getText();
+ try {
+ AbstractContext context = StorageUtils.getContext(activityId);
+ if (context != null) {
+ BAActivityContext baContext = (BAActivityContext) context;
+ BACoordinator atomicBACoordinator = new BACoordinator();
+ atomicBACoordinator.closedOperation(baContext, enlistmentId);
+ }
+ } catch (AbstractKandulaException e) {
+ log.fatal("WS_BA : message " + MessageContext.getCurrentMessageContext().getMessageID()
+ + " : ClosedOperation :" + e);
+ throw new AxisFault(e);
+ }
+ }
+
+ public void CanceledOperation(org.oasis_open.docs.ws_tx.wsba._2006._06.Canceled param8) throws AxisFault
+
+ {
+ OMElement header = MessageContext.getCurrentMessageContext().getEnvelope().getHeader();
+ String activityId = header.getFirstChildWithName(Constants.TRANSACTION_ID_PARAMETER)
+ .getText();
+ String enlistmentId = header.getFirstChildWithName(Constants.ENLISTMENT_ID_PARAMETER)
+ .getText();
+ try {
+ AbstractContext context = StorageUtils.getContext(activityId);
+ if (context != null) {
+ BAActivityContext baContext = (BAActivityContext) context;
+ BACoordinator atomicBACoordinator = new BACoordinator();
+ atomicBACoordinator.canceledOperation(baContext, enlistmentId);
+ }
+ } catch (AbstractKandulaException e) {
+ log.fatal("WS_BA : message " + MessageContext.getCurrentMessageContext().getMessageID()
+ + " : CanceledOperation :" + e);
+ throw new AxisFault(e);
+ }
+
+ }
+
+ public void CompensatedOperation(org.oasis_open.docs.ws_tx.wsba._2006._06.Compensated param0)
+
+ {
+/* try {
+ OMElement header = MessageContext.getCurrentMessageContext().getEnvelope().getHeader();
+ String requesterID = header.getFirstChildWithName(Constants.REQUESTER_ID_PARAMETER)
+ .getText();
+ AbstractContext contextx = (AbstractContext) StorageUtils.getContext(requesterID);
+ BAParticipantTransactionSentCoordinator BAStxManager = new BAParticipantTransactionSentCoordinator();
+ BAStxManager.Fault(contextx, Constants.WS_BA_PC);
+ } catch (Exception e) {
+ }
+ // =====================end=========================z //Todo fill this
+ // with the necessary business logic
+*/
+ }
+
+ /**
+ * Auto generated method signature
+ *
+ * @param param2
+ *
+ */
+ public void ExitOperation(org.oasis_open.docs.ws_tx.wsba._2006._06.Exit param2)
+
+ {
+ // Todo fill this with the necessary business logic
+ try {
+ OMElement header = MessageContext.getCurrentMessageContext().getEnvelope().getHeader();
+ String requesterID = header.getFirstChildWithName(Constants.REQUESTER_ID_PARAMETER)
+ .getText();
+ AbstractContext context = (AbstractContext) StorageUtils.getContext(requesterID);
+ // BAParticipantTransactionSentCoordinator BAStxManager = new
+ // BAParticipantTransactionSentCoordinator();
+ // BAStxManager.exit(context);
+ } catch (Exception e) {
+ }
+ }
+
+ /**
+ * Auto generated method signature
+ *
+ * @param param4
+ *
+ */
+ public void CannotComplete(org.oasis_open.docs.ws_tx.wsba._2006._06.CannotComplete param4)
+
+ {
+ // Todo fill this with the necessary business logic
+
+ }
+
+ /**
+ * Auto generated method signature
+ *
+ * @param param5
+ *
+ */
+ public void GetStatusOperation(org.oasis_open.docs.ws_tx.wsba._2006._06.GetStatus param5)
+
+ {
+ // Todo fill this with the necessary business logic
+
+ }
+
+ /**
+ * Auto generated method signature
+ *
+ * @param param6
+ *
+ */
+ public void FailOperation(org.oasis_open.docs.ws_tx.wsba._2006._06.Fail param6)
+
+ {
+ // Todo fill this with the necessary business logic
+
+ }
+
+ /**
+ * Auto generated method signature
+ *
+ * @param param7
+ *
+ */
+ public void StatusOperation(org.oasis_open.docs.ws_tx.wsba._2006._06.Status param7)
+
+ {
+ // Todo fill this with the necessary business logic
+
+ }
+}
diff --git a/src/org/apache/kandula/wsba/BAParticipantCompletionParticipantServiceSkeleton.java b/src/org/apache/kandula/wsba/BAParticipantCompletionParticipantServiceSkeleton.java
new file mode 100644
index 0000000..8b48b27
--- /dev/null
+++ b/src/org/apache/kandula/wsba/BAParticipantCompletionParticipantServiceSkeleton.java
@@ -0,0 +1,220 @@
+
+ /**
+ * BAParticipantCompletionParticipantServiceSkeleton.java
+ *
+ * This file was auto-generated from WSDL
+ * by the Apache Axis2 version: #axisVersion# #today#
+ */
+ package org.apache.kandula.wsba;
+
+import org.apache.axiom.om.OMElement;
+import org.apache.axis2.context.MessageContext;
+import org.apache.kandula.Constants;
+import org.apache.kandula.context.AbstractContext;
+import org.apache.kandula.faults.AbstractKandulaException;
+import org.apache.kandula.participant.ba.BAParticipantTransactionCoordinator;
+import org.apache.kandula.storage.Store;
+ /**
+ * BAParticipantCompletionParticipantServiceSkeleton java skeleton for the axisService
+ */
+ public class BAParticipantCompletionParticipantServiceSkeleton{
+
+
+ /**
+ * Auto generated method signature
+
+ * @param param0
+
+ */
+ public void FailedOperation
+ (
+ org.oasis_open.docs.ws_tx.wsba._2006._06.Failed param0
+ )
+
+ {
+ //==filed by nis===========================================
+ try{
+// StorageFactory.getInstance().setConfigurationContext(
+// MessageContext.getCurrentMessageContext().getServiceContext().getConfigurationContext());
+// OMElement header = MessageContext.getCurrentMessageContext().getEnvelope().getHeader();
+// String requesterID = header.getFirstChildWithName(
+// Constants.REQUESTER_ID_PARAMETER).getText();
+// Store store = StorageFactory.getInstance().getStore();
+// AbstractContext context = (AbstractContext) store.get(requesterID);
+// BAParticipantTransactionCoordinator BAtxManager = new BAParticipantTransactionCoordinator();
+// BAtxManager.Faulted(context,Constants.WS_BA_PC);
+ }catch(Exception e){}
+ //=====================end=========================z
+
+ }
+
+
+ /**
+ * Auto generated method signature
+
+ * @param param1
+
+ */
+ public void CloseOperation
+ (
+ org.oasis_open.docs.ws_tx.wsba._2006._06.Close param1
+ )
+
+ {
+ try{
+ //==============filled by nis======================
+// StorageFactory.getInstance().setConfigurationContext(
+// MessageContext.getCurrentMessageContext().getServiceContext().getConfigurationContext());
+// OMElement header = MessageContext.getCurrentMessageContext().getEnvelope().getHeader();
+// String requesterID = header.getFirstChildWithName(
+// Constants.REQUESTER_ID_PARAMETER).getText();
+// Store store = StorageFactory.getInstance().getStore();
+// AbstractContext context = (AbstractContext) store.get(requesterID);
+// BAParticipantTransactionCoordinator BAtxManager = new BAParticipantTransactionCoordinator();
+// BAtxManager.Close(context,Constants.WS_BA_PC);
+ }catch(Exception e){}
+
+ //=====================end===============================
+ //Todo fill this with the necessary business logic
+
+ }
+
+
+ /**
+ * Auto generated method signature
+
+ * @param param2
+
+ */
+ public void CompensateOperation
+ (
+ org.oasis_open.docs.ws_tx.wsba._2006._06.Compensate param2
+ )
+
+ {
+ try{
+ // == filled by nis===============================
+// StorageFactory.getInstance().setConfigurationContext(
+// MessageContext.getCurrentMessageContext().getServiceContext().getConfigurationContext());
+// OMElement header = MessageContext.getCurrentMessageContext().getEnvelope().getHeader();
+// String requesterID = header.getFirstChildWithName(
+// Constants.REQUESTER_ID_PARAMETER).getText();
+// Store store = StorageFactory.getInstance().getStore();
+// AbstractContext context = (AbstractContext) store.get(requesterID);
+// BAParticipantTransactionCoordinator batxManager = new BAParticipantTransactionCoordinator();
+//
+// batxManager.Compensate(context,Constants.WS_BA_PC);//Todo fill this with the necessary business logic
+ //=====================end===================================
+ }catch(Exception e){
+
+
+ } }
+
+
+ /**
+ * Auto generated method signature
+
+ * @param param3
+
+ */
+ public void CancelOperation( org.oasis_open.docs.ws_tx.wsba._2006._06.Cancel param3)
+ {
+// StorageFactory.getInstance().setConfigurationContext(
+// MessageContext.getCurrentMessageContext().getServiceContext().getConfigurationContext());
+// OMElement header = MessageContext.getCurrentMessageContext().getEnvelope().getHeader();
+// String requesterID = header.getFirstChildWithName(
+// Constants.REQUESTER_ID_PARAMETER).getText();
+// Store store = StorageFactory.getInstance().getStore();
+// AbstractContext context = (AbstractContext) store.get(requesterID);
+// //Need a BAParticipantTransactionCoordinator
+// BAParticipantTransactionCoordinator baParticipantTxManager = new BAParticipantTransactionCoordinator();
+// try {
+// baParticipantTxManager.Cancel(context,Constants.WS_BA_PC);
+// } catch (AbstractKandulaException e) {
+//
+// }
+
+ }
+
+ /**
+ * Auto generated method signature
+
+ * @param param4
+
+ */
+ public void GetStatusOperation
+ (
+ org.oasis_open.docs.ws_tx.wsba._2006._06.GetStatus param4
+ )
+
+ {
+ //Todo fill this with the necessary business logic
+
+ }
+
+
+ /**
+ * Auto generated method signature
+
+ * @param param5
+
+ */
+ public void NotCompleted
+ (
+ org.oasis_open.docs.ws_tx.wsba._2006._06.NotCompleted param5
+ )
+
+ {
+ //Todo fill this with the necessary business logic
+
+ }
+
+
+ /**
+ * Auto generated method signature
+
+ * @param param6
+
+ */
+ public void StatusOperation
+ (
+ org.oasis_open.docs.ws_tx.wsba._2006._06.Status param6
+ )
+
+ {
+ //Todo fill this with the necessary business logic
+
+ }
+
+
+ /**
+ * Auto generated method signature
+
+ * @param param7
+
+ */
+ public void ExitedOperation
+ (
+ org.oasis_open.docs.ws_tx.wsba._2006._06.Exited param7
+ )
+
+ {
+ try{
+ //== filled by nis===============================
+// StorageFactory.getInstance().setConfigurationContext(
+// MessageContext.getCurrentMessageContext().getServiceContext().getConfigurationContext());
+// OMElement header = MessageContext.getCurrentMessageContext().getEnvelope().getHeader();
+// String requesterID = header.getFirstChildWithName(
+// Constants.REQUESTER_ID_PARAMETER).getText();
+// Store store = StorageFactory.getInstance().getStore();
+// AbstractContext context = (AbstractContext) store.get(requesterID);
+// BAParticipantTransactionCoordinator batxManager = new BAParticipantTransactionCoordinator();
+// //=======================================end=====================
+// batxManager.Exited(context,Constants.WS_BA_PC);
+ }catch(Exception e){
+
+
+ } }
+
+ }
+
\ No newline at end of file
diff --git a/src/org/apache/kandula/wscoor/ActivationServiceSkeleton.java b/src/org/apache/kandula/wscoor/ActivationServiceSkeleton.java
index 40ef6c4..68a0f26 100644
--- a/src/org/apache/kandula/wscoor/ActivationServiceSkeleton.java
+++ b/src/org/apache/kandula/wscoor/ActivationServiceSkeleton.java
@@ -69,7 +69,7 @@
Coordinator coordinator = new Coordinator();
AbstractContext context = coordinator.createCoordinationContext(coordinationType,
expiresL);
- StorageUtils.putContext(context);
+// StorageUtils.putContext(context);
CoordinationContext coordinationContext = context.getCoordinationContext();
@@ -82,7 +82,7 @@
coordinationContext_type3.setExpires(expires_type0);
coordinationContext_type3.setRegistrationService(EndpointReferenceFactory
- .getADBEPRTypeFromEPR(coordinationContext.getRegistrationService()));
+ .getEPRTypeFromEPR(coordinationContext.getRegistrationService()));
Identifier_type1 identifier_type1 = new Identifier_type1();
identifier_type1.setAnyURI(new URI("http", "thilina"));
diff --git a/src/org/apache/kandula/wscoor/RegistrationServiceSkeleton.java b/src/org/apache/kandula/wscoor/RegistrationServiceSkeleton.java
index 3336baf..0453f1c 100644
--- a/src/org/apache/kandula/wscoor/RegistrationServiceSkeleton.java
+++ b/src/org/apache/kandula/wscoor/RegistrationServiceSkeleton.java
@@ -51,6 +51,7 @@
String protocolIdentifier;
EndpointReference participantEPR;
String activityId;
+ String participantId=null;
/*
* Extracting data from the received message
*/
@@ -63,6 +64,11 @@
.getEnvelope().getHeader();
activityId = header.getFirstChildWithName(
Constants.TRANSACTION_ID_PARAMETER).getText();
+ OMElement participantIDElement = header.getFirstChildWithName(
+ Constants.PARTICIPANT_ID_PARAMETER);
+ if (participantIDElement != null) {
+ participantId = participantIDElement.getText();
+ }
/*
* Registering the participant for the activity for the given protocol
*/
@@ -75,10 +81,10 @@
"No Activity Found for this Activity ID");
}
EndpointReference epr = coordinator.registerParticipant(context,
- protocolIdentifier, participantEPR);
+ protocolIdentifier, participantEPR,participantId);
RegisterResponseType registerResponseType = new RegisterResponseType();
- registerResponseType.setCoordinatorProtocolService(EndpointReferenceFactory.getADBEPRTypeFromEPR(epr));
+ registerResponseType.setCoordinatorProtocolService(EndpointReferenceFactory.getEPRTypeFromEPR(epr));
RegisterResponse registerResponse = new RegisterResponse();
registerResponse.setRegisterResponse(registerResponseType);
return registerResponse;