You are viewing a plain text version of this content. The canonical link for it is here.
Posted to kandula-dev@ws.apache.org by th...@apache.org on 2006/01/31 13:28:25 UTC
svn commit: r373804 [1/4] - in /webservices/kandula/trunk/java/src: ./
org/apache/kandula/ org/apache/kandula/context/
org/apache/kandula/context/at/ org/apache/kandula/context/coordination/
org/apache/kandula/coordinator/ org/apache/kandula/coordinato...
Author: thilina
Date: Tue Jan 31 04:25:53 2006
New Revision: 373804
URL: http://svn.apache.org/viewcvs?rev=373804&view=rev
Log:
Updating to work with Axis2 -0.95...
Configuration improved
Added:
webservices/kandula/trunk/java/src/org/apache/kandula/participant/Participant.java
webservices/kandula/trunk/java/src/org/apache/kandula/utility/EPRHandlingUtils.java
Removed:
webservices/kandula/trunk/java/src/org/apache/kandula/context/Participant.java
webservices/kandula/trunk/java/src/org/apache/kandula/utility/KandulaUtils.java
Modified:
webservices/kandula/trunk/java/src/endpoints.conf
webservices/kandula/trunk/java/src/org/apache/kandula/Constants.java
webservices/kandula/trunk/java/src/org/apache/kandula/Status.java
webservices/kandula/trunk/java/src/org/apache/kandula/context/AbstractContext.java
webservices/kandula/trunk/java/src/org/apache/kandula/context/ContextFactory.java
webservices/kandula/trunk/java/src/org/apache/kandula/context/at/ATActivityContext.java
webservices/kandula/trunk/java/src/org/apache/kandula/context/at/ATParticipantContext.java
webservices/kandula/trunk/java/src/org/apache/kandula/context/coordination/CoordinationContext.java
webservices/kandula/trunk/java/src/org/apache/kandula/context/coordination/SimpleCoordinationContext.java
webservices/kandula/trunk/java/src/org/apache/kandula/coordinator/Coordinator.java
webservices/kandula/trunk/java/src/org/apache/kandula/coordinator/Registerable.java
webservices/kandula/trunk/java/src/org/apache/kandula/coordinator/at/ATCoordinator.java
webservices/kandula/trunk/java/src/org/apache/kandula/coordinator/at/ATSubCoordinator.java
webservices/kandula/trunk/java/src/org/apache/kandula/coordinator/ba/BACoordinator.java
webservices/kandula/trunk/java/src/org/apache/kandula/faults/AbstractKandulaException.java
webservices/kandula/trunk/java/src/org/apache/kandula/faults/AlreadyRegisteredException.java
webservices/kandula/trunk/java/src/org/apache/kandula/faults/ContextRefusedException.java
webservices/kandula/trunk/java/src/org/apache/kandula/faults/InvalidParameterException.java
webservices/kandula/trunk/java/src/org/apache/kandula/faults/InvalidProtocolException.java
webservices/kandula/trunk/java/src/org/apache/kandula/faults/InvalidStateException.java
webservices/kandula/trunk/java/src/org/apache/kandula/faults/KandulaGeneralException.java
webservices/kandula/trunk/java/src/org/apache/kandula/faults/NoActivityException.java
webservices/kandula/trunk/java/src/org/apache/kandula/initiator/ATInitiatorTransaction.java
webservices/kandula/trunk/java/src/org/apache/kandula/initiator/TransactionManager.java
webservices/kandula/trunk/java/src/org/apache/kandula/initiator/TransactionOutHandler.java
webservices/kandula/trunk/java/src/org/apache/kandula/participant/KandulaResource.java
webservices/kandula/trunk/java/src/org/apache/kandula/participant/ParticipantTransactionManager.java
webservices/kandula/trunk/java/src/org/apache/kandula/participant/TransactionInHandler.java
webservices/kandula/trunk/java/src/org/apache/kandula/participant/Vote.java
webservices/kandula/trunk/java/src/org/apache/kandula/storage/Axis1Store.java
webservices/kandula/trunk/java/src/org/apache/kandula/storage/Axis2Store.java
webservices/kandula/trunk/java/src/org/apache/kandula/storage/SimpleStore.java
webservices/kandula/trunk/java/src/org/apache/kandula/storage/StorageFactory.java
webservices/kandula/trunk/java/src/org/apache/kandula/storage/Store.java
webservices/kandula/trunk/java/src/org/apache/kandula/utility/EndpointReferenceFactory.java
webservices/kandula/trunk/java/src/org/apache/kandula/utility/KandulaListener.java
webservices/kandula/trunk/java/src/org/apache/kandula/wsat/AbstractATNotifierStub.java
webservices/kandula/trunk/java/src/org/apache/kandula/wsat/completion/CompletionCoordinatorPortTypeRawXMLSkeleton.java
webservices/kandula/trunk/java/src/org/apache/kandula/wsat/completion/CompletionCoordinatorPortTypeRawXMLStub.java
webservices/kandula/trunk/java/src/org/apache/kandula/wsat/completion/CompletionInitiatorPortTypeRawXMLSkeleton.java
webservices/kandula/trunk/java/src/org/apache/kandula/wsat/completion/CompletionInitiatorPortTypeRawXMLStub.java
webservices/kandula/trunk/java/src/org/apache/kandula/wsat/completion/CompletionInitiatorServiceListener.java
webservices/kandula/trunk/java/src/org/apache/kandula/wsat/twopc/CoordinatorPortTypeRawXMLSkeleton.java
webservices/kandula/trunk/java/src/org/apache/kandula/wsat/twopc/CoordinatorPortTypeRawXMLStub.java
webservices/kandula/trunk/java/src/org/apache/kandula/wsat/twopc/ParticipantPortTypeRawXMLSkeleton.java
webservices/kandula/trunk/java/src/org/apache/kandula/wsat/twopc/ParticipantPortTypeRawXMLStub.java
webservices/kandula/trunk/java/src/org/apache/kandula/wsat/twopc/ParticipantServiceListener.java
webservices/kandula/trunk/java/src/org/apache/kandula/wscoor/ActivationCoordinatorPortTypeRawXMLStub.java
webservices/kandula/trunk/java/src/org/apache/kandula/wscoor/ActivationPortTypeRawXMLAsyncMessageReceiver.java
webservices/kandula/trunk/java/src/org/apache/kandula/wscoor/ActivationPortTypeRawXMLSkeleton.java
webservices/kandula/trunk/java/src/org/apache/kandula/wscoor/ActivationRequesterPortTypeRawXMLSkeleton.java
webservices/kandula/trunk/java/src/org/apache/kandula/wscoor/RegistrationCoordinatorPortTypeRawXMLStub.java
webservices/kandula/trunk/java/src/org/apache/kandula/wscoor/RegistrationPortTypeRawXMLAsyncMessageReceiver.java
webservices/kandula/trunk/java/src/org/apache/kandula/wscoor/RegistrationPortTypeRawXMLSkeleton.java
webservices/kandula/trunk/java/src/org/apache/kandula/wscoor/RegistrationRequesterPortTypeRawXMLSkeleton.java
Modified: webservices/kandula/trunk/java/src/endpoints.conf
URL: http://svn.apache.org/viewcvs/webservices/kandula/trunk/java/src/endpoints.conf?rev=373804&r1=373803&r2=373804&view=diff
==============================================================================
--- webservices/kandula/trunk/java/src/endpoints.conf (original)
+++ webservices/kandula/trunk/java/src/endpoints.conf Tue Jan 31 04:25:53 2006
@@ -1,5 +1,11 @@
host=127.0.0.1
-port=8082
+port=8081
tcpmon_enable=false
-PARTICIPANT_REPOSITORY =.
+COORDINATOR_REPOSITORY=target/testing-repository
+COORDINATOR_AXIS2XML=target/testing-repository/axis2.xml
+PARTICIPANT_REPOSITORY=target/testing-repository
+
+PARTICIPANT_AXIS2_CONF=target/testing-repository/axis2.xml
+KANDULA_LISTENER_REPOSITORY=target/initiator-repository
+KANDULA_LISTENER_AXIS2XML=target/initiator-repository/axis2.xml
KANDULA_LISTENER_PORT=5050
Modified: webservices/kandula/trunk/java/src/org/apache/kandula/Constants.java
URL: http://svn.apache.org/viewcvs/webservices/kandula/trunk/java/src/org/apache/kandula/Constants.java?rev=373804&r1=373803&r2=373804&view=diff
==============================================================================
--- webservices/kandula/trunk/java/src/org/apache/kandula/Constants.java (original)
+++ webservices/kandula/trunk/java/src/org/apache/kandula/Constants.java Tue Jan 31 04:25:53 2006
@@ -23,68 +23,78 @@
*/
abstract public interface Constants {
- //WS-Coordination URI's
+ //WS-Coordination URI's
- public static final String WS_COOR = "http://schemas.xmlsoap.org/ws/2004/10/wscoor";
+ public static final String WS_COOR = "http://schemas.xmlsoap.org/ws/2004/10/wscoor";
- public static final String WS_COOR_CREATE_COORDINATIONCONTEXT = "http://schemas.xmlsoap.org/ws/2004/10/wscoor/CreateCoordinationContext";
+ public static final String WS_COOR_CREATE_COORDINATIONCONTEXT = "http://schemas.xmlsoap.org/ws/2004/10/wscoor/CreateCoordinationContext";
- public static final String WS_COOR_CREATE_COORDINATIONCONTEXT_RESPONSE = "http://schemas.xmlsoap.org/ws/2004/10/wscoor/CreateCoordinationContextResponse";
+ public static final String WS_COOR_CREATE_COORDINATIONCONTEXT_RESPONSE = "http://schemas.xmlsoap.org/ws/2004/10/wscoor/CreateCoordinationContextResponse";
- public static final String WS_COOR_REGISTER = "http://schemas.xmlsoap.org/ws/2004/10/wscoor/Register";
+ public static final String WS_COOR_REGISTER = "http://schemas.xmlsoap.org/ws/2004/10/wscoor/Register";
- public static final String WS_COOR_REGISTER_RESPONSE = "http://schemas.xmlsoap.org/ws/2004/10/wscoor/RegisterResponse";
+ public static final String WS_COOR_REGISTER_RESPONSE = "http://schemas.xmlsoap.org/ws/2004/10/wscoor/RegisterResponse";
- //WS-AT URI's
+ //WS-AT URI's
- public static final String WS_AT = "http://schemas.xmlsoap.org/ws/2004/10/wsat";
+ public static final String WS_AT = "http://schemas.xmlsoap.org/ws/2004/10/wsat";
- public static final String WS_AT_COMPLETION = "http://schemas.xmlsoap.org/ws/2004/10/wsat/Completion";
+ public static final String WS_AT_COMPLETION = "http://schemas.xmlsoap.org/ws/2004/10/wsat/Completion";
- public static final String WS_AT_COMMIT = "http://schemas.xmlsoap.org/ws/2004/10/wsat/Commit";
+ public static final String WS_AT_COMMIT = "http://schemas.xmlsoap.org/ws/2004/10/wsat/Commit";
- public static final String WS_AT_COMMITTED = "http://schemas.xmlsoap.org/ws/2004/10/wsat/Committed";
+ public static final String WS_AT_COMMITTED = "http://schemas.xmlsoap.org/ws/2004/10/wsat/Committed";
- public static final String WS_AT_ROLLBACK = "http://schemas.xmlsoap.org/ws/2004/10/wsat/Rollback";
+ public static final String WS_AT_ROLLBACK = "http://schemas.xmlsoap.org/ws/2004/10/wsat/Rollback";
- public static final String WS_AT_ABORTED = "http://schemas.xmlsoap.org/ws/2004/10/wsat/Aborted";
+ public static final String WS_AT_ABORTED = "http://schemas.xmlsoap.org/ws/2004/10/wsat/Aborted";
- public static final String WS_AT_DURABLE2PC = "http://schemas.xmlsoap.org/ws/2004/10/wsat/Durable2PC";
+ public static final String WS_AT_DURABLE2PC = "http://schemas.xmlsoap.org/ws/2004/10/wsat/Durable2PC";
- public static final String WS_AT_VOLATILE2PC = "http://schemas.xmlsoap.org/ws/2004/10/wsat/Volatile2PC";
+ public static final String WS_AT_VOLATILE2PC = "http://schemas.xmlsoap.org/ws/2004/10/wsat/Volatile2PC";
- public static final String WS_AT_PREPARE = "http://schemas.xmlsoap.org/ws/2004/10/wsat/Prepare";
+ public static final String WS_AT_PREPARE = "http://schemas.xmlsoap.org/ws/2004/10/wsat/Prepare";
- public static final String WS_AT_PREPARED = "http://schemas.xmlsoap.org/ws/2004/10/wsat/Prepared";
+ public static final String WS_AT_PREPARED = "http://schemas.xmlsoap.org/ws/2004/10/wsat/Prepared";
- public static final String WS_AT_REPLAY = "http://schemas.xmlsoap.org/ws/2004/10/wsat/Replay";
+ public static final String WS_AT_REPLAY = "http://schemas.xmlsoap.org/ws/2004/10/wsat/Replay";
- public static final String WS_AT_READONLY = "http://schemas.xmlsoap.org/ws/2004/10/wsat/ReadOnly";
+ public static final String WS_AT_READONLY = "http://schemas.xmlsoap.org/ws/2004/10/wsat/ReadOnly";
- public static final String SUB_VOLATILE_REGISTERED = "registered for volatile 2PC";
+ public static final String SUB_VOLATILE_REGISTERED = "registered for volatile 2PC";
- public 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
+ //WS-BA URI's
- public static final String WS_BA = "http://schemas.xmlsoap.org/ws/2004/10/wsba";
-
- //Kandula Specific Constants----------------------------------------------------------------------------------------------------
- public static String KANDULA_URI = "http://ws.apache.org/kandula";
+ public static final String WS_BA = "http://schemas.xmlsoap.org/ws/2004/10/wsba";
- public static String KANDULA_RESOURCE = "KandulaResource";
-
- public static String KANDULA_PRE = "kand";
+ //Kandula Specific
+ // Constants----------------------------------------------------------------------------------------------------
+ public static String KANDULA_URI = "http://ws.apache.org/kandula";
- public static String KANDULA_STORE = "KandulaStore" ;
-
- public static final QName TRANSACTION_ID_PARAMETER = new QName(
- KANDULA_URI, "TransactionID",KANDULA_PRE);
-
- public static final QName REQUESTER_ID_PARAMETER = new QName(
- KANDULA_URI, "RequesterID",KANDULA_PRE);
-
- public static final QName ENLISTMENT_ID_PARAMETER = new QName(
- KANDULA_URI, "EnlistmentID",KANDULA_PRE);
+ public static String KANDULA_RESOURCE = "KandulaResource";
+
+ public static String KANDULA_PRE = "kand";
+
+ public static String KANDULA_STORE = "KandulaStore";
+
+ // For the coordinator to identify seperate distributed
+ // activities(transactions)
+ // Common to all the parties participating in a single distributed tx.
+ 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
+ public static final QName REQUESTER_ID_PARAMETER = new QName(KANDULA_URI,
+ "RequesterID", KANDULA_PRE);
+
+ //For the coordinator to identify each and every registered participant
+ // whithing a transaction
+ //This + Tx_ID will be unique for a participant
+ public static final QName ENLISTMENT_ID_PARAMETER = new QName(KANDULA_URI,
+ "EnlistmentID", KANDULA_PRE);
}
Modified: webservices/kandula/trunk/java/src/org/apache/kandula/Status.java
URL: http://svn.apache.org/viewcvs/webservices/kandula/trunk/java/src/org/apache/kandula/Status.java?rev=373804&r1=373803&r2=373804&view=diff
==============================================================================
--- webservices/kandula/trunk/java/src/org/apache/kandula/Status.java (original)
+++ webservices/kandula/trunk/java/src/org/apache/kandula/Status.java Tue Jan 31 04:25:53 2006
@@ -20,42 +20,42 @@
* @author <a href="mailto:thilina@opensource.lk"> Thilina Gunarathne </a>
*/
abstract public interface Status {
- //TODO remove the inner interfaces..
- interface ParticipantStatus {
+ //TODO remove the inner interfaces..
+ interface ParticipantStatus {
- public static final int STATUS_VOLATILE_PREPARING = 20;
+ public static final int STATUS_VOLATILE_PREPARING = 20;
- public static final int STATUS_DURABLE_PREPARING = 21;
+ public static final int STATUS_DURABLE_PREPARING = 21;
- public static final int STATUS_ABORTED = 22;
+ public static final int STATUS_ABORTED = 22;
- public static final int STATUS_READ_ONLY = 23;
+ public static final int STATUS_READ_ONLY = 23;
- public static final int STATUS_COMMITED = 24;
+ public static final int STATUS_COMMITED = 24;
- }
+ }
- interface CoordinatorStatus {
+ interface CoordinatorStatus {
- public static final int STATUS_NONE = 6;
+ public static final int STATUS_NONE = 6;
- public static final int STATUS_COMMITTING = 8;
+ public static final int STATUS_COMMITTING = 8;
- public static final int STATUS_PREPARING = 10;
+ public static final int STATUS_PREPARING = 10;
- public static final int STATUS_PREPARING_DURABLE = 11;
+ public static final int STATUS_PREPARING_DURABLE = 11;
- public static final int STATUS_PREPARING_VOLATILE = 12;
+ public static final int STATUS_PREPARING_VOLATILE = 12;
- public static final int STATUS_PREPARED_SUCCESS = 13;
+ public static final int STATUS_PREPARED_SUCCESS = 13;
- public static final int STATUS_READ_ONLY = 23;
-
- public static final int STATUS_PREPARED = 14;
+ public static final int STATUS_READ_ONLY = 23;
- public static final int STATUS_ABORTING = 9;
+ public static final int STATUS_PREPARED = 14;
- public static final int STATUS_ACTIVE = 0;
+ public static final int STATUS_ABORTING = 9;
- }
+ public static final int STATUS_ACTIVE = 0;
+
+ }
}
Modified: webservices/kandula/trunk/java/src/org/apache/kandula/context/AbstractContext.java
URL: http://svn.apache.org/viewcvs/webservices/kandula/trunk/java/src/org/apache/kandula/context/AbstractContext.java?rev=373804&r1=373803&r2=373804&view=diff
==============================================================================
--- webservices/kandula/trunk/java/src/org/apache/kandula/context/AbstractContext.java (original)
+++ webservices/kandula/trunk/java/src/org/apache/kandula/context/AbstractContext.java Tue Jan 31 04:25:53 2006
@@ -18,98 +18,95 @@
import java.util.HashMap;
-import org.apache.axis2.addressing.AnyContentType;
import org.apache.axis2.addressing.EndpointReference;
import org.apache.kandula.Status.CoordinatorStatus;
import org.apache.kandula.context.coordination.CoordinationContext;
+import org.apache.kandula.utility.EPRHandlingUtils;
import org.apache.kandula.utility.EndpointReferenceFactory;
-import org.apache.kandula.utility.KandulaUtils;
/**
* @author <a href="mailto:thilina@opensource.lk"> Thilina Gunarathne </a>
*/
public abstract class AbstractContext {
- private final HashMap propertyBag;
+ private final HashMap propertyBag;
- protected String activityID;
+ protected String activityID;
- private int status = CoordinatorStatus.STATUS_NONE;
+ private int status = CoordinatorStatus.STATUS_NONE;
- private boolean locked = false;
+ private boolean locked = false;
- protected CoordinationContext coordinationContext = null;
-
- public static String REQUESTER_ID = "requesterID";
-
- public static String COORDINATION_EPR = "coordinationEPR";
-
- public static String ACTIVATION_EPR = "activationEPR";
-
- protected AbstractContext() {
- propertyBag = new HashMap();
- }
-
- public AbstractContext(String coordinationType) {
- propertyBag = new HashMap();
- activityID = KandulaUtils.getRandomStringOf18Characters();
- EndpointReference registrationEpr = EndpointReferenceFactory
- .getInstance().getRegistrationEndpoint(activityID);
- AnyContentType referenceProp = new AnyContentType();
- registrationEpr.setReferenceProperties(referenceProp);
- coordinationContext = CoordinationContext.Factory.newContext(
- activityID, coordinationType, registrationEpr);
- }
-
- public final CoordinationContext getCoordinationContext() {
- return coordinationContext;
- }
-
- public final void setCoordinationContext(CoordinationContext context) {
- this.coordinationContext = context;
- }
-
- public final int getStatus() {
- return status;
- }
-
- // we can use a publisher-subscriber in the future to notify listeners abt
- // state changes.
- public final void setStatus(int value) {
- status = value;
- }
-
- public final synchronized void lock() {
- if (locked) {
- while (locked) {
- try {
- wait();
- } catch (InterruptedException ex) {
- // ignore
- }
- if (status == CoordinatorStatus.STATUS_NONE)
- throw new IllegalStateException();
- }
- }
-
- locked = true;
- }
-
- public final synchronized void unlock() {
- if (!locked)
- throw new IllegalStateException();
- locked = false;
- notify();
- }
-
- public final void setProperty(Object key, Object value) {
- propertyBag.put(key, value);
-
- }
-
- public final Object getProperty(Object key) {
- return propertyBag.get(key);
- }
+ protected CoordinationContext coordinationContext = null;
+
+ public static String REQUESTER_ID = "requesterID";
+
+ public static String COORDINATION_EPR = "coordinationEPR";
+
+ public static String ACTIVATION_EPR = "activationEPR";
+
+ protected AbstractContext() {
+ propertyBag = new HashMap();
+ }
+
+ public AbstractContext(String coordinationType) {
+ propertyBag = new HashMap();
+ activityID = EPRHandlingUtils.getRandomStringOf18Characters();
+ EndpointReference registrationEpr = EndpointReferenceFactory
+ .getInstance().getRegistrationEndpoint(activityID);
+ coordinationContext = CoordinationContext.Factory.newContext(
+ activityID, coordinationType, registrationEpr);
+ }
+
+ public final CoordinationContext getCoordinationContext() {
+ return coordinationContext;
+ }
+
+ public final void setCoordinationContext(CoordinationContext context) {
+ this.coordinationContext = context;
+ }
+
+ public final int getStatus() {
+ return status;
+ }
+
+ // we can use a publisher-subscriber in the future to notify listeners abt
+ // state changes.
+ public final void setStatus(int value) {
+ status = value;
+ }
+
+ public final synchronized void lock() {
+ if (locked) {
+ while (locked) {
+ try {
+ wait();
+ } catch (InterruptedException ex) {
+ // ignore
+ }
+ if (status == CoordinatorStatus.STATUS_NONE)
+ throw new IllegalStateException();
+ }
+ }
+
+ locked = true;
+ }
+
+ public final synchronized void unlock() {
+ if (!locked)
+ throw new IllegalStateException();
+ locked = false;
+ notify();
+ }
+
+ public final void setProperty(Object key, Object value) {
+ propertyBag.put(key, value);
+
+ }
+
+ public final Object getProperty(Object key) {
+ return propertyBag.get(key);
+ }
- public abstract String getCoordinationType();
+ public abstract String getCoordinationType();
}
Modified: webservices/kandula/trunk/java/src/org/apache/kandula/context/ContextFactory.java
URL: http://svn.apache.org/viewcvs/webservices/kandula/trunk/java/src/org/apache/kandula/context/ContextFactory.java?rev=373804&r1=373803&r2=373804&view=diff
==============================================================================
--- webservices/kandula/trunk/java/src/org/apache/kandula/context/ContextFactory.java (original)
+++ webservices/kandula/trunk/java/src/org/apache/kandula/context/ContextFactory.java Tue Jan 31 04:25:53 2006
@@ -25,37 +25,37 @@
* @author <a href="mailto:thilina@opensource.lk"> Thilina Gunarathne </a>
*/
public class ContextFactory {
- private static ContextFactory instance = new ContextFactory();
+ private static ContextFactory instance = new ContextFactory();
- public static ContextFactory getInstance() {
- return instance;
- }
+ public static ContextFactory getInstance() {
+ return instance;
+ }
- public AbstractContext createActivity(String protocol)
- throws InvalidProtocolException {
- if (org.apache.kandula.Constants.WS_AT.equalsIgnoreCase(protocol)) {
- return new ATActivityContext();
- } else {
- throw new InvalidProtocolException("Unsupported Protocol Type");
- }
- }
+ public AbstractContext createActivity(String protocol)
+ throws InvalidProtocolException {
+ if (org.apache.kandula.Constants.WS_AT.equalsIgnoreCase(protocol)) {
+ return new ATActivityContext();
+ } else {
+ throw new InvalidProtocolException("Unsupported Protocol Type");
+ }
+ }
- public AbstractContext createActivity(String protocol,
- EndpointReference activationEPR) throws InvalidProtocolException {
- if (org.apache.kandula.Constants.WS_AT.equalsIgnoreCase(protocol)) {
- return new ATActivityContext(activationEPR);
- } else {
- throw new InvalidProtocolException("Unsupported Protocol Type");
- }
- }
+ public AbstractContext createActivity(String protocol,
+ EndpointReference activationEPR) throws InvalidProtocolException {
+ if (org.apache.kandula.Constants.WS_AT.equalsIgnoreCase(protocol)) {
+ return new ATActivityContext(activationEPR);
+ } else {
+ throw new InvalidProtocolException("Unsupported Protocol Type");
+ }
+ }
- public AbstractContext createActivity(CoordinationContext context)
- throws InvalidProtocolException {
- if (org.apache.kandula.Constants.WS_AT.equalsIgnoreCase(context
- .getCoordinationType())) {
- return new ATActivityContext(context);
- } else {
- throw new InvalidProtocolException("Unsupported Protocol Type");
- }
- }
+ public AbstractContext createActivity(CoordinationContext context)
+ throws InvalidProtocolException {
+ if (org.apache.kandula.Constants.WS_AT.equalsIgnoreCase(context
+ .getCoordinationType())) {
+ return new ATActivityContext(context);
+ } else {
+ throw new InvalidProtocolException("Unsupported Protocol Type");
+ }
+ }
}
Modified: webservices/kandula/trunk/java/src/org/apache/kandula/context/at/ATActivityContext.java
URL: http://svn.apache.org/viewcvs/webservices/kandula/trunk/java/src/org/apache/kandula/context/at/ATActivityContext.java?rev=373804&r1=373803&r2=373804&view=diff
==============================================================================
--- webservices/kandula/trunk/java/src/org/apache/kandula/context/at/ATActivityContext.java (original)
+++ webservices/kandula/trunk/java/src/org/apache/kandula/context/at/ATActivityContext.java Tue Jan 31 04:25:53 2006
@@ -24,191 +24,190 @@
import org.apache.kandula.Constants;
import org.apache.kandula.Status;
import org.apache.kandula.context.AbstractContext;
-import org.apache.kandula.context.Participant;
import org.apache.kandula.context.coordination.CoordinationContext;
import org.apache.kandula.faults.AbstractKandulaException;
import org.apache.kandula.faults.AlreadyRegisteredException;
import org.apache.kandula.faults.InvalidProtocolException;
+import org.apache.kandula.participant.Participant;
+import org.apache.kandula.utility.EPRHandlingUtils;
import org.apache.kandula.utility.EndpointReferenceFactory;
-import org.apache.kandula.utility.KandulaUtils;
/**
* @author <a href="mailto:thilina@opensource.lk"> Thilina Gunarathne </a>
*/
public class ATActivityContext extends AbstractContext {
- private int preparingParticipantsCount = 0;
+ private int preparingParticipantsCount = 0;
- private boolean subOrdinate = false;
+ private boolean subOrdinate = false;
- private Hashtable volatileParticipantsTable;
+ private Hashtable volatileParticipantsTable;
- private Hashtable durableParticipantsTable;
+ private Hashtable durableParticipantsTable;
- //TODO : check whether there can be more than 1 initiator
- private EndpointReference completionParticipant;
-
- private boolean subVolatileRegistered = false;
-
- private boolean subDurableRegistered = false;
-
- private EndpointReference parentEPR;
-
- /**
- * Used when creating new activities
- */
- public ATActivityContext() {
- super(Constants.WS_AT);
- this.setStatus(Status.CoordinatorStatus.STATUS_ACTIVE);
- volatileParticipantsTable = new Hashtable();
- durableParticipantsTable = new Hashtable();
- }
-
- /**
- * @param context
- * To be used when coordinator is used as a sub ordinate to an
- * another cooordinator
- */
- public ATActivityContext(CoordinationContext context) {
- subOrdinate = true;
- parentEPR = context.getRegistrationService();
- // context.setRegistrationService(EndpointReferenceFactory.getInstance()
- // .getRegistrationEndpoint());
- this.setStatus(Status.CoordinatorStatus.STATUS_ACTIVE);
- volatileParticipantsTable = new Hashtable();
- durableParticipantsTable = new Hashtable();
- setCoordinationContext(context);
- }
-
- /**
- * @param id
- * To be used when using as the requester
- */
- public ATActivityContext(EndpointReference activationEPR) {
- super();
- this.setProperty(REQUESTER_ID, KandulaUtils
- .getRandomStringOf18Characters());
- this.setProperty(ACTIVATION_EPR, activationEPR);
- }
-
- /**
- * @param participantEPR
- * @param protocol
- * @return Coordinator protocol service.
- * @throws AbstractKandulaException
- */
- public EndpointReference addParticipant(EndpointReference participantEPR,
- String protocol) throws AbstractKandulaException {
- String enlistmentID = KandulaUtils.getRandomStringOf18Characters();
- if (Constants.WS_AT_VOLATILE2PC.equals(protocol)) {
- addVolatileParticipant(participantEPR, enlistmentID);
- return EndpointReferenceFactory.getInstance()
- .get2PCCoordinatorEndpoint(activityID,enlistmentID);
- } else if (Constants.WS_AT_DURABLE2PC.equals(protocol)) {
- addDurableParticipant(participantEPR, enlistmentID);
- return EndpointReferenceFactory.getInstance()
- .get2PCCoordinatorEndpoint(activityID,enlistmentID);
- } else if (Constants.WS_AT_COMPLETION.equals(protocol)) {
- completionParticipant = participantEPR;
- return EndpointReferenceFactory.getInstance()
- .getCompletionEndpoint(this.activityID);
- } else {
- throw new InvalidProtocolException();
- }
- }
-
- public void addVolatileParticipant(EndpointReference participantEPR,
- String enlistmentID) throws AbstractKandulaException {
- if (volatileParticipantsTable.contains(participantEPR))
- throw new AlreadyRegisteredException();
- Participant participant = new Participant(participantEPR,
- Constants.WS_AT_VOLATILE2PC, enlistmentID);
- volatileParticipantsTable.put(enlistmentID, participant);
- }
-
- public void addDurableParticipant(EndpointReference participantEPR,
- String enlistmentID) throws AlreadyRegisteredException {
- if (durableParticipantsTable.contains(participantEPR)) {
- throw new AlreadyRegisteredException();
- }
- Participant participant = new Participant(participantEPR,
- Constants.WS_AT_DURABLE2PC, enlistmentID);
- durableParticipantsTable.put(enlistmentID, participant);
-
- }
-
- public Iterator getRegistered2PCParticipants(String protocol) {
- if (protocol.equals(Constants.WS_AT_VOLATILE2PC)) {
- return volatileParticipantsTable.values().iterator();
- } else if (protocol.equals(Constants.WS_AT_DURABLE2PC)) {
- return durableParticipantsTable.values().iterator();
- }
- return null;
- }
-
- public Iterator getAll2PCParticipants() {
- LinkedList list = new LinkedList(volatileParticipantsTable.values());
- list.addAll(durableParticipantsTable.values());
- return list.iterator();
- }
-
- public Participant getParticipant(String enlistmentId) {
- if (volatileParticipantsTable.containsKey(enlistmentId)) {
- return (Participant) volatileParticipantsTable.get(enlistmentId);
- } else if (durableParticipantsTable.containsKey(enlistmentId)) {
- return (Participant) durableParticipantsTable.get(enlistmentId);
- } else {
- return null;
- }
- }
-
- /**
- * @return the completion initiator epr
- */
- public EndpointReference getCompletionParticipant() {
- return completionParticipant;
- }
-
- public void countPreparing() {
- preparingParticipantsCount++;
-
- }
-
- public void decrementPreparing() {
- preparingParticipantsCount--;
- }
-
- public boolean hasMorePreparing() {
- return (preparingParticipantsCount > 0);
- }
-
- public boolean getSubVolatileRegistered() {
-
- return subVolatileRegistered;
- }
-
- public boolean getSubDurableRegistered() {
- return subDurableRegistered;
- }
-
- public void setSubVolatileRegistered(boolean value) {
- subVolatileRegistered = value;
- }
-
- public void setSubDurableRegistered(boolean value) {
- subDurableRegistered = value;
- }
-
- // public void prepared(Participant participant)
- // {
- // if (participant.getStatus()==Status.ParticipantStatus.STATUS_ABORTED)
- // {
- // //throw new
- // }
- // }
-
- public String getCoordinationType() {
- return Constants.WS_AT;
- }
+ //TODO : check whether there can be more than 1 initiator
+ private EndpointReference completionParticipant;
+
+ private boolean subVolatileRegistered = false;
+
+ private boolean subDurableRegistered = false;
+
+ private EndpointReference parentEPR;
+
+ /**
+ * Used when creating new activities
+ */
+ public ATActivityContext() {
+ super(Constants.WS_AT);
+ this.setStatus(Status.CoordinatorStatus.STATUS_ACTIVE);
+ volatileParticipantsTable = new Hashtable();
+ durableParticipantsTable = new Hashtable();
+ }
+
+ /**
+ * @param context
+ * To be used when coordinator is used as a sub ordinate to an
+ * another cooordinator
+ */
+ public ATActivityContext(CoordinationContext context) {
+ subOrdinate = true;
+ parentEPR = context.getRegistrationService();
+ // context.setRegistrationService(EndpointReferenceFactory.getInstance()
+ // .getRegistrationEndpoint());
+ this.setStatus(Status.CoordinatorStatus.STATUS_ACTIVE);
+ volatileParticipantsTable = new Hashtable();
+ durableParticipantsTable = new Hashtable();
+ setCoordinationContext(context);
+ }
+
+ /**
+ * @param id
+ * To be used when using as the requester
+ */
+ public ATActivityContext(EndpointReference activationEPR) {
+ super();
+ this.setProperty(REQUESTER_ID, EPRHandlingUtils
+ .getRandomStringOf18Characters());
+ this.setProperty(ACTIVATION_EPR, activationEPR);
+ }
+
+ /**
+ * @param participantEPR
+ * @param protocol
+ * @return Coordinator protocol service.
+ * @throws AbstractKandulaException
+ */
+ public EndpointReference addParticipant(EndpointReference participantEPR,
+ String protocol) throws AbstractKandulaException {
+ String enlistmentID = EPRHandlingUtils.getRandomStringOf18Characters();
+ if (Constants.WS_AT_VOLATILE2PC.equals(protocol)) {
+ addVolatileParticipant(participantEPR, enlistmentID);
+ return EndpointReferenceFactory.getInstance()
+ .get2PCCoordinatorEndpoint(activityID, enlistmentID);
+ } else if (Constants.WS_AT_DURABLE2PC.equals(protocol)) {
+ addDurableParticipant(participantEPR, enlistmentID);
+ return EndpointReferenceFactory.getInstance()
+ .get2PCCoordinatorEndpoint(activityID, enlistmentID);
+ } else if (Constants.WS_AT_COMPLETION.equals(protocol)) {
+ completionParticipant = participantEPR;
+ return EndpointReferenceFactory.getInstance()
+ .getCompletionEndpoint(this.activityID);
+ } else {
+ throw new InvalidProtocolException();
+ }
+ }
+
+ public void addVolatileParticipant(EndpointReference participantEPR,
+ String enlistmentID) throws AbstractKandulaException {
+ if (volatileParticipantsTable.contains(participantEPR))
+ throw new AlreadyRegisteredException();
+ Participant participant = new Participant(participantEPR,
+ Constants.WS_AT_VOLATILE2PC, enlistmentID);
+ volatileParticipantsTable.put(enlistmentID, participant);
+ }
+
+ public void addDurableParticipant(EndpointReference participantEPR,
+ String enlistmentID) throws AlreadyRegisteredException {
+ if (durableParticipantsTable.contains(participantEPR)) {
+ throw new AlreadyRegisteredException();
+ }
+ Participant participant = new Participant(participantEPR,
+ Constants.WS_AT_DURABLE2PC, enlistmentID);
+ durableParticipantsTable.put(enlistmentID, participant);
+ }
+
+ public Iterator getRegistered2PCParticipants(String protocol) {
+ if (protocol.equals(Constants.WS_AT_VOLATILE2PC)) {
+ return volatileParticipantsTable.values().iterator();
+ } else if (protocol.equals(Constants.WS_AT_DURABLE2PC)) {
+ return durableParticipantsTable.values().iterator();
+ }
+ return null;
+ }
+
+ public Iterator getAll2PCParticipants() {
+ LinkedList list = new LinkedList(volatileParticipantsTable.values());
+ list.addAll(durableParticipantsTable.values());
+ return list.iterator();
+ }
+
+ public Participant getParticipant(String enlistmentId) {
+ if (volatileParticipantsTable.containsKey(enlistmentId)) {
+ return (Participant) volatileParticipantsTable.get(enlistmentId);
+ } else if (durableParticipantsTable.containsKey(enlistmentId)) {
+ return (Participant) durableParticipantsTable.get(enlistmentId);
+ } else {
+ return null;
+ }
+ }
+
+ /**
+ * @return the completion initiator epr
+ */
+ public EndpointReference getCompletionParticipant() {
+ return completionParticipant;
+ }
+
+ public void countPreparing() {
+ preparingParticipantsCount++;
+
+ }
+
+ public void decrementPreparing() {
+ preparingParticipantsCount--;
+ }
+
+ public boolean hasMorePreparing() {
+ return (preparingParticipantsCount > 0);
+ }
+
+ public boolean getSubVolatileRegistered() {
+
+ return subVolatileRegistered;
+ }
+
+ public boolean getSubDurableRegistered() {
+ return subDurableRegistered;
+ }
+
+ public void setSubVolatileRegistered(boolean value) {
+ subVolatileRegistered = value;
+ }
+
+ public void setSubDurableRegistered(boolean value) {
+ subDurableRegistered = value;
+ }
+
+ // public void prepared(Participant participant)
+ // {
+ // if (participant.getStatus()==Status.ParticipantStatus.STATUS_ABORTED)
+ // {
+ // //throw new
+ // }
+ // }
+
+ public String getCoordinationType() {
+ return Constants.WS_AT;
+ }
}
Modified: webservices/kandula/trunk/java/src/org/apache/kandula/context/at/ATParticipantContext.java
URL: http://svn.apache.org/viewcvs/webservices/kandula/trunk/java/src/org/apache/kandula/context/at/ATParticipantContext.java?rev=373804&r1=373803&r2=373804&view=diff
==============================================================================
--- webservices/kandula/trunk/java/src/org/apache/kandula/context/at/ATParticipantContext.java (original)
+++ webservices/kandula/trunk/java/src/org/apache/kandula/context/at/ATParticipantContext.java Tue Jan 31 04:25:53 2006
@@ -26,39 +26,38 @@
* @author <a href="mailto:thilina@opensource.lk"> Thilina Gunarathne </a>
*/
public class ATParticipantContext extends AbstractContext {
- KandulaResource resource;
+ KandulaResource resource;
+ public ATParticipantContext() {
+ this.setStatus(Status.CoordinatorStatus.STATUS_ACTIVE);
+ }
- public ATParticipantContext() {
- this.setStatus(Status.CoordinatorStatus.STATUS_ACTIVE);
- }
- /**
- * @return Returns the resource.
- */
- public KandulaResource getResource() {
- return resource;
- }
+ /**
+ * @return Returns the resource.
+ */
+ public KandulaResource getResource() {
+ return resource;
+ }
- /**
- * @param resource
- * The resource to set.
- */
- public void setResource(KandulaResource resource) {
- this.resource = resource;
- }
+ /**
+ * @param resource
+ * The resource to set.
+ */
+ public void setResource(KandulaResource resource) {
+ this.resource = resource;
+ }
- /*
- * (non-Javadoc)
- *
- * @see org.apache.kandula.context.AbstractContext#getCoordinationType()
- */
- public String getCoordinationType() {
- return Constants.WS_AT;
- }
-
- public EndpointReference getCoordinationEPR()
- {
- return (EndpointReference)getProperty(ATActivityContext.COORDINATION_EPR);
- }
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.apache.kandula.context.AbstractContext#getCoordinationType()
+ */
+ public String getCoordinationType() {
+ return Constants.WS_AT;
+ }
+
+ public EndpointReference getCoordinationEPR() {
+ return (EndpointReference) getProperty(ATActivityContext.COORDINATION_EPR);
+ }
}
Modified: webservices/kandula/trunk/java/src/org/apache/kandula/context/coordination/CoordinationContext.java
URL: http://svn.apache.org/viewcvs/webservices/kandula/trunk/java/src/org/apache/kandula/context/coordination/CoordinationContext.java?rev=373804&r1=373803&r2=373804&view=diff
==============================================================================
--- webservices/kandula/trunk/java/src/org/apache/kandula/context/coordination/CoordinationContext.java (original)
+++ webservices/kandula/trunk/java/src/org/apache/kandula/context/coordination/CoordinationContext.java Tue Jan 31 04:25:53 2006
@@ -23,42 +23,42 @@
* @author <a href="mailto:thilina@opensource.lk"> Thilina Gunarathne </a>
*/
public interface CoordinationContext {
- public abstract String getActivityID();
+ public abstract String getActivityID();
- public abstract String getCoordinationType();
+ public abstract String getCoordinationType();
- public abstract EndpointReference getRegistrationService();
+ public abstract EndpointReference getRegistrationService();
- public abstract long getExpires();
+ public abstract long getExpires();
- public abstract void setActivityID(String value);
+ public abstract void setActivityID(String value);
- public abstract void setCoordinationType(String value);
+ public abstract void setCoordinationType(String value);
- public abstract void setRegistrationService(EndpointReference value);
+ public abstract void setRegistrationService(EndpointReference value);
- public abstract void setExpires(long value);
+ public abstract void setExpires(long value);
- public abstract OMElement toOM();
+ public abstract OMElement toOM();
- public abstract Object getCoordinationContextType();
+ public abstract Object getCoordinationContextType();
- public static final class Factory {
- public static CoordinationContext newContext(String activityId,
- String coordinationType, EndpointReference epr) {
- return new SimpleCoordinationContext(activityId, coordinationType,
- epr);
- }
+ public static final class Factory {
+ public static CoordinationContext newContext(String activityId,
+ String coordinationType, EndpointReference epr) {
+ return new SimpleCoordinationContext(activityId, coordinationType,
+ epr);
+ }
- public static CoordinationContext newContext(OMElement contextElement) {
- return new SimpleCoordinationContext(contextElement);
- }
+ public static CoordinationContext newContext(OMElement contextElement) {
+ return new SimpleCoordinationContext(contextElement);
+ }
- // public static CoordinationContext newInstance(Object contextType) {
- // return new XmlBeansTypeCoordinationContext(contextType);
- // }
+ // public static CoordinationContext newInstance(Object contextType) {
+ // return new XmlBeansTypeCoordinationContext(contextType);
+ // }
- private Factory() {
- } // No instance of this class allowed
- }
+ private Factory() {
+ } // No instance of this class allowed
+ }
}
Modified: webservices/kandula/trunk/java/src/org/apache/kandula/context/coordination/SimpleCoordinationContext.java
URL: http://svn.apache.org/viewcvs/webservices/kandula/trunk/java/src/org/apache/kandula/context/coordination/SimpleCoordinationContext.java?rev=373804&r1=373803&r2=373804&view=diff
==============================================================================
--- webservices/kandula/trunk/java/src/org/apache/kandula/context/coordination/SimpleCoordinationContext.java (original)
+++ webservices/kandula/trunk/java/src/org/apache/kandula/context/coordination/SimpleCoordinationContext.java Tue Jan 31 04:25:53 2006
@@ -24,109 +24,109 @@
import org.apache.axis2.om.OMNamespace;
import org.apache.axis2.soap.SOAPFactory;
import org.apache.kandula.Constants;
-import org.apache.kandula.utility.KandulaUtils;
+import org.apache.kandula.utility.EPRHandlingUtils;
/**
* @author <a href="mailto:thilina@opensource.lk"> Thilina Gunarathne </a>
*/
public class SimpleCoordinationContext implements CoordinationContext {
- private String activityID;
+ private String activityID;
- private String coordinationType;
+ private String coordinationType;
- private long expires;
+ private long expires;
- private EndpointReference registrationServiceEpr;
+ private EndpointReference registrationServiceEpr;
- private OMElement contextElement = null;
-
- public SimpleCoordinationContext(String activityID,
- String coordinationType, EndpointReference epr) {
- this.activityID = activityID;
- this.coordinationType = coordinationType;
- this.registrationServiceEpr = epr;
- }
-
- public SimpleCoordinationContext(OMElement contextElement) {
- super();
- this.contextElement = contextElement;
- activityID = contextElement.getFirstChildWithName(
- new QName("Identifier")).getText();
- coordinationType = contextElement.getFirstChildWithName(
- new QName("CoordinationType")).getText();
- OMElement registrationElement = contextElement
- .getFirstChildWithName(new QName("RegistrationService"));
- registrationServiceEpr = KandulaUtils
- .endpointFromOM(registrationElement);
- }
-
- public String getActivityID() {
- return activityID;
- }
-
- public String getCoordinationType() {
- return coordinationType;
- }
-
- public EndpointReference getRegistrationService() {
- return this.registrationServiceEpr;
- }
-
- public long getExpires() {
- return expires;
- }
-
- public void setActivityID(String value) {
- this.activityID = value;
-
- }
-
- public void setCoordinationType(String value) {
- this.coordinationType = value;
-
- }
-
- public void setRegistrationService(EndpointReference epr) {
- this.registrationServiceEpr = epr;
- }
-
- public void setExpires(long value) {
- this.expires = value;
- }
-
- public Object getCoordinationContextType() {
- return this;
- }
-
- public OMElement toOM() {
- if (contextElement != null) {
- return contextElement;
- } else {
- SOAPFactory factory = OMAbstractFactory.getSOAP12Factory();
- OMNamespace wsCoor = factory.createOMNamespace(Constants.WS_COOR,
- "wscoor");
- OMElement contextElement = factory.createOMElement(
- "CoordinationContext", wsCoor);
- if (this.expires != 0) {
- OMElement expiresElement = factory.createOMElement("Expires",
- wsCoor);
- expiresElement.setText(Long.toString(this.expires));
- contextElement.addChild(expiresElement);
- }
- OMElement identifierElement = factory.createOMElement("Identifier",
- wsCoor);
- identifierElement.setText(this.activityID);
- contextElement.addChild(identifierElement);
- OMElement coorTypeElement = factory.createOMElement(
- "CoordinationType", wsCoor);
- coorTypeElement.setText(this.coordinationType);
- contextElement.addChild(coorTypeElement);
- OMElement registrationServiceElement = factory.createOMElement(
- "RegistrationService", wsCoor);
- KandulaUtils.endpointToOM(registrationServiceEpr,
- registrationServiceElement, factory);
- contextElement.addChild(registrationServiceElement);
- return contextElement;
- }
- }
+ private OMElement contextElement = null;
+
+ public SimpleCoordinationContext(String activityID,
+ String coordinationType, EndpointReference epr) {
+ this.activityID = activityID;
+ this.coordinationType = coordinationType;
+ this.registrationServiceEpr = epr;
+ }
+
+ public SimpleCoordinationContext(OMElement contextElement) {
+ super();
+ this.contextElement = contextElement;
+ activityID = contextElement.getFirstChildWithName(
+ new QName("Identifier")).getText();
+ coordinationType = contextElement.getFirstChildWithName(
+ new QName("CoordinationType")).getText();
+ OMElement registrationElement = contextElement
+ .getFirstChildWithName(new QName("RegistrationService"));
+ registrationServiceEpr = EPRHandlingUtils
+ .endpointFromOM(registrationElement);
+ }
+
+ public String getActivityID() {
+ return activityID;
+ }
+
+ public String getCoordinationType() {
+ return coordinationType;
+ }
+
+ public EndpointReference getRegistrationService() {
+ return this.registrationServiceEpr;
+ }
+
+ public long getExpires() {
+ return expires;
+ }
+
+ public void setActivityID(String value) {
+ this.activityID = value;
+
+ }
+
+ public void setCoordinationType(String value) {
+ this.coordinationType = value;
+
+ }
+
+ public void setRegistrationService(EndpointReference epr) {
+ this.registrationServiceEpr = epr;
+ }
+
+ public void setExpires(long value) {
+ this.expires = value;
+ }
+
+ public Object getCoordinationContextType() {
+ return this;
+ }
+
+ public OMElement toOM() {
+ if (contextElement != null) {
+ return contextElement;
+ } else {
+ SOAPFactory factory = OMAbstractFactory.getSOAP12Factory();
+ OMNamespace wsCoor = factory.createOMNamespace(Constants.WS_COOR,
+ "wscoor");
+ OMElement contextElement = factory.createOMElement(
+ "CoordinationContext", wsCoor);
+ if (this.expires != 0) {
+ OMElement expiresElement = factory.createOMElement("Expires",
+ wsCoor);
+ expiresElement.setText(Long.toString(this.expires));
+ contextElement.addChild(expiresElement);
+ }
+ OMElement identifierElement = factory.createOMElement("Identifier",
+ wsCoor);
+ identifierElement.setText(this.activityID);
+ contextElement.addChild(identifierElement);
+ OMElement coorTypeElement = factory.createOMElement(
+ "CoordinationType", wsCoor);
+ coorTypeElement.setText(this.coordinationType);
+ contextElement.addChild(coorTypeElement);
+ OMElement registrationServiceElement = factory.createOMElement(
+ "RegistrationService", wsCoor);
+ EPRHandlingUtils.endpointToOM(registrationServiceEpr,
+ registrationServiceElement, factory);
+ contextElement.addChild(registrationServiceElement);
+ return contextElement;
+ }
+ }
}
Modified: webservices/kandula/trunk/java/src/org/apache/kandula/coordinator/Coordinator.java
URL: http://svn.apache.org/viewcvs/webservices/kandula/trunk/java/src/org/apache/kandula/coordinator/Coordinator.java?rev=373804&r1=373803&r2=373804&view=diff
==============================================================================
--- webservices/kandula/trunk/java/src/org/apache/kandula/coordinator/Coordinator.java (original)
+++ webservices/kandula/trunk/java/src/org/apache/kandula/coordinator/Coordinator.java Tue Jan 31 04:25:53 2006
@@ -29,76 +29,76 @@
*/
public class Coordinator {
- private Store store;
+ private Store store;
- public Coordinator() {
- StorageFactory storageFactory = StorageFactory.getInstance();
- store = storageFactory.getStore();
- }
-
- /**
- * @param coordinationType
- * @return the Coordination Context created <p/>Initiators can use this to
- * Create new Distributed transactions.This will take in the
- * Coordination Type and will create an instance of the reapective
- * ActivityContext. The Coordination Context created by this can be
- * used to convey the information about the transaction between
- * initiator,Participants and coordinator
- * @throws AbstractKandulaException
- */
- public AbstractContext createCoordinationContext(String coordinationType,
- long expires) throws AbstractKandulaException {
- ContextFactory factory = ContextFactory.getInstance();
- AbstractContext context = factory.createActivity(coordinationType);
- context.getCoordinationContext().setExpires(expires);
- store.put(context.getCoordinationContext().getActivityID(), context);
- return context;
- }
-
- /**
- * @param coorContext
- * @return the interposed Coordination Context created <p/>Participants
- * decided to use this Coordinator as a interposed
- * sub-coordinator.The newly created CoordinationContext will
- * contain the same ActivityIdentifier & Protocol type. Registration
- * EPR of the earlier CoordinationContext will be replaced by the
- * RegistrationEPR of this Coordinator.
- */
- public AbstractContext createCoordinationContext(
- CoordinationContext coorContext) throws AbstractKandulaException {
- ContextFactory factory = ContextFactory.getInstance();
- AbstractContext context = factory.createActivity(coorContext);
- store.put(context.getCoordinationContext().getActivityID(), context);
- return context;
- }
-
- /**
- * @param protocol
- * @param participantEPR
- * @param id
- * @return Should return the particular Coordiators End Point Reference <p/>
- * This method provides the functional logic for participants to
- * register for a particular transaction activity which was created
- * by a initiator. Registration request will be forwarded to
- * repective protocol coordinators.
- * @throws AbstractKandulaException
- */
- public EndpointReference registerParticipant(String id, String protocol,
- EndpointReference participantEPR) throws AbstractKandulaException {
-
- AbstractContext context = getCoordinationContext(id);
- if (context == null) {
- throw new IllegalStateException(
- "No Activity Found for this Activity ID");
- }
-
- Registerable registerableCoordinator = Registerable.Factory
- .newRegisterable(context.getCoordinationType());
- return registerableCoordinator.register(context, protocol,
- participantEPR);
- }
-
- private AbstractContext getCoordinationContext(String id) {
- return (AbstractContext) store.get(id);
- }
+ public Coordinator() {
+ StorageFactory storageFactory = StorageFactory.getInstance();
+ store = storageFactory.getStore();
+ }
+
+ /**
+ * @param coordinationType
+ * @return the Coordination Context created <p/>Initiators can use this to
+ * Create new Distributed transactions.This will take in the
+ * Coordination Type and will create an instance of the reapective
+ * ActivityContext. The Coordination Context created by this can be
+ * used to convey the information about the transaction between
+ * initiator,Participants and coordinator
+ * @throws AbstractKandulaException
+ */
+ public AbstractContext createCoordinationContext(String coordinationType,
+ long expires) throws AbstractKandulaException {
+ ContextFactory factory = ContextFactory.getInstance();
+ AbstractContext context = factory.createActivity(coordinationType);
+ context.getCoordinationContext().setExpires(expires);
+ store.put(context.getCoordinationContext().getActivityID(), context);
+ return context;
+ }
+
+ /**
+ * @param coorContext
+ * @return the interposed Coordination Context created <p/>Participants
+ * decided to use this Coordinator as a interposed
+ * sub-coordinator.The newly created CoordinationContext will
+ * contain the same ActivityIdentifier & Protocol type. Registration
+ * EPR of the earlier CoordinationContext will be replaced by the
+ * RegistrationEPR of this Coordinator.
+ */
+ public AbstractContext createCoordinationContext(
+ CoordinationContext coorContext) throws AbstractKandulaException {
+ ContextFactory factory = ContextFactory.getInstance();
+ AbstractContext context = factory.createActivity(coorContext);
+ store.put(context.getCoordinationContext().getActivityID(), context);
+ return context;
+ }
+
+ /**
+ * @param protocol
+ * @param participantEPR
+ * @param id
+ * @return Should return the particular Coordiators End Point Reference <p/>
+ * This method provides the functional logic for participants to
+ * register for a particular transaction activity which was created
+ * by a initiator. Registration request will be forwarded to
+ * repective protocol coordinators.
+ * @throws AbstractKandulaException
+ */
+ public EndpointReference registerParticipant(String id, String protocol,
+ EndpointReference participantEPR) throws AbstractKandulaException {
+
+ AbstractContext context = getCoordinationContext(id);
+ if (context == null) {
+ throw new IllegalStateException(
+ "No Activity Found for this Activity ID");
+ }
+
+ Registerable registerableCoordinator = Registerable.Factory
+ .newRegisterable(context.getCoordinationType());
+ return registerableCoordinator.register(context, protocol,
+ participantEPR);
+ }
+
+ private AbstractContext getCoordinationContext(String id) {
+ return (AbstractContext) store.get(id);
+ }
}
Modified: webservices/kandula/trunk/java/src/org/apache/kandula/coordinator/Registerable.java
URL: http://svn.apache.org/viewcvs/webservices/kandula/trunk/java/src/org/apache/kandula/coordinator/Registerable.java?rev=373804&r1=373803&r2=373804&view=diff
==============================================================================
--- webservices/kandula/trunk/java/src/org/apache/kandula/coordinator/Registerable.java (original)
+++ webservices/kandula/trunk/java/src/org/apache/kandula/coordinator/Registerable.java Tue Jan 31 04:25:53 2006
@@ -27,23 +27,23 @@
* @author <a href="mailto:thilina@opensource.lk"> Thilina Gunarathne </a>
*/
public interface Registerable {
- public EndpointReference register(AbstractContext context, String protocol,
- EndpointReference participantEPR) throws AbstractKandulaException;
+ public EndpointReference register(AbstractContext context, String protocol,
+ EndpointReference participantEPR) throws AbstractKandulaException;
- public static final class Factory {
- public static Registerable newRegisterable(String coordinationType)
- throws InvalidProtocolException {
- if (Constants.WS_AT.equals(coordinationType)) {
+ public static final class Factory {
+ public static Registerable newRegisterable(String coordinationType)
+ throws InvalidProtocolException {
+ if (Constants.WS_AT.equals(coordinationType)) {
- return new ATCoordinator();
+ return new ATCoordinator();
- } else {
- throw new InvalidProtocolException(
- "Unsupported Coordination Type");
- }
- }
+ } else {
+ throw new InvalidProtocolException(
+ "Unsupported Coordination Type");
+ }
+ }
- private Factory() {
- }
- }
+ private Factory() {
+ }
+ }
}
Modified: webservices/kandula/trunk/java/src/org/apache/kandula/coordinator/at/ATCoordinator.java
URL: http://svn.apache.org/viewcvs/webservices/kandula/trunk/java/src/org/apache/kandula/coordinator/at/ATCoordinator.java?rev=373804&r1=373803&r2=373804&view=diff
==============================================================================
--- webservices/kandula/trunk/java/src/org/apache/kandula/coordinator/at/ATCoordinator.java (original)
+++ webservices/kandula/trunk/java/src/org/apache/kandula/coordinator/at/ATCoordinator.java Tue Jan 31 04:25:53 2006
@@ -23,11 +23,11 @@
import org.apache.kandula.Status;
import org.apache.kandula.Status.CoordinatorStatus;
import org.apache.kandula.context.AbstractContext;
-import org.apache.kandula.context.Participant;
import org.apache.kandula.context.at.ATActivityContext;
import org.apache.kandula.coordinator.Registerable;
import org.apache.kandula.faults.AbstractKandulaException;
import org.apache.kandula.faults.InvalidStateException;
+import org.apache.kandula.participant.Participant;
import org.apache.kandula.participant.Vote;
import org.apache.kandula.storage.StorageFactory;
import org.apache.kandula.storage.Store;
@@ -39,290 +39,286 @@
*/
public class ATCoordinator implements Registerable {
- private Store store;
+ private Store store;
- public ATCoordinator() {
- StorageFactory storageFactory = StorageFactory.getInstance();
- store = storageFactory.getStore();
- }
-
- public EndpointReference register(AbstractContext context, String protocol,
- EndpointReference participantEPR) throws AbstractKandulaException {
- ATActivityContext atContext = (ATActivityContext) context;
- atContext.lock();
- switch (atContext.getStatus()) {
- case CoordinatorStatus.STATUS_PREPARING_DURABLE:
- atContext.unlock();
- try {
- this.abortActivity(atContext);
- } catch (Exception e) {
- throw new InvalidStateException(e);
- }
- throw new InvalidStateException(
- "Coordinator is in preparing state - Durable ");
- case CoordinatorStatus.STATUS_PREPARED_SUCCESS:
- atContext.unlock();
- throw new InvalidStateException(
- "Coordinator is in prepared success state");
- case CoordinatorStatus.STATUS_COMMITTING:
- atContext.unlock();
- throw new InvalidStateException(
- "Coordinator is in committing state");
- case CoordinatorStatus.STATUS_ABORTING:
- atContext.unlock();
- throw new InvalidStateException("Coordinator is in Aborting state");
- case CoordinatorStatus.STATUS_ACTIVE:
- case CoordinatorStatus.STATUS_PREPARING_VOLATILE:
- atContext.unlock();
- return atContext.addParticipant(participantEPR, protocol);
-
- case CoordinatorStatus.STATUS_NONE:
- default:
- atContext.unlock();
- throw new InvalidStateException();
- }
- }
-
- /**
- * should send be a notification This wraps the Commit operation defined in
- * Ws-AtomicTransaction specification.
- *
- * @throws Exception
- */
- public void commitOperation(String id) throws AbstractKandulaException {
- CompletionInitiatorPortTypeRawXMLStub stub;
- ATActivityContext atContext = (ATActivityContext) store.get(id);
-
- if (atContext == null) {
- throw new IllegalStateException(
- "No Activity Found for this Activity ID");
- }
-
- /*
- * Check for states TODO Do we actually need to lock the activity
- */
- atContext.lock();
- switch (atContext.getStatus()) {
- case CoordinatorStatus.STATUS_NONE:
- case CoordinatorStatus.STATUS_ABORTING:
- atContext.unlock();
- stub = new CompletionInitiatorPortTypeRawXMLStub(".", atContext
- .getCompletionParticipant());
- stub.abortedOperation();
- break;
- case CoordinatorStatus.STATUS_PREPARING_DURABLE:
- case CoordinatorStatus.STATUS_PREPARING_VOLATILE:
- case CoordinatorStatus.STATUS_PREPARED_SUCCESS:
- //If prepared success Ignore this message
- atContext.unlock();
- break;
- case CoordinatorStatus.STATUS_COMMITTING:
- atContext.unlock();
- stub = new CompletionInitiatorPortTypeRawXMLStub(".", atContext
- .getCompletionParticipant());
- stub.committedOperation();
- break;
- case Status.CoordinatorStatus.STATUS_ACTIVE:
- atContext.setStatus(Status.CoordinatorStatus.STATUS_PREPARING);
- atContext.unlock();
- volatilePrepare(atContext);
- // wait till all the Volatile prepare()'s are done
- while (atContext.hasMorePreparing()) {
- if (atContext.getStatus() == Status.CoordinatorStatus.STATUS_ABORTING) {
- return;
- }
- }
- durablePrepare(atContext);
- //wait till all the Durable prepare()'s are done
- while (atContext.hasMorePreparing()) {
- if (atContext.getStatus() == Status.CoordinatorStatus.STATUS_ABORTING) {
- return;
- }
- }
- if (!(atContext.getStatus() == Status.CoordinatorStatus.STATUS_ABORTING)) {
- commitActivity(atContext);
- }
- break;
- default:
- atContext.unlock();
- break;
- }
-
- }
-
- public void rollbackOperation(String id) throws Exception {
- CompletionInitiatorPortTypeRawXMLStub stub;
- ATActivityContext atContext = (ATActivityContext) store.get(id);
-
- // if store throws a Exception capture it
- if (atContext == null) {
- throw new IllegalStateException(
- "No Activity Found for this Activity ID");
- }
- /*
- * Check for states TODO Do we need to lock the activity
- */
- atContext.lock();
- switch (atContext.getStatus()) {
- case CoordinatorStatus.STATUS_NONE:
- case CoordinatorStatus.STATUS_ABORTING:
- atContext.unlock();
- stub = new CompletionInitiatorPortTypeRawXMLStub(".", atContext
- .getCompletionParticipant());
- stub.abortedOperation();
- break;
- case CoordinatorStatus.STATUS_PREPARING_DURABLE:
- case CoordinatorStatus.STATUS_PREPARING_VOLATILE:
- case CoordinatorStatus.STATUS_PREPARED_SUCCESS:
- //If prepared success Ignoring
- atContext.unlock();
- break;
- case CoordinatorStatus.STATUS_COMMITTING:
- atContext.unlock();
- stub = new CompletionInitiatorPortTypeRawXMLStub(".", atContext
- .getCompletionParticipant());
- stub.committedOperation();
- break;
- case Status.CoordinatorStatus.STATUS_ACTIVE:
- atContext.setStatus(Status.CoordinatorStatus.STATUS_ABORTING);
- atContext.unlock();
- abortActivity(atContext);
- break;
- default:
- atContext.unlock();
- break;
- }
- }
-
- /**
- * @param context
- * @throws Exception
- * @see This methode issues the oneway prepare() message. Does not wait till
- * partipants responds. Used in 2PC after user commits as well as in
- * subordinate scenerio, when parent issues volatile prepare(). One can
- * check if there are any more participants to be responded by checking
- * the hasMorePreparing() methode of the context.
- */
- public void volatilePrepare(AbstractContext context)
- throws AbstractKandulaException {
- ParticipantPortTypeRawXMLStub stub = new ParticipantPortTypeRawXMLStub(
- ".");
- ATActivityContext atContext = (ATActivityContext) context;
- Iterator volatilePartipantIterator = atContext
- .getRegistered2PCParticipants(Constants.WS_AT_VOLATILE2PC);
- if (volatilePartipantIterator.hasNext()) {
- atContext.lock();
- atContext
- .setStatus(Status.CoordinatorStatus.STATUS_PREPARING_VOLATILE);
- atContext.unlock();
- while (volatilePartipantIterator.hasNext()) {
- atContext.countPreparing();
- stub.prepareOperation(((Participant) volatilePartipantIterator
- .next()).getEpr());
- }
- }
- }
-
- public void countVote(String activityID, Vote vote, String enlistmentID)
- throws AbstractKandulaException {
- ATActivityContext context = (ATActivityContext) store.get(activityID);
- Participant participant = context.getParticipant(enlistmentID);
-
- if (Vote.PREPARED.equals(vote)) {
- participant.setStatus(Status.CoordinatorStatus.STATUS_PREPARED);
- } else if (Vote.READ_ONLY.equals(vote)) {
- participant.setStatus(Status.CoordinatorStatus.STATUS_READ_ONLY);
- } else if (Vote.ABORT.equals(vote)) {
- participant.setStatus(Status.ParticipantStatus.STATUS_ABORTED);
- abortActivity(context);
- }
- context.decrementPreparing();
- }
-
- /**
- * @param context
- * @throws Exception
- * @see This methode issues the oneway prepare() message. Does not wait till
- * partipants responds. Used in 2PC after user commits as well as in
- * subordinate scenerio, when parent issues Durable prepare(). One can
- * check if there are any more participants to be responded by checking
- * the hasMorePreparing() methode of the context.
- */
- public void durablePrepare(AbstractContext context)
- throws AbstractKandulaException {
- ParticipantPortTypeRawXMLStub stub = new ParticipantPortTypeRawXMLStub(
- ".");
- ATActivityContext atContext = (ATActivityContext) context;
- Iterator durablePartipantIterator = atContext
- .getRegistered2PCParticipants(Constants.WS_AT_DURABLE2PC);
- if (durablePartipantIterator.hasNext()) {
- atContext.lock();
- atContext
- .setStatus(Status.CoordinatorStatus.STATUS_PREPARING_DURABLE);
- atContext.unlock();
- while (durablePartipantIterator.hasNext()) {
- atContext.countPreparing();
- stub.prepareOperation(((Participant) durablePartipantIterator
- .next()).getEpr());
- }
- }
- }
-
- /**
- * @param context
- * @throws Exception
- * @see This will send the commit() messages to all the participants
- * registered for the Transaction Must check whether all the
- * participants have replied to the prepare()
- */
- private void commitActivity(AbstractContext context)
- throws AbstractKandulaException {
- // check whether all participants have prepared
- ParticipantPortTypeRawXMLStub stub = new ParticipantPortTypeRawXMLStub(
- ".");
- ATActivityContext atContext = (ATActivityContext) context;
-
- atContext.lock();
- atContext.setStatus(Status.CoordinatorStatus.STATUS_COMMITTING);
- atContext.unlock();
- Iterator participants = atContext.getAll2PCParticipants();
- while (participants.hasNext()) {
- Participant participant = (Participant) participants.next();
- if (!(Status.CoordinatorStatus.STATUS_READ_ONLY == participant
- .getStatus())) {
- stub.commitOperation(participant.getEpr());
- }
- }
- CompletionInitiatorPortTypeRawXMLStub completionStub = new CompletionInitiatorPortTypeRawXMLStub(
- ".", atContext.getCompletionParticipant());
- completionStub.committedOperation();
- }
-
- /**
- * @param context
- * @throws Exception
- * @see This will send the rollback() messages to all the participants
- * registered for the Transaction Do not have to check whether all the
- * participants have replied to the prepare()
- */
- private void abortActivity(AbstractContext context)
- throws AbstractKandulaException {
- ParticipantPortTypeRawXMLStub stub = new ParticipantPortTypeRawXMLStub(
- ".");
- ATActivityContext atContext = (ATActivityContext) context;
- atContext.lock();
- atContext.setStatus(Status.CoordinatorStatus.STATUS_ABORTING);
- atContext.unlock();
- Iterator participants = atContext.getAll2PCParticipants();
-
- while (participants.hasNext()) {
- stub
- .rollbackOperation(((Participant) participants.next())
- .getEpr());
- }
- CompletionInitiatorPortTypeRawXMLStub completionStub = new CompletionInitiatorPortTypeRawXMLStub(
- ".", atContext.getCompletionParticipant());
- completionStub.abortedOperation();
- }
+ public ATCoordinator() {
+ StorageFactory storageFactory = StorageFactory.getInstance();
+ store = storageFactory.getStore();
+ }
+
+ public EndpointReference register(AbstractContext context, String protocol,
+ EndpointReference participantEPR) throws AbstractKandulaException {
+ ATActivityContext atContext = (ATActivityContext) context;
+ atContext.lock();
+ switch (atContext.getStatus()) {
+ case CoordinatorStatus.STATUS_PREPARING_DURABLE:
+ atContext.unlock();
+ try {
+ this.abortActivity(atContext);
+ } catch (Exception e) {
+ throw new InvalidStateException(e);
+ }
+ throw new InvalidStateException(
+ "Coordinator is in preparing state - Durable ");
+ case CoordinatorStatus.STATUS_PREPARED_SUCCESS:
+ atContext.unlock();
+ throw new InvalidStateException(
+ "Coordinator is in prepared success state");
+ case CoordinatorStatus.STATUS_COMMITTING:
+ atContext.unlock();
+ throw new InvalidStateException(
+ "Coordinator is in committing state");
+ case CoordinatorStatus.STATUS_ABORTING:
+ atContext.unlock();
+ throw new InvalidStateException("Coordinator is in Aborting state");
+ case CoordinatorStatus.STATUS_ACTIVE:
+ case CoordinatorStatus.STATUS_PREPARING_VOLATILE:
+ atContext.unlock();
+ return atContext.addParticipant(participantEPR, protocol);
+
+ case CoordinatorStatus.STATUS_NONE:
+ default:
+ atContext.unlock();
+ throw new InvalidStateException();
+ }
+ }
+
+ /**
+ * should send be a notification This wraps the Commit operation defined in
+ * Ws-AtomicTransaction specification.
+ *
+ * @throws Exception
+ */
+ public void commitOperation(String id) throws AbstractKandulaException {
+ CompletionInitiatorPortTypeRawXMLStub stub;
+ ATActivityContext atContext = (ATActivityContext) store.get(id);
+
+ if (atContext == null) {
+ throw new IllegalStateException(
+ "No Activity Found for this Activity ID");
+ }
+
+ /*
+ * Check for states TODO Do we actually need to lock the activity
+ */
+ atContext.lock();
+ switch (atContext.getStatus()) {
+ case CoordinatorStatus.STATUS_NONE:
+ case CoordinatorStatus.STATUS_ABORTING:
+ atContext.unlock();
+ stub = new CompletionInitiatorPortTypeRawXMLStub(atContext
+ .getCompletionParticipant());
+ stub.abortedOperation();
+ break;
+ case CoordinatorStatus.STATUS_PREPARING_DURABLE:
+ case CoordinatorStatus.STATUS_PREPARING_VOLATILE:
+ case CoordinatorStatus.STATUS_PREPARED_SUCCESS:
+ //If prepared success Ignore this message
+ atContext.unlock();
+ break;
+ case CoordinatorStatus.STATUS_COMMITTING:
+ atContext.unlock();
+ stub = new CompletionInitiatorPortTypeRawXMLStub(atContext
+ .getCompletionParticipant());
+ stub.committedOperation();
+ break;
+ case Status.CoordinatorStatus.STATUS_ACTIVE:
+ atContext.setStatus(Status.CoordinatorStatus.STATUS_PREPARING);
+ atContext.unlock();
+ volatilePrepare(atContext);
+ // wait till all the Volatile prepare()'s are done
+ while (atContext.hasMorePreparing()) {
+ if (atContext.getStatus() == Status.CoordinatorStatus.STATUS_ABORTING) {
+ return;
+ }
+ }
+ durablePrepare(atContext);
+ //wait till all the Durable prepare()'s are done
+ while (atContext.hasMorePreparing()) {
+ if (atContext.getStatus() == Status.CoordinatorStatus.STATUS_ABORTING) {
+ return;
+ }
+ }
+ if (!(atContext.getStatus() == Status.CoordinatorStatus.STATUS_ABORTING)) {
+ commitActivity(atContext);
+ }
+ break;
+ default:
+ atContext.unlock();
+ break;
+ }
+
+ }
+
+ public void rollbackOperation(String id) throws Exception {
+ CompletionInitiatorPortTypeRawXMLStub stub;
+ ATActivityContext atContext = (ATActivityContext) store.get(id);
+
+ // if store throws a Exception capture it
+ if (atContext == null) {
+ throw new IllegalStateException(
+ "No Activity Found for this Activity ID");
+ }
+ /*
+ * Check for states TODO Do we need to lock the activity
+ */
+ atContext.lock();
+ switch (atContext.getStatus()) {
+ case CoordinatorStatus.STATUS_NONE:
+ case CoordinatorStatus.STATUS_ABORTING:
+ atContext.unlock();
+ stub = new CompletionInitiatorPortTypeRawXMLStub(atContext
+ .getCompletionParticipant());
+ stub.abortedOperation();
+ break;
+ case CoordinatorStatus.STATUS_PREPARING_DURABLE:
+ case CoordinatorStatus.STATUS_PREPARING_VOLATILE:
+ case CoordinatorStatus.STATUS_PREPARED_SUCCESS:
+ //If prepared success Ignoring
+ atContext.unlock();
+ break;
+ case CoordinatorStatus.STATUS_COMMITTING:
+ atContext.unlock();
+ stub = new CompletionInitiatorPortTypeRawXMLStub(atContext
+ .getCompletionParticipant());
+ stub.committedOperation();
+ break;
+ case Status.CoordinatorStatus.STATUS_ACTIVE:
+ atContext.setStatus(Status.CoordinatorStatus.STATUS_ABORTING);
+ atContext.unlock();
+ abortActivity(atContext);
+ break;
+ default:
+ atContext.unlock();
+ break;
+ }
+ }
+
+ /**
+ * @param context
+ * @throws Exception
+ * @see This methode issues the oneway prepare() message. Does not wait till
+ * partipants responds. Used in 2PC after user commits as well as in
+ * subordinate scenerio, when parent issues volatile prepare(). One can
+ * check if there are any more participants to be responded by checking
+ * the hasMorePreparing() methode of the context.
+ */
+ public void volatilePrepare(AbstractContext context)
+ throws AbstractKandulaException {
+ ParticipantPortTypeRawXMLStub stub = new ParticipantPortTypeRawXMLStub();
+ ATActivityContext atContext = (ATActivityContext) context;
+ Iterator volatilePartipantIterator = atContext
+ .getRegistered2PCParticipants(Constants.WS_AT_VOLATILE2PC);
+ if (volatilePartipantIterator.hasNext()) {
+ atContext.lock();
+ atContext
+ .setStatus(Status.CoordinatorStatus.STATUS_PREPARING_VOLATILE);
+ atContext.unlock();
+ while (volatilePartipantIterator.hasNext()) {
+ atContext.countPreparing();
+ stub.prepareOperation(((Participant) volatilePartipantIterator
+ .next()).getEpr());
+ }
+ }
+ }
+
+ public void countVote(String activityID, Vote vote, String enlistmentID)
+ throws AbstractKandulaException {
+ ATActivityContext context = (ATActivityContext) store.get(activityID);
+ Participant participant = context.getParticipant(enlistmentID);
+
+ if (Vote.PREPARED.equals(vote)) {
+ participant.setStatus(Status.CoordinatorStatus.STATUS_PREPARED);
+ } else if (Vote.READ_ONLY.equals(vote)) {
+ participant.setStatus(Status.CoordinatorStatus.STATUS_READ_ONLY);
+ } else if (Vote.ABORT.equals(vote)) {
+ participant.setStatus(Status.ParticipantStatus.STATUS_ABORTED);
+ abortActivity(context);
+ }
+ context.decrementPreparing();
+ }
+
+ /**
+ * @param context
+ * @throws Exception
+ * @see This methode issues the oneway prepare() message. Does not wait till
+ * partipants responds. Used in 2PC after user commits as well as in
+ * subordinate scenerio, when parent issues Durable prepare(). One can
+ * check if there are any more participants to be responded by checking
+ * the hasMorePreparing() methode of the context.
+ */
+ public void durablePrepare(AbstractContext context)
+ throws AbstractKandulaException {
+ ParticipantPortTypeRawXMLStub stub = new ParticipantPortTypeRawXMLStub();
+ ATActivityContext atContext = (ATActivityContext) context;
+ Iterator durablePartipantIterator = atContext
+ .getRegistered2PCParticipants(Constants.WS_AT_DURABLE2PC);
+ if (durablePartipantIterator.hasNext()) {
+ atContext.lock();
+ atContext
+ .setStatus(Status.CoordinatorStatus.STATUS_PREPARING_DURABLE);
+ atContext.unlock();
+ while (durablePartipantIterator.hasNext()) {
+ atContext.countPreparing();
+ stub.prepareOperation(((Participant) durablePartipantIterator
+ .next()).getEpr());
+ }
+ }
+ }
+
+ /**
+ * @param context
+ * @throws Exception
+ * @see This will send the commit() messages to all the participants
+ * registered for the Transaction Must check whether all the
+ * participants have replied to the prepare()
+ */
+ private void commitActivity(AbstractContext context)
+ throws AbstractKandulaException {
+ // check whether all participants have prepared
+ ParticipantPortTypeRawXMLStub stub = new ParticipantPortTypeRawXMLStub();
+ ATActivityContext atContext = (ATActivityContext) context;
+
+ atContext.lock();
+ atContext.setStatus(Status.CoordinatorStatus.STATUS_COMMITTING);
+ atContext.unlock();
+ Iterator participants = atContext.getAll2PCParticipants();
+ while (participants.hasNext()) {
+ Participant participant = (Participant) participants.next();
+ if (!(Status.CoordinatorStatus.STATUS_READ_ONLY == participant
+ .getStatus())) {
+ stub.commitOperation(participant.getEpr());
+ }
+ }
+ CompletionInitiatorPortTypeRawXMLStub completionStub = new CompletionInitiatorPortTypeRawXMLStub(
+ atContext.getCompletionParticipant());
+ completionStub.committedOperation();
+ }
+
+ /**
+ * @param context
+ * @throws Exception
+ * @see This will send the rollback() messages to all the participants
+ * registered for the Transaction Do not have to check whether all the
+ * participants have replied to the prepare()
+ */
+ private void abortActivity(AbstractContext context)
+ throws AbstractKandulaException {
+ ParticipantPortTypeRawXMLStub stub = new ParticipantPortTypeRawXMLStub();
+ ATActivityContext atContext = (ATActivityContext) context;
+ atContext.lock();
+ atContext.setStatus(Status.CoordinatorStatus.STATUS_ABORTING);
+ atContext.unlock();
+ Iterator participants = atContext.getAll2PCParticipants();
+
+ while (participants.hasNext()) {
+ stub
+ .rollbackOperation(((Participant) participants.next())
+ .getEpr());
+ }
+ CompletionInitiatorPortTypeRawXMLStub completionStub = new CompletionInitiatorPortTypeRawXMLStub(
+ atContext.getCompletionParticipant());
+ completionStub.abortedOperation();
+ }
}
Modified: webservices/kandula/trunk/java/src/org/apache/kandula/coordinator/at/ATSubCoordinator.java
URL: http://svn.apache.org/viewcvs/webservices/kandula/trunk/java/src/org/apache/kandula/coordinator/at/ATSubCoordinator.java?rev=373804&r1=373803&r2=373804&view=diff
==============================================================================
--- webservices/kandula/trunk/java/src/org/apache/kandula/coordinator/at/ATSubCoordinator.java (original)
+++ webservices/kandula/trunk/java/src/org/apache/kandula/coordinator/at/ATSubCoordinator.java Tue Jan 31 04:25:53 2006
@@ -28,36 +28,36 @@
*/
public class ATSubCoordinator extends ATCoordinator {
- public void commitOperation(String id) throws AbstractKandulaException {
- throw new InvalidProtocolException(
- "This activity is a Sub Ordinate activity. Completion Protocol not supported.");
- }
+ public void commitOperation(String id) throws AbstractKandulaException {
+ throw new InvalidProtocolException(
+ "This activity is a Sub Ordinate activity. Completion Protocol not supported.");
+ }
- public void rollbackOperation(String id) throws AbstractKandulaException {
- throw new InvalidProtocolException(
- "This activity is a Sub Ordinate activity. Completion Protocol not supported.");
- }
+ public void rollbackOperation(String id) throws AbstractKandulaException {
+ throw new InvalidProtocolException(
+ "This activity is a Sub Ordinate activity. Completion Protocol not supported.");
+ }
- public EndpointReference addParticipant(AbstractContext context,
- String protocol, EndpointReference participantEPR)
- throws AbstractKandulaException {
- ATActivityContext atContext = (ATActivityContext) context;
- if (protocol.equals(Constants.WS_AT_DURABLE2PC)) {
- if (!atContext.getSubDurableRegistered()) {
- //have to register with the parent coordinator
- atContext.setSubDurableRegistered(true);
- }
- return atContext.addParticipant(participantEPR, protocol);
- }
+ public EndpointReference addParticipant(AbstractContext context,
+ String protocol, EndpointReference participantEPR)
+ throws AbstractKandulaException {
+ ATActivityContext atContext = (ATActivityContext) context;
+ if (protocol.equals(Constants.WS_AT_DURABLE2PC)) {
+ if (!atContext.getSubDurableRegistered()) {
+ //have to register with the parent coordinator
+ atContext.setSubDurableRegistered(true);
+ }
+ return atContext.addParticipant(participantEPR, protocol);
+ }
- else if (protocol.equals(Constants.WS_AT_VOLATILE2PC)) {
- if (!atContext.getSubDurableRegistered()) {
- //have to register with the parent coordinator
- atContext.setSubDurableRegistered(true);
- }
- return atContext.addParticipant(participantEPR, protocol);
- } else
- throw new InvalidProtocolException();
- }
+ else if (protocol.equals(Constants.WS_AT_VOLATILE2PC)) {
+ if (!atContext.getSubDurableRegistered()) {
+ //have to register with the parent coordinator
+ atContext.setSubDurableRegistered(true);
+ }
+ return atContext.addParticipant(participantEPR, protocol);
+ } else
+ throw new InvalidProtocolException();
+ }
}
Modified: webservices/kandula/trunk/java/src/org/apache/kandula/coordinator/ba/BACoordinator.java
URL: http://svn.apache.org/viewcvs/webservices/kandula/trunk/java/src/org/apache/kandula/coordinator/ba/BACoordinator.java?rev=373804&r1=373803&r2=373804&view=diff
==============================================================================
--- webservices/kandula/trunk/java/src/org/apache/kandula/coordinator/ba/BACoordinator.java (original)
+++ webservices/kandula/trunk/java/src/org/apache/kandula/coordinator/ba/BACoordinator.java Tue Jan 31 04:25:53 2006
@@ -26,9 +26,9 @@
*/
public class BACoordinator implements Registerable {
- public EndpointReference register(AbstractContext context, String protocol,
- EndpointReference participantEPR) throws AbstractKandulaException {
- return null; //To change body of implemented methods use File |
- // Settings | File Templates.
- }
+ public EndpointReference register(AbstractContext context, String protocol,
+ EndpointReference participantEPR) throws AbstractKandulaException {
+ return null; //To change body of implemented methods use File |
+ // Settings | File Templates.
+ }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: kandula-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: kandula-dev-help@ws.apache.org