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 ja...@apache.org on 2005/06/22 15:38:12 UTC
cvs commit: ws-fx/sandesha/test/org/apache/sandesha/intergratedtest TCScenarioTest.java
jaliya 2005/06/22 06:38:12
Modified: sandesha/interop/org/apache/sandesha/interop
IBMAsyncPing.java IBMEcho.java IBMSyncPing.java
MicrosoftAsyncPing.java MicrosoftSyncPing.java
RMInteropService.java SystinetAsyncPing.java
SystinetSyncPing.java
sandesha/interop/org/apache/sandesha/interop/testclient
InteropStub.java ResponseWriter.java
sandesha/samples/org/apache/sandesha/samples
AsyncPingClient.java EchoClientAsyncAck.java
EchoClientSyncAck.java SyncPingClient.java
sandesha/src/org/apache/sandesha Constants.java
RMMessageContext.java RMReport.java
SandeshaContext.java
sandesha/src/org/apache/sandesha/client
ClientPropertyValidator.java
ClientStorageManager.java RMSender.java
sandesha/src/org/apache/sandesha/server SenderWorker.java
sandesha/src/org/apache/sandesha/storage/queue
SandeshaQueue.java
sandesha/src/org/apache/sandesha/util PropertyLoader.java
RMMessageCreator.java
sandesha/test/org/apache/sandesha/intergratedtest
TCScenarioTest.java
Log:
Changes the SandeshaContext , now it can handle multiple call components for single sequence
In addition the client can use AsyncCall provided by axis for non blocking opertions
Revision Changes Path
1.2 +7 -11 ws-fx/sandesha/interop/org/apache/sandesha/interop/IBMAsyncPing.java
Index: IBMAsyncPing.java
===================================================================
RCS file: /home/cvs/ws-fx/sandesha/interop/org/apache/sandesha/interop/IBMAsyncPing.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- IBMAsyncPing.java 11 Jun 2005 08:57:31 -0000 1.1
+++ IBMAsyncPing.java 22 Jun 2005 13:38:11 -0000 1.2
@@ -1,4 +1,3 @@
-
/*
* Copyright 1999-2004 The Apache Software Foundation.
*
@@ -47,16 +46,13 @@
Call call = (Call) service.createCall();
SandeshaContext ctx = new SandeshaContext();
- ctx.addNewSequeceContext(call, targetURL, "urn:wsrm:Ping",
- Constants.ClientProperties.IN_ONLY);
- ctx.setToUrl(call, "http://wsi.alphaworks.ibm.com:8080/wsrm/services/rmDemos");
- ctx.setFaultToUrl(call,
- "http://" + sourceHost + ":" + sourcePort + "/axis/services/RMService");
- ctx.setAcksToUrl(call,
- "http://" + sourceHost + ":" + sourcePort + "/axis/services/RMService");
- ctx.setFromUrl(call,
- "http://" + sourceHost + ":" + sourcePort + "/axis/services/RMService");
+ ctx.setToURL("http://wsi.alphaworks.ibm.com:8080/wsrm/services/rmDemos");
+ ctx.setFaultToURL("http://" + sourceHost + ":" + sourcePort + "/axis/services/RMService");
+ ctx.setAcksToURL("http://" + sourceHost + ":" + sourcePort + "/axis/services/RMService");
+ ctx.setFromURL("http://" + sourceHost + ":" + sourcePort + "/axis/services/RMService");
+
+ ctx.initCall(call, targetURL, "urn:wsrm:Ping", Constants.ClientProperties.IN_ONLY);
call.setOperationName(new QName("http://tempuri.org/", "Ping"));
@@ -67,7 +63,7 @@
ctx.setLastMessage(call);
call.invoke(new Object[]{"Ping Message Number Three"});
- ctx.endSequence(call);
+ ctx.endSequence();
} catch (Exception e) {
e.printStackTrace();
1.2 +12 -10 ws-fx/sandesha/interop/org/apache/sandesha/interop/IBMEcho.java
Index: IBMEcho.java
===================================================================
RCS file: /home/cvs/ws-fx/sandesha/interop/org/apache/sandesha/interop/IBMEcho.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- IBMEcho.java 11 Jun 2005 08:57:31 -0000 1.1
+++ IBMEcho.java 22 Jun 2005 13:38:11 -0000 1.2
@@ -44,21 +44,23 @@
System.out.println("Client started...... Asynchronous EchoString - IBM");
- UUIDGen uuidGen = UUIDGenFactory.getUUIDGen(); //Can use this for continuous testing.
- String str = uuidGen.nextUUID();
+ UUIDGen uuidGen = UUIDGenFactory.getUUIDGen(); //Can use this for continuous testing.
+ String str = uuidGen.nextUUID();
try {
- Service service = new Service();
+ Service service = new Service();
Call call = (Call) service.createCall();
SandeshaContext ctx = new SandeshaContext();
- ctx.addNewSequeceContext(call, targetURL, "urn:wsrm:echoString",Constants.ClientProperties.IN_OUT);
- ctx.setToUrl(call, "http://wsi.alphaworks.ibm.com:8080/wsrm/services/rmDemos");
- ctx.setFaultToUrl(call,"http://" + sourceHost + ":" + sourcePort + "/axis/services/RMService");
- ctx.setAcksToUrl(call,"http://" + sourceHost + ":" + sourcePort + "/axis/services/RMService");
- ctx.setFromUrl(call,"http://" + sourceHost + ":" + sourcePort + "/axis/services/RMService");
- ctx.setReplyToUrl(call,"http://" + sourceHost + ":" + sourcePort + "/axis/services/RMService");
+
+ ctx.setToURL("http://wsi.alphaworks.ibm.com:8080/wsrm/services/rmDemos");
+ ctx.setFaultToURL("http://" + sourceHost + ":" + sourcePort + "/axis/services/RMService");
+ ctx.setAcksToURL("http://" + sourceHost + ":" + sourcePort + "/axis/services/RMService");
+ ctx.setFromURL("http://" + sourceHost + ":" + sourcePort + "/axis/services/RMService");
+ ctx.setReplyToURL("http://" + sourceHost + ":" + sourcePort + "/axis/services/RMService");
+
+ ctx.initCall(call,targetURL, "urn:wsrm:echoString", Constants.ClientProperties.IN_OUT);
call.setOperationName(new QName("http://tempuri.org/", "echoString"));
@@ -76,7 +78,7 @@
ret = (String) call.invoke(new Object[]{"Sandesha Echo 3", str});
System.out.println("The Response for Third Messsage is :" + ret);
- ctx.endSequence(call);
+ ctx.endSequence();
} catch (Exception e) {
e.printStackTrace();
}
1.2 +6 -7 ws-fx/sandesha/interop/org/apache/sandesha/interop/IBMSyncPing.java
Index: IBMSyncPing.java
===================================================================
RCS file: /home/cvs/ws-fx/sandesha/interop/org/apache/sandesha/interop/IBMSyncPing.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- IBMSyncPing.java 11 Jun 2005 08:57:31 -0000 1.1
+++ IBMSyncPing.java 22 Jun 2005 13:38:11 -0000 1.2
@@ -43,12 +43,11 @@
Service service = new Service();
Call call = (Call) service.createCall();
- SandeshaContext ctx = new SandeshaContext();
- ctx.addNewSequeceContext(call, targetURL, "urn:wsrm:Ping",
- Constants.ClientProperties.IN_ONLY);
- ctx.setSynchronous(call);
- ctx.setToUrl(call, "http://wsi.alphaworks.ibm.com:8080/wsrm/services/rmDemos");
- ctx.setAcksToUrl(call, Constants.WSA.NS_ADDRESSING_ANONYMOUS);
+ SandeshaContext ctx = new SandeshaContext(Constants.SYNCHRONIZED);
+
+ ctx.setToURL("http://wsi.alphaworks.ibm.com:8080/wsrm/services/rmDemos");
+ ctx.setAcksToURL(Constants.WSA.NS_ADDRESSING_ANONYMOUS);
+ ctx.initCall(call, targetURL, "urn:wsrm:Ping", Constants.ClientProperties.IN_ONLY);
call.setOperationName(new QName("http://tempuri.org/", "Ping"));
@@ -59,7 +58,7 @@
ctx.setLastMessage(call);
call.invoke(new Object[]{"Ping Message Number Three"});
- ctx.endSequence(call);
+ ctx.endSequence();
} catch (Exception e) {
//System.err.println(e.toString());
1.2 +8 -13 ws-fx/sandesha/interop/org/apache/sandesha/interop/MicrosoftAsyncPing.java
Index: MicrosoftAsyncPing.java
===================================================================
RCS file: /home/cvs/ws-fx/sandesha/interop/org/apache/sandesha/interop/MicrosoftAsyncPing.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- MicrosoftAsyncPing.java 11 Jun 2005 08:57:31 -0000 1.1
+++ MicrosoftAsyncPing.java 22 Jun 2005 13:38:11 -0000 1.2
@@ -42,19 +42,14 @@
Call call = (Call) service.createCall();
SandeshaContext ctx = new SandeshaContext();
- ctx.addNewSequeceContext(call, targetURL, "urn:wsrm:Ping",
- Constants.ClientProperties.IN_ONLY);
- ctx.setToUrl(call,
- "http://131.107.153.195/SecureReliableMessaging/ReliableOneWayDual.svc");
- ctx.setFromUrl(call,
- "http://" + sourceHost + ":" + sourcePort + "/axis/services/RMService");
- ctx.setAcksToUrl(call,
- "http://" + sourceHost + ":" + sourcePort + "/axis/services/RMService");
- ctx.setFaultToUrl(call,
- "http://" + sourceHost + ":" + sourcePort + "/axis/services/RMService");
- ctx.setReplyToUrl(call,
- "http://" + sourceHost + ":" + sourcePort + "/axis/services/RMService");
+ ctx.setToURL("http://131.107.153.195/SecureReliableMessaging/ReliableOneWayDual.svc");
+ ctx.setFromURL("http://" + sourceHost + ":" + sourcePort + "/axis/services/RMService");
+ ctx.setAcksToURL("http://" + sourceHost + ":" + sourcePort + "/axis/services/RMService");
+ ctx.setFaultToURL("http://" + sourceHost + ":" + sourcePort + "/axis/services/RMService");
+ ctx.setReplyToURL("http://" + sourceHost + ":" + sourcePort + "/axis/services/RMService");
+
+ ctx.initCall(call, targetURL, "urn:wsrm:Ping", Constants.ClientProperties.IN_ONLY);
call.setOperationName("Ping");
call.invoke(new Message(getSOAPEnvelope(1)));
@@ -62,7 +57,7 @@
ctx.setLastMessage(call);
call.invoke(new Message(getSOAPEnvelope(3)));
- ctx.endSequence(call);
+ ctx.endSequence();
} catch (Exception e) {
e.printStackTrace();
1.2 +8 -8 ws-fx/sandesha/interop/org/apache/sandesha/interop/MicrosoftSyncPing.java
Index: MicrosoftSyncPing.java
===================================================================
RCS file: /home/cvs/ws-fx/sandesha/interop/org/apache/sandesha/interop/MicrosoftSyncPing.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- MicrosoftSyncPing.java 11 Jun 2005 08:57:31 -0000 1.1
+++ MicrosoftSyncPing.java 22 Jun 2005 13:38:11 -0000 1.2
@@ -38,14 +38,14 @@
Service service = new Service();
Call call = (Call) service.createCall();
- SandeshaContext ctx = new SandeshaContext();
- ctx.addNewSequeceContext(call, targetURL, "urn:wsrm:Ping",
- Constants.ClientProperties.IN_ONLY);
- ctx.setSynchronous(call);
- ctx.setToUrl(call, "http://131.107.153.195/SecureReliableMessaging/ReliableOneWay.svc");
- //We really do not want to send wsa:ReplyTo header for a synchronous operation.
+ SandeshaContext ctx = new SandeshaContext(Constants.SYNCHRONIZED);
+
+ ctx.setToURL("http://131.107.153.195/SecureReliableMessaging/ReliableOneWay.svc");
+ //We really do not want to send wsa:ReplyTo header for a synchronous operation.
//But Microsoft endpoint expects it for all the messages. So let's set that manually.
- ctx.setReplyToUrl(call, Constants.WSA.NS_ADDRESSING_ANONYMOUS);
+ ctx.setReplyToURL(Constants.WSA.NS_ADDRESSING_ANONYMOUS);
+
+ ctx.initCall(call, targetURL, "urn:wsrm:Ping", Constants.ClientProperties.IN_ONLY);
call.setOperationName("Ping");
@@ -54,7 +54,7 @@
ctx.setLastMessage(call);
call.invoke(new Message(getSOAPEnvelope(3)));
- ctx.endSequence(call);
+ ctx.endSequence();
} catch (Exception e) {
e.printStackTrace();
1.2 +7 -2 ws-fx/sandesha/interop/org/apache/sandesha/interop/RMInteropService.java
Index: RMInteropService.java
===================================================================
RCS file: /home/cvs/ws-fx/sandesha/interop/org/apache/sandesha/interop/RMInteropService.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- RMInteropService.java 11 Jun 2005 08:57:31 -0000 1.1
+++ RMInteropService.java 22 Jun 2005 13:38:11 -0000 1.2
@@ -17,6 +17,10 @@
package org.apache.sandesha.interop;
+import org.apache.commons.logging.Log;
+import org.apache.axis.components.logger.LogFactory;
+import org.apache.sandesha.client.RMSender;
+
import java.util.HashMap;
import java.util.Map;
@@ -28,6 +32,7 @@
*/
public class RMInteropService {
private static Map sequences = new HashMap();
+ private static final Log log = LogFactory.getLog(RMInteropService.class.getName());
public String echoString(String text, String sequence) {
@@ -38,11 +43,11 @@
sequences.put(sequence, (new String(text)));
}
- System.out.println("ECHO-STRING SERVICE " + text);
+ log.debug("Echo Service "+text);
return text;
}
public void ping(String text) {
- System.out.println("PING-STRING SERVICE " + text);
+ log.debug("Ping Service "+text);
}
}
1.2 +7 -9 ws-fx/sandesha/interop/org/apache/sandesha/interop/SystinetAsyncPing.java
Index: SystinetAsyncPing.java
===================================================================
RCS file: /home/cvs/ws-fx/sandesha/interop/org/apache/sandesha/interop/SystinetAsyncPing.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- SystinetAsyncPing.java 11 Jun 2005 08:57:31 -0000 1.1
+++ SystinetAsyncPing.java 22 Jun 2005 13:38:11 -0000 1.2
@@ -29,15 +29,13 @@
Call call = (Call) service.createCall();
SandeshaContext ctx = new SandeshaContext();
- ctx.addNewSequeceContext(call, targetURL, "urn:wsrm:Ping",
- Constants.ClientProperties.IN_ONLY);
- ctx.setToUrl(call, "http://soap.systinet.net:6064/Service");
- ctx.setAcksToUrl(call, "http://" + sourceHost + ":" + sourcePort +
- "/axis/services/RMService");
- ctx.setFromUrl(call, "http://" + sourceHost + ":" + sourcePort + "/axis/services/RMService");
- ctx.setFaultToUrl(call, "http://" + sourceHost + ":" + sourcePort +
- "/axis/services/RMService");
+ ctx.setToURL("http://soap.systinet.net:6064/Service");
+ ctx.setAcksToURL("http://" + sourceHost + ":" + sourcePort + "/axis/services/RMService");
+ ctx.setFromURL("http://" + sourceHost + ":" + sourcePort + "/axis/services/RMService");
+ ctx.setFaultToURL("http://" + sourceHost + ":" + sourcePort + "/axis/services/RMService");
+
+ ctx.initCall(call, targetURL, "urn:wsrm:Ping", Constants.ClientProperties.IN_ONLY);
call.setOperationName(new QName("http://tempuri.org/", "Ping"));
@@ -49,7 +47,7 @@
ctx.setLastMessage(call);
call.invoke(new Object[]{"Ping Message Number Three"});
- ctx.endSequence(call);
+ ctx.endSequence();
} catch (Exception e) {
e.printStackTrace();
1.2 +5 -5 ws-fx/sandesha/interop/org/apache/sandesha/interop/SystinetSyncPing.java
Index: SystinetSyncPing.java
===================================================================
RCS file: /home/cvs/ws-fx/sandesha/interop/org/apache/sandesha/interop/SystinetSyncPing.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- SystinetSyncPing.java 11 Jun 2005 08:57:31 -0000 1.1
+++ SystinetSyncPing.java 22 Jun 2005 13:38:11 -0000 1.2
@@ -42,10 +42,10 @@
Service service = new Service();
Call call = (Call) service.createCall();
- SandeshaContext ctx = new SandeshaContext();
- ctx.addNewSequeceContext(call, targetURL, "urn:wsrm:Ping",
- Constants.ClientProperties.IN_ONLY,true);
- ctx.setToUrl(call, "http://soap.systinet.net:6064/Service");
+ SandeshaContext ctx = new SandeshaContext(Constants.SYNCHRONIZED);
+
+ ctx.setToURL("http://soap.systinet.net:6064/Service");
+ ctx.initCall(call, targetURL, "urn:wsrm:Ping", Constants.ClientProperties.IN_ONLY);
call.setTargetEndpointAddress(targetURL);
call.setOperationName(new QName("http://tempuri.org/", "Ping"));
@@ -58,7 +58,7 @@
ctx.setLastMessage(call);
call.invoke(new Object[]{"Ping Message Number Three"});
- ctx.endSequence(call);
+ ctx.endSequence();
} catch (Exception e) {
e.printStackTrace();
1.2 +31 -29 ws-fx/sandesha/interop/org/apache/sandesha/interop/testclient/InteropStub.java
Index: InteropStub.java
===================================================================
RCS file: /home/cvs/ws-fx/sandesha/interop/org/apache/sandesha/interop/testclient/InteropStub.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- InteropStub.java 11 Jun 2005 08:57:31 -0000 1.1
+++ InteropStub.java 22 Jun 2005 13:38:11 -0000 1.2
@@ -37,6 +37,7 @@
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
+import java.io.IOException;
/**
* This is class has the client for the interop testing. interop.jsp
@@ -89,32 +90,32 @@
sendOffer = true;
if (replyTo != null && replyTo.equalsIgnoreCase("anonymous")) {
- ctx.setReplyToUrl(call, Constants.WSA.NS_ADDRESSING_ANONYMOUS);
+ ctx.setReplyToURL(Constants.WSA.NS_ADDRESSING_ANONYMOUS);
} else if (replyTo != null) {
- ctx.setReplyToUrl(call, bean.getReplyto());
+ ctx.setReplyToURL(bean.getReplyto());
}
if (from != null && from.equalsIgnoreCase("anonymous")) {
- ctx.setFromUrl(call, Constants.WSA.NS_ADDRESSING_ANONYMOUS);
+ ctx.setFromURL(Constants.WSA.NS_ADDRESSING_ANONYMOUS);
} else if (from != null) {
- ctx.setFromUrl(call, from);
+ ctx.setFromURL(from);
}
if (acksTo != null && acksTo.equalsIgnoreCase("anonymous")) {
- ctx.setAcksToUrl(call, Constants.WSA.NS_ADDRESSING_ANONYMOUS);
+ ctx.setAcksToURL(Constants.WSA.NS_ADDRESSING_ANONYMOUS);
} else if (acksTo != null) {
- ctx.setAcksToUrl(call, acksTo);
+ ctx.setAcksToURL(acksTo);
}
if (faultTo != null && faultTo.equalsIgnoreCase("anonymous")) {
- ctx.setFaultToUrl(call, Constants.WSA.NS_ADDRESSING_ANONYMOUS);
+ ctx.setFaultToURL(Constants.WSA.NS_ADDRESSING_ANONYMOUS);
} else if (faultTo != null) {
- ctx.setFaultToUrl(call, bean.getFaultto());
+ ctx.setFaultToURL(bean.getFaultto());
}
if (sendOffer)
- ctx.setSendOffer(call);
+ ctx.setSendOffer(true);
}
@@ -129,12 +130,9 @@
Call call = (Call) service.createCall();
SandeshaContext ctx = new SandeshaContext(true);
- ctx.setSourceUrl(call, bean.getSourceURL());
- ctx.addNewSequeceContext(call, target, "urn:wsrm:ping",
- Constants.ClientProperties.IN_ONLY);
-
+ ctx.setSourceURL(bean.getSourceURL());
configureContext(ctx, call, bean);
-
+ ctx.initCall(call, target, "urn:wsrm:ping", Constants.ClientProperties.IN_ONLY);
call.setOperationName(new QName("http://tempuri.org", "Ping"));
@@ -149,12 +147,12 @@
}
//InteropStub.stopClient();
- ctx.endSequence(call);
+ ctx.endSequence();
} catch (Exception e) {
if (callback != null)
callback.onError(e);
- log.info(e);
+ log.info(e);
}
}
@@ -177,11 +175,10 @@
Call call = (Call) service.createCall();
SandeshaContext ctx = new SandeshaContext(true);
- ctx.setSourceUrl(call, bean.getSourceURL());
- ctx.addNewSequeceContext(call, target, "urn:wsrm:echoString",
- Constants.ClientProperties.IN_OUT);
+ ctx.setSourceURL( bean.getSourceURL());
configureContext(ctx, call, bean);
+ ctx.initCall(call, target, "urn:wsrm:echoString", Constants.ClientProperties.IN_OUT);
call.setOperationName(new QName("http://tempuri.org/", "echoString"));
@@ -197,10 +194,10 @@
}
String ret = (String) call.invoke(new Object[]{msg, seq});
- log.info("Got response from server " + ret);
+ log.info("Got response from server " + ret);
}
- ctx.endSequence(call);
+ ctx.endSequence();
} catch (Exception e) {
if (callback != null)
@@ -210,12 +207,17 @@
}
- public static void initClient() {
- log.info("STARTING SENDER FOR THE CLIENT .......");
+ public static void initClient() throws AxisFault {
+ log.info("STARTING SENDER FOR THE CLIENT .......");
sender = new Sender(storageManager);
-
- SimpleChain reqChain = getRequestChain();
- SimpleChain resChain = getResponseChain();
+ SimpleChain reqChain = null;
+ SimpleChain resChain = null;
+ try {
+ reqChain = getRequestChain();
+ resChain = getResponseChain();
+ } catch (Exception e) {
+ throw new AxisFault(e.getMessage());
+ }
if (reqChain != null)
sender.setRequestChain(reqChain);
if (resChain != null)
@@ -240,7 +242,7 @@
stopClientByForce();
}
} catch (InterruptedException e) {
- log.error(e);
+ log.error(e);
}
}
@@ -257,13 +259,13 @@
throw new AxisFault("Inactivity Timeout Reached, No Response from the Server");
}
- private static SimpleChain getRequestChain() {
+ private static SimpleChain getRequestChain() throws Exception {
ArrayList arr = PropertyLoader.getRequestHandlerNames();
return getHandlerChain(arr);
}
- private static SimpleChain getResponseChain() {
+ private static SimpleChain getResponseChain() throws Exception {
ArrayList arr = PropertyLoader.getResponseHandlerNames();
return getHandlerChain(arr);
1.2 +28 -25 ws-fx/sandesha/interop/org/apache/sandesha/interop/testclient/ResponseWriter.java
Index: ResponseWriter.java
===================================================================
RCS file: /home/cvs/ws-fx/sandesha/interop/org/apache/sandesha/interop/testclient/ResponseWriter.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- ResponseWriter.java 11 Jun 2005 08:57:31 -0000 1.1
+++ ResponseWriter.java 22 Jun 2005 13:38:11 -0000 1.2
@@ -1,35 +1,38 @@
-
package org.apache.sandesha.interop.testclient;
+import org.apache.commons.logging.LogFactory;
+import org.apache.commons.logging.Log;
+
import java.io.PrintWriter;
/**
* @author root
- *
- * To change the template for this generated type comment go to
- * Window>Preferences>Java>Code Generation>Code and Comments
+ * <p/>
+ * To change the template for this generated type comment go to
+ * Window>Preferences>Java>Code Generation>Code and Comments
*/
public class ResponseWriter {
-
- private PrintWriter writer;
-
- public ResponseWriter(PrintWriter writer){
- this.writer = writer;
- }
-
- public synchronized boolean write(String s){
- try{
- writer.println(s);
- flush();
- return true;
- }catch(Exception e){
- System.out.println("Exception: In method 'write' of 'ResponseWriter'");
- return false;
- }
- }
-
- public synchronized void flush(){
- writer.flush();
- }
+
+ private PrintWriter writer;
+ private static final Log log = LogFactory.getLog(PrintWriter.class.getName());
+
+ public ResponseWriter(PrintWriter writer) {
+ this.writer = writer;
+ }
+
+ public synchronized boolean write(String s) {
+ try {
+ writer.println(s);
+ flush();
+ return true;
+ } catch (Exception e) {
+ log.error("Exception: In method 'write' of 'ResponseWriter");
+ return false;
+ }
+ }
+
+ public synchronized void flush() {
+ writer.flush();
+ }
}
1.2 +8 -10 ws-fx/sandesha/samples/org/apache/sandesha/samples/AsyncPingClient.java
Index: AsyncPingClient.java
===================================================================
RCS file: /home/cvs/ws-fx/sandesha/samples/org/apache/sandesha/samples/AsyncPingClient.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- AsyncPingClient.java 11 Jun 2005 10:00:05 -0000 1.1
+++ AsyncPingClient.java 22 Jun 2005 13:38:11 -0000 1.2
@@ -46,10 +46,8 @@
Call call = (Call) service.createCall();
SandeshaContext ctx = new SandeshaContext();
- ctx.addNewSequeceContext(call, targetURL, "urn:wsrm:ping",
- Constants.ClientProperties.IN_ONLY);
- ctx.setAcksToUrl(call,
- "http://127.0.0.1:" + defaultClientPort + "/axis/services/RMService");
+ ctx.setAcksToURL("http://127.0.0.1:" + defaultClientPort + "/axis/services/RMService");
+ ctx.initCall(call, targetURL, "urn:wsrm:ping", Constants.ClientProperties.IN_ONLY);
call.setOperationName(new QName("http://tempuri.org", "Ping"));
call.addParameter("Text", XMLType.XSD_STRING, ParameterMode.IN);
@@ -59,14 +57,14 @@
ctx.setLastMessage(call);
call.invoke(new Object[]{"Ping Message Number Three"});
- RMReport report = ctx.endSequence(call);
+ ctx.endSequence();
- if (report != null) {
- System.out.println("\n***********Printing RM Report***********");
- System.out.println("Were all messages acked - " + report.isAllAcked());
- System.out.println("****************************************\n");
- }
+ // if (report != null) {
+ System.out.println("\n***********Printing RM Report***********");
+ // System.out.println("Were all messages acked - " + report.isAllAcked());
+ System.out.println("****************************************\n");
+ // }
} catch (Exception e) {
1.2 +6 -8 ws-fx/sandesha/samples/org/apache/sandesha/samples/EchoClientAsyncAck.java
Index: EchoClientAsyncAck.java
===================================================================
RCS file: /home/cvs/ws-fx/sandesha/samples/org/apache/sandesha/samples/EchoClientAsyncAck.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- EchoClientAsyncAck.java 11 Jun 2005 10:00:05 -0000 1.1
+++ EchoClientAsyncAck.java 22 Jun 2005 13:38:11 -0000 1.2
@@ -48,13 +48,11 @@
Call call = (Call) service.createCall();
SandeshaContext ctx = new SandeshaContext();
- ctx.addNewSequeceContext(call, targetURL, "urn:wsrm:echoString",
- Constants.ClientProperties.IN_OUT);
- ctx.setAcksToUrl(call,
- "http://127.0.0.1:" + defaultClientPort + "/axis/services/RMService");
- ctx.setReplyToUrl(call,
- "http://127.0.0.1:" + defaultClientPort + "/axis/services/RMService");
- ctx.setSendOffer(call);
+
+ ctx.setAcksToURL("http://127.0.0.1:" + defaultClientPort + "/axis/services/RMService");
+ ctx.setReplyToURL("http://127.0.0.1:" + defaultClientPort + "/axis/services/RMService");
+ ctx.setSendOffer(true);
+ ctx.initCall(call, targetURL, "urn:wsrm:echoString", Constants.ClientProperties.IN_OUT);
call.setOperationName(new QName("http://tempuri.org/", "echoString"));
@@ -72,7 +70,7 @@
ret = (String) call.invoke(new Object[]{"Sandesha Echo 3", str});
System.out.println("The Response for Third Messsage is :" + ret);
- RMReport report = ctx.endSequence(call);
+ RMReport report = ctx.endSequence();
if (report != null) {
1.2 +15 -17 ws-fx/sandesha/samples/org/apache/sandesha/samples/EchoClientSyncAck.java
Index: EchoClientSyncAck.java
===================================================================
RCS file: /home/cvs/ws-fx/sandesha/samples/org/apache/sandesha/samples/EchoClientSyncAck.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- EchoClientSyncAck.java 11 Jun 2005 10:00:05 -0000 1.1
+++ EchoClientSyncAck.java 22 Jun 2005 13:38:11 -0000 1.2
@@ -26,6 +26,7 @@
import javax.xml.namespace.QName;
import javax.xml.rpc.ParameterMode;
+
/**
* Test client for echoString scenario.
*
@@ -51,42 +52,39 @@
Call call = (Call) service.createCall();
SandeshaContext ctx = new SandeshaContext();
- ctx.addNewSequeceContext(call, targetURL, "urn:wsrm:echoString",
- Constants.ClientProperties.IN_OUT);
- ctx.setAcksToUrl(call, Constants.WSA.NS_ADDRESSING_ANONYMOUS);
- ctx.setReplyToUrl(call,
- "http://127.0.0.1:" + defaultClientPort + "/axis/services/RMService");
+ ctx.setAcksToURL(Constants.WSA.NS_ADDRESSING_ANONYMOUS);
+ ctx.setReplyToURL("http://127.0.0.1:" + defaultClientPort + "/axis/services/RMService");
+ ctx.initCall(call, targetURL, "urn:wsrm:echoString", Constants.ClientProperties.IN_OUT);
- call.setOperationName(new QName("http://tempuri.org/", "echoString"));
+ call.setOperationName(new QName("http://tempuri.org/", "echoString"));
call.addParameter("arg1", XMLType.XSD_STRING, ParameterMode.IN);
call.addParameter("arg2", XMLType.XSD_STRING, ParameterMode.IN);
call.setReturnType(org.apache.axis.encoding.XMLType.XSD_STRING);
- String ret = (String) call.invoke(new Object[]{"Sandesha Echo 1", str});
+ String ret = (String) call.invoke(new Object[]{"Sandesha Echo 1", str});
System.out.println("The Response for First Messsage is :" + ret);
ret = (String) call.invoke(new Object[]{"Sandesha Echo 2", str});
System.out.println("The Response for Second Messsage is :" + ret);
//For last message.
- ctx.setLastMessage(call);
+ ctx.setLastMessage(call);
ret = (String) call.invoke(new Object[]{"Sandesha Echo 3", str});
System.out.println("The Response for Third Messsage is :" + ret);
- RMReport report = ctx.endSequence(call);
+ RMReport report = ctx.endSequence();
+
+ if (report != null) {
+ System.out.println("\n***********Printing RM Report***********");
+ System.out.println("Were all messages add - " + report.isAllAcked());
+ System.out.println("No of response messages - " + report.getNumberOfReturnMessages());
+ System.out.println("****************************************\n");
+ }
- if (report != null) {
- System.out.println("\n***********Printing RM Report***********");
- System.out.println("Were all messages add - " + report.isAllAcked());
- System.out.println(
- "No of response messages - " + report.getNumberOfReturnMessages());
- System.out.println("****************************************\n");
- }
-
} catch (Exception e) {
e.printStackTrace();
}
1.2 +4 -5 ws-fx/sandesha/samples/org/apache/sandesha/samples/SyncPingClient.java
Index: SyncPingClient.java
===================================================================
RCS file: /home/cvs/ws-fx/sandesha/samples/org/apache/sandesha/samples/SyncPingClient.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- SyncPingClient.java 11 Jun 2005 10:00:05 -0000 1.1
+++ SyncPingClient.java 22 Jun 2005 13:38:11 -0000 1.2
@@ -48,11 +48,10 @@
Service service = new Service();
Call call = (Call) service.createCall();
- SandeshaContext ctx = new SandeshaContext();
- ctx.addNewSequeceContext(call, targetURL, "urn:wsrm:Ping",
+ SandeshaContext ctx = new SandeshaContext(Constants.SYNCHRONIZED);
+ ctx.initCall(call, targetURL, "urn:wsrm:Ping",
Constants.ClientProperties.IN_ONLY);
- ctx.setSynchronous(call);
-
+
call.setOperationName(new QName("http://tempuri.org/", "Ping"));
call.addParameter("arg1", XMLType.XSD_STRING, ParameterMode.IN);
@@ -61,7 +60,7 @@
ctx.setLastMessage(call);
call.invoke(new Object[]{"Ping Message Number Three"});
- RMReport report = ctx.endSequence(call);
+ RMReport report = ctx.endSequence();
if (report != null) {
1.56 +5 -0 ws-fx/sandesha/src/org/apache/sandesha/Constants.java
Index: Constants.java
===================================================================
RCS file: /home/cvs/ws-fx/sandesha/src/org/apache/sandesha/Constants.java,v
retrieving revision 1.55
retrieving revision 1.56
diff -u -r1.55 -r1.56
--- Constants.java 10 Jun 2005 11:46:37 -0000 1.55
+++ Constants.java 22 Jun 2005 13:38:11 -0000 1.56
@@ -68,6 +68,8 @@
byte SERVER = (byte) 1;
byte CLIENT = (byte) 0;
+ int SYNCHRONIZED=0;
+
public interface WSA {
String NS_ADDRESSING_ANONYMOUS = AddressingUtils.getAnonymousRoleURI();
}
@@ -145,6 +147,9 @@
String NULL_REQUEST_MSG = "ERROR: NULL REQUEST MESSAGE";
String SEQ_IS_NOT_CREATED = "ERROR: Sequence was not created correcly in the in queue";
+
+ String CANNOT_LOAD_PROPERTIES="Cannot Load Properties. Check Whether sandesha.properties file is " +
+ "in your classpath. ";
}
public interface InfomationMessage {
1.35 +10 -0 ws-fx/sandesha/src/org/apache/sandesha/RMMessageContext.java
Index: RMMessageContext.java
===================================================================
RCS file: /home/cvs/ws-fx/sandesha/src/org/apache/sandesha/RMMessageContext.java,v
retrieving revision 1.34
retrieving revision 1.35
diff -u -r1.34 -r1.35
--- RMMessageContext.java 8 Jun 2005 08:58:31 -0000 1.34
+++ RMMessageContext.java 22 Jun 2005 13:38:11 -0000 1.35
@@ -67,6 +67,16 @@
private String acksTo;
private String to;
+ public SandeshaContext getCtx() {
+ return ctx;
+ }
+
+ public void setCtx(SandeshaContext ctx) {
+ this.ctx = ctx;
+ }
+
+ private SandeshaContext ctx;
+
public boolean isLocked() {
return locked;
}
1.7 +18 -1 ws-fx/sandesha/src/org/apache/sandesha/RMReport.java
Index: RMReport.java
===================================================================
RCS file: /home/cvs/ws-fx/sandesha/src/org/apache/sandesha/RMReport.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- RMReport.java 25 May 2005 10:08:59 -0000 1.6
+++ RMReport.java 22 Jun 2005 13:38:11 -0000 1.7
@@ -25,7 +25,24 @@
private boolean allAcked;
private int returns;
-
+ private String error;
+
+ public String getError() {
+ return error;
+ }
+
+ public void setError(String error) {
+ this.error = error;
+ }
+
+ public int getReturns() {
+ return returns;
+ }
+
+ public void setReturns(int returns) {
+ this.returns = returns;
+ }
+
public boolean isAllAcked() {
return this.allAcked;
}
1.8 +205 -180 ws-fx/sandesha/src/org/apache/sandesha/SandeshaContext.java
Index: SandeshaContext.java
===================================================================
RCS file: /home/cvs/ws-fx/sandesha/src/org/apache/sandesha/SandeshaContext.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- SandeshaContext.java 11 Jun 2005 08:24:56 -0000 1.7
+++ SandeshaContext.java 22 Jun 2005 13:38:11 -0000 1.8
@@ -25,6 +25,7 @@
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
+import java.io.IOException;
/**
* SandeshaContext will keep track of different Call objects that the user may use inside
@@ -34,6 +35,8 @@
*/
public class SandeshaContext {
+ private static final Log log = LogFactory.getLog(SandeshaContext.class.getName());
+
private static boolean rmInvokerStarted = false;
private static boolean cleintSenderStarted = false;
private static boolean serverSenderStarted = false;
@@ -43,36 +46,182 @@
private static Sender serverSender;
private static boolean insideServer;
- private static HashMap callMap = new HashMap();
- private static int activeSequenes = 0;
- public SandeshaContext() {
+ private HashMap callMap = new HashMap();
+ private static HashMap seqMap = new HashMap();
+
+ private long key;
+
+ private String toURL;
+ private String sourceURL;
+ private String replyToURL;
+
+ public String getReplyToURL() {
+ return replyToURL;
+ }
+
+ public void setReplyToURL(String replyToURL) {
+ this.replyToURL = replyToURL;
+ }
+
+ private String faultToURL;
+ private String fromURL;
+ private String acksToURL;
+ private boolean sendOffer;
+ // private boolean lastMessage;
+ private long messageNumber;
+
+ private RMReport report;
+
+ private boolean sync;
+
+ public boolean isSync() {
+ return sync;
+ }
+
+ public void setSync(boolean sync) {
+ this.sync = sync;
+ }
+
+ public long getMessageNumber() {
+ return messageNumber;
+ }
+
+ public void setMessageNumber(long messageNumber) {
+ this.messageNumber = messageNumber;
+ }
+
+ public boolean isSendOffer() {
+ return sendOffer;
+ }
+
+ public void setSendOffer(boolean sendOffer) {
+ this.sendOffer = sendOffer;
+ }
+
+ public String getAcksToURL() {
+ return acksToURL;
+ }
+
+ public void setAcksToURL(String acksToURL) {
+ this.acksToURL = acksToURL;
+ }
+
+ public String getFromURL() {
+ return fromURL;
+ }
+
+ public void setFromURL(String fromURL) {
+ this.fromURL = fromURL;
+ }
+
+ public String getFaultURL() {
+ return faultToURL;
+ }
+
+ public void setFaultToURL(String faultURL) {
+ this.faultToURL = faultURL;
+ }
+
+ public String getSourceURL() {
+ return sourceURL;
+ }
+
+ public void setSourceURL(String sourceURL) {
+ this.sourceURL = sourceURL;
+ }
+
+ public String getToURL() {
+ return toURL;
+ }
+
+ public void setToURL(String toURL) {
+ this.toURL = toURL;
+ }
+
+ public SandeshaContext() throws AxisFault {
+ messageNumber = 0;
+ key = System.currentTimeMillis();
SandeshaContext.insideServer = false;
+ init(true);
+ startListener();
+ seqMap.put(new Long(key), this);
+ report = new RMReport();
}
- public SandeshaContext(boolean insideServer) {
+ public SandeshaContext(int sync) throws AxisFault {
+ this.sync = true;
+ messageNumber = 0;
+ key = System.currentTimeMillis();
+ SandeshaContext.insideServer = false;
+ init(true);
+ seqMap.put(new Long(key), this);
+ report = new RMReport();
+ }
+
+ public SandeshaContext(boolean insideServer) throws AxisFault {
+ messageNumber = 0;
+ key = System.currentTimeMillis();
SandeshaContext.insideServer = insideServer;
+ init(true);
+ seqMap.put(new Long(key), this);
+ report = new RMReport();
}
+ public SandeshaContext(boolean insideServer, int sync) throws AxisFault {
+ this.sync = true;
+ messageNumber = 0;
+ key = System.currentTimeMillis();
+ SandeshaContext.insideServer = insideServer;
+ init(true);
+ seqMap.put(new Long(key), this);
+ report = new RMReport();
+ }
- public static HashMap getCallMap() {
- return callMap;
+ public void initCall(Call call, String targetUrl, String action, short MEP) throws AxisFault {
+ if (toURL != null)
+ call.setProperty(Constants.ClientProperties.TO, toURL);
+ if (sourceURL != null)
+ call.setProperty(Constants.ClientProperties.SOURCE_URL, sourceURL);
+ if (faultToURL != null)
+ call.setProperty(Constants.ClientProperties.FAULT_TO, faultToURL);
+ if (fromURL != null)
+ call.setProperty(Constants.ClientProperties.FROM, fromURL);
+ if (replyToURL != null)
+ call.setProperty(Constants.ClientProperties.REPLY_TO, replyToURL);
+ if (acksToURL != null)
+ call.setProperty(Constants.ClientProperties.ACKS_TO, acksToURL);
+
+ call.setProperty(Constants.ClientProperties.SEND_OFFER, Boolean.valueOf(sendOffer));
+ call.setProperty(Constants.ClientProperties.SYNC, Boolean.valueOf(sync));
+ call.setProperty("context", this);
+
+ String key = initialize(call, targetUrl, action, MEP);
+ callMap.put(key, call);
}
- public static void setCallMap(HashMap callMap) {
- SandeshaContext.callMap = callMap;
+ public HashMap getCallMap() {
+ return callMap;
}
- private static final Log log = LogFactory.getLog(SandeshaContext.class.getName());
+ public void setCallMap(HashMap callMap) {
+ this.callMap = callMap;
+ }
- public static IStorageManager init(boolean client) {
+ public static IStorageManager init(boolean client) throws AxisFault {
if (client) {
IStorageManager storageManager = new ClientStorageManager();
if (!cleintSenderStarted) {
log.info(Constants.InfomationMessage.SENDER_STARTED);
cleintSender = new Sender(storageManager);
- SimpleChain reqChain = getRequestChain();
- SimpleChain resChain = getResponseChain();
+ SimpleChain reqChain = null;
+ SimpleChain resChain = null;
+ try {
+ reqChain = getRequestChain();
+ resChain = getResponseChain();
+ } catch (Exception e) {
+ throw new AxisFault(e.getMessage());
+ }
if (reqChain != null)
cleintSender.setRequestChain(reqChain);
if (resChain != null)
@@ -97,8 +246,7 @@
}
}
-
- private static void validateProperties(Call call, String targetUrl, String action, short MEP)
+ private void validateProperties(Call call, String targetUrl, String action, short MEP)
throws AxisFault {
if (action == null)
throw new AxisFault("Please sepeicfy Action");
@@ -106,99 +254,43 @@
throw new AxisFault("TargetUrl cannot be null");
if (call == null)
throw new AxisFault("Call cannot be null");
- if (!(MEP == Constants.ClientProperties.IN_ONLY ||
- MEP == Constants.ClientProperties.IN_OUT))
+ if (!(MEP == Constants.ClientProperties.IN_ONLY || MEP == Constants.ClientProperties.IN_OUT))
throw new AxisFault("Invalid MEP");
}
-
- public void addNewSequeceContext(Call call, String targetUrl, String action, short MEP)
- throws AxisFault {
- String key = initialize(call, targetUrl, action, MEP);
- init(true);
- startListener();
- callMap.put(key, call);
- activeSequenes++;
- }
-
- public void addNewSequeceContext(Call call, String targetUrl, String action, short MEP,
- boolean sync) throws AxisFault {
- String key = initialize(call, targetUrl, action, MEP);
- setSynchronous(call);
- init(true);
- if (!sync) {
- startListener();
- }
- callMap.put(key, call);
- activeSequenes++;
- }
-
- public void endAllSequence(Call call) throws AxisFault {
+ public RMReport endSequence() throws AxisFault {
IStorageManager storageManager = new ClientStorageManager();
long startingTime = System.currentTimeMillis();
long inactivityTimeOut = PolicyLoader.getInstance().getInactivityTimeout();
- while (!storageManager.isAllSequenceComplete()) {
- try {
- log.info(Constants.InfomationMessage.WAITING_TO_STOP_CLIENT);
- Thread.sleep(Constants.CLIENT_WAIT_PERIOD_FOR_COMPLETE);
- if ((System.currentTimeMillis() - startingTime) >= inactivityTimeOut) {
- stopClientByForce();
- }
- } catch (InterruptedException e) {
- e.printStackTrace();
- log.error(e);
- }
- }
- endAllSequences();
+ Iterator ite = callMap.keySet().iterator();
- }
-
- public RMReport endSequence(Call call) throws AxisFault {
-
- IStorageManager storageManager = new ClientStorageManager();
- long startingTime = System.currentTimeMillis();
- long inactivityTimeOut = PolicyLoader.getInstance().getInactivityTimeout();
- String seqId = (String) call.getProperty(Constants.ClientProperties.CALL_KEY);
- while (!storageManager.isSequenceComplete(seqId)) {
- try {
- log.info(Constants.InfomationMessage.WAITING_TO_STOP_CLIENT);
- Thread.sleep(Constants.CLIENT_WAIT_PERIOD_FOR_COMPLETE);
- if ((System.currentTimeMillis() - startingTime) >= inactivityTimeOut) {
- stopClientByForce();
+ while (ite.hasNext()) {
+ String key = (String) ite.next();
+ Call tempCall = (Call) callMap.get(key);
+ String seqId = (String) tempCall.getProperty(Constants.ClientProperties.CALL_KEY);
+ while (!storageManager.isSequenceComplete(seqId)) {
+ try {
+ log.info(Constants.InfomationMessage.WAITING_TO_STOP_CLIENT);
+ Thread.sleep(Constants.CLIENT_WAIT_PERIOD_FOR_COMPLETE);
+ if ((System.currentTimeMillis() - startingTime) >= inactivityTimeOut) {
+ stopClientByForce();
+ this.report.setError("Inactivity Time Out Reached. Sequence not complete");
+ }
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ log.error(e);
}
- } catch (InterruptedException e) {
- e.printStackTrace();
- log.error(e);
}
}
- RMReport rmReport = (RMReport) call.getProperty(Constants.ClientProperties.REPORT);
- rmReport.setAllAcked(true);
-
- if (activeSequenes == 1) {
- if (listenerStarted) {
- sas.stop();
- listenerStarted = false;
- }
- cleintSender.stop();
- cleintSenderStarted = false;
- storageManager.clearStorage();
- activeSequenes--;
- return rmReport;
+ if (this.report.getError() == null) {
+ this.report.setAllAcked(true);
}
- activeSequenes--;
- return rmReport;
- }
-
-
- public void endAllSequences() throws AxisFault {
- IStorageManager storageManager = new ClientStorageManager();
- if (activeSequenes >= 1) {
- stopClientByForce();
- } else {
+ seqMap.remove(new Long(key));
+ if (seqMap.isEmpty()) {
if (listenerStarted) {
sas.stop();
listenerStarted = false;
@@ -206,39 +298,33 @@
cleintSender.stop();
cleintSenderStarted = false;
storageManager.clearStorage();
- activeSequenes--;
}
+ return this.report;
+
}
- public static void stopClientByForce() throws AxisFault {
+ public void stopClientByForce() throws AxisFault {
if (listenerStarted) {
sas.stop();
-
- //FOR JSP
- listenerStarted = false;
- //END JSP
listenerStarted = false;
}
cleintSender.stop();
-
- //FOR JSP
cleintSenderStarted = false;
- //END JSP
throw new AxisFault("Inactivity Timeout Reached, No Response from the Server");
}
- private static String initialize(Call call, String targetUrl, String action, short MEP)
+ private String initialize(Call call, String targetUrl, String action, short MEP)
throws AxisFault {
validateProperties(call, targetUrl, action, MEP);
- String keyOfCall = System.currentTimeMillis() + action;
+ String keyOfCall = this.key + action;
call.setTargetEndpointAddress(targetUrl);
call.setProperty(Constants.ClientProperties.ACTION, action);
call.setTransport(new RMTransport(targetUrl, ""));
call.setProperty(Constants.ClientProperties.MEP, new Short(MEP));
call.setProperty(Constants.ClientProperties.CALL_KEY, keyOfCall);
- call.setProperty(Constants.ClientProperties.REPORT, new RMReport());
+ call.setProperty(Constants.ClientProperties.REPORT, this.report);
if (!insideServer) {
InetAddress addr = null;
@@ -248,9 +334,15 @@
log.error(e);
}
- String sourceURL = Constants.HTTP + Constants.COLON + Constants.SLASH +
- Constants.SLASH + addr.getHostAddress() + Constants.COLON +
- PropertyLoader.getClientSideListenerPort() + Constants.URL_RM_SERVICE;
+ String sourceURL = null;
+ try {
+ sourceURL = Constants.HTTP + Constants.COLON + Constants.SLASH +
+ Constants.SLASH + addr.getHostAddress() + Constants.COLON +
+ PropertyLoader.getClientSideListenerPort() + Constants.URL_RM_SERVICE;
+ } catch (Exception e) {
+ throw new AxisFault(e.getMessage());
+ }
+
call.setProperty(Constants.ClientProperties.SOURCE_URL, sourceURL);
}
return keyOfCall;
@@ -284,8 +376,7 @@
desc.setName(Constants.ClientProperties.RMSERVICE);
rmService.setServiceDescription(desc);
sp.deployService(Constants.ClientProperties.RMSERVICE, rmService);
- sas.setServerSocket(
- new ServerSocket(PropertyLoader.getClientSideListenerPort()));
+ sas.setServerSocket(new ServerSocket(PropertyLoader.getClientSideListenerPort()));
Thread serverThread = new Thread(sas);
serverThread.start();
@@ -298,8 +389,7 @@
}
-
- public static SimpleChain getHandlerChain(List arr) {
+ private static SimpleChain getHandlerChain(List arr) {
SimpleChain reqHandlers = new SimpleChain();
Iterator it = arr.iterator();
boolean hasReqHandlers = false;
@@ -322,87 +412,31 @@
}
- private static SimpleChain getRequestChain() {
+ private static SimpleChain getRequestChain() throws Exception {
ArrayList arr = PropertyLoader.getRequestHandlerNames();
return getHandlerChain(arr);
}
- private static SimpleChain getResponseChain() {
+ private static SimpleChain getResponseChain() throws Exception {
ArrayList arr = PropertyLoader.getResponseHandlerNames();
return getHandlerChain(arr);
}
- private static SimpleChain getListenerRequestChain() {
+ private static SimpleChain getListenerRequestChain() throws Exception {
ArrayList arr = PropertyLoader.getListenerRequestHandlerNames();
return getHandlerChain(arr);
}
- private static SimpleChain getListenerResponseChain() {
+ private static SimpleChain getListenerResponseChain() throws Exception {
ArrayList arr = PropertyLoader.getListenerResponseHandlerNames();
return getHandlerChain(arr);
}
- public String getToUrl(Call call) {
- return (String) call.getProperty(Constants.ClientProperties.TO);
- }
-
- public void setToUrl(Call call, String toUrl) {
- call.setProperty(Constants.ClientProperties.TO, toUrl);
- }
-
- public String getSourceUrl(Call call) {
- return (String) call.getProperty(Constants.ClientProperties.SOURCE_URL);
- }
-
- public void setSourceUrl(Call call, String toUrl) {
- call.setProperty(Constants.ClientProperties.SOURCE_URL, toUrl);
- }
-
- public String getFaultTo(Call call) {
- return (String) call.getProperty(Constants.ClientProperties.FAULT_TO);
- }
-
- public void setFaultToUrl(Call call, String faultTo) {
- call.setProperty(Constants.ClientProperties.FAULT_TO, faultTo);
- }
-
- public String getFromUrl(Call call) {
- return (String) call.getProperty(Constants.ClientProperties.FROM);
- }
-
- public void setFromUrl(Call call, String fromUrl) {
- call.setProperty(Constants.ClientProperties.FROM, fromUrl);
- }
-
- public String getReplyToUrl(Call call) {
- return (String) call.getProperty(Constants.ClientProperties.REPLY_TO);
- }
-
- public void setReplyToUrl(Call call, String replyToUrl) {
- call.setProperty(Constants.ClientProperties.REPLY_TO, replyToUrl);
- }
-
- public String getAcksToUrl(Call call) {
- return (String) call.getProperty(Constants.ClientProperties.ACKS_TO);
- }
-
- public void setAcksToUrl(Call call, String acksToUrl) {
- call.setProperty(Constants.ClientProperties.ACKS_TO, acksToUrl);
- }
-
- public boolean isSendOffer(Call call) {
- return ((Boolean) call.getProperty(Constants.ClientProperties.SEND_OFFER)).booleanValue();
- }
-
- public void setSendOffer(Call call) {
- call.setProperty(Constants.ClientProperties.SEND_OFFER, Boolean.valueOf(true));
- }
-
public void setLastMessage(Call call) {
call.setProperty(Constants.ClientProperties.LAST_MESSAGE, Boolean.valueOf(true));
}
@@ -418,13 +452,4 @@
public void setMessageNumber(Call call, long msgNumber) {
call.setProperty(Constants.ClientProperties.MSG_NUMBER, new Long(msgNumber));
}
-
- public void setSynchronous(Call call) {
- call.setProperty(Constants.ClientProperties.SYNC, Boolean.valueOf(true));
- }
-
- public boolean getSynchronous(Call call) {
- return ((Boolean) call.getProperty(Constants.ClientProperties.SYNC)).booleanValue();
- }
-
}
1.30 +15 -8 ws-fx/sandesha/src/org/apache/sandesha/client/ClientPropertyValidator.java
Index: ClientPropertyValidator.java
===================================================================
RCS file: /home/cvs/ws-fx/sandesha/src/org/apache/sandesha/client/ClientPropertyValidator.java,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -r1.29 -r1.30
--- ClientPropertyValidator.java 8 Jun 2005 08:58:31 -0000 1.29
+++ ClientPropertyValidator.java 22 Jun 2005 13:38:11 -0000 1.30
@@ -20,6 +20,7 @@
import org.apache.axis.client.Call;
import org.apache.sandesha.Constants;
import org.apache.sandesha.RMMessageContext;
+import org.apache.sandesha.SandeshaContext;
import javax.xml.namespace.QName;
@@ -30,7 +31,7 @@
*/
public class ClientPropertyValidator {
- public static RMMessageContext validate(Call call) throws AxisFault {
+ public static synchronized RMMessageContext validate(Call call) throws AxisFault {
RMMessageContext rmMessageContext = null;
@@ -47,6 +48,7 @@
String faultTo = getFaultTo(call);
boolean sendOffer = getOffer(call);
String key = getKey(call);
+ SandeshaContext ctx=getCtx(call);
try {
sourceURL = getSourceURL(call);
@@ -71,6 +73,7 @@
rmMessageContext.setTo(to);
rmMessageContext.setFaultTo(faultTo);
rmMessageContext.setSendOffer(sendOffer);
+ rmMessageContext.setCtx(ctx);
return rmMessageContext;
} else
@@ -78,6 +81,10 @@
}
+ private static SandeshaContext getCtx(Call call){
+ return (SandeshaContext) call.getProperty("context");
+ }
+
private static String getKey(Call call) {
return (String) call.getProperty(Constants.ClientProperties.CALL_KEY);
}
@@ -166,17 +173,17 @@
* @return
*/
private static long getMessageNumber(Call call) {
- Object temp = call.getProperty(Constants.ClientProperties.MSG_NUMBER);
- long msgNumber = 0;
+ Object temp = call.getProperty(Constants.ClientProperties.MSG_NUMBER);
+ SandeshaContext ctx=(SandeshaContext)call.getProperty("context");
+ long msgNo=ctx.getMessageNumber();
if (temp == null) {
- call.setProperty(Constants.ClientProperties.MSG_NUMBER, new Long(++msgNumber));
+ ctx.setMessageNumber(++msgNo);
} else {
- msgNumber =
- ((Long) call.getProperty(Constants.ClientProperties.MSG_NUMBER)).longValue();
- call.setProperty(Constants.ClientProperties.MSG_NUMBER, new Long(++msgNumber));
+ msgNo = ((Long) call.getProperty(Constants.ClientProperties.MSG_NUMBER)).longValue();
+
}
- return msgNumber;
+ return msgNo;
}
private static boolean getLastMessage(Call call) {
1.44 +11 -12 ws-fx/sandesha/src/org/apache/sandesha/client/ClientStorageManager.java
Index: ClientStorageManager.java
===================================================================
RCS file: /home/cvs/ws-fx/sandesha/src/org/apache/sandesha/client/ClientStorageManager.java,v
retrieving revision 1.43
retrieving revision 1.44
diff -u -r1.43 -r1.44
--- ClientStorageManager.java 8 Jun 2005 08:58:31 -0000 1.43
+++ ClientStorageManager.java 22 Jun 2005 13:38:11 -0000 1.44
@@ -48,7 +48,7 @@
Constants.CLIENT);
}
- public boolean isSequenceExist(String sequenceID) {
+ public boolean isSequenceExist(String sequenceID) {
return accessor.isOutgoingSequenceExists(sequenceID);
}
@@ -100,9 +100,9 @@
*/
public void addAcknowledgement(RMMessageContext rmMessageContext) {
String sequenceID = rmMessageContext.getSequenceID();
- if(sequenceID!=null)
+ if (sequenceID != null)
accessor.removeAllAcks(sequenceID);
-
+
addPriorityMessage(rmMessageContext);
}
@@ -162,15 +162,15 @@
if (null == msg) {
msg = accessor.getNextLowPriorityMessageContextToSend();
- // checks whether all the request messages hv been acked
+ // checks whether all the request messages have been acked
}
if (null != callBack && null != msg)
informOutgoingMessage(msg);
- if (msg != null && !msg.isLocked()){
+ if (msg != null && !msg.isLocked()) {
msg.setLocked(true);
- return msg;
- }else{
+ return msg;
+ } else {
return null;
}
}
@@ -226,9 +226,9 @@
* @see org.apache.sandesha.IStorageManager#insertOutgoingMessage
* (org.apache.sandesha.RMMessageContext)
*/
- public void insertOutgoingMessage(RMMessageContext msg) {
- String sequenceId = msg.getSequenceID();
- accessor.addMessageToOutgoingSequence(sequenceId, msg);
+ public void insertOutgoingMessage(RMMessageContext msg) {
+ String sequenceId = msg.getSequenceID();
+ accessor.addMessageToOutgoingSequence(sequenceId, msg);
}
/*
@@ -380,7 +380,6 @@
cbData.setSequenceId(rmMsgContext.getSequenceID());
cbData.setMessageId(rmMsgContext.getMessageID());
cbData.setMessageType(rmMsgContext.getMessageType());
-
}
if (null != callBack)
@@ -396,7 +395,7 @@
boolean incomingTerminateReceived = accessor.isIncommingTerminateReceived(seqId);
return outTerminateSent && incomingTerminateReceived;
}
-
+
public void sendAck(String sequenceId) {
String keyId = accessor.getKeyFromIncomingSequenceId(sequenceId);
accessor.sendAck(keyId);
1.47 +47 -42 ws-fx/sandesha/src/org/apache/sandesha/client/RMSender.java
Index: RMSender.java
===================================================================
RCS file: /home/cvs/ws-fx/sandesha/src/org/apache/sandesha/client/RMSender.java,v
retrieving revision 1.46
retrieving revision 1.47
diff -u -r1.46 -r1.47
--- RMSender.java 8 Jun 2005 08:58:31 -0000 1.46
+++ RMSender.java 22 Jun 2005 13:38:11 -0000 1.47
@@ -27,6 +27,7 @@
import org.apache.axis.message.addressing.AddressingHeaders;
import org.apache.commons.logging.Log;
import org.apache.sandesha.*;
+import org.apache.sandesha.storage.queue.SandeshaQueue;
import org.apache.sandesha.util.PolicyLoader;
import org.apache.sandesha.util.RMMessageCreator;
import org.apache.sandesha.ws.rm.RMHeaders;
@@ -50,7 +51,8 @@
private IStorageManager storageManager;
private static final Log log = LogFactory.getLog(RMSender.class.getName());
- private static final UUIDGen uuidGen = UUIDGenFactory.getUUIDGen();
+ private final UUIDGen uuidGen = UUIDGenFactory.getUUIDGen();
+ private static Boolean lock = new Boolean(false);
/**
* This is the main method that is invoked by the axis engine. This method will add the reqest
@@ -66,52 +68,43 @@
storageManager = new ClientStorageManager();
try {
- RMMessageContext reqMsgCtx = getRMMessageContext(msgContext);
- String tempSeqID = reqMsgCtx.getSequenceID();
+ RMMessageContext reqMsgCtx = null;
+ String tempSeqID = null;
- long msgNo = reqMsgCtx.getMsgNumber();
+ reqMsgCtx = getRMMessageContext(msgContext);
- if (msgNo == 1) {
- reqMsgCtx = processFirstRequestMessage(reqMsgCtx, reqMsgCtx.getSync());
- } else {
- reqMsgCtx = processRequestMessage(reqMsgCtx);
- }
+ tempSeqID = reqMsgCtx.getSequenceID();
- if (reqMsgCtx.isLastMessage()) {
- storageManager.insertTerminateSeqMessage(
- RMMessageCreator.createTerminateSeqMsg(reqMsgCtx, Constants.CLIENT));
- }
+ reqMsgCtx = processFirstRequestMessage(reqMsgCtx, reqMsgCtx.getSync());
if (reqMsgCtx.isHasResponse()) {
RMMessageContext responseMessageContext = null;
long startingTime = System.currentTimeMillis();
long inactivityTimeOut = PolicyLoader.getInstance().getInactivityTimeout();
+
while (responseMessageContext == null) {
+ synchronized(lock){
responseMessageContext =
checkTheQueueForResponse(tempSeqID, reqMsgCtx.getMessageID());
if ((System.currentTimeMillis() - startingTime) >= inactivityTimeOut) {
- SandeshaContext.stopClientByForce();
+ reqMsgCtx.getCtx().stopClientByForce();
}
Thread.sleep(Constants.CLIENT_RESPONSE_CHECKING_INTERVAL);
+ }
}
-
-
+
//setting RMReport;
if (responseMessageContext != null) {
String oldSeqId = reqMsgCtx.getOldSequenceID();
if (oldSeqId != null) {
- Call call = (Call) SandeshaContext.getCallMap().get(
- reqMsgCtx.getOldSequenceID());
+ Call call = (Call) reqMsgCtx.getCtx().getCallMap().get(reqMsgCtx.getOldSequenceID());
if (call != null) {
- RMReport report = (RMReport) call.getProperty(
- Constants.ClientProperties.REPORT);
+ RMReport report = (RMReport) call.getProperty(Constants.ClientProperties.REPORT);
report.incrementReturnedMsgCount();
}
}
}
-
-
//We need these steps to filter all addressing and rm related headers.
Message resMsg = responseMessageContext.getMsgContext().getRequestMessage();
@@ -126,6 +119,7 @@
} catch (Exception ex) {
log.error(ex);
+
throw new AxisFault(ex.getLocalizedMessage());
}
@@ -141,32 +135,44 @@
*/
private RMMessageContext processFirstRequestMessage(RMMessageContext reqRMMsgContext,
boolean sync) throws Exception {
- String msgID = Constants.UUID + uuidGen.nextUUID();
- String offerID = null;
- if (reqRMMsgContext.isHasResponse() && reqRMMsgContext.isSendOffer()) {
- offerID = Constants.UUID + uuidGen.nextUUID();
- storageManager.addRequestedSequence(offerID);
- storageManager.addOffer(msgID, offerID);
+ synchronized (lock) {
+
+ if (!storageManager.isSequenceExist(reqRMMsgContext.getSequenceID())) {
+ String msgID = Constants.UUID + uuidGen.nextUUID();
+ String offerID = null;
+ if (reqRMMsgContext.isHasResponse() && reqRMMsgContext.isSendOffer()) {
+ offerID = Constants.UUID + uuidGen.nextUUID();
+ storageManager.addRequestedSequence(offerID);
+ storageManager.addOffer(msgID, offerID);
+ }
+
+ RMMessageContext createSeqRMMsgContext = RMMessageCreator.createCreateSeqMsg(reqRMMsgContext, Constants.CLIENT, msgID, offerID);
+ storageManager.addOutgoingSequence(reqRMMsgContext.getSequenceID());
+ storageManager.setTemporaryOutSequence(reqRMMsgContext.getSequenceID(),
+ createSeqRMMsgContext.getMessageID());
+
+ createSeqRMMsgContext.setSync(sync);
+ storageManager.addCreateSequenceRequest(createSeqRMMsgContext);
+ processRequestMessage(reqRMMsgContext);
+
+ } else {
+ processRequestMessage(reqRMMsgContext);
+ }
+
}
- RMMessageContext createSeqRMMsgContext = RMMessageCreator.createCreateSeqMsg(
- reqRMMsgContext, Constants.CLIENT, msgID, offerID);
- storageManager.addOutgoingSequence(reqRMMsgContext.getSequenceID());
- storageManager.setTemporaryOutSequence(reqRMMsgContext.getSequenceID(),
- createSeqRMMsgContext.getMessageID());
-
- createSeqRMMsgContext.setSync(sync);
- storageManager.addCreateSequenceRequest(createSeqRMMsgContext);
- processRequestMessage(reqRMMsgContext);
+
return reqRMMsgContext;
}
private RMMessageContext processRequestMessage(RMMessageContext reqRMMsgContext)
throws Exception {
- RMMessageContext serviceRequestMsg = RMMessageCreator.createServiceRequestMessage(
- reqRMMsgContext);
+ if (reqRMMsgContext.isLastMessage()) {
+ storageManager.insertTerminateSeqMessage(RMMessageCreator.createTerminateSeqMsg(reqRMMsgContext, Constants.CLIENT));
+ }
+ RMMessageContext serviceRequestMsg = RMMessageCreator.createServiceRequestMessage(reqRMMsgContext);
storageManager.insertOutgoingMessage(serviceRequestMsg);
- return reqRMMsgContext;
+ return reqRMMsgContext;
}
private RMMessageContext checkTheQueueForResponse(String sequenceId, String reqMessageID) {
@@ -181,8 +187,7 @@
Call call = (Call) newMsgContext.getProperty(MessageContext.CALL);
requestMesssageContext = ClientPropertyValidator.validate(call);
- requestMesssageContext.setOutGoingAddress(
- (String) msgCtx.getProperty(MessageContext.TRANS_URL));
+ requestMesssageContext.setOutGoingAddress((String) msgCtx.getProperty(MessageContext.TRANS_URL));
requestMesssageContext.setMsgContext(newMsgContext);
return requestMesssageContext;
}
1.5 +1 -1 ws-fx/sandesha/src/org/apache/sandesha/server/SenderWorker.java
Index: SenderWorker.java
===================================================================
RCS file: /home/cvs/ws-fx/sandesha/src/org/apache/sandesha/server/SenderWorker.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- SenderWorker.java 11 Jun 2005 08:24:56 -0000 1.4
+++ SenderWorker.java 22 Jun 2005 13:38:12 -0000 1.5
@@ -290,7 +290,7 @@
//i.e. we are not expecting any response for this.
if (rmMessageContext.getMsgContext().getResponseMessage() == null) {
//The code should not come to this point.
- System.err.println(Constants.ErrorMessages.NULL_REQUEST_MSG);
+ log.error(Constants.ErrorMessages.NULL_REQUEST_MSG);
} else {
Call call = prepareCall(rmMessageContext);
call.setRequestMessage(rmMessageContext.getMsgContext().getResponseMessage());
1.26 +10 -7 ws-fx/sandesha/src/org/apache/sandesha/storage/queue/SandeshaQueue.java
Index: SandeshaQueue.java
===================================================================
RCS file: /home/cvs/ws-fx/sandesha/src/org/apache/sandesha/storage/queue/SandeshaQueue.java,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -r1.25 -r1.26
--- SandeshaQueue.java 10 Jun 2005 11:46:37 -0000 1.25
+++ SandeshaQueue.java 22 Jun 2005 13:38:12 -0000 1.26
@@ -141,7 +141,7 @@
}
}
- public boolean isOutgoingSequenceExists(String resSeqId) {
+ public synchronized boolean isOutgoingSequenceExists(String resSeqId) {
synchronized (outgoingMap) {
return outgoingMap.containsKey(resSeqId);
}
@@ -225,7 +225,7 @@
synchronized (lowPriorityQueue) {
if (msg == null)
throw new QueueException(Constants.Queue.MESSAGE_ID_NULL);
- lowPriorityQueue.add(msg);
+ lowPriorityQueue.add(msg);
}
}
@@ -234,6 +234,7 @@
synchronized (highPriorityQueue) {
+
if (highPriorityQueue.size() <= 0)
return null;
@@ -552,7 +553,7 @@
}
}
- public RMMessageContext checkForResponseMessage(String requestId, String seqId) {
+ public synchronized RMMessageContext checkForResponseMessage(String requestId, String seqId) {
IncomingSequence sh = (IncomingSequence) incomingMap.get(seqId);
if (sh == null) {
return null;
@@ -792,8 +793,7 @@
}
public void setTerminateReceived(String seqId) {
- IncomingSequence ics = (IncomingSequence) incomingMap.get(
- getKeyFromIncomingSequenceId(seqId));
+ IncomingSequence ics = (IncomingSequence) incomingMap.get(getKeyFromIncomingSequenceId(seqId));
ics.setTerminateReceived(true);
}
@@ -853,9 +853,12 @@
IncomingSequence ics = (IncomingSequence) incomingMap.get(seqId);
OutgoingSequence ogs = (OutgoingSequence) outgoingMap.get(seqId);
- boolean hasResponse = ogs.hasResponse();
+ boolean hasResponse = false;
+ if (ogs != null) {
+ hasResponse = ogs.hasResponse();
+ }
- if (hasResponse && !ics.isTerminateReceived())
+ if (hasResponse && ics != null && !ics.isTerminateReceived())
return false;
else
return true;
1.11 +30 -35 ws-fx/sandesha/src/org/apache/sandesha/util/PropertyLoader.java
Index: PropertyLoader.java
===================================================================
RCS file: /home/cvs/ws-fx/sandesha/src/org/apache/sandesha/util/PropertyLoader.java,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- PropertyLoader.java 25 May 2005 10:09:00 -0000 1.10
+++ PropertyLoader.java 22 Jun 2005 13:38:12 -0000 1.11
@@ -18,20 +18,23 @@
package org.apache.sandesha.util;
import org.apache.sandesha.Constants;
+import org.apache.axis.AxisFault;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Properties;
- /**
- * This is the property loader for Sandesha. All the properties will be loaded from the
- * sandesha.properties file that is found in the classpath.
- *
- * @auther Jaliya Ekanayake
- */
+
+/**
+ * This is the property loader for Sandesha. All the properties will be loaded from the
+ * sandesha.properties file that is found in the classpath.
+ *
+ * @auther Jaliya Ekanayake
+ */
public class PropertyLoader {
- public static int getClientSideListenerPort() {
- Properties prop = loadProperties();
+ public static int getClientSideListenerPort() throws Exception {
+ Properties prop = loadProperties();
+
if (prop != null) {
return new Integer(prop.getProperty(Constants.ClientProperties.CLIENT_LISTENER_PORT)).intValue();
} else
@@ -39,47 +42,42 @@
}
- public static int getSimpleAxisServerPort() {
+ public static int getSimpleAxisServerPort() throws Exception {
Properties prop = loadProperties();
if (prop != null) {
- return new Integer(
- prop.getProperty(Constants.ClientProperties.SIMPLE_AXIS_SERVER_PORT_POPERTY)).intValue();
+ return new Integer(prop.getProperty(Constants.ClientProperties.SIMPLE_AXIS_SERVER_PORT_POPERTY)).intValue();
} else
return Constants.DEFAULT_SIMPLE_AXIS_SERVER_PORT;
}
- private static Properties loadProperties() {
+ private static Properties loadProperties() throws Exception {
+
Properties properties = new Properties();
- try {
- InputStream in = Thread.currentThread().getContextClassLoader().getResourceAsStream(
- Constants.ClientProperties.PROPERTY_FILE);
- properties.load(in);
- return properties;
- } catch (IOException e) {
- e.printStackTrace();
- return null;
+ try{
+ InputStream in = Thread.currentThread().getContextClassLoader().getResourceAsStream(Constants.ClientProperties.PROPERTY_FILE);
+ properties.load(in);
+ }catch(IOException e){
+ throw new Exception(Constants.ErrorMessages.CANNOT_LOAD_PROPERTIES);
}
+
+ return properties;
+
}
//CHANGE FOR SECURITY ADDITION
- public static ArrayList getRequestHandlerNames() {
+ public static ArrayList getRequestHandlerNames() throws Exception {
return getHandlerNames(Constants.ClientProperties.REQUEST_HANDLER);
}
- public static ArrayList getResponseHandlerNames() {
+ public static ArrayList getResponseHandlerNames() throws Exception {
return getHandlerNames(Constants.ClientProperties.RESPONSE_HANDLER);
}
- public static ArrayList getHandlerNames(String type) {
+ public static ArrayList getHandlerNames(String type) throws Exception {
Properties properties = loadProperties();
ArrayList ret = new ArrayList();
- try {
- InputStream in = Thread.currentThread().getContextClassLoader().getResourceAsStream(
- Constants.ClientProperties.PROPERTY_FILE);
- properties.load(in);
-
int temp = 0;
String propVal;
do {
@@ -92,21 +90,18 @@
} while (propVal != null);
return ret;
- } catch (IOException e) {
- e.printStackTrace();
- return null;
- }
+
}
- public static ArrayList getListenerRequestHandlerNames() {
+ public static ArrayList getListenerRequestHandlerNames() throws Exception {
return getHandlerNames(Constants.ClientProperties.LISTENER_REQUEST_HANDLER);
}
- public static ArrayList getListenerResponseHandlerNames() {
+ public static ArrayList getListenerResponseHandlerNames() throws Exception {
return getHandlerNames(Constants.ClientProperties.LISTENER_RESPONSE_HANDLER);
}
- public static String getProvider() {
+ public static String getProvider() throws Exception {
Properties prop = loadProperties();
String s;
1.20 +18 -23 ws-fx/sandesha/src/org/apache/sandesha/util/RMMessageCreator.java
Index: RMMessageCreator.java
===================================================================
RCS file: /home/cvs/ws-fx/sandesha/src/org/apache/sandesha/util/RMMessageCreator.java,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -r1.19 -r1.20
--- RMMessageCreator.java 25 May 2005 10:09:00 -0000 1.19
+++ RMMessageCreator.java 22 Jun 2005 13:38:12 -0000 1.20
@@ -36,8 +36,8 @@
public class RMMessageCreator {
private static final UUIDGen uuidGen = UUIDGenFactory.getUUIDGen();
- public static RMMessageContext createCreateSeqMsg(RMMessageContext rmMsgCtx, byte endPoint,
- String msgID, String offer) throws Exception {
+ public static synchronized RMMessageContext createCreateSeqMsg(RMMessageContext rmMsgCtx, byte endPoint,
+ String msgID, String offer) throws Exception {
RMMessageContext createSeqRMMsgContext = new RMMessageContext();
rmMsgCtx.copyContents(createSeqRMMsgContext);
@@ -81,8 +81,7 @@
return createSeqRMMsgContext;
}
- private static AddressingHeaders getAddressingHeaedersForCreateSequenceRequest(
- RMMessageContext rmMsgCtx, byte endPoint, String msgID) throws Exception {
+ private static synchronized AddressingHeaders getAddressingHeaedersForCreateSequenceRequest(RMMessageContext rmMsgCtx, byte endPoint, String msgID) throws Exception {
AddressingHeaders csAddrHeaders = new AddressingHeaders();
csAddrHeaders.setMessageID(new MessageID(new URI(msgID)));
if (endPoint == Constants.SERVER) {
@@ -95,8 +94,7 @@
csAddrHeaders.setTo(new To(rmMsgCtx.getTo()));
if (rmMsgCtx.getSync()) {
setSyncAddressingHeaders(csAddrHeaders);
- csAddrHeaders.setReplyTo(
- new EndpointReference(Constants.WSA.NS_ADDRESSING_ANONYMOUS));
+ csAddrHeaders.setReplyTo(new EndpointReference(Constants.WSA.NS_ADDRESSING_ANONYMOUS));
} else {
String sourceURL = rmMsgCtx.getSourceURL();
@@ -115,15 +113,15 @@
return csAddrHeaders;
}
- private static void setSyncAddressingHeaders(AddressingHeaders csAddrHeaders)
+ private static synchronized void setSyncAddressingHeaders(AddressingHeaders csAddrHeaders)
throws URI.MalformedURIException {
csAddrHeaders.setFrom(new EndpointReference(Constants.WSA.NS_ADDRESSING_ANONYMOUS));
csAddrHeaders.setFaultTo(new EndpointReference(Constants.WSA.NS_ADDRESSING_ANONYMOUS));
}
- private static void setAsyncAddressingHeaders(RMMessageContext rmMsgCtx,
- AddressingHeaders csAddrHeaders)
+ private static synchronized void setAsyncAddressingHeaders(RMMessageContext rmMsgCtx,
+ AddressingHeaders csAddrHeaders)
throws URI.MalformedURIException {
String sourceURL = rmMsgCtx.getSourceURL();
if (rmMsgCtx.getFrom() != null)
@@ -139,7 +137,7 @@
}
- private static AcksTo getAcksTo(RMMessageContext rmMsgCtx, byte endPoint) throws Exception {
+ private static synchronized AcksTo getAcksTo(RMMessageContext rmMsgCtx, byte endPoint) throws Exception {
AcksTo acksTo = null;
if (endPoint == Constants.CLIENT) {
if (rmMsgCtx.getSync()) {
@@ -161,16 +159,16 @@
return acksTo;
}
- public static RMMessageContext createCreateSeqResponseMsg(RMMessageContext rmMsgCtx)
+ public static synchronized RMMessageContext createCreateSeqResponseMsg(RMMessageContext rmMsgCtx)
throws Exception {
return new RMMessageContext();
}
- public static RMMessageContext createTerminateSeqMsg(RMMessageContext rmMsgCtx, byte endPoint)
+ public static synchronized RMMessageContext createTerminateSeqMsg(RMMessageContext rmMsgCtx, byte endPoint)
throws Exception {
+
RMMessageContext terSeqRMMsgContext = new RMMessageContext();
- MessageContext terSeqMsgContext = new MessageContext(
- rmMsgCtx.getMsgContext().getAxisEngine());
+ MessageContext terSeqMsgContext = new MessageContext(rmMsgCtx.getMsgContext().getAxisEngine());
terSeqRMMsgContext.setSequenceID(rmMsgCtx.getSequenceID());
AddressingHeaders addHeaders = getAddressingHeadersForTerminateSequence(rmMsgCtx, endPoint);
@@ -186,8 +184,7 @@
return terSeqRMMsgContext;
}
- private static AddressingHeaders getAddressingHeadersForTerminateSequence(
- RMMessageContext rmMsgCtx, byte endPoint) throws Exception {
+ private static synchronized AddressingHeaders getAddressingHeadersForTerminateSequence(RMMessageContext rmMsgCtx, byte endPoint) throws Exception {
AddressingHeaders csAddrHeaders = new AddressingHeaders();
if (endPoint == Constants.SERVER) {
AddressingHeaders ah = rmMsgCtx.getAddressingHeaders();
@@ -205,20 +202,19 @@
return csAddrHeaders;
}
- public static RMMessageContext createAcknowledgementMsg(RMMessageContext rmMessageContext)
+ public static synchronized RMMessageContext createAcknowledgementMsg(RMMessageContext rmMessageContext)
throws Exception {
return new RMMessageContext();
}
- public static RMMessageContext createServiceResponseMessage(RMMessageContext rmMsgCtx)
+ public static synchronized RMMessageContext createServiceResponseMessage(RMMessageContext rmMsgCtx)
throws Exception {
return new RMMessageContext();
}
- public static RMMessageContext createServiceRequestMessage(RMMessageContext rmMsgCtx)
+ public static synchronized RMMessageContext createServiceRequestMessage(RMMessageContext rmMsgCtx)
throws Exception {
AddressingHeaders addrHeaders = getAddressingHeaedersForServiceRequest(rmMsgCtx);
-
if (rmMsgCtx.getAction() != null)
addrHeaders.setAction(new Action(new URI(rmMsgCtx.getAction())));
rmMsgCtx.setAddressingHeaders(addrHeaders);
@@ -228,8 +224,7 @@
}
- private static AddressingHeaders getAddressingHeaedersForServiceRequest(
- RMMessageContext rmMsgCtx) throws Exception {
+ private static synchronized AddressingHeaders getAddressingHeaedersForServiceRequest(RMMessageContext rmMsgCtx) throws Exception {
AddressingHeaders csAddrHeaders = new AddressingHeaders();
csAddrHeaders.setTo(new To(rmMsgCtx.getTo()));
if (rmMsgCtx.getSync()) {
@@ -242,7 +237,7 @@
return csAddrHeaders;
}
- public static MessageContext cloneMsgContext(MessageContext msgContext) throws AxisFault {
+ public static synchronized MessageContext cloneMsgContext(MessageContext msgContext) throws AxisFault {
MessageContext clone = new MessageContext(msgContext.getAxisEngine());
String str = msgContext.getRequestMessage().getSOAPPartAsString();
Message msg = new Message(str);
1.6 +34 -40 ws-fx/sandesha/test/org/apache/sandesha/intergratedtest/TCScenarioTest.java
Index: TCScenarioTest.java
===================================================================
RCS file: /home/cvs/ws-fx/sandesha/test/org/apache/sandesha/intergratedtest/TCScenarioTest.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- TCScenarioTest.java 11 Jun 2005 08:24:56 -0000 1.5
+++ TCScenarioTest.java 22 Jun 2005 13:38:12 -0000 1.6
@@ -93,10 +93,8 @@
Service service = new Service();
Call call = (Call) service.createCall();
- SandeshaContext ctx = new SandeshaContext();
- ctx.addNewSequeceContext(call, targetURL, "urn:wsrm:Ping",
- Constants.ClientProperties.IN_ONLY);
- ctx.setSynchronous(call);
+ SandeshaContext ctx = new SandeshaContext(Constants.SYNCHRONIZED);
+ ctx.initCall(call, targetURL, "urn:wsrm:Ping", Constants.ClientProperties.IN_ONLY);
call.setOperationName(new QName("http://tempuri.org/", "Ping"));
call.addParameter("arg1", XMLType.XSD_STRING, ParameterMode.IN);
@@ -106,7 +104,7 @@
ctx.setLastMessage(call);
call.invoke(new Object[]{"Ping Two"});
- RMReport report = ctx.endSequence(call);
+ RMReport report = ctx.endSequence();
assertEquals(report.isAllAcked(), true);
assertEquals(report.getNumberOfReturnMessages(), 0);
@@ -127,10 +125,9 @@
Call call = (Call) service.createCall();
SandeshaContext ctx = new SandeshaContext();
- ctx.addNewSequeceContext(call, targetURL, "urn:wsrm:ping",
- Constants.ClientProperties.IN_ONLY);
- ctx.setAcksToUrl(call,
- "http://127.0.0.1:" + defaultClientPort + "/axis/services/RMService");
+
+ ctx.setAcksToURL("http://127.0.0.1:" + defaultClientPort + "/axis/services/RMService");
+ ctx.initCall(call, targetURL, "urn:wsrm:ping", Constants.ClientProperties.IN_ONLY);
call.setOperationName(new QName("http://tempuri.org", "Ping"));
call.addParameter("Text", XMLType.XSD_STRING, ParameterMode.IN);
@@ -139,7 +136,7 @@
ctx.setLastMessage(call);
call.invoke(new Object[]{"Ping Two"});
- RMReport report = ctx.endSequence(call);
+ RMReport report = ctx.endSequence();
assertEquals(report.isAllAcked(), true);
assertEquals(report.getNumberOfReturnMessages(), 0);
@@ -167,12 +164,12 @@
Call call = (Call) service.createCall();
SandeshaContext ctx = new SandeshaContext();
- ctx.addNewSequeceContext(call, targetURL, "urn:wsrm:echoString",
- Constants.ClientProperties.IN_OUT);
- ctx.setAcksToUrl(call, Constants.WSA.NS_ADDRESSING_ANONYMOUS);
- ctx.setReplyToUrl(call,
- "http://127.0.0.1:" + defaultClientPort + "/axis/services/RMService");
- ctx.setSendOffer(call);
+
+ ctx.setAcksToURL(Constants.WSA.NS_ADDRESSING_ANONYMOUS);
+ ctx.setReplyToURL("http://127.0.0.1:" + defaultClientPort + "/axis/services/RMService");
+ ctx.setSendOffer(true);
+
+ ctx.initCall(call, targetURL, "urn:wsrm:echoString", Constants.ClientProperties.IN_OUT);
call.setOperationName(new QName("http://tempuri.org/", "echoString"));
@@ -187,7 +184,7 @@
ret = (String) call.invoke(new Object[]{" Echo 2 ", str});
System.out.println(" The Response for Second Messsage is :" + ret);
- RMReport report = ctx.endSequence(call);
+ RMReport report = ctx.endSequence();
assertEquals(report.isAllAcked(), true);
assertEquals(report.getNumberOfReturnMessages(), 2);
@@ -212,13 +209,12 @@
Call call = (Call) service.createCall();
SandeshaContext ctx = new SandeshaContext();
- ctx.addNewSequeceContext(call, targetURL, "urn:wsrm:echoString",
- Constants.ClientProperties.IN_OUT);
- ctx.setAcksToUrl(call,
- "http://127.0.0.1:" + defaultClientPort + "/axis/services/RMService");
- ctx.setReplyToUrl(call,
- "http://127.0.0.1:" + defaultClientPort + "/axis/services/RMService");
- ctx.setSendOffer(call);
+
+ ctx.setAcksToURL("http://127.0.0.1:" + defaultClientPort + "/axis/services/RMService");
+ ctx.setReplyToURL("http://127.0.0.1:" + defaultClientPort + "/axis/services/RMService");
+ ctx.setSendOffer(true);
+
+ ctx.initCall(call, targetURL, "urn:wsrm:echoString", Constants.ClientProperties.IN_OUT);
call.setOperationName(new QName("http://tempuri.org/", "echoString"));
@@ -233,7 +229,7 @@
ret = (String) call.invoke(new Object[]{" Echo 2 ", str});
System.out.println(" The Response for Second Messsage is :" + ret);
- RMReport report = ctx.endSequence(call);
+ RMReport report = ctx.endSequence();
assertEquals(report.isAllAcked(), true);
assertEquals(report.getNumberOfReturnMessages(), 2);
@@ -259,13 +255,11 @@
SandeshaContext ctx = new SandeshaContext();
//------------------------ECHO--------------------------------------------
- ctx.addNewSequeceContext(echoCall, targetURL, "urn:wsrm:echoString",
- Constants.ClientProperties.IN_OUT);
- ctx.setAcksToUrl(echoCall,
- "http://127.0.0.1:" + defaultClientPort + "/axis/services/RMService");
- ctx.setReplyToUrl(echoCall,
- "http://127.0.0.1:" + defaultClientPort + "/axis/services/RMService");
- ctx.setSendOffer(echoCall);
+
+ ctx.setAcksToURL("http://127.0.0.1:" + defaultClientPort + "/axis/services/RMService");
+ ctx.setReplyToURL("http://127.0.0.1:" + defaultClientPort + "/axis/services/RMService");
+ ctx.setSendOffer(true);
+ ctx.initCall(echoCall, targetURL, "urn:wsrm:echoString", Constants.ClientProperties.IN_OUT);
echoCall.setOperationName(new QName("http://tempuri.org/", "echoString"));
@@ -275,11 +269,11 @@
//----------------------ECHO------------------------------------------------
//------------------------PING--------------------------------------------
- Call pingCall = (Call) service.createCall();
- ctx.addNewSequeceContext(pingCall, targetURL, "urn:wsrm:Ping",
- Constants.ClientProperties.IN_ONLY);
- ctx.setAcksToUrl(pingCall,
- "http://127.0.0.1:" + defaultClientPort + "/axis/services/RMService");
+ Service pingService = new Service();
+ Call pingCall = (Call) pingService.createCall();
+ SandeshaContext pingCtx = new SandeshaContext();
+
+ pingCtx.initCall(pingCall, targetURL, "urn:wsrm:Ping", Constants.ClientProperties.IN_ONLY);
pingCall.setOperationName(new QName("http://tempuri.org/", "ping"));
pingCall.addParameter("arg2", XMLType.XSD_STRING, ParameterMode.IN);
@@ -295,11 +289,11 @@
System.out.println(" The Response for Second Messsage is :" + ret);
pingCall.invoke(new Object[]{ret});
- ctx.setLastMessage(pingCall);
+ pingCtx.setLastMessage(pingCall);
pingCall.invoke(new Object[]{ret});
- RMReport echoReport = ctx.endSequence(echoCall);
- RMReport pingReport = ctx.endSequence(pingCall);
+ RMReport echoReport = ctx.endSequence();
+ RMReport pingReport = pingCtx.endSequence();
assertEquals(echoReport.isAllAcked(), true);
assertEquals(echoReport.getNumberOfReturnMessages(), 2);