jaliya 2005/05/30 22:51:54
Modified: sandesha/interop/org/apache/sandesha/samples/interop/testclient
InteropStub.java
sandesha/src/org/apache/sandesha SandeshaContext.java
sandesha/src/org/apache/sandesha/client
ClientPropertyValidator.java
Log:
Now a seperate Listener will not be started if SandeshaContext is constructed
using SandeshaContext(true)
Revision Changes Path
1.16 +19 -22
ws-fx/sandesha/interop/org/apache/sandesha/samples/interop/testclient/InteropStub.java
Index: InteropStub.java
===================================================================
RCS file:
/home/cvs/ws-fx/sandesha/interop/org/apache/sandesha/samples/interop/testclient/InteropStub.java,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -r1.15 -r1.16
--- InteropStub.java 29 May 2005 11:22:03 -0000 1.15
+++ InteropStub.java 31 May 2005 05:51:54 -0000 1.16
@@ -23,9 +23,7 @@
import org.apache.axis.client.Call;
import org.apache.axis.client.Service;
import org.apache.axis.encoding.XMLType;
-import org.apache.axis.message.addressing.util.AddressingUtils;
import org.apache.sandesha.Constants;
-import org.apache.sandesha.RMTransport;
import org.apache.sandesha.SandeshaContext;
import org.apache.sandesha.client.ClientStorageManager;
import org.apache.sandesha.server.Sender;
@@ -34,7 +32,6 @@
import javax.xml.namespace.QName;
import javax.xml.rpc.ParameterMode;
-import javax.xml.rpc.ServiceException;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
@@ -44,7 +41,6 @@
* simply calls the runPing and runEcho methods.
*
* @auther Chamikara Jayalath
- *
*/
@@ -79,7 +75,7 @@
private static InteropCallback callback = null;
- private void configureContext(SandeshaContext ctx,Call call, InteropBean
bean) {
+ private void configureContext(SandeshaContext ctx, Call call,
InteropBean bean) {
String from = bean.getFrom();
String replyTo = bean.getReplyto();
String acksTo = bean.getAcksTo();
@@ -90,34 +86,32 @@
sendOffer = true;
if (replyTo != null && replyTo.equalsIgnoreCase("anonymous")) {
- ctx.setReplyToUrl(call,Constants.WSA.NS_ADDRESSING_ANONYMOUS);
- } else if (replyTo != null) {
- ctx.setReplyToUrl(call, bean.getReplyto());
+ ctx.setReplyToUrl(call, Constants.WSA.NS_ADDRESSING_ANONYMOUS);
+ } else if (replyTo != null) {
+ ctx.setReplyToUrl(call, bean.getReplyto());
}
if (from != null && from.equalsIgnoreCase("anonymous")) {
- ctx.setFromUrl(call,Constants.WSA.NS_ADDRESSING_ANONYMOUS);
+ ctx.setFromUrl(call, Constants.WSA.NS_ADDRESSING_ANONYMOUS);
} else if (from != null) {
- ctx.setFromUrl(call, from);
+ ctx.setFromUrl(call, from);
}
if (acksTo != null && acksTo.equalsIgnoreCase("anonymous")) {
- ctx.setAcksToUrl(call,Constants.WSA.NS_ADDRESSING_ANONYMOUS);
+ ctx.setAcksToUrl(call, Constants.WSA.NS_ADDRESSING_ANONYMOUS);
} else if (acksTo != null) {
ctx.setAcksToUrl(call, acksTo);
}
if (faultTo != null && faultTo.equalsIgnoreCase("anonymous")) {
- ctx.setFaultToUrl(call,Constants.WSA.NS_ADDRESSING_ANONYMOUS);
+ ctx.setFaultToUrl(call, Constants.WSA.NS_ADDRESSING_ANONYMOUS);
} else if (faultTo != null) {
ctx.setFaultToUrl(call, bean.getFaultto());
}
if (sendOffer)
- ctx.setSendOffer(call);
-
- call.setProperty(Constants.ClientProperties.SOURCE_URL,
bean.getSourceURL());
+ ctx.setSendOffer(call);
}
@@ -131,11 +125,12 @@
Service service = new Service();
Call call = (Call) service.createCall();
- SandeshaContext ctx = new SandeshaContext();
- ctx.addNewSequeceContext(call, target, "urn:wsrm:ping",
Constants.ClientProperties.IN_ONLY);
-
- configureContext(ctx,call,bean);
+ SandeshaContext ctx = new SandeshaContext(true);
+ ctx.setSourceUrl(call, bean.getSourceURL());
+ ctx.addNewSequeceContext(call, target, "urn:wsrm:ping",
+ Constants.ClientProperties.IN_ONLY);
+ configureContext(ctx, call, bean);
call.setOperationName(new QName("http://tempuri.org", "Ping"));
@@ -178,10 +173,12 @@
Service service = new Service();
Call call = (Call) service.createCall();
- SandeshaContext ctx = new SandeshaContext();
- ctx.addNewSequeceContext(call, target, "urn:wsrm:echoString",
Constants.ClientProperties.IN_OUT);
+ SandeshaContext ctx = new SandeshaContext(true);
+ ctx.setSourceUrl(call, bean.getSourceURL());
+ ctx.addNewSequeceContext(call, target, "urn:wsrm:echoString",
+ Constants.ClientProperties.IN_OUT);
- configureContext(ctx,call,bean);
+ configureContext(ctx, call, bean);
call.setOperationName(new QName("http://tempuri.org/",
"echoString"));
1.5 +68 -29
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.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- SandeshaContext.java 29 May 2005 11:22:04 -0000 1.4
+++ SandeshaContext.java 31 May 2005 05:51:54 -0000 1.5
@@ -18,7 +18,9 @@
import org.apache.sandesha.util.PropertyLoader;
import org.apache.sandesha.ws.rm.providers.RMProvider;
+import java.net.InetAddress;
import java.net.ServerSocket;
+import java.net.UnknownHostException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
@@ -39,10 +41,20 @@
private static SimpleAxisServer sas = null;
private static Sender cleintSender;
private static Sender serverSender;
+ private static boolean insideServer;
private static HashMap callMap = new HashMap();
private static int activeSequenes = 0;
+ public SandeshaContext(){
+ SandeshaContext.insideServer = false;
+ }
+
+ public SandeshaContext(boolean insideServer) {
+ SandeshaContext.insideServer = insideServer;
+ }
+
+
public static HashMap getCallMap() {
return callMap;
}
@@ -227,42 +239,61 @@
call.setProperty(Constants.ClientProperties.MEP, new Short(MEP));
call.setProperty(Constants.ClientProperties.CALL_KEY, keyOfCall);
call.setProperty(Constants.ClientProperties.REPORT, new RMReport());
- return keyOfCall;
- }
-
- private static void startListener() {
- if (!listenerStarted) {
- listenerStarted = true;
+ if (!insideServer) {
+ InetAddress addr = null;
try {
-
System.out.println(Constants.InfomationMessage.CLIENT_LISTENER_STARTED);
- sas = new SimpleAxisServer();
-
- SimpleProvider sp = new SimpleProvider();
- sas.setMyConfig(sp);
-
- SimpleChain reqHandlers = getListenerRequestChain();
- SimpleChain resHandlers = getListenerResponseChain();
+ addr = InetAddress.getLocalHost();
+ } catch (UnknownHostException e) {
+ log.error(e);
+ }
- RMProvider rmp = new RMProvider();
- rmp.setClient(true);
- SOAPService rmService = new SOAPService(reqHandlers, rmp,
resHandlers);
+ String sourceURL = Constants.HTTP + Constants.COLON +
Constants.SLASH +
+ Constants.SLASH +
+ addr.getHostAddress() + Constants.COLON +
+ PropertyLoader.getClientSideListenerPort() +
Constants.URL_RM_SERVICE;
+ call.setProperty(Constants.ClientProperties.SOURCE_URL,
sourceURL);
+ }
+ return keyOfCall;
+ }
- JavaServiceDesc desc = new JavaServiceDesc();
- rmService.setOption(Constants.ClientProperties.CLASS_NAME,
- Constants.ClientProperties.RMSERVICE_CLASS);
-
rmService.setOption(Constants.ClientProperties.ALLOWED_METHODS,
Constants.ASTERISK);
- desc.setName(Constants.ClientProperties.RMSERVICE);
- rmService.setServiceDescription(desc);
- sp.deployService(Constants.ClientProperties.RMSERVICE,
rmService);
- sas.setServerSocket(new
ServerSocket(PropertyLoader.getClientSideListenerPort()));
+ private static void startListener() {
+ if (!insideServer) {
+ if (!listenerStarted) {
+ listenerStarted = true;
+ try {
+
System.out.println(Constants.InfomationMessage.CLIENT_LISTENER_STARTED);
+ sas = new SimpleAxisServer();
+
+ SimpleProvider sp = new SimpleProvider();
+ sas.setMyConfig(sp);
+
+ SimpleChain reqHandlers = getListenerRequestChain();
+ SimpleChain resHandlers = getListenerResponseChain();
+
+ RMProvider rmp = new RMProvider();
+ rmp.setClient(true);
+ SOAPService rmService = new SOAPService(reqHandlers,
rmp, resHandlers);
+
+ JavaServiceDesc desc = new JavaServiceDesc();
+
rmService.setOption(Constants.ClientProperties.CLASS_NAME,
+ Constants.ClientProperties.RMSERVICE_CLASS);
+
rmService.setOption(Constants.ClientProperties.ALLOWED_METHODS,
+ Constants.ASTERISK);
+
+ desc.setName(Constants.ClientProperties.RMSERVICE);
+ rmService.setServiceDescription(desc);
+ sp.deployService(Constants.ClientProperties.RMSERVICE,
rmService);
+ sas.setServerSocket(
+ new
ServerSocket(PropertyLoader.getClientSideListenerPort()));
- Thread serverThread = new Thread(sas);
- serverThread.start();
+ Thread serverThread = new Thread(sas);
+ serverThread.start();
- } catch (Exception e) {
- log.error(e);
+ } catch (Exception e) {
+ log.error(e);
+ }
}
}
@@ -325,6 +356,14 @@
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);
}
1.28 +10 -17
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.27
retrieving revision 1.28
diff -u -r1.27 -r1.28
--- ClientPropertyValidator.java 25 May 2005 10:09:00 -0000 1.27
+++ ClientPropertyValidator.java 31 May 2005 05:51:54 -0000 1.28
@@ -20,10 +20,8 @@
import org.apache.axis.client.Call;
import org.apache.sandesha.Constants;
import org.apache.sandesha.RMMessageContext;
-import org.apache.sandesha.util.PropertyLoader;
import javax.xml.namespace.QName;
-import java.net.InetAddress;
import java.net.UnknownHostException;
/**
@@ -49,11 +47,11 @@
String to = getTo(call);
String faultTo = getFaultTo(call);
boolean sendOffer = getOffer(call);
- String key=getKey(call);
+ String key = getKey(call);
try {
sourceURL = getSourceURL(call);
- } catch (UnknownHostException e) {
+ } catch (Exception e) {
throw new AxisFault(e.getMessage());
}
@@ -153,20 +151,14 @@
}
- private static String getSourceURL(Call call) throws
UnknownHostException {
+ private static String getSourceURL(Call call) throws Exception {
String sourceURL = null;
sourceURL = (String)
call.getProperty(Constants.ClientProperties.SOURCE_URL);
if (sourceURL != null) {
return sourceURL;
} else {
+ throw new Exception("No Source URL specified");
- InetAddress addr = InetAddress.getLocalHost();
-
- sourceURL = Constants.HTTP + Constants.COLON + Constants.SLASH +
Constants.SLASH +
- addr.getHostAddress() + Constants.COLON +
- PropertyLoader.getClientSideListenerPort() +
Constants.URL_RM_SERVICE;
-
- return sourceURL;
}
}
@@ -177,11 +169,12 @@
private static long getMessageNumber(Call call) {
Object temp =
call.getProperty(Constants.ClientProperties.MSG_NUMBER);
long msgNumber = 0;
- if (temp == null){
- call.setProperty(Constants.ClientProperties.MSG_NUMBER, new
Long(++msgNumber));
- }else{
-
msgNumber=((Long)call.getProperty(Constants.ClientProperties.MSG_NUMBER)).longValue();
- call.setProperty(Constants.ClientProperties.MSG_NUMBER,new
Long(++msgNumber));
+ if (temp == null) {
+ call.setProperty(Constants.ClientProperties.MSG_NUMBER, new
Long(++msgNumber));
+ } else {
+ msgNumber =
+ ((Long)
call.getProperty(Constants.ClientProperties.MSG_NUMBER)).longValue();
+ call.setProperty(Constants.ClientProperties.MSG_NUMBER, new
Long(++msgNumber));
}
return msgNumber;