Refactoring + introducing simple/SimpleResource.java
diff --git a/src/org/apache/kandula/Constants.java b/src/org/apache/kandula/Constants.java
index 31d56b3..c5fcaff 100644
--- a/src/org/apache/kandula/Constants.java
+++ b/src/org/apache/kandula/Constants.java
@@ -21,15 +21,13 @@
*/
abstract public interface Constants {
- public static final String WS_COOR="http://schemas.xmlsoap.org/ws/2004/10/wscoor";
- public static final String WS_AT = "http://schemas.xmlsoap.org/ws/2004/10/wsat";
- public static final String WS_BA = "http://schemas.xmlsoap.org/ws/2004/10/wsba";
- public static final String WS_AT_COMPLETION = "http://schemas.xmlsoap.org/ws/2004/10/wsat/Completion";
- 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 SUB_VOLATILE_REGISTERED = "registered for volatile 2PC";
-
- public static final String SUB_DURABLE_REGISTERED = "registered for durable 2PC";
-
+ public static final String WS_COOR = "http://schemas.xmlsoap.org/ws/2004/10/wscoor";
+ public static final String WS_AT = "http://schemas.xmlsoap.org/ws/2004/10/wsat";
+ public static final String WS_BA = "http://schemas.xmlsoap.org/ws/2004/10/wsba";
+ public static final String WS_AT_COMPLETION = "http://schemas.xmlsoap.org/ws/2004/10/wsat/Completion";
+ 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 SUB_VOLATILE_REGISTERED = "registered for volatile 2PC";
+ public static final String SUB_DURABLE_REGISTERED = "registered for durable 2PC";
+
}
diff --git a/src/org/apache/kandula/Status.java b/src/org/apache/kandula/Status.java
index a9b2ff1..3e36216 100644
--- a/src/org/apache/kandula/Status.java
+++ b/src/org/apache/kandula/Status.java
@@ -23,21 +23,22 @@
interface ParticipantStatus {
public static final int STATUS_VOLATILE_PREPARING = 20;
-
+
public static final int STATUS_DURABLE_PREPARING = 21;
-
+
public static final int STATUS_PREPARED = 22;
-
- public static final int STATUS_ABORTED = 23;
-
+
+ public static final int STATUS_ABORTED = 23;
+
public static final int STATUS_READ_ONLY = 24;
}
+
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;
diff --git a/src/org/apache/kandula/coordinator/Coordinator.java b/src/org/apache/kandula/coordinator/Coordinator.java
index 0fabf30..74c8f1a 100644
--- a/src/org/apache/kandula/coordinator/Coordinator.java
+++ b/src/org/apache/kandula/coordinator/Coordinator.java
@@ -18,22 +18,20 @@
import org.apache.axis2.addressing.EndpointReference;
import org.apache.kandula.KandulaException;
-import org.apache.kandula.coordinator.at.ATCoordinator;
import org.apache.kandula.context.ActivityContext;
import org.apache.kandula.context.ContextFactory;
+import org.apache.kandula.coordinator.at.ATCoordinator;
import org.apache.kandula.storage.StorageFactory;
import org.apache.kandula.storage.Store;
-import org.apache.kandula.typemapping.CoordinationContext;
+import org.apache.kandula.context.coordination.CoordinationContext;
/**
* @author <a href="mailto:thilina@opensource.lk"> Thilina Gunarathne </a>
- *
- * This class implements the operations defined in WS-Coordination specification
*/
public class Coordinator {
private Store store;
- //till we be able to use refrence propoerties correctly
+ //till we be able to use reference properties correctly
public static String ACTIVITY_ID;
public Coordinator() {
@@ -42,23 +40,22 @@
}
/**
- * @param Coordination
- * Type
+ * @param Coordination Type
* @return the Coordination Context created
- *
- * 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
+ * <p/>
+ * Initiators can use this to Create new Distributed transactions.This will
+ * take in the Coordination Type and will create an instance of the
+ * reapective ActivityContext. The Coordination Context created by this can
+ * be used to convey the information about the transaction between
+ * initiator,Participants and coordinator
* @throws KandulaException
*/
public ActivityContext createCoordinationContext(String coordinationType,
- long expires) throws KandulaException {
+ long expires) throws KandulaException {
ContextFactory factory = ContextFactory.getInstance();
ActivityContext context = factory.createActivity(coordinationType);
context.getCoordinationContext().setExpires(expires);
- ACTIVITY_ID = context.getCoordinationContext().getActivityID();
+ ACTIVITY_ID = context.getCoordinationContext().getActivityID();
store.putContext(context.getCoordinationContext().getActivityID(),
context);
return context;
@@ -67,12 +64,12 @@
/**
* @param CoordinationContext
* @return the interposed Coordination Context created
- *
- * 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.
+ * <p/>
+ * Participants decided to use this Coordinator as a interposed
+ * sub-coordinator.The newly created CoordinationContext will contain the
+ * same ActivityIdentifier & Protocol type. Registration EPR of the earlier
+ * CoordinationContext will be replaced by the RegistrationEPR of this
+ * Coordinator.
*/
public ActivityContext createCoordinationContext(
CoordinationContext coorContext) throws KandulaException {
@@ -88,15 +85,15 @@
* @param participantEPR
* @param Activity-id
* @return Should return the particular Coordiators End Point Reference
- *
- * 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.
+ * <p/>
+ * This method provides the functional logic for participants to register
+ * for a particular transaction activity which was created by a initiator.
+ * Registration request will be forwarded to repective protocol
+ * coordinators.
* @throws KandulaException
*/
public EndpointReference registerParticipant(String id, String protocol,
- EndpointReference participantEPR) throws KandulaException {
+ EndpointReference participantEPR) throws KandulaException {
ActivityContext context = getCoordinationContext(id);
if (context == null) {
diff --git a/src/org/apache/kandula/coordinator/CoordinatorUtils.java b/src/org/apache/kandula/coordinator/CoordinatorUtils.java
index 43bbef5..92821dd 100644
--- a/src/org/apache/kandula/coordinator/CoordinatorUtils.java
+++ b/src/org/apache/kandula/coordinator/CoordinatorUtils.java
@@ -16,14 +16,14 @@
*/
package org.apache.kandula.coordinator;
+import org.apache.kandula.context.ActivityContext;
+
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.Random;
-import org.apache.kandula.context.ActivityContext;
-
/**
* @author <a href="mailto:thilina@opensource.lk"> Thilina Gunarathne </a>
*/
@@ -33,49 +33,4 @@
public static ActivityContext getActivityContext(String id) {
return null;
}
-
- /**
- * MD5 a random string with localhost/date etc will return 128 bits
- * construct a string of 18 characters from those bits.
- *
- * @return string
- */
- public static String getRandomStringOf18Characters() {
- if (myRand == null) {
- myRand = new Random();
- }
- long rand = myRand.nextLong();
- String sid;
- try {
- sid = InetAddress.getLocalHost().toString();
- } catch (UnknownHostException e) {
- sid = Thread.currentThread().getName();
- }
- long time = System.currentTimeMillis();
- StringBuffer sb = new StringBuffer();
- sb.append(sid);
- sb.append(":");
- sb.append(Long.toString(time));
- sb.append(":");
- sb.append(Long.toString(rand));
- MessageDigest md5 = null;
- try {
- md5 = MessageDigest.getInstance("MD5");
- } catch (NoSuchAlgorithmException e) {
- System.out.println("Error: " + e);
- }
- md5.update(sb.toString().getBytes());
- byte[] array = md5.digest();
- StringBuffer sb2 = new StringBuffer();
- for (int j = 0; j < array.length; ++j) {
- int b = array[j] & 0xFF;
- sb2.append(Integer.toHexString(b));
- }
- int begin = myRand.nextInt();
- if (begin < 0)
- begin = begin * -1;
- begin = begin % 8;
- return new String(sb2.toString().substring(begin, begin + 18))
- .toUpperCase();
- }
}
\ No newline at end of file
diff --git a/src/org/apache/kandula/coordinator/Registerable.java b/src/org/apache/kandula/coordinator/Registerable.java
index 2c303c1..5072582 100644
--- a/src/org/apache/kandula/coordinator/Registerable.java
+++ b/src/org/apache/kandula/coordinator/Registerable.java
@@ -1,15 +1,27 @@
+/*
+ * 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.coordinator;
import org.apache.axis2.addressing.EndpointReference;
-import org.apache.kandula.context.ActivityContext;
import org.apache.kandula.KandulaException;
+import org.apache.kandula.context.ActivityContext;
/**
- * Created by IntelliJ IDEA.
- * User: Thilina
- * Date: Sep 13, 2005
- * Time: 8:17:20 PM
- * To change this template use File | Settings | File Templates.
+ * @author <a href="mailto:thilina@opensource.lk"> Thilina Gunarathne </a>
*/
public interface Registerable {
public EndpointReference register(ActivityContext context, String protocol,
diff --git a/src/org/apache/kandula/coordinator/at/ATCoordinator.java b/src/org/apache/kandula/coordinator/at/ATCoordinator.java
index a841268..6fcc5bb 100644
--- a/src/org/apache/kandula/coordinator/at/ATCoordinator.java
+++ b/src/org/apache/kandula/coordinator/at/ATCoordinator.java
@@ -16,17 +16,17 @@
*/
package org.apache.kandula.coordinator.at;
-import java.util.Iterator;
-
import org.apache.axis2.addressing.EndpointReference;
import org.apache.kandula.Constants;
import org.apache.kandula.KandulaException;
import org.apache.kandula.Status;
import org.apache.kandula.Status.CoordinatorStatus;
-import org.apache.kandula.coordinator.CoordinatorUtils;
-import org.apache.kandula.coordinator.Registerable;
import org.apache.kandula.context.ActivityContext;
import org.apache.kandula.context.at.ATActivityContext;
+import org.apache.kandula.coordinator.CoordinatorUtils;
+import org.apache.kandula.coordinator.Registerable;
+
+import java.util.Iterator;
/**
* @author <a href="mailto:thilina@opensource.lk"> Thilina Gunarathne </a>
@@ -34,37 +34,36 @@
public class ATCoordinator implements Registerable {
public EndpointReference register(ActivityContext context, String protocol,
- EndpointReference participantEPR) throws KandulaException {
+ EndpointReference participantEPR) throws KandulaException {
context.lock();
switch (context.getStatus()) {
- case CoordinatorStatus.STATUS_PREPARING_DURABLE:
- context.unlock();
- this.abort(context);
- throw new IllegalStateException(
- "Coordinator is in preparing state - Durable ");
- case CoordinatorStatus.STATUS_PREPARED_SUCCESS:
- context.unlock();
- throw new IllegalStateException(
- "Coordinator is in prepared success state");
- case CoordinatorStatus.STATUS_COMMITTING:
- context.unlock();
- throw new IllegalStateException(
- "Coordinator is in committing state");
- case CoordinatorStatus.STATUS_ABORTING:
- throw new IllegalStateException("Coordinator is in Aborting state");
- case CoordinatorStatus.STATUS_ACTIVE:
- case CoordinatorStatus.STATUS_PREPARING_VOLATILE:
- return addParticipant(context,protocol, participantEPR);
- case CoordinatorStatus.STATUS_NONE:
- default:
- context.unlock();
- throw new IllegalStateException();
+ case CoordinatorStatus.STATUS_PREPARING_DURABLE:
+ context.unlock();
+ this.abort(context);
+ throw new IllegalStateException(
+ "Coordinator is in preparing state - Durable ");
+ case CoordinatorStatus.STATUS_PREPARED_SUCCESS:
+ context.unlock();
+ throw new IllegalStateException(
+ "Coordinator is in prepared success state");
+ case CoordinatorStatus.STATUS_COMMITTING:
+ context.unlock();
+ throw new IllegalStateException(
+ "Coordinator is in committing state");
+ case CoordinatorStatus.STATUS_ABORTING:
+ throw new IllegalStateException("Coordinator is in Aborting state");
+ case CoordinatorStatus.STATUS_ACTIVE:
+ case CoordinatorStatus.STATUS_PREPARING_VOLATILE:
+ return addParticipant(context, protocol, participantEPR);
+ case CoordinatorStatus.STATUS_NONE:
+ default:
+ context.unlock();
+ throw new IllegalStateException();
}
}
/**
- * @param Activity
- * Id taken from the Request
+ * @param Activity Id taken from the Request
* @return should be a notification This wraps the Commit operation defined
* in Ws-AtomicTransaction specification.
*/
@@ -81,35 +80,35 @@
*/
context.lock();
switch (context.getStatus()) {
- case CoordinatorStatus.STATUS_NONE:
- case CoordinatorStatus.STATUS_ABORTING:
- context.unlock();
- return "Aborted";
- case CoordinatorStatus.STATUS_PREPARING_DURABLE:
- case CoordinatorStatus.STATUS_PREPARING_VOLATILE:
- case CoordinatorStatus.STATUS_PREPARED_SUCCESS:
- //If prepared success Ignore this message
- context.unlock();
- return null;
- case CoordinatorStatus.STATUS_COMMITTING:
- context.unlock();
- return "Committed";
- case Status.CoordinatorStatus.STATUS_ACTIVE:
- int result;
- result = volatilePrepare(context);
-
- if (result == Status.CoordinatorStatus.STATUS_ABORTING) {
- context.lock();
- context.setStatus(Status.CoordinatorStatus.STATUS_ABORTING);
+ case CoordinatorStatus.STATUS_NONE:
+ case CoordinatorStatus.STATUS_ABORTING:
context.unlock();
- abort(context);
- }
+ return "Aborted";
+ case CoordinatorStatus.STATUS_PREPARING_DURABLE:
+ case CoordinatorStatus.STATUS_PREPARING_VOLATILE:
+ case CoordinatorStatus.STATUS_PREPARED_SUCCESS:
+ //If prepared success Ignore this message
+ context.unlock();
+ return null;
+ case CoordinatorStatus.STATUS_COMMITTING:
+ context.unlock();
+ return "Committed";
+ case Status.CoordinatorStatus.STATUS_ACTIVE:
+ int result;
+ result = volatilePrepare(context);
- result = commit(context);
- return null;
- default:
- context.unlock();
- return null;
+ if (result == Status.CoordinatorStatus.STATUS_ABORTING) {
+ context.lock();
+ context.setStatus(Status.CoordinatorStatus.STATUS_ABORTING);
+ context.unlock();
+ abort(context);
+ }
+
+ result = commit(context);
+ return null;
+ default:
+ context.unlock();
+ return null;
}
}
@@ -126,32 +125,32 @@
*/
context.lock();
switch (context.getStatus()) {
- case CoordinatorStatus.STATUS_NONE:
- case CoordinatorStatus.STATUS_ABORTING:
- context.unlock();
- return "Aborted";
- case CoordinatorStatus.STATUS_PREPARING_DURABLE:
- case CoordinatorStatus.STATUS_PREPARING_VOLATILE:
- case CoordinatorStatus.STATUS_PREPARED_SUCCESS:
- //If prepared success Ignore this message
- context.unlock();
- return null;
- case CoordinatorStatus.STATUS_COMMITTING:
- context.unlock();
- return "Committed";
- case Status.CoordinatorStatus.STATUS_ACTIVE:
- context.setStatus(Status.CoordinatorStatus.STATUS_ABORTING);
- context.unlock();
- int result = abort(context);
- // if (result ==fdsfsfd)
- // {
- // throw new Exception
- // }
+ case CoordinatorStatus.STATUS_NONE:
+ case CoordinatorStatus.STATUS_ABORTING:
+ context.unlock();
+ return "Aborted";
+ case CoordinatorStatus.STATUS_PREPARING_DURABLE:
+ case CoordinatorStatus.STATUS_PREPARING_VOLATILE:
+ case CoordinatorStatus.STATUS_PREPARED_SUCCESS:
+ //If prepared success Ignore this message
+ context.unlock();
+ return null;
+ case CoordinatorStatus.STATUS_COMMITTING:
+ context.unlock();
+ return "Committed";
+ case Status.CoordinatorStatus.STATUS_ACTIVE:
+ context.setStatus(Status.CoordinatorStatus.STATUS_ABORTING);
+ context.unlock();
+ int result = abort(context);
+ // if (result ==fdsfsfd)
+ // {
+ // throw new Exception
+ // }
- return null;
- default:
- context.unlock();
- return null;
+ return null;
+ default:
+ context.unlock();
+ return null;
}
}
@@ -258,7 +257,7 @@
}
public EndpointReference addParticipant(ActivityContext context, String protocol,
- EndpointReference participantEPR) throws KandulaException {
+ EndpointReference participantEPR) throws KandulaException {
ATActivityContext atContext = (ATActivityContext) context;
if (protocol.equals(Constants.WS_AT_DURABLE2PC))
return atContext.addParticipant(participantEPR, protocol);
diff --git a/src/org/apache/kandula/coordinator/at/ATSubCoordinator.java b/src/org/apache/kandula/coordinator/at/ATSubCoordinator.java
index a9faf6b..0804bd2 100644
--- a/src/org/apache/kandula/coordinator/at/ATSubCoordinator.java
+++ b/src/org/apache/kandula/coordinator/at/ATSubCoordinator.java
@@ -38,7 +38,7 @@
}
public EndpointReference addParticipant(ActivityContext context, String protocol,
- EndpointReference participantEPR) throws KandulaException {
+ EndpointReference participantEPR) throws KandulaException {
ATActivityContext atContext = (ATActivityContext) context;
if (protocol.equals(Constants.WS_AT_DURABLE2PC)) {
if (!atContext.getSubDurableRegistered()) {
diff --git a/src/org/apache/kandula/coordinator/ba/BACoordinator.java b/src/org/apache/kandula/coordinator/ba/BACoordinator.java
index 5cd18de..f018786 100644
--- a/src/org/apache/kandula/coordinator/ba/BACoordinator.java
+++ b/src/org/apache/kandula/coordinator/ba/BACoordinator.java
@@ -16,13 +16,17 @@
*/
package org.apache.kandula.coordinator.ba;
+import org.apache.axis2.addressing.EndpointReference;
+import org.apache.kandula.KandulaException;
import org.apache.kandula.context.ActivityContext;
+import org.apache.kandula.coordinator.Registerable;
/**
* @author <a href="mailto:thilina@opensource.lk"> Thilina Gunarathne </a>
*/
-public interface BACoordinator {
- public abstract String register(ActivityContext context, String protocol,
- String participantEPR);
+public class BACoordinator implements Registerable {
+ public EndpointReference register(ActivityContext context, String protocol, EndpointReference participantEPR) throws KandulaException {
+ return null; //To change body of implemented methods use File | Settings | File Templates.
+ }
}
\ No newline at end of file
diff --git a/src/org/apache/kandula/initiator/TransactionManager.java b/src/org/apache/kandula/initiator/TransactionManager.java
index d14166d..6436b58 100644
--- a/src/org/apache/kandula/initiator/TransactionManager.java
+++ b/src/org/apache/kandula/initiator/TransactionManager.java
@@ -16,8 +16,6 @@
*/
package org.apache.kandula.initiator;
-import java.rmi.RemoteException;
-
import org.apache.axis2.addressing.EndpointReference;
import org.apache.kandula.KandulaException;
import org.apache.kandula.context.ActivityContext;
@@ -29,6 +27,8 @@
import org.apache.kandula.wscoor.ActivationCoordinatorPortTypeRawXMLStub;
import org.apache.kandula.wscoor.RegistrationCoordinatorPortTypeRawXMLStub;
+import java.rmi.RemoteException;
+
/**
* @author Dasarath Weeratunge
* @author <a href="mailto:thilina@apache.org"> Thilina Gunarathne </a>
@@ -42,7 +42,7 @@
public static String tempID;
public TransactionManager(String coordinationType,
- EndpointReference coordEPR) throws KandulaException {
+ EndpointReference coordEPR) throws KandulaException {
threadInfo = new ThreadLocal();
ActivityContext context = ContextFactory.getInstance().createActivity(
coordinationType, coordEPR);
@@ -66,7 +66,7 @@
threadInfo.set(id);
ActivationCoordinatorPortTypeRawXMLStub activationCoordinator = new ActivationCoordinatorPortTypeRawXMLStub(
".", (EndpointReference) context
- .getProperty(ATActivityContext.ACTIVATION_EPR));
+ .getProperty(ATActivityContext.ACTIVATION_EPR));
activationCoordinator.createCoordinationContextOperation(
org.apache.kandula.Constants.WS_AT, id);
while (context.getCoordinationContext() == null) {
diff --git a/src/org/apache/kandula/initiator/handler/TransactionHandler.java b/src/org/apache/kandula/initiator/handler/TransactionHandler.java
deleted file mode 100644
index c967a87..0000000
--- a/src/org/apache/kandula/initiator/handler/TransactionHandler.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Copyright 2004 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-package org.apache.kandula.participant.initiator;
-
-
-
-
-/**
- * @author Dasarath Weeratunge
- */
-//public class TransactionHandler extends BasicHandler {
-//// TransactionManager tm= TransactionManager.getInstance();
-//// public void invoke(MessageContext msgContext) throws AxisFault {
-//// Transaction tx= tm.getTransaction();
-//// if (tx != null) {
-//// try {
-//// SOAPHeader header= msgContext.getCurrentMessage().getSOAPEnvelope().getHeader();
-//// tx.getCoordinationContex().toSOAPHeaderElement(header);
-//// }
-//// catch (Exception e) {
-//// throw AxisFault.makeFault(e);
-//// }
-//// }
-//// }
-//}
diff --git a/src/org/apache/kandula/initiator/handler/TransactionOutHandler.java b/src/org/apache/kandula/initiator/handler/TransactionOutHandler.java
new file mode 100644
index 0000000..79c4727
--- /dev/null
+++ b/src/org/apache/kandula/initiator/handler/TransactionOutHandler.java
@@ -0,0 +1,49 @@
+/*
+ * Copyright 2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+package org.apache.kandula.initiator.handler;
+
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.addressing.MessageInformationHeaders;
+import org.apache.axis2.context.MessageContext;
+import org.apache.axis2.handlers.AbstractHandler;
+import org.apache.axis2.soap.SOAPHeader;
+import org.apache.kandula.context.ActivityContext;
+import org.apache.kandula.context.coordination.CoordinationContext;
+import org.apache.kandula.storage.StorageFactory;
+
+
+public class TransactionOutHandler extends AbstractHandler {
+ private ThreadLocal threadInfo = new ThreadLocal();
+
+ public void invoke(MessageContext msgContext) throws AxisFault {
+ Object key = threadInfo.get();
+ if (null != key) {
+ ActivityContext context = StorageFactory.getInstance().getStore()
+ .getContext(key);
+ if (context == null) {
+ throw new AxisFault("IllegalState");
+ }
+
+ MessageInformationHeaders messageInformationHeaders =
+ msgContext.getMessageInformationHeaders();
+ SOAPHeader soapHeader = msgContext.getEnvelope().getHeader();
+ CoordinationContext coorContext = context.getCoordinationContext();
+ soapHeader.addChild(coorContext.toOM());
+ }
+ }
+}
+
diff --git a/src/org/apache/kandula/participant/simple/SimpleResource.java b/src/org/apache/kandula/participant/simple/SimpleResource.java
new file mode 100644
index 0000000..9ffc443
--- /dev/null
+++ b/src/org/apache/kandula/participant/simple/SimpleResource.java
@@ -0,0 +1,26 @@
+/*
+ * Copyright 2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+package org.apache.kandula.participant.simple;
+
+/**
+ * @author <a href="mailto:thilina@opensource.lk"> Thilina Gunarathne </a>
+ */
+public interface SimpleResource {
+ public void commit();
+ public void rollback();
+ public boolean prepare();
+}
diff --git a/src/org/apache/kandula/storage/Axis1Store.java b/src/org/apache/kandula/storage/Axis1Store.java
index c6e1c2e..24852de 100644
--- a/src/org/apache/kandula/storage/Axis1Store.java
+++ b/src/org/apache/kandula/storage/Axis1Store.java
@@ -23,28 +23,28 @@
*/
public class Axis1Store implements Store {
- /* (non-Javadoc)
- * @see org.apache.kandula.storage.Store#putContext(java.lang.String, org.apache.kandula.context.CoordinationContext)
- */
- public void putContext(Object id, ActivityContext context) {
- // TODO Auto-generated method stub
-
- }
+ /* (non-Javadoc)
+ * @see org.apache.kandula.storage.Store#putContext(java.lang.String, org.apache.kandula.context.coordination.CoordinationContext)
+ */
+ public void putContext(Object id, ActivityContext context) {
+ // TODO Auto-generated method stub
- /* (non-Javadoc)
- * @see org.apache.kandula.storage.Store#getContext(java.lang.String)
- */
- public ActivityContext getContext(Object id) {
-
- return null;
- }
+ }
- /* (non-Javadoc)
- * @see org.apache.kandula.storage.Store#forgetContext(java.lang.String)
- */
- public void forgetContext(Object id) {
- // TODO Auto-generated method stub
-
- }
+ /* (non-Javadoc)
+ * @see org.apache.kandula.storage.Store#getContext(java.lang.String)
+ */
+ public ActivityContext getContext(Object id) {
+
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.kandula.storage.Store#forgetContext(java.lang.String)
+ */
+ public void forgetContext(Object id) {
+ // TODO Auto-generated method stub
+
+ }
}
diff --git a/src/org/apache/kandula/storage/Axis2Store.java b/src/org/apache/kandula/storage/Axis2Store.java
index 8f2614c..807cb37 100644
--- a/src/org/apache/kandula/storage/Axis2Store.java
+++ b/src/org/apache/kandula/storage/Axis2Store.java
@@ -21,26 +21,25 @@
/**
* @author <a href="mailto:thilina@opensource.lk"> Thilina Gunarathne </a>
*/
-public class Axis2Store implements Store{
+public class Axis2Store implements Store {
- /* (non-Javadoc)
- * @see org.apache.kandula.storage.Store#putContext(java.lang.String, org.apache.kandula.context.CoordinationContext)
- */
- public void putContext(Object id, ActivityContext context) {
- // TODO Auto-generated method stub
-
- }
+ /* (non-Javadoc)
+ * @see org.apache.kandula.storage.Store#putContext(java.lang.String, org.apache.kandula.context.coordination.CoordinationContext)
+ */
+ public void putContext(Object id, ActivityContext context) {
+ // TODO Auto-generated method stub
- /* (non-Javadoc)
- * @see org.apache.kandula.storage.Store#getContext(java.lang.String)
- */
- public ActivityContext getContext(Object id) {
- return null;
-
- }
-
- public void forgetContext(Object id)
- {
- }
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.kandula.storage.Store#getContext(java.lang.String)
+ */
+ public ActivityContext getContext(Object id) {
+ return null;
+
+ }
+
+ public void forgetContext(Object id) {
+ }
}
diff --git a/src/org/apache/kandula/storage/SimpleStore.java b/src/org/apache/kandula/storage/SimpleStore.java
index 5b79994..0220f13 100644
--- a/src/org/apache/kandula/storage/SimpleStore.java
+++ b/src/org/apache/kandula/storage/SimpleStore.java
@@ -16,23 +16,24 @@
*/
package org.apache.kandula.storage;
-import java.util.HashMap;
-
import org.apache.kandula.context.ActivityContext;
+import java.util.HashMap;
+
/**
* @author <a href="mailto:thilina@opensource.lk"> Thilina Gunarathne </a>
*/
public class SimpleStore implements Store {
private HashMap contextMap;
+
/* (non-Javadoc)
- * @see org.apache.kandula.storage.Store#putContext(java.lang.String, org.apache.kandula.context.ActivityContext)
- */
- public SimpleStore()
- {
+ * @see org.apache.kandula.storage.Store#putContext(java.lang.String, org.apache.kandula.context.ActivityContext)
+ */
+ public SimpleStore() {
contextMap = new HashMap();
}
+
public void putContext(Object id, ActivityContext context) {
contextMap.put(id, context);
}
@@ -41,7 +42,7 @@
* @see org.apache.kandula.storage.Store#getContext(java.lang.String)
*/
public ActivityContext getContext(Object id) {
- return (ActivityContext)contextMap.get(id);
+ return (ActivityContext) contextMap.get(id);
}
/* (non-Javadoc)
diff --git a/src/org/apache/kandula/storage/StorageFactory.java b/src/org/apache/kandula/storage/StorageFactory.java
index 2a743a9..2d8bd5c 100644
--- a/src/org/apache/kandula/storage/StorageFactory.java
+++ b/src/org/apache/kandula/storage/StorageFactory.java
@@ -21,18 +21,17 @@
* @author <a href="mailto:thilina@opensource.lk"> Thilina Gunarathne </a>
*/
public class StorageFactory {
- private static StorageFactory instance = new StorageFactory();
- private Store store;
- public static StorageFactory getInstance()
- {
- return instance;
- }
- public Store getStore()
- {
- if (store ==null)
- {
- store = new SimpleStore();
- }
- return store;
- }
+ private static StorageFactory instance = new StorageFactory();
+ private Store store;
+
+ public static StorageFactory getInstance() {
+ return instance;
+ }
+
+ public Store getStore() {
+ if (store == null) {
+ store = new SimpleStore();
+ }
+ return store;
+ }
}
diff --git a/src/org/apache/kandula/storage/Store.java b/src/org/apache/kandula/storage/Store.java
index bbee418..95b3d5e 100644
--- a/src/org/apache/kandula/storage/Store.java
+++ b/src/org/apache/kandula/storage/Store.java
@@ -22,7 +22,9 @@
* @author <a href="mailto:thilina@opensource.lk"> Thilina Gunarathne </a>
*/
public interface Store {
- void putContext(Object id,ActivityContext context);
- ActivityContext getContext(Object id);
- void forgetContext(Object id);
+ void putContext(Object id, ActivityContext context);
+
+ ActivityContext getContext(Object id);
+
+ void forgetContext(Object id);
}
diff --git a/src/org/apache/kandula/typemapping/CoordinationContext.java b/src/org/apache/kandula/typemapping/CoordinationContext.java
deleted file mode 100644
index 09e0ed7..0000000
--- a/src/org/apache/kandula/typemapping/CoordinationContext.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * Copyright 2004 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-package org.apache.kandula.typemapping;
-
-import org.apache.axis2.addressing.EndpointReference;
-import org.apache.axis2.om.OMElement;
-import org.apache.kandula.typemapping.xmlbeansimpl.XmlBeansTypeCoordinationContext;
-
-/**
- * @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 newInstance() {
- return new SimpleCoordinationContext();
- }
- public static CoordinationContext newInstance(OMElement contextElement) {
- return new SimpleCoordinationContext(contextElement);
- }
- public static CoordinationContext newInstance(Object contextType) {
- return new XmlBeansTypeCoordinationContext(contextType);
- }
-
- private Factory() {
- } // No instance of this class allowed
- }
-}
\ No newline at end of file
diff --git a/src/org/apache/kandula/typemapping/SimpleCoordinationContext.java b/src/org/apache/kandula/typemapping/SimpleCoordinationContext.java
deleted file mode 100644
index e6f7477..0000000
--- a/src/org/apache/kandula/typemapping/SimpleCoordinationContext.java
+++ /dev/null
@@ -1,170 +0,0 @@
-/*
- * Copyright 2004 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-package org.apache.kandula.typemapping;
-
-import java.util.Iterator;
-
-import javax.xml.namespace.QName;
-
-import org.apache.axis2.addressing.AddressingConstants;
-import org.apache.axis2.addressing.AnyContentType;
-import org.apache.axis2.addressing.EndpointReference;
-import org.apache.axis2.addressing.AddressingConstants.Final;
-import org.apache.axis2.om.OMAbstractFactory;
-import org.apache.axis2.om.OMElement;
-import org.apache.axis2.om.OMNamespace;
-import org.apache.axis2.soap.SOAPFactory;
-import org.apache.kandula.Constants;
-
-/**
- * @author <a href="mailto:thilina@opensource.lk"> Thilina Gunarathne </a>
- */
-public class SimpleCoordinationContext implements CoordinationContext {
- private String activityID;
-
- private String coordinationType;
-
- private long expires;
-
- private EndpointReference registrationServiceEpr;
-
- private OMElement contextElement = null;
-
- public SimpleCoordinationContext() {
- super();
-
- }
-
- public SimpleCoordinationContext(OMElement contextElement) {
- super();
- this.contextElement = contextElement;
- activityID = contextElement.getFirstChildWithName(
- new QName("Identifier")).getText();
- coordinationType = contextElement.getFirstChildWithName(
- new QName("CoordinationType")).getText();
- OMElement registrationElement = contextElement.getFirstChildWithName(
- new QName("RegistrationService"));
- registrationServiceEpr = new EndpointReference(registrationElement
- .getFirstChildWithName(new QName("Address")).getText());
- AnyContentType referenceProperties = new AnyContentType();
- OMElement referencePropertiesElement = registrationElement
- .getFirstChildWithName(new QName("ReferenceProperties"));
- Iterator propertyIter = referencePropertiesElement.getChildElements();
- while (propertyIter.hasNext()) {
- OMElement element = (OMElement) propertyIter.next();
- referenceProperties.addReferenceValue(element.getQName(), element
- .getText());
- }
- registrationServiceEpr.setReferenceProperties(referenceProperties);
- }
-
- public String getActivityID() {
- return activityID;
- }
-
- public String getCoordinationType() {
- return coordinationType;
- }
-
- public EndpointReference getRegistrationService() {
- return this.registrationServiceEpr;
- }
-
- public long getExpires() {
- return expires;
- }
-
- public void setActivityID(String value) {
- this.activityID = value;
-
- }
-
- public void setCoordinationType(String value) {
- this.coordinationType = value;
-
- }
-
- public void setRegistrationService(EndpointReference epr) {
- this.registrationServiceEpr = epr;
- }
-
- public void setExpires(long value) {
- this.expires = value;
- }
-
- public Object getCoordinationContextType() {
- return this;
- }
-
- public OMElement toOM() {
- if (contextElement != null) {
- return contextElement;
- } else {
- SOAPFactory factory = OMAbstractFactory.getSOAP12Factory();
- OMNamespace wsCoor = factory.createOMNamespace(Constants.WS_COOR,
- "wscoor");
- OMElement contextElement = factory.createOMElement(
- "CoordinationContext", wsCoor);
- if (this.expires != 0) {
- OMElement expiresElement = factory.createOMElement("Expires",
- wsCoor);
- expiresElement.setText(Long.toString(this.expires));
- contextElement.addChild(expiresElement);
- }
- OMElement identifierElement = factory.createOMElement("Identifier",
- wsCoor);
- identifierElement.setText(this.activityID);
- contextElement.addChild(identifierElement);
- OMElement coorTypeElement = factory.createOMElement(
- "CoordinationType", wsCoor);
- coorTypeElement.setText(this.coordinationType);
- contextElement.addChild(coorTypeElement);
- OMElement registrationServiceElement = factory.createOMElement(
- "RegistrationService", wsCoor);
- OMNamespace wsAddressing = factory.createOMNamespace(
- AddressingConstants.Submission.WSA_NAMESPACE,
- AddressingConstants.WSA_DEFAULT_PRFIX);
- OMElement addressElement = factory.createOMElement("Address",
- wsAddressing);
- addressElement.setText(registrationServiceEpr.getAddress());
- registrationServiceElement.addChild(addressElement);
- AnyContentType referenceValues = registrationServiceEpr
- .getReferenceProperties();
- if (referenceValues != null) {
- OMElement refPropertyElement = factory.createOMElement(
- "ReferenceProperties", wsAddressing);
- registrationServiceElement.addChild(refPropertyElement);
- Iterator iterator = referenceValues.getKeys();
- while (iterator.hasNext()) {
- QName key = (QName) iterator.next();
- String value = referenceValues.getReferenceValue(key);
- OMElement omElement = factory.createOMElement(key,
- refPropertyElement);
- refPropertyElement.addChild(omElement);
- if (Final.WSA_NAMESPACE.equals(wsAddressing)) {
- omElement.addAttribute(
- Final.WSA_IS_REFERENCE_PARAMETER_ATTRIBUTE,
- Final.WSA_TYPE_ATTRIBUTE_VALUE, wsAddressing);
- }
- omElement.setText(value);
- }
- }
- contextElement.addChild(registrationServiceElement);
- return contextElement;
- }
- }
-}
\ No newline at end of file
diff --git a/src/org/apache/kandula/typemapping/xmlbeansimpl/XmlBeansTypeCoordinationContext.java b/src/org/apache/kandula/typemapping/xmlbeansimpl/XmlBeansTypeCoordinationContext.java
index c8a429a..47c173b 100644
--- a/src/org/apache/kandula/typemapping/xmlbeansimpl/XmlBeansTypeCoordinationContext.java
+++ b/src/org/apache/kandula/typemapping/xmlbeansimpl/XmlBeansTypeCoordinationContext.java
@@ -18,7 +18,7 @@
import org.apache.axis2.addressing.EndpointReference;
import org.apache.axis2.om.OMElement;
-import org.apache.kandula.typemapping.CoordinationContext;
+import org.apache.kandula.context.coordination.CoordinationContext;
import org.apache.kandula.typemapping.EndPointReference;
import org.xmlsoap.schemas.ws.x2002.x07.utility.AttributedDateTime;
import org.xmlsoap.schemas.ws.x2002.x07.utility.AttributedURI;
@@ -30,20 +30,21 @@
*/
public class XmlBeansTypeCoordinationContext implements CoordinationContext {
private CoordinationContextType contextType;
-
+
public XmlBeansTypeCoordinationContext() {
super();
EndpointReferenceType epr = EndpointReferenceType.Factory.newInstance();
contextType = CoordinationContextType.Factory.newInstance();
}
+
/**
* @param contextType
*/
public XmlBeansTypeCoordinationContext(Object contextType) {
super();
- this.contextType = (CoordinationContextType)contextType;
+ this.contextType = (CoordinationContextType) contextType;
}
-
+
public String getActivityID() {
return contextType.getIdentifier().getId();
}
@@ -73,7 +74,7 @@
}
public void setRegistrationService(EndpointReference value) {
- // contextType.setRegistrationService((EndpointReferenceType)value.getEndPointReferenceType());
+ // contextType.setRegistrationService((EndpointReferenceType)value.getEndPointReferenceType());
}
@@ -86,9 +87,10 @@
public Object getCoordinationContextType() {
return contextType;
}
+
/* (non-Javadoc)
- * @see org.apache.kandula.typemapping.CoordinationContext#toOM()
- */
+ * @see org.apache.kandula.context.coordination.CoordinationContext#toOM()
+ */
public OMElement toOM() {
// TODO Auto-generated method stub
return null;
diff --git a/src/org/apache/kandula/typemapping/xmlbeansimpl/XmlBeansTypeEndPointReference.java b/src/org/apache/kandula/typemapping/xmlbeansimpl/XmlBeansTypeEndPointReference.java
index 32e7a4e..4b100ba 100644
--- a/src/org/apache/kandula/typemapping/xmlbeansimpl/XmlBeansTypeEndPointReference.java
+++ b/src/org/apache/kandula/typemapping/xmlbeansimpl/XmlBeansTypeEndPointReference.java
@@ -23,28 +23,30 @@
* @author <a href="mailto:thilina@opensource.lk"> Thilina Gunarathne </a>
*/
public class XmlBeansTypeEndPointReference implements EndPointReference {
-
+
EndpointReferenceType eprType;
-
+
/**
*
*/
public XmlBeansTypeEndPointReference() {
super();
- eprType = EndpointReferenceType.Factory.newInstance();
+ eprType = EndpointReferenceType.Factory.newInstance();
}
+
/**
* @param eprType
*/
public XmlBeansTypeEndPointReference(Object eprType) {
super();
- this.eprType = (EndpointReferenceType)eprType;
+ this.eprType = (EndpointReferenceType) eprType;
}
+
public Object getEndPointReferenceType() {
return eprType;
}
- public String getPortTypeLocalPart()
- {
+
+ public String getPortTypeLocalPart() {
return eprType.getPortType().getQNameValue().getLocalPart();
}
diff --git a/src/org/apache/kandula/utility/EndpointReferenceFactory.java b/src/org/apache/kandula/utility/EndpointReferenceFactory.java
index 76ebef3..0bfb3db 100644
--- a/src/org/apache/kandula/utility/EndpointReferenceFactory.java
+++ b/src/org/apache/kandula/utility/EndpointReferenceFactory.java
@@ -16,15 +16,17 @@
*/
package org.apache.kandula.utility;
-import java.io.InputStream;
-import java.net.InetAddress;
-import java.util.Properties;
-
-import javax.xml.namespace.QName;
-
import org.apache.axis2.addressing.AnyContentType;
import org.apache.axis2.addressing.EndpointReference;
+import javax.xml.namespace.QName;
+import java.util.Properties;
+
+/**
+ * @author Dasarath Weeratunge
+ * @author <a href="mailto:thilina@apache.org"> Thilina Gunarathne </a>
+ */
+
public class EndpointReferenceFactory {
static final String PROPERTY_FILE = "endpoints.conf";
@@ -76,7 +78,7 @@
epr.setReferenceProperties(refProperties);
return epr;
}
-
+
public EndpointReference getCompletionParticipantEndpoint(String id) {
//TODO set this somehow reading the conf file
EndpointReference epr = new EndpointReference(
diff --git a/src/org/apache/kandula/utility/KandulaListener.java b/src/org/apache/kandula/utility/KandulaListener.java
index 3401d79..ac4a1a9 100644
--- a/src/org/apache/kandula/utility/KandulaListener.java
+++ b/src/org/apache/kandula/utility/KandulaListener.java
@@ -16,12 +16,6 @@
*/
package org.apache.kandula.utility;
-import java.io.IOException;
-import java.net.InetAddress;
-import java.net.UnknownHostException;
-
-import javax.xml.namespace.QName;
-
import org.apache.axis2.AxisFault;
import org.apache.axis2.context.ConfigurationContext;
import org.apache.axis2.description.ParameterImpl;
@@ -31,6 +25,11 @@
import org.apache.axis2.transport.http.SimpleHTTPServer;
import org.apache.axis2.util.Utils;
+import javax.xml.namespace.QName;
+import java.io.IOException;
+import java.net.InetAddress;
+import java.net.UnknownHostException;
+
/**
* @author <a href="mailto:thilina@opensource.lk"> Thilina Gunarathne </a>
*/
@@ -72,9 +71,8 @@
}
}
-
- public void stop()
- {
+
+ public void stop() {
receiver.stop();
serverStarted = false;
}
@@ -82,12 +80,11 @@
/**
* @param serviceName
* @param operationName
- * @throws AxisFault
- * To add services with only one operation, which is the
- * frequent case in reponses
+ * @throws AxisFault To add services with only one operation, which is the
+ * frequent case in reponses
*/
public void addService(QName serviceName, QName operationName,
- String className) throws AxisFault {
+ String className) throws AxisFault {
ServiceDescription service = new ServiceDescription(serviceName);
service.addParameter(new ParameterImpl(
AbstractMessageReceiver.SERVICE_CLASS, className));
@@ -110,7 +107,7 @@
}
public String getHost() throws UnknownHostException {
- return "http://"+InetAddress.getLocalHost().getHostAddress() + ":" + SERVER_PORT
+ return "http://" + InetAddress.getLocalHost().getHostAddress() + ":" + SERVER_PORT
+ "/axis2/services/";
}
}
\ No newline at end of file
diff --git a/src/org/apache/kandula/utility/KandulaUtils.java b/src/org/apache/kandula/utility/KandulaUtils.java
index d0bbb71..8e2d8d0 100644
--- a/src/org/apache/kandula/utility/KandulaUtils.java
+++ b/src/org/apache/kandula/utility/KandulaUtils.java
@@ -16,6 +16,15 @@
*/
package org.apache.kandula.utility;
+import org.apache.axis2.addressing.AddressingConstants;
+import org.apache.axis2.addressing.AddressingConstants.Final;
+import org.apache.axis2.addressing.AnyContentType;
+import org.apache.axis2.addressing.EndpointReference;
+import org.apache.axis2.om.OMElement;
+import org.apache.axis2.om.OMNamespace;
+import org.apache.axis2.soap.SOAPFactory;
+
+import javax.xml.namespace.QName;
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.security.MessageDigest;
@@ -23,22 +32,11 @@
import java.util.Iterator;
import java.util.Random;
-import javax.xml.namespace.QName;
-
-import org.apache.axis2.addressing.AddressingConstants;
-import org.apache.axis2.addressing.AnyContentType;
-import org.apache.axis2.addressing.EndpointReference;
-import org.apache.axis2.addressing.AddressingConstants.Final;
-import org.apache.axis2.om.OMElement;
-import org.apache.axis2.om.OMNamespace;
-import org.apache.axis2.soap.SOAPFactory;
-
/**
* @author <a href="mailto:thilina@opensource.lk"> Thilina Gunarathne </a>
*/
public class KandulaUtils {
- public static void endpointToOM(EndpointReference epr, OMElement parentEPR,SOAPFactory factory)
- {
+ public static void endpointToOM(EndpointReference epr, OMElement parentEPR, SOAPFactory factory) {
OMNamespace wsAddressing = factory.createOMNamespace(
AddressingConstants.Submission.WSA_NAMESPACE,
AddressingConstants.WSA_DEFAULT_PRFIX);
@@ -67,9 +65,11 @@
}
}
}
+
/**
* MD5 a random string with localhost/date etc will return 128 bits
* construct a string of 18 characters from those bits.
+ *
* @return string
*/
public static String getRandomStringOf18Characters() {
@@ -103,7 +103,7 @@
sb2.append(Integer.toHexString(b));
}
int begin = myRand.nextInt();
- if(begin < 0) begin = begin * -1;
+ if (begin < 0) begin = begin * -1;
begin = begin % 8;
return new String(sb2.toString().substring(begin, begin + 18)).toUpperCase();
}
diff --git a/src/org/apache/kandula/wscoor/ActivationCoordinatorPortTypeRawXMLStub.java b/src/org/apache/kandula/wscoor/ActivationCoordinatorPortTypeRawXMLStub.java
index 4ea137a..e7d94df 100644
--- a/src/org/apache/kandula/wscoor/ActivationCoordinatorPortTypeRawXMLStub.java
+++ b/src/org/apache/kandula/wscoor/ActivationCoordinatorPortTypeRawXMLStub.java
@@ -16,10 +16,6 @@
*/
package org.apache.kandula.wscoor;
-import java.io.IOException;
-
-import javax.xml.namespace.QName;
-
import org.apache.axis2.addressing.AnyContentType;
import org.apache.axis2.addressing.EndpointReference;
import org.apache.axis2.clientapi.MessageSender;
@@ -29,6 +25,9 @@
import org.apache.kandula.Constants;
import org.apache.kandula.utility.KandulaListener;
+import javax.xml.namespace.QName;
+import java.io.IOException;
+
/**
* @author <a href="mailto:thilina@opensource.lk"> Thilina Gunarathne </a>
*/
@@ -65,7 +64,7 @@
* Constructor
*/
public ActivationCoordinatorPortTypeRawXMLStub(String axis2Home,
- EndpointReference targetEndpoint) throws java.lang.Exception {
+ EndpointReference targetEndpoint) throws java.lang.Exception {
this.toEPR = targetEndpoint;
//creating the configuration
_configurationContext = new org.apache.axis2.context.ConfigurationContextFactory()
@@ -95,7 +94,7 @@
}
public void createCoordinationContextOperation(String coordinationType,
- String id) throws IOException {
+ String id) throws IOException {
QName serviceName = new QName("ActivationRequesterPortType");
QName operationName = new QName(Constants.WS_COOR,
diff --git a/src/org/apache/kandula/wscoor/ActivationPortTypeRawXMLAsyncMessageReceiver.java b/src/org/apache/kandula/wscoor/ActivationPortTypeRawXMLAsyncMessageReceiver.java
index c73b88c..24e4622 100644
--- a/src/org/apache/kandula/wscoor/ActivationPortTypeRawXMLAsyncMessageReceiver.java
+++ b/src/org/apache/kandula/wscoor/ActivationPortTypeRawXMLAsyncMessageReceiver.java
@@ -62,7 +62,7 @@
}
newMsgContext.setEnvelope(envelope);
newMsgContext.setSoapAction("CreateCoordinationContextOperation");
- // callback.handleResult(newMsgContext);
+ // callback.handleResult(newMsgContext);
}
} catch (Exception e) {
throw AxisFault.makeFault(e);
diff --git a/src/org/apache/kandula/wscoor/ActivationPortTypeRawXMLSkeleton.java b/src/org/apache/kandula/wscoor/ActivationPortTypeRawXMLSkeleton.java
index 4a5e60e..931987d 100644
--- a/src/org/apache/kandula/wscoor/ActivationPortTypeRawXMLSkeleton.java
+++ b/src/org/apache/kandula/wscoor/ActivationPortTypeRawXMLSkeleton.java
@@ -1,21 +1,22 @@
package org.apache.kandula.wscoor;
-import javax.xml.namespace.QName;
-
import org.apache.axis2.om.OMElement;
import org.apache.kandula.KandulaException;
-import org.apache.kandula.coordinator.Coordinator;
import org.apache.kandula.context.ActivityContext;
+import org.apache.kandula.coordinator.Coordinator;
+
+import javax.xml.namespace.QName;
/**
- * Auto generated java skeleton for the service by the Axis code generator
+ * Auto generated java skeleton for the service by the Axis code generator
*/
public class ActivationPortTypeRawXMLSkeleton {
/**
* Auto generated method signature
- *@param requestElement
+ *
+ * @param requestElement
* @throws KandulaException
*/
public OMElement CreateCoordinationContextOperation(
@@ -23,7 +24,7 @@
throws KandulaException {
ActivityContext context;
Coordinator coordinator = new Coordinator();
-
+
// ActivityContext context;
// Coordinator coordinator = new Coordinator();
// if (requestDoc.getCreateCoordinationContext().getCurrentContext() != null) {
@@ -34,30 +35,27 @@
// {
String coordinationType = requestElement.getFirstChildWithName(new QName("CoordinationType")).getText();
OMElement expiresElement = requestElement.getFirstChildWithName(new QName("Expires"));
- String expires=null;
+ String expires = null;
long expiresL = 0;
- if (expiresElement!=null)
- {
+ if (expiresElement != null) {
expires = expiresElement.getText();
- if ((expires!=null)&&(expires.equals("")))
- {
+ if ((expires != null) && (expires.equals(""))) {
expiresL = Long.parseLong(expires);
- }
- }
- context = coordinator.createCoordinationContext(coordinationType,expiresL);
+ }
+ }
+ context = coordinator.createCoordinationContext(coordinationType, expiresL);
return context.getCoordinationContext().toOM();
-
+
// context(coordinationType, expiresL);
- // }
+ // }
// CreateCoordinationContextResponseDocument responseDoc = CreateCoordinationContextResponseDocument.Factory
// .newInstance();
// CreateCoordinationContextResponseType responseType = CreateCoordinationContextResponseType.Factory
// .newInstance();
// responseType.setCoordinationContext((CoordinationContextType)context.getCoordinationContext().getCoordinationContextType());
// responseDoc.setCreateCoordinationContextResponse(responseType);
- // return new OMElementImpl("Thilina",new OMNamespaceImpl("pre","http://www.thilina.org"));
-
-
+ // return new OMElementImpl("Thilina",new OMNamespaceImpl("pre","http://www.thilina.org"));
+
// if (requestDoc.getCreateCoordinationContext().getCurrentContext() != null) {
// CoordinationContext coorContext = CoordinationContext.Factory.newInstance(requestDoc
// .getCreateCoordinationContext().getCurrentContext());
diff --git a/src/org/apache/kandula/wscoor/ActivationRequesterPortTypeRawXMLSkeleton.java b/src/org/apache/kandula/wscoor/ActivationRequesterPortTypeRawXMLSkeleton.java
index e93f48e..2e74089 100644
--- a/src/org/apache/kandula/wscoor/ActivationRequesterPortTypeRawXMLSkeleton.java
+++ b/src/org/apache/kandula/wscoor/ActivationRequesterPortTypeRawXMLSkeleton.java
@@ -5,7 +5,7 @@
import org.apache.kandula.context.ActivityContext;
import org.apache.kandula.initiator.TransactionManager;
import org.apache.kandula.storage.StorageFactory;
-import org.apache.kandula.typemapping.CoordinationContext;
+import org.apache.kandula.context.coordination.CoordinationContext;
/*
* Copyright 2004,2005 The Apache Software Foundation.
@@ -39,12 +39,11 @@
public OMElement CreateCoordinationContextOperation(OMElement requestElement) {
// OMElement coordinationContextElement = requestElement
// .getFirstChildWithName(new QName("CoordinationContext"));
- if ("CoordinationContext".equals(requestElement.getLocalName()))
- {
- msgContext.getMessageInformationHeaders().getReferenceParameters();
- CoordinationContext coordinationContext =CoordinationContext.Factory.newInstance(requestElement);
- ActivityContext context = StorageFactory.getInstance().getStore().getContext(TransactionManager.tempID);
- context.setCoordinationContext(coordinationContext);
+ if ("CoordinationContext".equals(requestElement.getLocalName())) {
+ msgContext.getMessageInformationHeaders().getReferenceParameters();
+ CoordinationContext coordinationContext = CoordinationContext.Factory.newInstance(requestElement);
+ ActivityContext context = StorageFactory.getInstance().getStore().getContext(TransactionManager.tempID);
+ context.setCoordinationContext(coordinationContext);
}
return null;
}
diff --git a/src/org/apache/kandula/wscoor/RegistrationCoordinatorPortTypeRawXMLStub.java b/src/org/apache/kandula/wscoor/RegistrationCoordinatorPortTypeRawXMLStub.java
index 5338c59..c9be136 100644
--- a/src/org/apache/kandula/wscoor/RegistrationCoordinatorPortTypeRawXMLStub.java
+++ b/src/org/apache/kandula/wscoor/RegistrationCoordinatorPortTypeRawXMLStub.java
@@ -1,9 +1,5 @@
package org.apache.kandula.wscoor;
-import java.io.IOException;
-
-import javax.xml.namespace.QName;
-
import org.apache.axis2.addressing.AnyContentType;
import org.apache.axis2.addressing.EndpointReference;
import org.apache.axis2.clientapi.MessageSender;
@@ -14,6 +10,9 @@
import org.apache.kandula.utility.KandulaListener;
import org.apache.kandula.utility.KandulaUtils;
+import javax.xml.namespace.QName;
+import java.io.IOException;
+
public class RegistrationCoordinatorPortTypeRawXMLStub extends
org.apache.axis2.clientapi.Stub {
@@ -46,7 +45,7 @@
* Constructor
*/
public RegistrationCoordinatorPortTypeRawXMLStub(String axis2Home,
- EndpointReference targetEndpoint) throws java.lang.Exception {
+ EndpointReference targetEndpoint) throws java.lang.Exception {
this.toEPR = targetEndpoint;
//creating the configuration
_configurationContext = new org.apache.axis2.context.ConfigurationContextFactory()
@@ -58,7 +57,7 @@
}
private org.apache.axis2.soap.SOAPEnvelope createSOAPEnvelope(
- String protocolType,EndpointReference epr) {
+ String protocolType, EndpointReference epr) {
org.apache.axis2.soap.SOAPEnvelope env = super.createEnvelope();
org.apache.axis2.soap.SOAPFactory factory = OMAbstractFactory
.getSOAP12Factory();
@@ -70,9 +69,9 @@
"ProtocolIdentifier", wsCoor);
protocolTypeElement.setText(protocolType);
request.addChild(protocolTypeElement);
-
- OMElement protocolService = factory.createOMElement("ParticipantProtocolService",wsCoor);
- KandulaUtils.endpointToOM(epr,protocolService,factory);
+
+ OMElement protocolService = factory.createOMElement("ParticipantProtocolService", wsCoor);
+ KandulaUtils.endpointToOM(epr, protocolService, factory);
request.addChild(protocolService);
env.getBody().addChild(request);
return env;
@@ -81,7 +80,7 @@
}
public void RegisterOperation(String protocolType, EndpointReference epr,
- String id) throws IOException {
+ String id) throws IOException {
QName serviceName = new QName("RegistrationRequesterPortType");
QName operationName = new QName(Constants.WS_COOR, "RegisterOperation");
@@ -104,7 +103,7 @@
messageSender.setTo(this.toEPR);
messageSender.setSoapAction("RegisterOperation");
//_call.setWsaAction("CreateCoordinationContextOperation");
- org.apache.axis2.soap.SOAPEnvelope env = createSOAPEnvelope(protocolType,epr);
+ org.apache.axis2.soap.SOAPEnvelope env = createSOAPEnvelope(protocolType, epr);
messageContext.setEnvelope(env);
System.out.println("visited registration send");
diff --git a/src/org/apache/kandula/wscoor/RegistrationPortTypeRawXMLSkeleton.java b/src/org/apache/kandula/wscoor/RegistrationPortTypeRawXMLSkeleton.java
index 571a283..bc78b84 100644
--- a/src/org/apache/kandula/wscoor/RegistrationPortTypeRawXMLSkeleton.java
+++ b/src/org/apache/kandula/wscoor/RegistrationPortTypeRawXMLSkeleton.java
@@ -16,11 +16,6 @@
*/
package org.apache.kandula.wscoor;
-import java.util.ArrayList;
-import java.util.Iterator;
-
-import javax.xml.namespace.QName;
-
import org.apache.axis2.addressing.AnyContentType;
import org.apache.axis2.addressing.EndpointReference;
import org.apache.axis2.context.MessageContext;
@@ -32,6 +27,10 @@
import org.apache.kandula.coordinator.Coordinator;
import org.apache.kandula.utility.KandulaUtils;
+import javax.xml.namespace.QName;
+import java.util.ArrayList;
+import java.util.Iterator;
+
/**
* @author <a href="mailto:thilina@apache.org"> Thilina Gunarathne </a>
*/
@@ -83,7 +82,7 @@
"CoordinatorProtocolService", wsCoor);
OMElement coordinatorProtocolService = factory.createOMElement(
"CoordinatorProtocolService", wsCoor);
- KandulaUtils.endpointToOM(epr,coordinatorProtocolService,factory);
+ KandulaUtils.endpointToOM(epr, coordinatorProtocolService, factory);
protocolService.addChild(coordinatorProtocolService);
return protocolService;
}