You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fx-dev@ws.apache.org by th...@apache.org on 2006/05/13 15:47:09 UTC
svn commit: r406098 [1/2] - in
/webservices/kandula/trunk/java/src/org/apache/kandula: ./ context/
context/impl/ coordinator/ coordinator/at/ coordinator/ba/ faults/
initiator/ participant/ utility/ wsat/ wsat/completion/ wsat/twopc/ wscoor/
Author: thilina
Date: Sat May 13 06:47:07 2006
New Revision: 406098
URL: http://svn.apache.org/viewcvs?rev=406098&view=rev
Log:
Updating the code base
Provided sync support for Registration & create CoordinationContext
Assigned resources per operation basis
Kandula2 Back to working state
Added:
webservices/kandula/trunk/java/src/org/apache/kandula/wscoor/ActivationPortTypeRawXMLSyncMessageReceiver.java
webservices/kandula/trunk/java/src/org/apache/kandula/wscoor/RegistrationPortTypeRawXMLSyncMessageReceiver.java
Removed:
webservices/kandula/trunk/java/src/org/apache/kandula/wscoor/ActivationPortTypeRawXMLAsyncMessageReceiver.java
webservices/kandula/trunk/java/src/org/apache/kandula/wscoor/RegistrationPortTypeRawXMLAsyncMessageReceiver.java
Modified:
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/CoordinationContext.java
webservices/kandula/trunk/java/src/org/apache/kandula/context/impl/ATActivityContext.java
webservices/kandula/trunk/java/src/org/apache/kandula/context/impl/ATParticipantContext.java
webservices/kandula/trunk/java/src/org/apache/kandula/context/impl/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/ATParticipantInformation.java
webservices/kandula/trunk/java/src/org/apache/kandula/coordinator/at/ATSubCoordinator.java
webservices/kandula/trunk/java/src/org/apache/kandula/coordinator/at/ExecutionCallBack.java
webservices/kandula/trunk/java/src/org/apache/kandula/coordinator/ba/BACoordinator.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/TransactionManager.java
webservices/kandula/trunk/java/src/org/apache/kandula/initiator/TransactionOutHandler.java
webservices/kandula/trunk/java/src/org/apache/kandula/participant/ParticipantTransactionCoordinator.java
webservices/kandula/trunk/java/src/org/apache/kandula/participant/TransactionInHandler.java
webservices/kandula/trunk/java/src/org/apache/kandula/utility/KandulaConfiguration.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/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/RegistrationPortTypeRawXMLSkeleton.java
webservices/kandula/trunk/java/src/org/apache/kandula/wscoor/RegistrationRequesterPortTypeRawXMLSkeleton.java
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=406098&r1=406097&r2=406098&view=diff
==============================================================================
--- webservices/kandula/trunk/java/src/org/apache/kandula/Constants.java (original)
+++ webservices/kandula/trunk/java/src/org/apache/kandula/Constants.java Sat May 13 06:47:07 2006
@@ -21,80 +21,77 @@
/**
* @author <a href="mailto:thilina@opensource.lk"> Thilina Gunarathne </a>
*/
-abstract public interface Constants {
-
- //WS-Coordination URI's
-
- public static final String WS_COOR = "http://schemas.xmlsoap.org/ws/2004/10/wscoor";
-
- 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_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";
-
- //WS-AT URI's
-
- public static final String WS_AT = "http://schemas.xmlsoap.org/ws/2004/10/wsat";
-
- public static final String WS_AT_COMPLETION = "http://schemas.xmlsoap.org/ws/2004/10/wsat/Completion";
-
- public static final String WS_AT_COMMIT = "http://schemas.xmlsoap.org/ws/2004/10/wsat/Commit";
-
- 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_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_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_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_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_DURABLE_REGISTERED = "registered for durable 2PC";
-
- //WS-BA URI's
-
- public static final String WS_BA = "http://schemas.xmlsoap.org/ws/2004/10/wsba";
-
- //Kandula Specific
+public interface Constants {
+
+ // WS-Coordination URI's
+
+ static final String WS_COOR = "http://schemas.xmlsoap.org/ws/2004/10/wscoor";
+
+ static final String WS_COOR_CREATE_COORDINATIONCONTEXT = "http://schemas.xmlsoap.org/ws/2004/10/wscoor/CreateCoordinationContext";
+
+ static final String WS_COOR_CREATE_COORDINATIONCONTEXT_RESPONSE = "http://schemas.xmlsoap.org/ws/2004/10/wscoor/CreateCoordinationContextResponse";
+
+ static final String WS_COOR_REGISTER = "http://schemas.xmlsoap.org/ws/2004/10/wscoor/Register";
+
+ static final String WS_COOR_REGISTER_RESPONSE = "http://schemas.xmlsoap.org/ws/2004/10/wscoor/RegisterResponse";
+
+ // WS-AT URI's
+
+ static final String WS_AT = "http://schemas.xmlsoap.org/ws/2004/10/wsat";
+
+ static final String WS_AT_COMPLETION = "http://schemas.xmlsoap.org/ws/2004/10/wsat/Completion";
+
+ static final String WS_AT_COMMIT = "http://schemas.xmlsoap.org/ws/2004/10/wsat/Commit";
+
+ static final String WS_AT_COMMITTED = "http://schemas.xmlsoap.org/ws/2004/10/wsat/Committed";
+
+ static final String WS_AT_ROLLBACK = "http://schemas.xmlsoap.org/ws/2004/10/wsat/Rollback";
+
+ static final String WS_AT_ABORTED = "http://schemas.xmlsoap.org/ws/2004/10/wsat/Aborted";
+
+ static final String WS_AT_DURABLE2PC = "http://schemas.xmlsoap.org/ws/2004/10/wsat/Durable2PC";
+
+ static final String WS_AT_VOLATILE2PC = "http://schemas.xmlsoap.org/ws/2004/10/wsat/Volatile2PC";
+
+ static final String WS_AT_PREPARE = "http://schemas.xmlsoap.org/ws/2004/10/wsat/Prepare";
+
+ static final String WS_AT_PREPARED = "http://schemas.xmlsoap.org/ws/2004/10/wsat/Prepared";
+
+ static final String WS_AT_REPLAY = "http://schemas.xmlsoap.org/ws/2004/10/wsat/Replay";
+
+ static final String WS_AT_READONLY = "http://schemas.xmlsoap.org/ws/2004/10/wsat/ReadOnly";
+
+ static final String SUB_VOLATILE_REGISTERED = "registered for volatile 2PC";
+
+ static final String SUB_DURABLE_REGISTERED = "registered for durable 2PC";
+
+ // WS-BA URI's
+
+ 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 String KANDULA_RESOURCE = "KandulaResource";
-
- public static String KANDULA_PRE = "kand";
-
- public static String KANDULA_STORE = "KandulaStore";
-
+ static String KANDULA_URI = "http://ws.apache.org/kandula";
+
+ static String KANDULA_RESOURCE = "KandulaResource";
+
+ static String KANDULA_PRE = "kand";
+
+ 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,
+ 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,
+
+ // Used by the Initiator Transaction Manager & participant TM to track the seperate transactions
+ static final QName REQUESTER_ID_PARAMETER = new QName(KANDULA_URI,
"RequesterID", KANDULA_PRE);
-
- //For the coordinator to identify each and every registered participant
+
+ // 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,
+ // This + Tx_ID will be unique for a participant
+ 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=406098&r1=406097&r2=406098&view=diff
==============================================================================
--- webservices/kandula/trunk/java/src/org/apache/kandula/Status.java (original)
+++ webservices/kandula/trunk/java/src/org/apache/kandula/Status.java Sat May 13 06:47:07 2006
@@ -1,61 +1,61 @@
/*
- * Copyright 2004 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
+* Copyright 2004 The Apache Software Foundation.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*
+*/
package org.apache.kandula;
/**
* @author <a href="mailto:thilina@opensource.lk"> Thilina Gunarathne </a>
*/
-abstract public interface Status {
- //TODO remove the inner interfaces..
- interface ParticipantStatus {
-
- public static final int STATUS_VOLATILE_PREPARING = 20;
-
- public static final int STATUS_DURABLE_PREPARING = 21;
-
- public static final int STATUS_ABORTED = 22;
-
- public static final int STATUS_READ_ONLY = 23;
-
- public static final int STATUS_COMMITED = 24;
-
- }
-
+public abstract interface Status {
interface CoordinatorStatus {
-
- public static final int STATUS_NONE = 6;
-
- public static final int STATUS_COMMITTING = 8;
-
- public static final int STATUS_PREPARING = 10;
-
- public static final int STATUS_PREPARING_DURABLE = 11;
-
- public static final int STATUS_PREPARING_VOLATILE = 12;
-
- public static final int STATUS_PREPARED_SUCCESS = 13;
-
- public static final int STATUS_READ_ONLY = 23;
-
- public static final int STATUS_PREPARED = 14;
-
- public static final int STATUS_ABORTING = 9;
-
- public static final int STATUS_ACTIVE = 0;
-
+
+ static final int STATUS_ABORTING = 9;
+
+ static final int STATUS_ACTIVE = 0;
+
+ static final int STATUS_COMMITTING = 8;
+
+ static final int STATUS_NONE = 6;
+
+ static final int STATUS_PREPARED = 14;
+
+ static final int STATUS_PREPARED_SUCCESS = 13;
+
+ static final int STATUS_PREPARING = 10;
+
+ static final int STATUS_PREPARING_DURABLE = 11;
+
+ static final int STATUS_PREPARING_VOLATILE = 12;
+
+ static final int STATUS_READ_ONLY = 23;
+
+ }
+
+ // TODO remove the inner interfaces..
+ interface ParticipantStatus {
+
+ static final int STATUS_ABORTED = 22;
+
+ static final int STATUS_COMMITED = 24;
+
+ static final int STATUS_DURABLE_PREPARING = 21;
+
+ static final int STATUS_READ_ONLY = 23;
+
+ static final int STATUS_VOLATILE_PREPARING = 20;
+
}
}
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=406098&r1=406097&r2=406098&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 Sat May 13 06:47:07 2006
@@ -26,86 +26,89 @@
* @author <a href="mailto:thilina@opensource.lk"> Thilina Gunarathne </a>
*/
public abstract class AbstractContext {
-
- private final HashMap propertyBag;
-
+
+ public static String ACTIVATION_EPR = "activationEPR";
+
+ public static String COORDINATION_EPR = "coordinationEPR";
+
+ public static String REQUESTER_ID = "requesterID";
+
protected String activityID;
-
- private int status = Status.CoordinatorStatus.STATUS_NONE;
-
- 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";
-
+
+ private boolean locked = false;
+
+ private final HashMap propertyBag;
+
+ private int status = Status.CoordinatorStatus.STATUS_NONE;
+
protected AbstractContext() {
propertyBag = new HashMap();
}
-
+
public AbstractContext(String coordinationType) {
propertyBag = new HashMap();
- activityID = "urn:"+EndpointReferenceFactory.getRandomStringOf18Characters();
+ activityID = "urn:"
+ + EndpointReferenceFactory.getRandomStringOf18Characters();
EndpointReference registrationEpr = EndpointReferenceFactory
- .getInstance().getRegistrationEndpoint(activityID);
+ .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 abstract String getCoordinationType();
+
+ public abstract String getRegistrationProtocol();
+
+ public final Object getProperty(Object key) {
+ return propertyBag.get(key);
}
-
+
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
+ // ignore
}
if (status == Status.CoordinatorStatus.STATUS_NONE)
throw new IllegalStateException();
}
}
-
+
locked = true;
}
-
+
+ public final void setCoordinationContext(CoordinationContext context) {
+ this.coordinationContext = context;
+ }
+
+ public final void setProperty(Object key, Object value) {
+ propertyBag.put(key, value);
+
+ }
+
+ // we can use a publisher-subscriber in the future to notify listeners abt
+ // state changes.
+ public final void setStatus(int value) {
+ status = value;
+ }
+
public 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();
-
+
}
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=406098&r1=406097&r2=406098&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 Sat May 13 06:47:07 2006
@@ -25,22 +25,33 @@
*/
public class ContextFactory {
private static ContextFactory instance = new ContextFactory();
-
+
public static ContextFactory getInstance() {
return instance;
}
-
+
+ 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(String protocol)
- throws InvalidProtocolException {
+ throws InvalidProtocolException {
if (org.apache.kandula.Constants.WS_AT.equalsIgnoreCase(protocol)) {
return new ATActivityContext();
} else {
throw new InvalidProtocolException("Unsupported Protocol Type");
}
}
-
+
/**
* To be used by the initaitor TxManager to create the initial context
+ *
* @param protocol
* @param activationEPR
* @return
@@ -50,16 +61,6 @@
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");
}
Modified: webservices/kandula/trunk/java/src/org/apache/kandula/context/CoordinationContext.java
URL: http://svn.apache.org/viewcvs/webservices/kandula/trunk/java/src/org/apache/kandula/context/CoordinationContext.java?rev=406098&r1=406097&r2=406098&view=diff
==============================================================================
--- webservices/kandula/trunk/java/src/org/apache/kandula/context/CoordinationContext.java (original)
+++ webservices/kandula/trunk/java/src/org/apache/kandula/context/CoordinationContext.java Sat May 13 06:47:07 2006
@@ -24,42 +24,42 @@
* @author <a href="mailto:thilina@opensource.lk"> Thilina Gunarathne </a>
*/
public interface CoordinationContext {
- public abstract String getActivityID();
-
- public abstract String getCoordinationType();
-
- public abstract EndpointReference getRegistrationService();
-
- public abstract long getExpires();
-
- public abstract void setActivityID(String value);
-
- public abstract void setCoordinationType(String value);
-
- public abstract void setRegistrationService(EndpointReference value);
-
- public abstract void setExpires(long value);
-
- public abstract OMElement toOM();
-
- public abstract Object getCoordinationContextType();
-
public static final class Factory {
+ public static CoordinationContext newContext(OMElement contextElement) {
+ return new SimpleCoordinationContext(contextElement);
+ }
+
public static CoordinationContext newContext(String activityId,
String coordinationType, EndpointReference epr) {
return new SimpleCoordinationContext(activityId, coordinationType,
epr);
}
-
- public static CoordinationContext newContext(OMElement contextElement) {
- return new SimpleCoordinationContext(contextElement);
- }
-
- // public static CoordinationContext newInstance(Object contextType) {
- // return new XmlBeansTypeCoordinationContext(contextType);
- // }
-
+
+ // public static CoordinationContext newInstance(Object contextType) {
+ // return new XmlBeansTypeCoordinationContext(contextType);
+ // }
+
private Factory() {
} // No instance of this class allowed
}
+
+ public abstract String getActivityID();
+
+ public abstract Object getCoordinationContextType();
+
+ public abstract String getCoordinationType();
+
+ public abstract long getExpires();
+
+ public abstract EndpointReference getRegistrationService();
+
+ public abstract void setActivityID(String value);
+
+ public abstract void setCoordinationType(String value);
+
+ public abstract void setExpires(long value);
+
+ public abstract void setRegistrationService(EndpointReference value);
+
+ public abstract OMElement toOM();
}
Modified: webservices/kandula/trunk/java/src/org/apache/kandula/context/impl/ATActivityContext.java
URL: http://svn.apache.org/viewcvs/webservices/kandula/trunk/java/src/org/apache/kandula/context/impl/ATActivityContext.java?rev=406098&r1=406097&r2=406098&view=diff
==============================================================================
--- webservices/kandula/trunk/java/src/org/apache/kandula/context/impl/ATActivityContext.java (original)
+++ webservices/kandula/trunk/java/src/org/apache/kandula/context/impl/ATActivityContext.java Sat May 13 06:47:07 2006
@@ -36,26 +36,26 @@
* @author <a href="mailto:thilina@opensource.lk"> Thilina Gunarathne </a>
*/
public class ATActivityContext extends AbstractContext {
-
+
+ private Method callBackMethod = null;
+
+ // TODO : check whether there can be more than 1 initiator
+ private EndpointReference completionParticipant;
+
+ private Hashtable durableParticipantsTable;
+
+ private EndpointReference parentEPR;
+
private int preparingParticipantsCount = 0;
-
+
+ private boolean subDurableRegistered = false;
+
private boolean subOrdinate = false;
-
- private Hashtable volatileParticipantsTable;
-
- 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;
- private Method callBackMethod=null;
-
+ private Hashtable volatileParticipantsTable;
+
/**
* Used when creating new activities
*/
@@ -65,7 +65,7 @@
volatileParticipantsTable = new Hashtable();
durableParticipantsTable = new Hashtable();
}
-
+
/**
* @param context
* To be used when coordinator is used as a sub ordinate to an
@@ -74,14 +74,14 @@
public ATActivityContext(CoordinationContext context) {
subOrdinate = true;
parentEPR = context.getRegistrationService();
- // context.setRegistrationService(EndpointReferenceFactory.getInstance()
- // .getRegistrationEndpoint());
+ // context.setRegistrationService(EndpointReferenceFactory.getInstance()
+ // .getRegistrationEndpoint());
this.setStatus(Status.CoordinatorStatus.STATUS_ACTIVE);
volatileParticipantsTable = new Hashtable();
durableParticipantsTable = new Hashtable();
setCoordinationContext(context);
}
-
+
/**
* @param id
* To be used when using as the requester
@@ -92,7 +92,17 @@
.getRandomStringOf18Characters());
this.setProperty(ACTIVATION_EPR, activationEPR);
}
-
+
+ public void addDurableParticipant(EndpointReference participantEPR,
+ String enlistmentID) throws AlreadyRegisteredException {
+ if (durableParticipantsTable.contains(participantEPR)) {
+ throw new AlreadyRegisteredException();
+ }
+ ATParticipantInformation participant = new ATParticipantInformation(
+ participantEPR, Constants.WS_AT_DURABLE2PC, enlistmentID);
+ durableParticipantsTable.put(enlistmentID, participant);
+ }
+
/**
* @param participantEPR
* @param protocol
@@ -101,144 +111,136 @@
*/
public EndpointReference addParticipant(EndpointReference participantEPR,
String protocol) throws AbstractKandulaException {
- String enlistmentID = EndpointReferenceFactory.getRandomStringOf18Characters();
+ String enlistmentID = EndpointReferenceFactory
+ .getRandomStringOf18Characters();
if (Constants.WS_AT_VOLATILE2PC.equals(protocol)) {
addVolatileParticipant(participantEPR, enlistmentID);
return EndpointReferenceFactory.getInstance()
- .get2PCCoordinatorEndpoint(activityID, enlistmentID);
+ .get2PCCoordinatorEndpoint(activityID, enlistmentID);
} else if (Constants.WS_AT_DURABLE2PC.equals(protocol)) {
addDurableParticipant(participantEPR, enlistmentID);
return EndpointReferenceFactory.getInstance()
- .get2PCCoordinatorEndpoint(activityID, enlistmentID);
+ .get2PCCoordinatorEndpoint(activityID, enlistmentID);
} else if (Constants.WS_AT_COMPLETION.equals(protocol)) {
completionParticipant = participantEPR;
return EndpointReferenceFactory.getInstance()
- .getCompletionEndpoint(this.activityID);
+ .getCompletionEndpoint(this.activityID);
} else {
throw new InvalidProtocolException();
}
}
-
- public void removeParticipant(String enlistmentID)
- {
- //TODO: what to do if the participant is not found
- if (durableParticipantsTable.containsKey(enlistmentID))
- {
- durableParticipantsTable.remove(enlistmentID);
- }else if(volatileParticipantsTable.containsKey(enlistmentID))
- {
- volatileParticipantsTable.remove(enlistmentID);
- }
- }
-
public void addVolatileParticipant(EndpointReference participantEPR,
String enlistmentID) throws AbstractKandulaException {
if (volatileParticipantsTable.contains(participantEPR))
throw new AlreadyRegisteredException();
- ATParticipantInformation participant = new ATParticipantInformation(participantEPR,
- Constants.WS_AT_VOLATILE2PC, enlistmentID);
+ ATParticipantInformation participant = new ATParticipantInformation(
+ 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();
- }
- ATParticipantInformation participant = new ATParticipantInformation(participantEPR,
- Constants.WS_AT_DURABLE2PC, enlistmentID);
- durableParticipantsTable.put(enlistmentID, participant);
+
+ public synchronized void countPreparing() {
+ preparingParticipantsCount++;
+
}
-
- 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 synchronized void decrementPreparing() {
+ preparingParticipantsCount--;
}
-
+
public Iterator getAll2PCParticipants() {
LinkedList list = new LinkedList(volatileParticipantsTable.values());
list.addAll(durableParticipantsTable.values());
return list.iterator();
}
-
- public ATParticipantInformation getParticipant(String enlistmentId) {
- if (volatileParticipantsTable.containsKey(enlistmentId)) {
- return (ATParticipantInformation) volatileParticipantsTable.get(enlistmentId);
- } else if (durableParticipantsTable.containsKey(enlistmentId)) {
- return (ATParticipantInformation) durableParticipantsTable.get(enlistmentId);
- } else {
- return null;
- }
+
+ /**
+ * @return Returns the callBackMethod.
+ */
+ public Method getCallBackMethod() {
+ return callBackMethod;
}
-
+
/**
* @return the completion initiator epr
*/
public EndpointReference getCompletionParticipant() {
return completionParticipant;
}
-
- public synchronized void countPreparing() {
- preparingParticipantsCount++;
-
- }
-
- public synchronized void decrementPreparing() {
- preparingParticipantsCount--;
+
+ public String getCoordinationType() {
+ return Constants.WS_AT;
}
-
- public synchronized boolean hasMorePreparing() {
- return (preparingParticipantsCount > 0);
+
+ public int getDurableParticipantCount() {
+ return durableParticipantsTable.size();
}
-
- public int getVolatileParticipantCount()
+
+ public String getRegistrationProtocol()
{
- return volatileParticipantsTable.size();
+ return Constants.WS_AT_COMPLETION;
}
- public int getDurableParticipantCount()
- {
- return durableParticipantsTable.size();
+ public ATParticipantInformation getParticipant(String enlistmentId) {
+ if (volatileParticipantsTable.containsKey(enlistmentId)) {
+ return (ATParticipantInformation) volatileParticipantsTable
+ .get(enlistmentId);
+ } else if (durableParticipantsTable.containsKey(enlistmentId)) {
+ return (ATParticipantInformation) durableParticipantsTable
+ .get(enlistmentId);
+ } else {
+ return null;
+ }
}
-
+ 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 boolean getSubDurableRegistered() {
+ return subDurableRegistered;
+ }
- public String getCoordinationType() {
- return Constants.WS_AT;
+ public boolean getSubVolatileRegistered() {
+
+ return subVolatileRegistered;
}
-
- /**
- * @return Returns the callBackMethod.
- */
- public Method getCallBackMethod() {
- return callBackMethod;
+
+ public int getVolatileParticipantCount() {
+ return volatileParticipantsTable.size();
+ }
+
+ public synchronized boolean hasMorePreparing() {
+ return (preparingParticipantsCount > 0);
}
+
+ public void removeParticipant(String enlistmentID) {
+ // TODO: what to do if the participant is not found
+ if (durableParticipantsTable.containsKey(enlistmentID)) {
+ durableParticipantsTable.remove(enlistmentID);
+ } else if (volatileParticipantsTable.containsKey(enlistmentID)) {
+ volatileParticipantsTable.remove(enlistmentID);
+ }
+ }
+
/**
- * @param callBackMethod The callBackMethod to set.
+ * @param callBackMethod
+ * The callBackMethod to set.
*/
public void setCallBackMethod(Method callBackMethod) {
this.callBackMethod = callBackMethod;
}
- public boolean getSubVolatileRegistered() {
-
- return subVolatileRegistered;
- }
-
- public boolean getSubDurableRegistered() {
- return subDurableRegistered;
+
+ public void setSubDurableRegistered(boolean value) {
+ subDurableRegistered = value;
}
-
+
public void setSubVolatileRegistered(boolean value) {
subVolatileRegistered = value;
- }
-
- public void setSubDurableRegistered(boolean value) {
- subDurableRegistered = value;
}
}
Modified: webservices/kandula/trunk/java/src/org/apache/kandula/context/impl/ATParticipantContext.java
URL: http://svn.apache.org/viewcvs/webservices/kandula/trunk/java/src/org/apache/kandula/context/impl/ATParticipantContext.java?rev=406098&r1=406097&r2=406098&view=diff
==============================================================================
--- webservices/kandula/trunk/java/src/org/apache/kandula/context/impl/ATParticipantContext.java (original)
+++ webservices/kandula/trunk/java/src/org/apache/kandula/context/impl/ATParticipantContext.java Sat May 13 06:47:07 2006
@@ -27,37 +27,40 @@
*/
public class ATParticipantContext extends AbstractContext {
KandulaResource resource;
-
+
public ATParticipantContext() {
this.setStatus(Status.CoordinatorStatus.STATUS_ACTIVE);
}
-
+
+ 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;
+ }
+
/**
- * @return Returns the resource.
+ * @return Returns the transaction partcipant resource.
*/
public KandulaResource getResource() {
return resource;
}
-
+
/**
- * @param resource
- * The resource to set.
+ * @param setting the transaction participant resource
*/
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);
+ public String getRegistrationProtocol() {
+ return resource.getProtocol();
}
-
+
}
Modified: webservices/kandula/trunk/java/src/org/apache/kandula/context/impl/SimpleCoordinationContext.java
URL: http://svn.apache.org/viewcvs/webservices/kandula/trunk/java/src/org/apache/kandula/context/impl/SimpleCoordinationContext.java?rev=406098&r1=406097&r2=406098&view=diff
==============================================================================
--- webservices/kandula/trunk/java/src/org/apache/kandula/context/impl/SimpleCoordinationContext.java (original)
+++ webservices/kandula/trunk/java/src/org/apache/kandula/context/impl/SimpleCoordinationContext.java Sat May 13 06:47:07 2006
@@ -32,22 +32,15 @@
*/
public class SimpleCoordinationContext implements CoordinationContext {
private String activityID;
-
+
+ private OMElement contextElement = null;
+
private String coordinationType;
-
+
private long expires;
-
+
private EndpointReference registrationServiceEpr;
-
- private OMElement contextElement = null;
-
- public SimpleCoordinationContext(String activityID,
- String coordinationType, EndpointReference epr) {
- this.activityID = activityID;
- this.coordinationType = coordinationType;
- this.registrationServiceEpr = epr;
- }
-
+
public SimpleCoordinationContext(OMElement contextElement) {
super();
this.contextElement = contextElement;
@@ -56,56 +49,63 @@
coordinationType = contextElement.getFirstChildWithName(
new QName("CoordinationType")).getText();
OMElement registrationElement = contextElement
- .getFirstChildWithName(new QName("RegistrationService"));
+ .getFirstChildWithName(new QName("RegistrationService"));
registrationServiceEpr = EndpointReferenceFactory
- .endpointFromOM(registrationElement);
+ .endpointFromOM(registrationElement);
}
-
+
+ public SimpleCoordinationContext(String activityID,
+ String coordinationType, EndpointReference epr) {
+ this.activityID = activityID;
+ this.coordinationType = coordinationType;
+ this.registrationServiceEpr = epr;
+ }
+
public String getActivityID() {
return activityID;
}
-
+
+ public Object getCoordinationContextType() {
+ return this;
+ }
+
public String getCoordinationType() {
return coordinationType;
}
-
- public EndpointReference getRegistrationService() {
- return this.registrationServiceEpr;
- }
-
+
public long getExpires() {
return expires;
}
-
+
+ public EndpointReference getRegistrationService() {
+ return this.registrationServiceEpr;
+ }
+
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 void setRegistrationService(EndpointReference epr) {
+ this.registrationServiceEpr = epr;
}
-
+
public OMElement toOM() {
if (contextElement != null) {
return contextElement;
} else {
SOAPFactory factory = OMAbstractFactory.getSOAP12Factory();
OMNamespace wsCoor = factory.createOMNamespace(Constants.WS_COOR,
- "wscoor");
+ "wscoor");
OMElement contextElement = factory.createOMElement(
"CoordinationContext", wsCoor);
if (this.expires != 0) {
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=406098&r1=406097&r2=406098&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 Sat May 13 06:47:07 2006
@@ -37,6 +37,23 @@
}
/**
+ * @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 coordinationType
* @return the Coordination Context created <p/>Initiators can use this to
* Create new Distributed transactions.This will take in the
@@ -55,21 +72,8 @@
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;
+ private AbstractContext getCoordinationContext(String id) {
+ return (AbstractContext) store.get(id);
}
/**
@@ -96,9 +100,5 @@
.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=406098&r1=406097&r2=406098&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 Sat May 13 06:47:07 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 static final class Factory {
public static Registerable newRegisterable(String coordinationType)
- throws InvalidProtocolException {
+ throws InvalidProtocolException {
if (Constants.WS_AT.equals(coordinationType)) {
-
+
return new ATCoordinator();
-
+
} else {
throw new InvalidProtocolException(
- "Unsupported Coordination Type");
+ "Unsupported Coordination Type");
}
}
-
+
private Factory() {
}
}
+
+ public EndpointReference register(AbstractContext context, String protocol,
+ EndpointReference participantEPR) throws AbstractKandulaException;
}
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=406098&r1=406097&r2=406098&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 Sat May 13 06:47:07 2006
@@ -47,41 +47,92 @@
store = storageFactory.getStore();
}
- public EndpointReference register(AbstractContext context, String protocol,
- EndpointReference participantEPR) throws AbstractKandulaException {
+ /**
+ * @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();
- switch (atContext.getStatus()) {
- case CoordinatorStatus.STATUS_PREPARING_DURABLE:
- atContext.unlock();
- try {
- this.abortActivity(atContext);
- } catch (Exception e) {
- throw new InvalidStateException(e);
+ atContext.setStatus(Status.CoordinatorStatus.STATUS_ABORTING);
+ atContext.unlock();
+ Iterator participants = atContext.getAll2PCParticipants();
+
+ while (participants.hasNext()) {
+ stub.rollbackOperation(((ATParticipantInformation) participants
+ .next()).getEpr());
+ }
+ CompletionInitiatorPortTypeRawXMLStub completionStub = new CompletionInitiatorPortTypeRawXMLStub(
+ atContext.getCompletionParticipant());
+ completionStub.abortedOperation();
+
+ }
+
+ public void abortedOperation(String activityID, String enlistmentID)
+ throws AbstractKandulaException {
+ ATActivityContext atContext = (ATActivityContext) store.get(activityID);
+ synchronized (atContext) {
+ atContext.lock();
+ switch (atContext.getStatus()) {
+ case CoordinatorStatus.STATUS_NONE:
+ atContext.unlock();
+ break;
+ case CoordinatorStatus.STATUS_ABORTING:
+ atContext.unlock();
+ atContext.removeParticipant(enlistmentID);
+ break;
+ case CoordinatorStatus.STATUS_PREPARING_DURABLE:
+ case CoordinatorStatus.STATUS_PREPARING_VOLATILE:
+ case Status.CoordinatorStatus.STATUS_ACTIVE:
+ atContext.unlock();
+ atContext.removeParticipant(enlistmentID);
+ abortActivity(atContext);
+ break;
+ case CoordinatorStatus.STATUS_PREPARED_SUCCESS:
+ case CoordinatorStatus.STATUS_COMMITTING:
+ // Invalid state
+ atContext.unlock();
+ break;
+ default:
+ atContext.unlock();
+ break;
}
- throw new InvalidStateException(
- "Coordinator is in preparing state - Durable ");
- case CoordinatorStatus.STATUS_PREPARED_SUCCESS:
- atContext.unlock();
- throw new InvalidStateException(
- "Coordinator is in prepared success state");
- case CoordinatorStatus.STATUS_COMMITTING:
- atContext.unlock();
- throw new InvalidStateException(
- "Coordinator is in committing state");
- case CoordinatorStatus.STATUS_ABORTING:
- atContext.unlock();
- throw new InvalidStateException("Coordinator is in Aborting state");
- case CoordinatorStatus.STATUS_ACTIVE:
- case CoordinatorStatus.STATUS_PREPARING_VOLATILE:
- atContext.unlock();
- return atContext.addParticipant(participantEPR, protocol);
+ }
+ }
- case CoordinatorStatus.STATUS_NONE:
- default:
- atContext.unlock();
- throw new InvalidStateException();
+ /**
+ * @param 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()
+ */
+ public 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()) {
+ ATParticipantInformation participant = (ATParticipantInformation) participants
+ .next();
+ if (!(Status.CoordinatorStatus.STATUS_READ_ONLY == participant
+ .getStatus())) {
+ stub.commitOperation(participant.getEpr());
+ }
}
+ CompletionInitiatorPortTypeRawXMLStub completionStub = new CompletionInitiatorPortTypeRawXMLStub(
+ atContext.getCompletionParticipant());
+ completionStub.committedOperation();
}
/**
@@ -141,7 +192,137 @@
}
- public void rollbackOperation(String id) throws Exception {
+ public void countParticipantOutcome(String activityID, String enlistmentID)
+ throws AbstractKandulaException {
+ ATActivityContext context = (ATActivityContext) store.get(activityID);
+ context.removeParticipant(enlistmentID);
+ }
+
+ /**
+ *
+ * @param activityID
+ * @param vote
+ * @param enlistmentID
+ * @throws AbstractKandulaException
+ */
+ // TODO seperate these TWO and check states for each case
+ public void countVote(String activityID, Vote vote, String enlistmentID)
+ throws AbstractKandulaException {
+ ATActivityContext context = (ATActivityContext) store.get(activityID);
+ ATParticipantInformation 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);
+ }
+ /*
+ * There can be a two invocations of the callback methode due to race
+ * conditions at decrement preparing and count preparing
+ */
+ synchronized (context) {
+ context.decrementPreparing();
+ if (!context.hasMorePreparing()) {
+ context.lock();
+ if (!(context.getStatus() == Status.CoordinatorStatus.STATUS_ABORTING)) {
+ context.unlock();
+ Method method = context.getCallBackMethod();
+ try {
+ method.invoke(this, new Object[] { context });
+
+ } catch (Exception e) {
+ throw new KandulaGeneralException(
+ "Internal Server Error", e);
+ }
+ } else {
+ context.unlock();
+ }
+ }
+ }
+
+ }
+
+ /**
+ * @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);
+
+ synchronized (atContext) {
+ if (durablePartipantIterator.hasNext()) {
+ atContext.lock();
+ atContext
+ .setStatus(Status.CoordinatorStatus.STATUS_PREPARING_DURABLE);
+ atContext.unlock();
+ while (durablePartipantIterator.hasNext()) {
+ atContext.countPreparing();
+ stub
+ .prepareOperation(((ATParticipantInformation) durablePartipantIterator
+ .next()).getEpr());
+ }
+ }
+
+ try {
+ Method method = ATCoordinator.class.getMethod("commitActivity",
+ new Class[] { AbstractContext.class });
+ atContext.setCallBackMethod(method);
+ } catch (Exception e) {
+ throw new KandulaGeneralException(
+ "Internal Kandula Server Error ", e);
+ }
+ }
+
+ }
+
+ 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();
+ }
+ }
+
+ public void rollbackOperation(String id) throws AbstractKandulaException {
CompletionInitiatorPortTypeRawXMLStub stub;
ATActivityContext atContext = (ATActivityContext) store.get(id);
@@ -185,37 +366,6 @@
}
}
- public void abortedOperation(String activityID, String enlistmentID) throws AbstractKandulaException {
- ATActivityContext atContext = (ATActivityContext) store.get(activityID);
- synchronized (atContext) {
- atContext.lock();
- switch (atContext.getStatus()) {
- case CoordinatorStatus.STATUS_NONE:
- atContext.unlock();
- break;
- case CoordinatorStatus.STATUS_ABORTING:
- atContext.unlock();
- atContext.removeParticipant(enlistmentID);
- break;
- case CoordinatorStatus.STATUS_PREPARING_DURABLE:
- case CoordinatorStatus.STATUS_PREPARING_VOLATILE:
- case Status.CoordinatorStatus.STATUS_ACTIVE:
- atContext.unlock();
- atContext.removeParticipant(enlistmentID);
- abortActivity(atContext);
- break;
- case CoordinatorStatus.STATUS_PREPARED_SUCCESS:
- case CoordinatorStatus.STATUS_COMMITTING:
- // Invalid state
- atContext.unlock();
- break;
- default:
- atContext.unlock();
- break;
- }
- }
- }
-
/**
* @param context
* @throws Exception
@@ -267,155 +417,6 @@
}
}
- }
-
- /**
- * @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);
-
- synchronized (atContext) {
- if (durablePartipantIterator.hasNext()) {
- atContext.lock();
- atContext
- .setStatus(Status.CoordinatorStatus.STATUS_PREPARING_DURABLE);
- atContext.unlock();
- while (durablePartipantIterator.hasNext()) {
- atContext.countPreparing();
- stub
- .prepareOperation(((ATParticipantInformation) durablePartipantIterator
- .next()).getEpr());
- }
- }
-
- try {
- Method method = ATCoordinator.class.getMethod("commitActivity",
- new Class[] { AbstractContext.class });
- atContext.setCallBackMethod(method);
- } catch (Exception e) {
- throw new KandulaGeneralException(
- "Internal Kandula Server Error ", e);
- }
- }
-
- }
-
- /**
- * @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()
- */
- public 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()) {
- ATParticipantInformation participant = (ATParticipantInformation) 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(((ATParticipantInformation) participants
- .next()).getEpr());
- }
- CompletionInitiatorPortTypeRawXMLStub completionStub = new CompletionInitiatorPortTypeRawXMLStub(
- atContext.getCompletionParticipant());
- completionStub.abortedOperation();
-
- }
-
- /**
- *
- * @param activityID
- * @param vote
- * @param enlistmentID
- * @throws AbstractKandulaException
- */
- // TODO seperate these TWO and check states for each case
- public void countVote(String activityID, Vote vote, String enlistmentID)
- throws AbstractKandulaException {
- ATActivityContext context = (ATActivityContext) store.get(activityID);
- ATParticipantInformation 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);
- }
- /*
- * There can be a two invocations of the callback methode due to race
- * conditions at decrement preparing and count preparing
- */
- synchronized (context) {
- context.decrementPreparing();
- if (!context.hasMorePreparing()) {
- context.lock();
- if (!(context.getStatus() == Status.CoordinatorStatus.STATUS_ABORTING)) {
- context.unlock();
- Method method = context.getCallBackMethod();
- try {
- method.invoke(this, new Object[] { context });
-
- } catch (Exception e) {
- throw new KandulaGeneralException(
- "Internal Server Error", e);
- }
- } else {
- context.unlock();
- }
- }
- }
-
- }
-
- public void countParticipantOutcome(String activityID, String enlistmentID)
- throws AbstractKandulaException {
- ATActivityContext context = (ATActivityContext) store.get(activityID);
- context.removeParticipant(enlistmentID);
}
}
Modified: webservices/kandula/trunk/java/src/org/apache/kandula/coordinator/at/ATParticipantInformation.java
URL: http://svn.apache.org/viewcvs/webservices/kandula/trunk/java/src/org/apache/kandula/coordinator/at/ATParticipantInformation.java?rev=406098&r1=406097&r2=406098&view=diff
==============================================================================
--- webservices/kandula/trunk/java/src/org/apache/kandula/coordinator/at/ATParticipantInformation.java (original)
+++ webservices/kandula/trunk/java/src/org/apache/kandula/coordinator/at/ATParticipantInformation.java Sat May 13 06:47:07 2006
@@ -17,25 +17,27 @@
package org.apache.kandula.coordinator.at;
import org.apache.axis2.addressing.EndpointReference;
+
/**
- * * @author <a href="mailto:thilina@opensource.lk"> Thilina Gunarathne </a>
+ * *
+ *
+ * @author <a href="mailto:thilina@opensource.lk"> Thilina Gunarathne </a>
*/
/**
- * <p/>
- * Used to store the details about the participant & to store the
- * runtime status of Participants in the coordinator.
+ * <p/> Used to store the details about the participant & to store the runtime
+ * status of Participants in the coordinator.
*/
public class ATParticipantInformation {
+ private String enlistmentId;
+
private EndpointReference epr;
private String protocol;
private int status;
- private String enlistmentId;
-
/**
* @param epr
* @param protocol
@@ -50,46 +52,39 @@
}
/**
- * @return Returns the enlistmentId.
+ * @return Returns the Id which this participant is registered with the
+ * coordinator
*/
public String getEnlistmentId() {
return enlistmentId;
}
/**
- * @return Returns the epr.
+ * @return Returns the epr of the participant
*/
public EndpointReference getEpr() {
return epr;
}
/**
- * @param epr -
- * The epr to set.
+ * @return Returns the protocol of the participant (Eg: WS-AT, WS-BA)
*/
- public void setEpr(EndpointReference epr) {
- this.epr = epr;
+ public String getProtocol() {
+ return protocol;
}
/**
- * @return Returns the status.
+ * @return Returns the status of the participant
*/
public int getStatus() {
return status;
}
- /**
- * @param status -
- * The status to set.
- */
- public void setStatus(int status) {
- this.status = status;
+ public void setEpr(EndpointReference epr) {
+ this.epr = epr;
}
- /**
- * @return Returns the protocol.
- */
- public String getProtocol() {
- return protocol;
+ public void setStatus(int status) {
+ this.status = status;
}
}
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=406098&r1=406097&r2=406098&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 Sat May 13 06:47:07 2006
@@ -28,23 +28,13 @@
*/
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 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
+ // have to register with the parent coordinator
atContext.setSubDurableRegistered(true);
}
return atContext.addParticipant(participantEPR, protocol);
@@ -52,12 +42,22 @@
else if (protocol.equals(Constants.WS_AT_VOLATILE2PC)) {
if (!atContext.getSubDurableRegistered()) {
- //have to register with the parent coordinator
+ // have to register with the parent coordinator
atContext.setSubDurableRegistered(true);
}
return atContext.addParticipant(participantEPR, protocol);
} else
throw new InvalidProtocolException();
+ }
+
+ 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.");
}
}
Modified: webservices/kandula/trunk/java/src/org/apache/kandula/coordinator/at/ExecutionCallBack.java
URL: http://svn.apache.org/viewcvs/webservices/kandula/trunk/java/src/org/apache/kandula/coordinator/at/ExecutionCallBack.java?rev=406098&r1=406097&r2=406098&view=diff
==============================================================================
--- webservices/kandula/trunk/java/src/org/apache/kandula/coordinator/at/ExecutionCallBack.java (original)
+++ webservices/kandula/trunk/java/src/org/apache/kandula/coordinator/at/ExecutionCallBack.java Sat May 13 06:47:07 2006
@@ -25,5 +25,6 @@
public interface ExecutionCallBack {
- public void process(AbstractContext context) throws AbstractKandulaException;
+ public void process(AbstractContext context)
+ throws AbstractKandulaException;
}
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=406098&r1=406097&r2=406098&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 Sat May 13 06:47:07 2006
@@ -28,7 +28,7 @@
public EndpointReference register(AbstractContext context, String protocol,
EndpointReference participantEPR) throws AbstractKandulaException {
- return null; //To change body of implemented methods use File |
+ return null; // To change body of implemented methods use File |
// Settings | File Templates.
}
}
Modified: webservices/kandula/trunk/java/src/org/apache/kandula/faults/AlreadyRegisteredException.java
URL: http://svn.apache.org/viewcvs/webservices/kandula/trunk/java/src/org/apache/kandula/faults/AlreadyRegisteredException.java?rev=406098&r1=406097&r2=406098&view=diff
==============================================================================
--- webservices/kandula/trunk/java/src/org/apache/kandula/faults/AlreadyRegisteredException.java (original)
+++ webservices/kandula/trunk/java/src/org/apache/kandula/faults/AlreadyRegisteredException.java Sat May 13 06:47:07 2006
@@ -21,11 +21,10 @@
*/
public class AlreadyRegisteredException extends AbstractKandulaException {
-
private static final long serialVersionUID = 354170092780305997L;
/**
- *
+ *
*/
public AlreadyRegisteredException() {
super();
Modified: webservices/kandula/trunk/java/src/org/apache/kandula/faults/ContextRefusedException.java
URL: http://svn.apache.org/viewcvs/webservices/kandula/trunk/java/src/org/apache/kandula/faults/ContextRefusedException.java?rev=406098&r1=406097&r2=406098&view=diff
==============================================================================
--- webservices/kandula/trunk/java/src/org/apache/kandula/faults/ContextRefusedException.java (original)
+++ webservices/kandula/trunk/java/src/org/apache/kandula/faults/ContextRefusedException.java Sat May 13 06:47:07 2006
@@ -27,7 +27,7 @@
private static final long serialVersionUID = -8743352104016426531L;
/**
- *
+ *
*/
public ContextRefusedException() {
super();
Modified: webservices/kandula/trunk/java/src/org/apache/kandula/faults/InvalidParameterException.java
URL: http://svn.apache.org/viewcvs/webservices/kandula/trunk/java/src/org/apache/kandula/faults/InvalidParameterException.java?rev=406098&r1=406097&r2=406098&view=diff
==============================================================================
--- webservices/kandula/trunk/java/src/org/apache/kandula/faults/InvalidParameterException.java (original)
+++ webservices/kandula/trunk/java/src/org/apache/kandula/faults/InvalidParameterException.java Sat May 13 06:47:07 2006
@@ -27,7 +27,7 @@
private static final long serialVersionUID = -6973003681131477662L;
/**
- *
+ *
*/
public InvalidParameterException() {
super();
Modified: webservices/kandula/trunk/java/src/org/apache/kandula/faults/InvalidProtocolException.java
URL: http://svn.apache.org/viewcvs/webservices/kandula/trunk/java/src/org/apache/kandula/faults/InvalidProtocolException.java?rev=406098&r1=406097&r2=406098&view=diff
==============================================================================
--- webservices/kandula/trunk/java/src/org/apache/kandula/faults/InvalidProtocolException.java (original)
+++ webservices/kandula/trunk/java/src/org/apache/kandula/faults/InvalidProtocolException.java Sat May 13 06:47:07 2006
@@ -27,7 +27,7 @@
private static final long serialVersionUID = -2145946140688935653L;
/**
- *
+ *
*/
public InvalidProtocolException() {
super();
Modified: webservices/kandula/trunk/java/src/org/apache/kandula/faults/InvalidStateException.java
URL: http://svn.apache.org/viewcvs/webservices/kandula/trunk/java/src/org/apache/kandula/faults/InvalidStateException.java?rev=406098&r1=406097&r2=406098&view=diff
==============================================================================
--- webservices/kandula/trunk/java/src/org/apache/kandula/faults/InvalidStateException.java (original)
+++ webservices/kandula/trunk/java/src/org/apache/kandula/faults/InvalidStateException.java Sat May 13 06:47:07 2006
@@ -27,7 +27,7 @@
private static final long serialVersionUID = 2526517532679685749L;
/**
- *
+ *
*/
public InvalidStateException() {
super();
Modified: webservices/kandula/trunk/java/src/org/apache/kandula/faults/KandulaGeneralException.java
URL: http://svn.apache.org/viewcvs/webservices/kandula/trunk/java/src/org/apache/kandula/faults/KandulaGeneralException.java?rev=406098&r1=406097&r2=406098&view=diff
==============================================================================
--- webservices/kandula/trunk/java/src/org/apache/kandula/faults/KandulaGeneralException.java (original)
+++ webservices/kandula/trunk/java/src/org/apache/kandula/faults/KandulaGeneralException.java Sat May 13 06:47:07 2006
@@ -27,7 +27,7 @@
private static final long serialVersionUID = 3605851255933308674L;
/**
- *
+ *
*/
public KandulaGeneralException(Exception e) {
super(e);
@@ -35,6 +35,10 @@
public KandulaGeneralException(String s, Exception e) {
super(s, e);
+ }
+
+ public KandulaGeneralException(String string) {
+ super(string);
}
/*
Modified: webservices/kandula/trunk/java/src/org/apache/kandula/faults/NoActivityException.java
URL: http://svn.apache.org/viewcvs/webservices/kandula/trunk/java/src/org/apache/kandula/faults/NoActivityException.java?rev=406098&r1=406097&r2=406098&view=diff
==============================================================================
--- webservices/kandula/trunk/java/src/org/apache/kandula/faults/NoActivityException.java (original)
+++ webservices/kandula/trunk/java/src/org/apache/kandula/faults/NoActivityException.java Sat May 13 06:47:07 2006
@@ -27,7 +27,7 @@
private static final long serialVersionUID = -1625567169353147393L;
/**
- *
+ *
*/
public NoActivityException() {
super();
Modified: webservices/kandula/trunk/java/src/org/apache/kandula/initiator/TransactionManager.java
URL: http://svn.apache.org/viewcvs/webservices/kandula/trunk/java/src/org/apache/kandula/initiator/TransactionManager.java?rev=406098&r1=406097&r2=406098&view=diff
==============================================================================
--- webservices/kandula/trunk/java/src/org/apache/kandula/initiator/TransactionManager.java (original)
+++ webservices/kandula/trunk/java/src/org/apache/kandula/initiator/TransactionManager.java Sat May 13 06:47:07 2006
@@ -54,33 +54,35 @@
store.put(context.getProperty(ATActivityContext.REQUESTER_ID), context);
}
+ public void begin(String axis2Home, String axis2Xml) throws Exception {
+ begin(axis2Home,axis2Xml,false);
+ }
/**
* @throws Exception
*/
- public void begin(String axis2Home, String axis2Xml) throws Exception {
+ public void begin(String axis2Home, String axis2Xml, boolean async) throws Exception {
this.axis2Home = axis2Home;
this.axis2Xml = axis2Xml;
AbstractContext context = getTransaction();
String id = (String) context
- .getProperty(ATActivityContext.REQUESTER_ID);
+ .getProperty(AbstractContext.REQUESTER_ID);
ActivationCoordinatorPortTypeRawXMLStub activationCoordinator = new ActivationCoordinatorPortTypeRawXMLStub(
axis2Home, axis2Xml, (EndpointReference) context
- .getProperty(ATActivityContext.ACTIVATION_EPR));
+ .getProperty(AbstractContext.ACTIVATION_EPR));
activationCoordinator.createCoordinationContextOperation(
- org.apache.kandula.Constants.WS_AT, id);
- while (context.getCoordinationContext() == null) {
- //allow other threads to execute
+ context,async);
+ while (async & context.getCoordinationContext() == null) {
+ // allow other threads to execute
Thread.sleep(10);
}
RegistrationCoordinatorPortTypeRawXMLStub registrationCoordinator = new RegistrationCoordinatorPortTypeRawXMLStub(
axis2Home, axis2Xml, context.getCoordinationContext()
.getRegistrationService());
+ //TODO make this unaware of the protocol
EndpointReference registrationRequeterPortEPR = EndpointReferenceFactory
.getInstance().getCompletionInitiatorEndpoint(id);
- registrationCoordinator.registerOperation(
- org.apache.kandula.Constants.WS_AT_COMPLETION,
- registrationRequeterPortEPR, id);
- while (context.getProperty(ATActivityContext.COORDINATION_EPR) == null) {
+ registrationCoordinator.registerOperation( context,registrationRequeterPortEPR,async);
+ while (async & context.getProperty(ATActivityContext.COORDINATION_EPR) == null) {
Thread.sleep(10);
}
}
@@ -99,6 +101,7 @@
if ((context.getStatus() == Status.ParticipantStatus.STATUS_ABORTED)) {
throw new Exception("Aborted");
}
+ forgetTransaction();
}
public void rollback() throws Exception {
@@ -112,24 +115,25 @@
| (context.getStatus() != Status.ParticipantStatus.STATUS_ABORTED)) {
Thread.sleep(10);
}
+ forgetTransaction();
}
- // public Transaction suspend() {
- // Transaction tx= getTransaction();
- // forget();
- // return tx;
- // }
+ // public Transaction suspend() {
+ // Transaction tx= getTransaction();
+ // forget();
+ // return tx;
+ // }
//
- // public void resume(Transaction tx) {
- // if (threadInfo.get() != null)
- // throw new IllegalStateException();
- // else
- // threadInfo.set(tx);
- // }
+ // public void resume(Transaction tx) {
+ // if (threadInfo.get() != null)
+ // throw new IllegalStateException();
+ // else
+ // threadInfo.set(tx);
+ // }
//
- // public void forget() {
- // threadInfo.set(null);
- // }
+ // public void forget() {
+ // threadInfo.set(null);
+ // }
public static AbstractContext getTransaction()
throws AbstractKandulaException {
@@ -140,5 +144,9 @@
throw new InvalidStateException("No Activity Found");
}
return context;
+ }
+ public static void forgetTransaction()
+ {
+ threadInfo.set(null);
}
}
Modified: webservices/kandula/trunk/java/src/org/apache/kandula/initiator/TransactionOutHandler.java
URL: http://svn.apache.org/viewcvs/webservices/kandula/trunk/java/src/org/apache/kandula/initiator/TransactionOutHandler.java?rev=406098&r1=406097&r2=406098&view=diff
==============================================================================
--- webservices/kandula/trunk/java/src/org/apache/kandula/initiator/TransactionOutHandler.java (original)
+++ webservices/kandula/trunk/java/src/org/apache/kandula/initiator/TransactionOutHandler.java Sat May 13 06:47:07 2006
@@ -25,7 +25,6 @@
import org.apache.kandula.context.CoordinationContext;
import org.apache.kandula.faults.AbstractKandulaException;
-
public class TransactionOutHandler extends AbstractHandler {
private static final long serialVersionUID = 4133392345837905499L;
@@ -50,4 +49,3 @@
}
}
}
-
Modified: webservices/kandula/trunk/java/src/org/apache/kandula/participant/ParticipantTransactionCoordinator.java
URL: http://svn.apache.org/viewcvs/webservices/kandula/trunk/java/src/org/apache/kandula/participant/ParticipantTransactionCoordinator.java?rev=406098&r1=406097&r2=406098&view=diff
==============================================================================
--- webservices/kandula/trunk/java/src/org/apache/kandula/participant/ParticipantTransactionCoordinator.java (original)
+++ webservices/kandula/trunk/java/src/org/apache/kandula/participant/ParticipantTransactionCoordinator.java Sat May 13 06:47:07 2006
@@ -43,7 +43,7 @@
case (Status.CoordinatorStatus.STATUS_PREPARING):
case (Status.CoordinatorStatus.STATUS_PREPARED):
case (Status.CoordinatorStatus.STATUS_COMMITTING):
- //Ignore the message
+ // Ignore the message
atContext.unlock();
break;
case (Status.CoordinatorStatus.STATUS_PREPARED_SUCCESS):
@@ -76,39 +76,37 @@
public void commit(AbstractContext context) throws AbstractKandulaException {
ATParticipantContext atContext = (ATParticipantContext) context;
boolean outcome = atContext.getResource().commit();
- CoordinatorPortTypeRawXMLStub stub = new CoordinatorPortTypeRawXMLStub(atContext
- .getCoordinationEPR());
- if (outcome)
- {
+ CoordinatorPortTypeRawXMLStub stub = new CoordinatorPortTypeRawXMLStub(
+ atContext.getCoordinationEPR());
+ if (outcome) {
stub.committedOperation();
- }else
- {
+ } else {
stub.abortedOperation();
}
- // ATParticipantContext atContext = (ATParticipantContext) context;
- // atContext.lock();
- // switch (context.getStatus()) {
- // case (Status.CoordinatorStatus.STATUS_NONE):
- // //TODO send aborted
- // atContext.unlock();
- // return Vote.ABORT;
- // case (Status.CoordinatorStatus.STATUS_PREPARING):
- // case (Status.CoordinatorStatus.STATUS_PREPARED):
- // case (Status.CoordinatorStatus.STATUS_COMMITTING):
- // //Ignore the message
- // atContext.unlock();
- // return Vote.NONE;
- // case (Status.CoordinatorStatus.STATUS_PREPARED_SUCCESS):
- // atContext.unlock();
- // return Vote.PREPARED;
- // case (Status.CoordinatorStatus.STATUS_ACTIVE):
- // atContext.setStatus(Status.CoordinatorStatus.STATUS_PREPARING);
- // KandulaResource resource = atContext.getResource();
- // return resource.prepare();
- // default:
- // context.unlock();
- // throw new InvalidStateException();
- // }
+ // ATParticipantContext atContext = (ATParticipantContext) context;
+ // atContext.lock();
+ // switch (context.getStatus()) {
+ // case (Status.CoordinatorStatus.STATUS_NONE):
+ // //TODO send aborted
+ // atContext.unlock();
+ // return Vote.ABORT;
+ // case (Status.CoordinatorStatus.STATUS_PREPARING):
+ // case (Status.CoordinatorStatus.STATUS_PREPARED):
+ // case (Status.CoordinatorStatus.STATUS_COMMITTING):
+ // //Ignore the message
+ // atContext.unlock();
+ // return Vote.NONE;
+ // case (Status.CoordinatorStatus.STATUS_PREPARED_SUCCESS):
+ // atContext.unlock();
+ // return Vote.PREPARED;
+ // case (Status.CoordinatorStatus.STATUS_ACTIVE):
+ // atContext.setStatus(Status.CoordinatorStatus.STATUS_PREPARING);
+ // KandulaResource resource = atContext.getResource();
+ // return resource.prepare();
+ // default:
+ // context.unlock();
+ // throw new InvalidStateException();
+ // }
}
public void rollback(AbstractContext context) throws InvalidStateException {
Modified: webservices/kandula/trunk/java/src/org/apache/kandula/participant/TransactionInHandler.java
URL: http://svn.apache.org/viewcvs/webservices/kandula/trunk/java/src/org/apache/kandula/participant/TransactionInHandler.java?rev=406098&r1=406097&r2=406098&view=diff
==============================================================================
--- webservices/kandula/trunk/java/src/org/apache/kandula/participant/TransactionInHandler.java (original)
+++ webservices/kandula/trunk/java/src/org/apache/kandula/participant/TransactionInHandler.java Sat May 13 06:47:07 2006
@@ -38,66 +38,73 @@
import org.apache.kandula.utility.KandulaConfiguration;
import org.apache.kandula.wscoor.RegistrationCoordinatorPortTypeRawXMLStub;
-
public class TransactionInHandler extends AbstractHandler {
-
+
private static final long serialVersionUID = 2098581248112968550L;
-// private ThreadLocal threadInfo = new ThreadLocal();
+
+ // private ThreadLocal threadInfo = new ThreadLocal();
public void invoke(MessageContext msgContext) throws AxisFault {
KandulaResource resource;
- StorageFactory.getInstance().setConfigurationContext(
- msgContext.getServiceContext().getConfigurationContext());
- ATParticipantContext context = new ATParticipantContext();
- SOAPHeader header = msgContext.getEnvelope().getHeader();
- OMElement coordinationElement = header.getFirstChildWithName(new QName(
- Constants.WS_COOR, "CoordinationContext"));
- if (coordinationElement == null) {
- throw new AxisFault(
- "Transaction Handler engaged.. No Coordination Context found");
- }
- CoordinationContext coorContext = new SimpleCoordinationContext(
- coordinationElement);
- context.setCoordinationContext(coorContext);
-
- // TODO : See whether we can allow the user to set the resource when the
- // business logic receives the message
- String resourceFile = (String) msgContext.getParameter(
- Constants.KANDULA_RESOURCE).getValue();
- String participantRepository = KandulaConfiguration.getInstance()
- .getParticipantRepository();
- String participantAxis2Xml = KandulaConfiguration.getInstance()
- .getParticipantAxis2Conf();
-
- try {
- resource = (KandulaResource) Class.forName(resourceFile)
- .newInstance();
- } catch (Exception e) {
- throw new AxisFault(e);
+ String wsaAction = msgContext.getWSAAction();
+ if ((wsaAction != Constants.WS_COOR_CREATE_COORDINATIONCONTEXT)
+ && (wsaAction != Constants.WS_COOR_REGISTER)
+ && (wsaAction != Constants.WS_AT_COMMIT)
+ && (wsaAction != Constants.WS_AT_ROLLBACK)) {
+ StorageFactory.getInstance().setConfigurationContext(
+ msgContext.getServiceContext().getConfigurationContext());
+ ATParticipantContext context = new ATParticipantContext();
+ SOAPHeader header = msgContext.getEnvelope().getHeader();
+ OMElement coordinationElement = header
+ .getFirstChildWithName(new QName(Constants.WS_COOR,
+ "CoordinationContext"));
+ if (coordinationElement == null) {
+ throw new AxisFault(
+ "Transaction Handler engaged.. No Coordination Context found");
+ }
+ CoordinationContext coorContext = new SimpleCoordinationContext(
+ coordinationElement);
+ context.setCoordinationContext(coorContext);
+
+ // TODO : See whether we can allow the user to set the resource when
+ // the
+ // business logic receives the message
+ String resourceFile = (String) msgContext.getParameter(
+ Constants.KANDULA_RESOURCE).getValue();
+ String participantRepository = KandulaConfiguration.getInstance()
+ .getParticipantRepository();
+ String participantAxis2Xml = KandulaConfiguration.getInstance()
+ .getParticipantAxis2Conf();
+
+ try {
+ resource = (KandulaResource) Class.forName(resourceFile)
+ .newInstance();
+ } catch (Exception e) {
+ throw new AxisFault(e);
+ }
+ context.setResource(resource);
+
+ String id = EndpointReferenceFactory
+ .getRandomStringOf18Characters();
+ Store store = StorageFactory.getInstance().getStore();
+ context.setProperty(AbstractContext.REQUESTER_ID, id);
+ store.put(id, context);
+ // ParticipantTransactionCoordinator txManager = new
+ // ParticipantTransactionCoordinator();
+ try {
+ RegistrationCoordinatorPortTypeRawXMLStub stub = new RegistrationCoordinatorPortTypeRawXMLStub(
+ participantRepository, participantAxis2Xml, coorContext
+ .getRegistrationService());
+ EndpointReference participantProtocolService = EndpointReferenceFactory
+ .getInstance().get2PCParticipantEndpoint(id);
+ stub.registerOperation(context,
+ participantProtocolService,false);
+ } catch (IOException e) {
+ throw new AxisFault(e);
+ } catch (AbstractKandulaException e) {
+ AxisFault e1 = new AxisFault(e);
+ throw e1;
+ }
}
- context.setResource(resource);
-
- String id = EndpointReferenceFactory.getRandomStringOf18Characters();
- Store store = StorageFactory.getInstance().getStore();
- context.setProperty(AbstractContext.REQUESTER_ID, id);
- store.put(id, context);
-// ParticipantTransactionCoordinator txManager = new ParticipantTransactionCoordinator();
- try {
- RegistrationCoordinatorPortTypeRawXMLStub stub = new RegistrationCoordinatorPortTypeRawXMLStub(
- participantRepository, participantAxis2Xml, coorContext
- .getRegistrationService());
- EndpointReference participantProtocolService = EndpointReferenceFactory
- .getInstance().get2PCParticipantEndpoint(id);
- stub.registerOperation(resource.getProtocol(),
- participantProtocolService, id);
- } catch (IOException e) {
- throw new AxisFault(e);
- } catch (AbstractKandulaException e) {
- AxisFault e1 = new AxisFault(e);
- e1.setFaultCode(e.getFaultCode());
- throw e1;
- }
-
}
}
-
Modified: webservices/kandula/trunk/java/src/org/apache/kandula/utility/KandulaConfiguration.java
URL: http://svn.apache.org/viewcvs/webservices/kandula/trunk/java/src/org/apache/kandula/utility/KandulaConfiguration.java?rev=406098&r1=406097&r2=406098&view=diff
==============================================================================
--- webservices/kandula/trunk/java/src/org/apache/kandula/utility/KandulaConfiguration.java (original)
+++ webservices/kandula/trunk/java/src/org/apache/kandula/utility/KandulaConfiguration.java Sat May 13 06:47:07 2006
@@ -20,16 +20,13 @@
import java.net.InetAddress;
import java.util.Properties;
-
-
-
/**
* @author <a href="mailto:thilina@opensource.lk"> Thilina Gunarathne </a>
*/
public class KandulaConfiguration {
static final String PROPERTY_FILE = "endpoints.conf";
- // static final String PROTOCOL_PROPERTY = "protocol";
+ // static final String PROTOCOL_PROPERTY = "protocol";
static final String HOST_PROPERTY = "host";
@@ -151,6 +148,7 @@
instance = new KandulaConfiguration();
return instance;
}
+
public String getParticipantRepository() {
return participantRepository;
}
@@ -170,6 +168,7 @@
public String getKadulaListenerPort() {
return kandulaListenerPort;
}
+
public String getKadulaListenerPortForEPR() {
if (debug.equals("true"))
return (Integer.parseInt(kandulaListenerPort) + 1) + "";
@@ -187,12 +186,13 @@
public String getKandulaListenerAxis2Xml() {
return kandulaListenerAxis2Xml;
}
- public String getLocationForEPR(){
+
+ public String getLocationForEPR() {
return location;
}
-// public static EndpointReferenceFactory getInstance() {
-// if (instance == null)
-// instance = new EndpointReferenceFactory();
-// return instance;
-// }
+ // public static EndpointReferenceFactory getInstance() {
+ // if (instance == null)
+ // instance = new EndpointReferenceFactory();
+ // return instance;
+ // }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: kandula-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: kandula-dev-help@ws.apache.org