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 ch...@apache.org on 2006/06/15 07:51:24 UTC
svn commit: r414476 [3/15] - in /webservices/sandesha/trunk: ./ c/ config/
interop/ java/ java/config/ java/interop/ java/interop/conf/
java/interop/src/ java/interop/src/org/ java/interop/src/org/apache/
java/interop/src/org/apache/sandesha2/ java/int...
Added: webservices/sandesha/trunk/java/samples/src/sandesha2/samples/userguide/AsyncEchoClient.java
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/java/samples/src/sandesha2/samples/userguide/AsyncEchoClient.java?rev=414476&view=auto
==============================================================================
--- webservices/sandesha/trunk/java/samples/src/sandesha2/samples/userguide/AsyncEchoClient.java (added)
+++ webservices/sandesha/trunk/java/samples/src/sandesha2/samples/userguide/AsyncEchoClient.java Wed Jun 14 22:51:15 2006
@@ -0,0 +1,204 @@
+/*
+ * Copyright 2004,2005 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 sandesha2.samples.userguide;
+
+import java.io.File;
+
+import javax.xml.namespace.QName;
+
+import org.apache.axiom.om.OMAbstractFactory;
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMFactory;
+import org.apache.axiom.om.OMNamespace;
+import org.apache.axiom.soap.SOAP12Constants;
+import org.apache.axiom.soap.SOAPBody;
+import org.apache.axis2.Constants;
+import org.apache.axis2.addressing.AddressingConstants;
+import org.apache.axis2.addressing.EndpointReference;
+import org.apache.axis2.client.Options;
+import org.apache.axis2.client.ServiceClient;
+import org.apache.axis2.client.async.AsyncResult;
+import org.apache.axis2.client.async.Callback;
+import org.apache.axis2.context.ConfigurationContext;
+import org.apache.axis2.context.ConfigurationContextFactory;
+import org.apache.axis2.context.MessageContextConstants;
+import org.apache.sandesha2.client.SandeshaClientConstants;
+import org.apache.sandesha2.util.SandeshaUtil;
+
+public class AsyncEchoClient {
+
+ private final static String applicationNamespaceName = "http://tempuri.org/";
+ private final static String echoString = "echoString";
+ private final static String Text = "Text";
+ private final static String Sequence = "Sequence";
+ private final static String echoStringResponse = "echoStringResponse";
+ private final static String EchoStringReturn = "EchoStringReturn";
+
+ private String toIP = "127.0.0.1";
+
+ private String toPort = "8070";
+
+ private String transportToPort = "8070";
+
+ private String toEPR = "http://" + toIP + ":" + toPort + "/axis2/services/RMSampleService";
+
+ private String transportToEPR = "http://" + toIP + ":" + transportToPort + "/axis2/services/RMSampleService";
+
+ private static String SANDESHA2_HOME = "<SANDESHA2_HOME>"; //Change this to ur path.
+
+ private static String AXIS2_CLIENT_PATH = SANDESHA2_HOME + File.separator + "target" + File.separator +"repos" + File.separator + "client" + File.separator; //this will be available after a maven build
+
+ public static void main(String[] args) throws Exception {
+
+
+ String axisClientRepo = null;
+ if (args!=null && args.length>0)
+ axisClientRepo = args[0];
+
+ if (axisClientRepo!=null && !"".equals(axisClientRepo)) {
+ AXIS2_CLIENT_PATH = axisClientRepo;
+ SANDESHA2_HOME = "";
+ }
+
+ new AsyncEchoClient ().run();
+ }
+
+ private void run () throws Exception {
+
+ if ("<SANDESHA2_HOME>".equals(SANDESHA2_HOME)){
+ System.out.println("ERROR: Please set the directory you unzipped Sandesha2 as the first option.");
+ return;
+ }
+
+ String axis2_xml = AXIS2_CLIENT_PATH + "client_axis2.xml";
+
+ ConfigurationContext configContext = ConfigurationContextFactory.createConfigurationContextFromFileSystem(AXIS2_CLIENT_PATH,axis2_xml);
+
+ ServiceClient serviceClient = new ServiceClient (configContext,null);
+
+ Options clientOptions = new Options ();
+
+ clientOptions.setTo(new EndpointReference (toEPR));
+
+
+ String acksTo = serviceClient.getMyEPR(Constants.TRANSPORT_HTTP).getAddress() + "/" + ServiceClient.ANON_OUT_IN_OP;
+ clientOptions.setProperty(SandeshaClientConstants.AcksTo,acksTo);
+
+ String sequenceKey = SandeshaUtil.getUUID(); //sequence key for thie sequence.
+ clientOptions.setProperty(SandeshaClientConstants.SEQUENCE_KEY,sequenceKey);
+
+ clientOptions.setProperty(MessageContextConstants.TRANSPORT_URL,transportToEPR);
+
+// clientOptions.setProperty(MessageContextConstants.CHUNKED,Constants.VALUE_FALSE); //uncomment this to send messages without chunking.
+
+ clientOptions.setSoapVersionURI(SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI); //uncomment this to send messages in SOAP 1.2
+
+// clientOptions.setProperty(SandeshaClientConstants.RM_SPEC_VERSION,Sandesha2Constants.SPEC_VERSIONS.v1_1); //uncomment this to send the messages according to the v1_1 spec.
+
+ clientOptions.setProperty(AddressingConstants.WS_ADDRESSING_VERSION,AddressingConstants.Submission.WSA_NAMESPACE);
+ clientOptions.setProperty(SandeshaClientConstants.OFFERED_SEQUENCE_ID,SandeshaUtil.getUUID()); //Uncomment this to offer a sequenceID for the incoming sequence.
+ clientOptions.setAction("urn:wsrm:EchoString");
+
+ //You must set the following two properties in the request-reply case.
+ clientOptions.setTransportInProtocol(Constants.TRANSPORT_HTTP);
+
+
+
+ clientOptions.setUseSeparateListener(true);
+
+ serviceClient.setOptions(clientOptions);
+
+ Callback callback1 = new TestCallback ("Callback 1");
+ serviceClient.sendReceiveNonBlocking (getEchoOMBlock("echo1",sequenceKey),callback1);
+
+ Callback callback2 = new TestCallback ("Callback 2");
+ serviceClient.sendReceiveNonBlocking(getEchoOMBlock("echo2",sequenceKey),callback2);
+
+ Callback callback3 = new TestCallback ("Callback 3");
+ serviceClient.sendReceiveNonBlocking(getEchoOMBlock("echo3",sequenceKey),callback3);
+
+ Callback callback4 = new TestCallback ("Callback 4");
+ serviceClient.sendReceiveNonBlocking(getEchoOMBlock("echo4",sequenceKey),callback4);
+
+ clientOptions.setProperty(SandeshaClientConstants.LAST_MESSAGE, "true");
+ Callback callback5 = new TestCallback ("Callback 5");
+ serviceClient.sendReceiveNonBlocking(getEchoOMBlock("echo5",sequenceKey),callback5);
+
+ while (!callback5.isComplete()) {
+ Thread.sleep(1000);
+ }
+
+ Thread.sleep(4000);
+
+ }
+
+ private static OMElement getEchoOMBlock(String text, String sequenceKey) {
+ OMFactory fac = OMAbstractFactory.getOMFactory();
+ OMNamespace applicationNamespace = fac.createOMNamespace(applicationNamespaceName,"ns1");
+ OMElement echoStringElement = fac.createOMElement(echoString, applicationNamespace);
+ OMElement textElem = fac.createOMElement(Text,applicationNamespace);
+ OMElement sequenceElem = fac.createOMElement(Sequence,applicationNamespace);
+
+ textElem.setText(text);
+ sequenceElem.setText(sequenceKey);
+ echoStringElement.addChild(textElem);
+ echoStringElement.addChild(sequenceElem);
+
+ return echoStringElement;
+ }
+
+ public class TestCallback extends Callback {
+
+ String name = null;
+
+ public TestCallback () {
+
+ }
+
+ public TestCallback (String name) {
+ this.name = name;
+ }
+
+ public void onComplete(AsyncResult result) {
+ //System.out.println("On Complete Called for " + text);
+ SOAPBody body = result.getResponseEnvelope().getBody();
+
+ OMElement echoStringResponseElem = body.getFirstChildWithName(new QName (applicationNamespaceName,echoStringResponse));
+ if (echoStringResponseElem==null) {
+ System.out.println("Error: SOAPBody does not have a 'echoStringResponse' child");
+ return;
+ }
+
+ OMElement echoStringReturnElem = echoStringResponseElem.getFirstChildWithName(new QName (applicationNamespaceName,EchoStringReturn));
+ if (echoStringReturnElem==null) {
+ System.out.println("Error: 'echoStringResponse' element does not have a 'EchoStringReturn' child");
+ return;
+ }
+
+ String resultStr = echoStringReturnElem.getText();
+ System.out.println("Callback '" + name + "' got result:" + resultStr);
+ }
+
+ public void onError (Exception e) {
+ // TODO Auto-generated method stub
+ System.out.println("Error reported for test call back");
+ e.printStackTrace();
+ }
+ }
+
+
+}
Added: webservices/sandesha/trunk/java/samples/src/sandesha2/samples/userguide/AsyncPingClient.java
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/java/samples/src/sandesha2/samples/userguide/AsyncPingClient.java?rev=414476&view=auto
==============================================================================
--- webservices/sandesha/trunk/java/samples/src/sandesha2/samples/userguide/AsyncPingClient.java (added)
+++ webservices/sandesha/trunk/java/samples/src/sandesha2/samples/userguide/AsyncPingClient.java Wed Jun 14 22:51:15 2006
@@ -0,0 +1,137 @@
+/*
+ * Copyright 2004,2005 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 sandesha2.samples.userguide;
+
+import java.io.File;
+
+import javax.xml.namespace.QName;
+
+import org.apache.axiom.om.OMAbstractFactory;
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMFactory;
+import org.apache.axiom.om.OMNamespace;
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.Constants;
+import org.apache.axis2.addressing.EndpointReference;
+import org.apache.axis2.client.Options;
+import org.apache.axis2.client.ServiceClient;
+import org.apache.axis2.context.ConfigurationContext;
+import org.apache.axis2.context.ConfigurationContextFactory;
+import org.apache.sandesha2.client.SandeshaClient;
+import org.apache.sandesha2.client.SandeshaClientConstants;
+import org.apache.sandesha2.client.SequenceReport;
+
+
+public class AsyncPingClient {
+
+ private static final String applicationNamespaceName = "http://tempuri.org/";
+ private static final String ping = "ping";
+ private static final String Text = "Text";
+
+ private String toIP = "127.0.0.1";
+
+ private String toPort = "8070";
+
+ private String toEPR = "http://" + toIP + ":" + toPort + "/axis2/services/RMSampleService";
+
+ private static String SANDESHA2_HOME = "<SANDESHA2_HOME>"; //Change this to ur path.
+
+ private static String AXIS2_CLIENT_PATH = SANDESHA2_HOME + File.separator + "target" + File.separator +"repos" + File.separator + "client" + File.separator; //this will be available after a maven build
+
+ public static void main(String[] args) throws AxisFault {
+
+ String axisClientRepo = null;
+ if (args!=null && args.length>0)
+ axisClientRepo = args[0];
+
+ if (axisClientRepo!=null && !"".equals(axisClientRepo)) {
+ AXIS2_CLIENT_PATH = axisClientRepo;
+ SANDESHA2_HOME = "";
+ }
+
+ new AsyncPingClient().run();
+ }
+
+ private void run () throws AxisFault {
+ if ("<SANDESHA2_HOME>".equals(SANDESHA2_HOME)){
+ System.out.println("ERROR: Please change <SANDESHA2_HOME> to your Sandesha2 installation directory.");
+ return;
+ }
+
+ String axis2_xml = AXIS2_CLIENT_PATH + "client_axis2.xml";
+ ConfigurationContext configContext = ConfigurationContextFactory.createConfigurationContextFromFileSystem(AXIS2_CLIENT_PATH,axis2_xml);
+
+ ServiceClient serviceClient = new ServiceClient (configContext,null);
+// serviceClient.engageModule(new QName ("sandesha2"));
+
+ Options clientOptions = new Options ();
+
+// clientOptions.setProperty(MessageContextConstants.CHUNKED,Constants.VALUE_FALSE); //uncomment this to send messages without chunking.
+
+// clientOptions.setSoapVersionURI(SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI); //uncomment this to send messages in SOAP 1.2
+
+// clientOptions.setProperty(SandeshaClient.RM_SPEC_VERSION,Sandesha2Constants.SPEC_VERSIONS.v1_1); //uncomment this to send the messages according to the v1_1 spec.
+
+ clientOptions.setTo(new EndpointReference (toEPR));
+
+ EndpointReference endpoint = serviceClient.getMyEPR(Constants.TRANSPORT_HTTP);
+ clientOptions.setProperty(SandeshaClientConstants.AcksTo,endpoint.getAddress());
+
+ clientOptions.setTransportInProtocol(Constants.TRANSPORT_HTTP);
+ clientOptions.setAction("urn:wsrm:Ping");
+
+ String sequenceKey = "sequence2";
+ clientOptions.setProperty(SandeshaClientConstants.SEQUENCE_KEY,sequenceKey);
+
+ serviceClient.setOptions(clientOptions);
+
+ serviceClient.fireAndForget(getPingOMBlock("ping1"));
+ serviceClient.fireAndForget(getPingOMBlock("ping2"));
+
+ clientOptions.setProperty(SandeshaClientConstants.LAST_MESSAGE, "true");
+ serviceClient.fireAndForget(getPingOMBlock("ping3"));
+
+ boolean complete = false;
+ while (!complete) {
+ SequenceReport sequenceReport = SandeshaClient.getOutgoingSequenceReport(serviceClient);
+ if (sequenceReport!=null && sequenceReport .getCompletedMessages().size()==3)
+ complete = true;
+ else {
+ try {
+ Thread.sleep(1000);
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ }
+ }
+
+ serviceClient.finalizeInvoke();
+ }
+
+ private static OMElement getPingOMBlock(String text) {
+ OMFactory fac = OMAbstractFactory.getOMFactory();
+ OMNamespace namespace = fac.createOMNamespace(applicationNamespaceName,"ns1");
+ OMElement pingElem = fac.createOMElement(ping, namespace);
+ OMElement textElem = fac.createOMElement(Text, namespace);
+
+ textElem.setText(text);
+ pingElem.addChild(textElem);
+
+ return pingElem;
+ }
+
+}
Added: webservices/sandesha/trunk/java/samples/src/sandesha2/samples/userguide/RMSampleService.java
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/java/samples/src/sandesha2/samples/userguide/RMSampleService.java?rev=414476&view=auto
==============================================================================
--- webservices/sandesha/trunk/java/samples/src/sandesha2/samples/userguide/RMSampleService.java (added)
+++ webservices/sandesha/trunk/java/samples/src/sandesha2/samples/userguide/RMSampleService.java Wed Jun 14 22:51:15 2006
@@ -0,0 +1,79 @@
+/*
+ * Copyright 1999-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 sandesha2.samples.userguide;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.xml.namespace.QName;
+
+import org.apache.axiom.om.OMAbstractFactory;
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMFactory;
+import org.apache.axiom.om.OMNamespace;
+
+public class RMSampleService {
+
+ private static Map sequenceStrings = new HashMap(); //TODO make this non static
+ private final String applicationNamespaceName = "http://tempuri.org/";
+ private final String Text = "Text";
+ private final String Sequence = "Sequence";
+ private final String echoStringResponse = "echoStringResponse";
+ private final String EchoStringReturn = "EchoStringReturn";
+
+ public OMElement echoString(OMElement in) throws Exception {
+
+ OMElement textElem = in.getFirstChildWithName(new QName (applicationNamespaceName,Text));
+ OMElement sequenceElem = in.getFirstChildWithName(new QName (applicationNamespaceName,Sequence));
+
+ if (textElem==null)
+ throw new Exception ("'Text' element is not present as a child of the 'echoString' element");
+ if (sequenceElem==null)
+ throw new Exception ("'Sequence' element is not present as a child of the 'echoString' element");
+
+ String textStr = textElem.getText();
+ String sequenceStr = sequenceElem.getText();
+
+ System.out.println("'EchoString' service got text '" + textStr + "' for the sequence '" + sequenceStr + "'");
+
+ String previousText = (String) sequenceStrings.get(sequenceStr);
+ String resultText = (previousText==null)?textStr:previousText+textStr;
+ sequenceStrings.put(sequenceStr,resultText);
+
+
+ OMFactory fac = OMAbstractFactory.getOMFactory();
+ OMNamespace applicationNamespace = fac.createOMNamespace(applicationNamespaceName,"ns1");
+ OMElement echoStringResponseElem = fac.createOMElement(echoStringResponse, applicationNamespace);
+ OMElement echoStringReturnElem = fac.createOMElement(EchoStringReturn, applicationNamespace);
+
+ echoStringReturnElem.setText(resultText);
+ echoStringResponseElem.addChild(echoStringReturnElem);
+
+ return echoStringResponseElem;
+ }
+
+ public void ping(OMElement in) throws Exception {
+ OMElement textElem = in.getFirstChildWithName(new QName (applicationNamespaceName,Text));
+ if (textElem==null)
+ throw new Exception ("'Text' element is not present as a child of the 'Ping' element");
+
+ String textValue = textElem.getText();
+
+ System.out.println("ping service got text:" + textValue);
+ }
+}
\ No newline at end of file
Added: webservices/sandesha/trunk/java/samples/src/sandesha2/samples/userguide/SyncEchoClient.java
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/java/samples/src/sandesha2/samples/userguide/SyncEchoClient.java?rev=414476&view=auto
==============================================================================
--- webservices/sandesha/trunk/java/samples/src/sandesha2/samples/userguide/SyncEchoClient.java (added)
+++ webservices/sandesha/trunk/java/samples/src/sandesha2/samples/userguide/SyncEchoClient.java Wed Jun 14 22:51:15 2006
@@ -0,0 +1,175 @@
+/*
+ * Copyright 2004,2005 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 sandesha2.samples.userguide;
+
+import java.io.File;
+
+import javax.xml.namespace.QName;
+
+import org.apache.axiom.om.OMAbstractFactory;
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMFactory;
+import org.apache.axiom.om.OMNamespace;
+import org.apache.axiom.soap.SOAPBody;
+import org.apache.axis2.Constants;
+import org.apache.axis2.addressing.EndpointReference;
+import org.apache.axis2.client.Options;
+import org.apache.axis2.client.ServiceClient;
+import org.apache.axis2.client.async.AsyncResult;
+import org.apache.axis2.client.async.Callback;
+import org.apache.axis2.context.ConfigurationContext;
+import org.apache.axis2.context.ConfigurationContextFactory;
+import org.apache.sandesha2.client.SandeshaClientConstants;
+
+
+public class SyncEchoClient {
+
+ private final static String applicationNamespaceName = "http://tempuri.org/";
+ private final static String echoString = "echoString";
+ private final static String Text = "Text";
+ private final static String Sequence = "Sequence";
+ private final static String echoStringResponse = "echoStringResponse";
+ private final static String EchoStringReturn = "EchoStringReturn";
+
+ private String toIP = "127.0.0.1";
+
+ private String toPort = "8070";
+
+ private String toEPR = "http://" + toIP + ":" + toPort + "/axis2/services/RMSampleService";
+
+ private static String SANDESHA2_HOME = "<SANDESHA2_HOME>"; //Change this to ur path.
+
+ private static String AXIS2_CLIENT_PATH = SANDESHA2_HOME + File.separator + "target" + File.separator +"repos" + File.separator + "client" + File.separator; //this will be available after a maven build
+
+ public static void main(String[] args) throws Exception {
+
+ String axisClientRepo = null;
+ if (args!=null && args.length>0)
+ axisClientRepo = args[0];
+
+ if (axisClientRepo!=null && !"".equals(axisClientRepo)) {
+ AXIS2_CLIENT_PATH = axisClientRepo;
+ SANDESHA2_HOME = "";
+ }
+
+ new SyncEchoClient().run();
+ }
+
+ private void run () throws Exception {
+ if ("<SANDESHA2_HOME>".equals(SANDESHA2_HOME)){
+ System.out.println("ERROR: Please change <SANDESHA2_HOME> to your Sandesha2 installation directory.");
+ return;
+ }
+
+ String axis2_xml = AXIS2_CLIENT_PATH + "client_axis2.xml";
+ ConfigurationContext configContext = ConfigurationContextFactory.createConfigurationContextFromFileSystem(AXIS2_CLIENT_PATH,axis2_xml);
+
+ ServiceClient serviceClient = new ServiceClient (configContext,null);
+
+// serviceClient.engageModule(new QName ("sandesha2"));
+
+ Options clientOptions = new Options ();
+
+ clientOptions.setTo(new EndpointReference (toEPR));
+
+ String sequenceKey = "sequence3";
+ clientOptions.setProperty(SandeshaClientConstants.SEQUENCE_KEY,sequenceKey);
+
+ //You must set the following two properties in the request-reply case.
+ clientOptions.setTransportInProtocol(Constants.TRANSPORT_HTTP);
+ clientOptions.setUseSeparateListener(true);
+ clientOptions.setAction("urn:wsrm:EchoString");
+
+// clientOptions.setProperty(MessageContextConstants.CHUNKED,Constants.VALUE_FALSE); //uncomment this to send messages without chunking.
+
+// clientOptions.setSoapVersionURI(SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI); //uncomment this to send messages in SOAP 1.2
+
+// clientOptions.setProperty(SandeshaClient.RM_SPEC_VERSION,Sandesha2Constants.SPEC_VERSIONS.v1_1); //uncomment this to send the messages according to the v1_1 spec.
+
+// clientOptions.setProperty(SandeshaClient.OFFERED_SEQUENCE_ID,SandeshaUtil.getUUID()); //Uncomment this to offer a sequenceID for the incoming sequence.
+
+ serviceClient.setOptions(clientOptions);
+
+ Callback callback1 = new TestCallback ("Callback 1");
+ serviceClient.sendReceiveNonBlocking(getEchoOMBlock("echo1",sequenceKey),callback1);
+ Callback callback2 = new TestCallback ("Callback 2");
+ serviceClient.sendReceiveNonBlocking(getEchoOMBlock("echo2",sequenceKey),callback2);
+
+ clientOptions.setProperty(SandeshaClientConstants.LAST_MESSAGE, "true");
+ Callback callback3 = new TestCallback ("Callback 3");
+ serviceClient.sendReceiveNonBlocking(getEchoOMBlock("echo3",sequenceKey),callback3);
+
+ while (!callback3.isComplete()) {
+ Thread.sleep(1000);
+ }
+ }
+
+ private static OMElement getEchoOMBlock(String text, String sequenceKey) {
+ OMFactory fac = OMAbstractFactory.getOMFactory();
+ OMNamespace applicationNamespace = fac.createOMNamespace(applicationNamespaceName,"ns1");
+ OMElement echoStringElement = fac.createOMElement(echoString, applicationNamespace);
+ OMElement textElem = fac.createOMElement(Text,applicationNamespace);
+ OMElement sequenceElem = fac.createOMElement(Sequence,applicationNamespace);
+
+ textElem.setText(text);
+ sequenceElem.setText(sequenceKey);
+ echoStringElement.addChild(textElem);
+ echoStringElement.addChild(sequenceElem);
+
+ return echoStringElement;
+ }
+
+ private class TestCallback extends Callback {
+
+ String name = null;
+
+ public TestCallback (String name) {
+ this.name = name;
+ }
+
+ public String toString () {
+ return name;
+ }
+
+ public void onComplete(AsyncResult result) {
+ //System.out.println("On Complete Called for " + text);
+ SOAPBody body = result.getResponseEnvelope().getBody();
+
+ OMElement echoStringResponseElem = body.getFirstChildWithName(new QName (applicationNamespaceName,echoStringResponse));
+ if (echoStringResponseElem==null) {
+ System.out.println("Error: SOAPBody does not have a 'echoStringResponse' child");
+ return;
+ }
+
+ OMElement echoStringReturnElem = echoStringResponseElem.getFirstChildWithName(new QName (applicationNamespaceName,EchoStringReturn));
+ if (echoStringReturnElem==null) {
+ System.out.println("Error: 'echoStringResponse' element does not have a 'EchoStringReturn' child");
+ return;
+ }
+
+ String resultStr = echoStringReturnElem.getText();
+ System.out.println("Callback '" + name + "' got result:" + resultStr);
+
+ }
+
+ public void onError(Exception e) {
+ // TODO Auto-generated method stub
+ System.out.println("Error reported for test call back");
+ }
+ }
+
+}
Added: webservices/sandesha/trunk/java/samples/src/sandesha2/samples/userguide/SyncPingClient.java
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/java/samples/src/sandesha2/samples/userguide/SyncPingClient.java?rev=414476&view=auto
==============================================================================
--- webservices/sandesha/trunk/java/samples/src/sandesha2/samples/userguide/SyncPingClient.java (added)
+++ webservices/sandesha/trunk/java/samples/src/sandesha2/samples/userguide/SyncPingClient.java Wed Jun 14 22:51:15 2006
@@ -0,0 +1,154 @@
+/*
+ * Copyright 2004,2005 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 sandesha2.samples.userguide;
+
+import java.io.File;
+
+import org.apache.axiom.om.OMAbstractFactory;
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMFactory;
+import org.apache.axiom.om.OMNamespace;
+import org.apache.axiom.soap.SOAP12Constants;
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.addressing.EndpointReference;
+import org.apache.axis2.client.Options;
+import org.apache.axis2.client.ServiceClient;
+import org.apache.axis2.context.ConfigurationContext;
+import org.apache.axis2.context.ConfigurationContextFactory;
+import org.apache.axis2.context.MessageContextConstants;
+import org.apache.sandesha2.client.SandeshaClient;
+import org.apache.sandesha2.client.SandeshaClientConstants;
+import org.apache.sandesha2.client.SandeshaListener;
+import org.apache.sandesha2.client.SequenceReport;
+import org.apache.sandesha2.util.SandeshaUtil;
+
+
+public class SyncPingClient {
+
+ private static final String applicationNamespaceName = "http://tempuri.org/";
+ private static final String ping = "ping";
+ private static final String Text = "Text";
+
+ private String toIP = "127.0.0.1";
+
+ private String toPort = "8080";
+ private String transportToPort = "8070";
+
+ private String toEPR = "http://" + toIP + ":" + toPort + "/axis2/services/RMSampleService";
+ private String transportToEPR = "http://" + toIP + ":" + transportToPort + "/axis2/services/RMSampleService";
+
+ private static String SANDESHA2_HOME = "<SANDESHA2_HOME>"; //Change this to ur path.
+
+ private static String AXIS2_CLIENT_PATH = SANDESHA2_HOME + File.separator + "target" + File.separator +"repos" + File.separator + "client" + File.separator; //this will be available after a maven build
+
+ public static void main(String[] args) throws AxisFault {
+
+ String axisClientRepo = null;
+ if (args!=null && args.length>0)
+ axisClientRepo = args[0];
+
+ if (axisClientRepo!=null && !"".equals(axisClientRepo)) {
+ AXIS2_CLIENT_PATH = axisClientRepo;
+ SANDESHA2_HOME = "";
+ }
+
+
+ new SyncPingClient ().run();
+ }
+
+ private void run () throws AxisFault {
+
+ if ("<SANDESHA2_HOME>".equals(SANDESHA2_HOME)){
+ System.out.println("ERROR: Please change <SANDESHA2_HOME> to your Sandesha2 installation directory.");
+ return;
+ }
+
+ String axis2_xml = AXIS2_CLIENT_PATH + "client_axis2.xml";
+ ConfigurationContext configContext = ConfigurationContextFactory.createConfigurationContextFromFileSystem(AXIS2_CLIENT_PATH,axis2_xml);
+
+ Options clientOptions = new Options ();
+ clientOptions.setProperty(MessageContextConstants.TRANSPORT_URL,transportToEPR);
+ clientOptions.setTo(new EndpointReference (toEPR));
+
+ String sequenceKey = SandeshaUtil.getUUID();// "sequence2";
+ clientOptions.setProperty(SandeshaClientConstants.SEQUENCE_KEY,sequenceKey);
+
+// clientOptions.setProperty(MessageContextConstants.CHUNKED,Constants.VALUE_FALSE); //uncomment this to send messages without chunking.
+
+ clientOptions.setSoapVersionURI(SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI); //uncomment this to send messages in SOAP 1.2
+
+// clientOptions.setProperty(SandeshaClient.RM_SPEC_VERSION,Sandesha2Constants.SPEC_VERSIONS.v1_1); //uncomment this to send the messages according to the v1_1 spec.
+
+// clientOptions.setProperty(AddressingConstants.WS_ADDRESSING_VERSION,AddressingConstants.Submission.WSA_NAMESPACE);
+
+ clientOptions.setProperty(SandeshaClientConstants.SANDESHA_LISTENER, new SandeshaListenerImpl ());
+ ServiceClient serviceClient = new ServiceClient (configContext,null);
+// serviceClient.engageModule(new QName ("sandesha2"));
+
+ clientOptions.setAction("urn:wsrm:Ping");
+ serviceClient.setOptions(clientOptions);
+
+ serviceClient.fireAndForget(getPingOMBlock("ping1"));
+ serviceClient.fireAndForget(getPingOMBlock("ping2"));
+
+ clientOptions.setProperty(SandeshaClientConstants.LAST_MESSAGE, "true");
+
+ serviceClient.fireAndForget(getPingOMBlock("ping3"));
+
+ SequenceReport sequenceReport = null;
+
+ boolean complete = false;
+ while (!complete) {
+ sequenceReport = SandeshaClient.getOutgoingSequenceReport(serviceClient);
+ if (sequenceReport!=null && sequenceReport.getCompletedMessages().size()==3)
+ complete = true;
+ else {
+ try {
+ Thread.sleep(1000);
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ }
+ }
+
+ serviceClient.finalizeInvoke();
+ }
+
+ private static OMElement getPingOMBlock(String text) {
+ OMFactory fac = OMAbstractFactory.getOMFactory();
+ OMNamespace namespace = fac.createOMNamespace(applicationNamespaceName,"ns1");
+ OMElement pingElem = fac.createOMElement(ping, namespace);
+ OMElement textElem = fac.createOMElement(Text, namespace);
+
+ textElem.setText(text);
+ pingElem.addChild(textElem);
+
+ return pingElem;
+ }
+
+ private class SandeshaListenerImpl implements SandeshaListener {
+
+ public void onError(AxisFault fault) {
+ System.out.println("*********** RM fault callbak called");
+ }
+
+ public void onTimeOut(SequenceReport report) {
+ System.out.println("Sequence timed out");
+ }
+ }
+
+}
Added: webservices/sandesha/trunk/java/samples/src/sandesha2/samples/userguide/UserguideEchoClient.java
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/java/samples/src/sandesha2/samples/userguide/UserguideEchoClient.java?rev=414476&view=auto
==============================================================================
--- webservices/sandesha/trunk/java/samples/src/sandesha2/samples/userguide/UserguideEchoClient.java (added)
+++ webservices/sandesha/trunk/java/samples/src/sandesha2/samples/userguide/UserguideEchoClient.java Wed Jun 14 22:51:15 2006
@@ -0,0 +1,113 @@
+/*
+ * Copyright 2004,2005 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 sandesha2.samples.userguide;
+
+import java.io.File;
+import javax.xml.namespace.QName;
+import org.apache.axiom.om.OMAbstractFactory;
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMFactory;
+import org.apache.axiom.om.OMNamespace;
+import org.apache.axiom.soap.SOAPBody;
+import org.apache.axis2.Constants;
+import org.apache.axis2.addressing.EndpointReference;
+import org.apache.axis2.client.Options;
+import org.apache.axis2.client.ServiceClient;
+import org.apache.axis2.client.async.AsyncResult;
+import org.apache.axis2.client.async.Callback;
+import org.apache.axis2.context.ConfigurationContext;
+import org.apache.axis2.context.ConfigurationContextFactory;
+import org.apache.sandesha2.client.SandeshaClientConstants;
+
+public class UserguideEchoClient {
+
+ private final static String applicationNamespaceName = "http://tempuri.org/";
+ private final static String echoString = "echoString";
+ private final static String Text = "Text";
+ private final static String Sequence = "Sequence";
+ private final static String echoStringResponse = "echoStringResponse";
+ private final static String EchoStringReturn = "EchoStringReturn";
+ private static String toEPR = "http://127.0.0.1:8070/axis2/services/RMSampleService";
+
+ private static String CLIENT_REPO_PATH = "Full path to the Client Repo folder";
+
+ public static void main(String[] args) throws Exception {
+
+ String axis2_xml = CLIENT_REPO_PATH + File.separator +"client_axis2.xml";
+ ConfigurationContext configContext = ConfigurationContextFactory.createConfigurationContextFromFileSystem(CLIENT_REPO_PATH,axis2_xml);
+ ServiceClient serviceClient = new ServiceClient (configContext,null);
+
+ Options clientOptions = new Options ();
+ clientOptions.setTo(new EndpointReference (toEPR));
+ clientOptions.setTransportInProtocol(Constants.TRANSPORT_HTTP);
+ clientOptions.setUseSeparateListener(true);
+ serviceClient.setOptions(clientOptions);
+
+ Callback callback1 = new TestCallback ("Callback 1");
+ serviceClient.sendReceiveNonBlocking (getEchoOMBlock("echo1","sequence1"),callback1);
+ Callback callback2 = new TestCallback ("Callback 2");
+ serviceClient.sendReceiveNonBlocking(getEchoOMBlock("echo2","sequence1"),callback2);
+
+ clientOptions.setProperty(SandeshaClientConstants.LAST_MESSAGE, "true");
+ Callback callback3 = new TestCallback ("Callback 3");
+ serviceClient.sendReceiveNonBlocking(getEchoOMBlock("echo3","sequence1"),callback3);
+
+ while (!callback3.isComplete()) {
+ Thread.sleep(1000);
+ }
+
+ Thread.sleep(4000);
+ }
+
+ private static OMElement getEchoOMBlock(String text, String sequenceKey) {
+ OMFactory fac = OMAbstractFactory.getOMFactory();
+ OMNamespace applicationNamespace = fac.createOMNamespace(applicationNamespaceName,"ns1");
+ OMElement echoStringElement = fac.createOMElement(echoString, applicationNamespace);
+ OMElement textElem = fac.createOMElement(Text,applicationNamespace);
+ OMElement sequenceElem = fac.createOMElement(Sequence,applicationNamespace);
+
+ textElem.setText(text);
+ sequenceElem.setText(sequenceKey);
+ echoStringElement.addChild(textElem);
+ echoStringElement.addChild(sequenceElem);
+
+ return echoStringElement;
+ }
+
+ static class TestCallback extends Callback {
+
+ String name = null;
+ public TestCallback (String name) {
+ this.name = name;
+ }
+
+ public void onComplete(AsyncResult result) {
+ SOAPBody body = result.getResponseEnvelope().getBody();
+
+ OMElement echoStringResponseElem = body.getFirstChildWithName(new QName (applicationNamespaceName,echoStringResponse));
+ OMElement echoStringReturnElem = echoStringResponseElem.getFirstChildWithName(new QName (applicationNamespaceName,EchoStringReturn));
+
+ String resultStr = echoStringReturnElem.getText();
+ System.out.println("Callback '" + name + "' got result:" + resultStr);
+ }
+
+ public void onError (Exception e) {
+ System.out.println("Error reported for test call back");
+ e.printStackTrace();
+ }
+ }
+}
Added: webservices/sandesha/trunk/java/samples/src/sandesha2/samples/userguide/UserguidePingClient.java
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/java/samples/src/sandesha2/samples/userguide/UserguidePingClient.java?rev=414476&view=auto
==============================================================================
--- webservices/sandesha/trunk/java/samples/src/sandesha2/samples/userguide/UserguidePingClient.java (added)
+++ webservices/sandesha/trunk/java/samples/src/sandesha2/samples/userguide/UserguidePingClient.java Wed Jun 14 22:51:15 2006
@@ -0,0 +1,75 @@
+/*
+ * Copyright 2004,2005 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 sandesha2.samples.userguide;
+
+import java.io.File;
+
+import org.apache.axiom.om.OMAbstractFactory;
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMFactory;
+import org.apache.axiom.om.OMNamespace;
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.addressing.EndpointReference;
+import org.apache.axis2.client.Options;
+import org.apache.axis2.client.ServiceClient;
+import org.apache.axis2.context.ConfigurationContext;
+import org.apache.axis2.context.ConfigurationContextFactory;
+import org.apache.sandesha2.client.SandeshaClientConstants;
+
+
+public class UserguidePingClient {
+
+ private static final String applicationNamespaceName = "http://tempuri.org/";
+ private static final String ping = "ping";
+ private static final String Text = "Text";
+ private static String toEPR = "http://127.0.0.1:8070/axis2/services/RMSampleService";
+
+ private static String CLIENT_REPO_PATH = "Full path to the Client Repo folder";
+
+ public static void main(String[] args) throws AxisFault {
+
+ String axis2_xml = CLIENT_REPO_PATH + File.separator + "client_axis2.xml";
+ ConfigurationContext configContext = ConfigurationContextFactory.createConfigurationContextFromFileSystem(CLIENT_REPO_PATH,axis2_xml);
+
+ Options clientOptions = new Options ();
+ clientOptions.setTo(new EndpointReference (toEPR));
+
+ ServiceClient serviceClient = new ServiceClient (configContext,null);
+ clientOptions.setAction("urn:wsrm:Ping");
+ serviceClient.setOptions(clientOptions);
+
+ serviceClient.fireAndForget(getPingOMBlock("ping1"));
+ serviceClient.fireAndForget(getPingOMBlock("ping2"));
+
+ clientOptions.setProperty(SandeshaClientConstants.LAST_MESSAGE, "true");
+ serviceClient.fireAndForget(getPingOMBlock("ping3"));
+
+ serviceClient.finalizeInvoke();
+ }
+
+ private static OMElement getPingOMBlock(String text) {
+ OMFactory fac = OMAbstractFactory.getOMFactory();
+ OMNamespace namespace = fac.createOMNamespace(applicationNamespaceName,"ns1");
+ OMElement pingElem = fac.createOMElement(ping, namespace);
+ OMElement textElem = fac.createOMElement(Text, namespace);
+
+ textElem.setText(text);
+ pingElem.addChild(textElem);
+
+ return pingElem;
+ }
+}
Added: webservices/sandesha/trunk/java/src/org/apache/sandesha2/FaultData.java
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/java/src/org/apache/sandesha2/FaultData.java?rev=414476&view=auto
==============================================================================
--- webservices/sandesha/trunk/java/src/org/apache/sandesha2/FaultData.java (added)
+++ webservices/sandesha/trunk/java/src/org/apache/sandesha2/FaultData.java Wed Jun 14 22:51:15 2006
@@ -0,0 +1,90 @@
+/*
+ * Copyright 1999-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.sandesha2;
+
+import org.apache.axiom.om.OMElement;
+
+/**
+ * Used to hold data related to a RM Fault.
+ *
+ * @author Chamikara Jayalath <ch...@gmail.com>
+ * @author Sanka Samaranayaka <ss...@gmail.com>
+ */
+
+public class FaultData {
+
+ private int type;
+
+ private String code;
+
+ private String subcode;
+
+ private String reason;
+
+ private OMElement detail;
+
+ private String sequenceId;
+
+ public OMElement getDetail() {
+ return detail;
+ }
+
+ public void setDetail(OMElement detail) {
+ this.detail = detail;
+ }
+
+ public String getReason() {
+ return reason;
+ }
+
+ public void setReason(String reason) {
+ this.reason = reason;
+ }
+
+ public String getSubcode() {
+ return subcode;
+ }
+
+ public void setSubcode(String subcode) {
+ this.subcode = subcode;
+ }
+
+ public int getType() {
+ return type;
+ }
+
+ public void setType(int type) {
+ this.type = type;
+ }
+
+ public String getCode() {
+ return code;
+ }
+
+ public void setCode(String code) {
+ this.code = code;
+ }
+
+ public String getSequenceId() {
+ return sequenceId;
+ }
+
+ public void setSequenceId(String sequenceId) {
+ this.sequenceId = sequenceId;
+ }
+}
\ No newline at end of file
Added: webservices/sandesha/trunk/java/src/org/apache/sandesha2/MessageValidator.java
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/java/src/org/apache/sandesha2/MessageValidator.java?rev=414476&view=auto
==============================================================================
--- webservices/sandesha/trunk/java/src/org/apache/sandesha2/MessageValidator.java (added)
+++ webservices/sandesha/trunk/java/src/org/apache/sandesha2/MessageValidator.java Wed Jun 14 22:51:15 2006
@@ -0,0 +1,57 @@
+/*
+ * Copyright 1999-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.sandesha2;
+
+import org.apache.sandesha2.storage.StorageManager;
+import org.apache.sandesha2.util.SandeshaUtil;
+import org.apache.sandesha2.util.SpecSpecificConstants;
+
+public class MessageValidator {
+
+ public static void validateMessage (RMMsgContext rmMsg,StorageManager storageManager) throws SandeshaException {
+
+ if (rmMsg.getMessageType()!=Sandesha2Constants.MessageTypes.CREATE_SEQ
+ && rmMsg.getMessageType()!=Sandesha2Constants.MessageTypes.UNKNOWN) {
+
+ String sequenceID = SandeshaUtil.getSequenceIDFromRMMessage(rmMsg);
+
+ if (sequenceID!=null) {
+ String rmVersionOfSequence = SandeshaUtil.getSequenceProperty(sequenceID,Sandesha2Constants.SequenceProperties.RM_SPEC_VERSION,storageManager);
+ String addressingNamespaceOfSequence = SandeshaUtil.getSequenceProperty(sequenceID,Sandesha2Constants.SequenceProperties.ADDRESSING_NAMESPACE_VALUE,storageManager);
+
+ String rmNamespaceOfMsg = rmMsg.getRMNamespaceValue();
+ String rmNamespaceOfSequence = null;
+ if (rmVersionOfSequence!=null)
+ rmNamespaceOfSequence = SpecSpecificConstants.getRMNamespaceValue(rmVersionOfSequence);
+ String addressingNamespaceOfMsg = rmMsg.getAddressingNamespaceValue();
+
+ if (rmNamespaceOfSequence!=null && !rmNamespaceOfSequence.equals(rmNamespaceOfMsg)) {
+ String message = "Validation failed. The RM namespace of the message does not match with the sequence";
+ throw new SandeshaException (message);
+ }
+
+ if (addressingNamespaceOfSequence!=null && !addressingNamespaceOfSequence.equals(addressingNamespaceOfMsg)) {
+ String message = "Validation failed. The Addressing namespace of the message does not match with the sequence";
+ throw new SandeshaException (message);
+ }
+
+ //TODO do validation based on states
+ }
+ }
+ }
+}
Added: webservices/sandesha/trunk/java/src/org/apache/sandesha2/RMMsgContext.java
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/java/src/org/apache/sandesha2/RMMsgContext.java?rev=414476&view=auto
==============================================================================
--- webservices/sandesha/trunk/java/src/org/apache/sandesha2/RMMsgContext.java (added)
+++ webservices/sandesha/trunk/java/src/org/apache/sandesha2/RMMsgContext.java Wed Jun 14 22:51:15 2006
@@ -0,0 +1,286 @@
+/*
+ * Copyright 1999-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.sandesha2;
+
+import java.util.HashMap;
+import java.util.Iterator;
+
+import org.apache.axiom.soap.SOAPEnvelope;
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.addressing.AddressingConstants;
+import org.apache.axis2.addressing.EndpointReference;
+import org.apache.axis2.addressing.RelatesTo;
+import org.apache.axis2.context.ConfigurationContext;
+import org.apache.axis2.context.MessageContext;
+import org.apache.sandesha2.util.SOAPAbstractFactory;
+import org.apache.sandesha2.wsrm.IOMRMElement;
+import org.apache.sandesha2.wsrm.IOMRMPart;
+
+/**
+ * This class is used to hold a MessageContext within Sandesha. This is used to
+ * easily manupilate the properties of a MessageContext.
+ *
+ *
+ * @author Chamikara Jayalath <ch...@gmail.com>
+ * @author Sanka Samaranayaka <ss...@gmail.com>
+ * @author Jaliya Ekanayaka <ja...@opensource.lk>
+ */
+
+public class RMMsgContext {
+
+ private MessageContext msgContext;
+
+ private HashMap rmMessageParts;
+
+ private int messageType;
+
+ private String rmNamespaceValue = null;
+
+ private String addressingNamespaceValue = null;
+
+ private String rmSpecVersion = null;
+
+ public RMMsgContext() {
+ rmMessageParts = new HashMap();
+ messageType = Sandesha2Constants.MessageTypes.UNKNOWN;
+ }
+
+ public void setMessageContext(MessageContext msgCtx) {
+ this.msgContext = msgCtx;
+ }
+
+ public RMMsgContext(MessageContext ctx) {
+ this();
+ this.msgContext = ctx;
+ }
+
+ /**
+ * To add a new SOAP envelope to the message. The generated envelope will belong
+ * to the SOAP version of the MessageContext.
+ *
+ * @throws SandeshaException
+ */
+ public void addSOAPEnvelope() throws SandeshaException {
+ int SOAPVersion = Sandesha2Constants.SOAPVersion.v1_1;
+
+ if (!msgContext.isSOAP11())
+ SOAPVersion = Sandesha2Constants.SOAPVersion.v1_2;
+
+ if (msgContext.getEnvelope() == null) {
+ try {
+ msgContext.setEnvelope(SOAPAbstractFactory.getSOAPFactory(
+ SOAPVersion).getDefaultEnvelope());
+ } catch (AxisFault e) {
+ throw new SandeshaException(e.getMessage());
+ }
+ }
+
+ SOAPEnvelope envelope = msgContext.getEnvelope();
+ Iterator keys = rmMessageParts.keySet().iterator();
+ while (keys.hasNext()) {
+ Object key = keys.next();
+ IOMRMPart rmPart = (IOMRMPart) rmMessageParts.get(key);
+ rmPart.toSOAPEnvelope(envelope);
+ }
+ }
+
+ public int getMessageType() {
+ return messageType;
+ }
+
+
+ /**
+ * The message type can be used to easily identify what this message is.
+ * Possible message types are given in the Constnts.MessageTypes interface.
+ *
+ * @param msgType
+ */
+ public void setMessageType(int msgType) {
+ if (msgType >= 0 && msgType <= Sandesha2Constants.MessageTypes.MAX_MESSAGE_TYPE)
+ this.messageType = msgType;
+ }
+
+
+ /**
+ * Sets an IRMPart object to the MessageContext. Possible parts are give in the
+ *
+ *
+ * @param partId
+ * @param part
+ */
+ public void setMessagePart(int partId, IOMRMPart part) {
+ if (partId >= 0 && partId <= Sandesha2Constants.MessageParts.MAX_MSG_PART_ID)
+ rmMessageParts.put(new Integer(partId), part);
+ }
+
+ public IOMRMElement getMessagePart(int partId) {
+ return (IOMRMElement) rmMessageParts.get(new Integer(partId));
+ }
+
+ public EndpointReference getFrom() {
+ return msgContext.getFrom();
+ }
+
+ public EndpointReference getTo() {
+ return msgContext.getTo();
+ }
+
+ public EndpointReference getReplyTo() {
+ return msgContext.getReplyTo();
+ }
+
+ public RelatesTo getRelatesTo() {
+ return msgContext.getRelatesTo();
+ }
+
+ public String getMessageId() {
+ return msgContext.getMessageID();
+ }
+
+ public void setFaultTo(EndpointReference epr) {
+ msgContext.setFaultTo(epr);
+ }
+
+ public EndpointReference getFaultTo() {
+ return msgContext.getFaultTo();
+ }
+
+ public SOAPEnvelope getSOAPEnvelope() {
+ return msgContext.getEnvelope();
+ }
+
+ public void setSOAPEnvelop(SOAPEnvelope envelope) throws SandeshaException {
+
+ try {
+ msgContext.setEnvelope(envelope);
+ } catch (AxisFault e) {
+ throw new SandeshaException(e.getMessage());
+ }
+ }
+
+ public void setFrom(EndpointReference epr) {
+ msgContext.setFrom(epr);
+ }
+
+ public void setTo(EndpointReference epr) {
+ msgContext.setTo(epr);
+ }
+
+ public void setReplyTo(EndpointReference epr) {
+ msgContext.setReplyTo(epr);
+ }
+
+ public void setMessageId(String messageId) {
+ msgContext.setMessageID(messageId);
+ }
+
+ public void setAction(String action) {
+ msgContext.setWSAAction(action);
+ }
+
+ public void addRelatesTo(RelatesTo relatesTo) {
+ msgContext.addRelatesTo(relatesTo);
+ }
+
+ public void setWSAAction(String URI) {
+ msgContext.setWSAAction(URI);
+ }
+
+ public String getWSAAction() {
+ return msgContext.getWSAAction();
+ }
+
+ public MessageContext getMessageContext() {
+ return msgContext;
+ }
+
+ public Object getProperty(String key) {
+ if (msgContext == null)
+ return null;
+
+ return msgContext.getProperty(key);
+ }
+
+ public boolean setProperty(String key, Object val) {
+ if (msgContext == null)
+ return false;
+
+ msgContext.setProperty(key, val);
+ return true;
+ }
+
+ public ConfigurationContext getConfigurationContext() {
+ if (msgContext == null)
+ return null;
+
+ return msgContext.getConfigurationContext();
+ }
+
+
+ public void setSOAPAction(String SOAPAction) {
+ msgContext.setSoapAction(SOAPAction);
+ }
+
+ public void pause () {
+ if (msgContext!=null)
+ msgContext.pause();
+ }
+
+ public void setPaused (boolean pause) {
+ if (msgContext!=null)
+ msgContext.setPaused(pause);
+ }
+
+ public String getRMNamespaceValue() {
+ return rmNamespaceValue;
+ }
+
+ public void setRMNamespaceValue(String rmNamespaceValue) {
+ this.rmNamespaceValue = rmNamespaceValue;
+
+ if (Sandesha2Constants.SPEC_2005_02.NS_URI.equals(rmNamespaceValue)) {
+ rmSpecVersion = Sandesha2Constants.SPEC_VERSIONS.v1_0;
+ } else if (Sandesha2Constants.SPEC_2005_10.NS_URI.equals(rmNamespaceValue)) {
+ rmSpecVersion = Sandesha2Constants.SPEC_VERSIONS.v1_1;
+ }
+ }
+
+ public String getRMSpecVersion () {
+ return rmSpecVersion;
+ }
+
+ public void setFlow (int flow) {
+ msgContext.setFLOW(flow);
+ }
+
+ public int getFlow () {
+ return msgContext.getFLOW();
+ }
+
+ public String getAddressingNamespaceValue() {
+ return addressingNamespaceValue;
+ }
+
+ public void setAddressingNamespaceValue(String addressingNamespaceValue) throws SandeshaException {
+ if (!AddressingConstants.Submission.WSA_NAMESPACE.equals(addressingNamespaceValue) &&
+ !AddressingConstants.Final.WSA_NAMESPACE.equals(addressingNamespaceValue))
+ throw new SandeshaException ("Unknown addressing version");
+
+ this.addressingNamespaceValue = addressingNamespaceValue;
+ }
+}
\ No newline at end of file
Added: webservices/sandesha/trunk/java/src/org/apache/sandesha2/Sandesha2Constants.java
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/java/src/org/apache/sandesha2/Sandesha2Constants.java?rev=414476&view=auto
==============================================================================
--- webservices/sandesha/trunk/java/src/org/apache/sandesha2/Sandesha2Constants.java (added)
+++ webservices/sandesha/trunk/java/src/org/apache/sandesha2/Sandesha2Constants.java Wed Jun 14 22:51:15 2006
@@ -0,0 +1,504 @@
+/*
+ * Copyright 1999-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.sandesha2;
+
+
+
+/**
+ * Contains all the Sandesha2Constants of Sandesha2.
+ * Please see sub-interfaces to see grouped data.
+ *
+ * @author Chamikara Jayalath <ch...@gmail.com>
+ * @author Sanka Samaranayaka <ss...@gmail.com>
+ * @author Jaliya Ekanayaka <ja...@opensource.lk>
+ */
+
+public interface Sandesha2Constants {
+
+
+ public interface SPEC_VERSIONS {
+ String v1_0 = "Spec_2005_02";
+ String v1_1 = "Spec_2005_10";
+ }
+
+ public interface SPEC_2005_02 {
+
+ String NS_URI = "http://schemas.xmlsoap.org/ws/2005/02/rm";
+
+ public interface Actions {
+
+ String ACTION_CREATE_SEQUENCE = "http://schemas.xmlsoap.org/ws/2005/02/rm/CreateSequence";
+
+ String ACTION_CREATE_SEQUENCE_RESPONSE = "http://schemas.xmlsoap.org/ws/2005/02/rm/CreateSequenceResponse";
+
+ String ACTION_SEQUENCE_ACKNOWLEDGEMENT = "http://schemas.xmlsoap.org/ws/2005/02/rm/SequenceAcknowledgement";
+
+ String ACTION_TERMINATE_SEQUENCE = "http://schemas.xmlsoap.org/ws/2005/02/rm/TerminateSequence";
+
+ String SOAP_ACTION_CREATE_SEQUENCE = "http://schemas.xmlsoap.org/ws/2005/02/rm/CreateSequence";
+
+ String SOAP_ACTION_CREATE_SEQUENCE_RESPONSE = "http://schemas.xmlsoap.org/ws/2005/02/rm/CreateSequenceResponse";
+
+ String SOAP_ACTION_SEQUENCE_ACKNOWLEDGEMENT = "http://schemas.xmlsoap.org/ws/2005/02/rm/SequenceAcknowledgement";
+
+ String SOAP_ACTION_TERMINATE_SEQUENCE = "http://schemas.xmlsoap.org/ws/2005/02/rm/TerminateSequence";
+ }
+ }
+
+ public interface SPEC_2005_10 {
+
+ String NS_URI = "http://docs.oasis-open.org/ws-rx/wsrm/200602";
+
+ public interface Actions {
+
+ String ACTION_CREATE_SEQUENCE = "http://docs.oasis-open.org/ws-rx/wsrm/200602/CreateSequence";
+
+ String ACTION_CREATE_SEQUENCE_RESPONSE = "http://docs.oasis-open.org/ws-rx/wsrm/200602/CreateSequenceResponse";
+
+ String ACTION_SEQUENCE_ACKNOWLEDGEMENT = "http://docs.oasis-open.org/ws-rx/wsrm/200602/SequenceAcknowledgement";
+
+ String ACTION_TERMINATE_SEQUENCE = "http://docs.oasis-open.org/ws-rx/wsrm/200602/TerminateSequence";
+
+ String ACTION_TERMINATE_SEQUENCE_RESPONSE = "http://docs.oasis-open.org/ws-rx/wsrm/200602/TerminateSequenceResponse";
+
+ String ACTION_ACK_REQUEST = "http://docs.oasis-open.org/ws-rx/wsrm/200602/AckRequested";
+
+ String ACTION_CLOSE_SEQUENCE = "http://docs.oasis-open.org/ws-rx/wsrm/200602/CloseSequence";
+
+ String ACTION_CLOSE_SEQUENCE_RESPONSE = "http://docs.oasis-open.org/ws-rx/wsrm/200602/CloseSequenceResponse";
+
+ String SOAP_ACTION_CREATE_SEQUENCE = "http://docs.oasis-open.org/ws-rx/wsrm/200602/CreateSequence";
+
+ String SOAP_ACTION_CREATE_SEQUENCE_RESPONSE = "http://docs.oasis-open.org/ws-rx/wsrm/200602/CreateSequenceResponse";
+
+ String SOAP_ACTION_SEQUENCE_ACKNOWLEDGEMENT = "http://docs.oasis-open.org/ws-rx/wsrm/200602/SequenceAcknowledgement";
+
+ String SOAP_ACTION_TERMINATE_SEQUENCE = "http://docs.oasis-open.org/ws-rx/wsrm/200602/TerminateSequence";
+
+ String SOAP_ACTION_TERMINATE_SEQUENCE_RESPONSE = "http://docs.oasis-open.org/ws-rx/wsrm/200602/TerminateSequenceResponse";
+
+ String SOAP_ACTION_ACK_REQUEST = "http://docs.oasis-open.org/ws-rx/wsrm/200602/AckRequested";
+
+ String SOAP_ACTION_CLOSE_SEQUENCE = "http://docs.oasis-open.org/ws-rx/wsrm/200602/CloseSequence";
+ }
+ }
+
+ public interface WSRM_COMMON {
+
+ String NS_PREFIX_RM = "wsrm";
+
+
+
+ String MSG_NUMBER = "MessageNumber";
+
+ String LAST_MSG = "LastMessage";
+
+ String SEQUENCE = "Sequence";
+
+ String SEQUENCE_OFFER = "Offer";
+
+ String TERMINATE_SEQUENCE = "TerminateSequence";
+
+ String CLOSE_SEQUENCE = "CloseSequence";
+
+ String CLOSE_SEQUENCE_RESPONSE = "CloseSequenceResponse";
+
+ String TERMINATE_SEQUENCE_RESPONSE = "TerminateSequenceResponse";
+
+ String FAULT_CODE = "FaultCode";
+
+ String SEQUENCE_FAULT = "SequenceFault";
+
+ String ACKS_TO = "AcksTo";
+
+ String EXPIRES = "Expires";
+
+ String CREATE_SEQUENCE = "CreateSequence";
+
+ String CREATE_SEQUENCE_RESPONSE = "CreateSequenceResponse";
+
+ String ACK_REQUESTED = "AckRequested";
+
+ String ACK_RANGE = "AcknowledgementRange";
+
+ String UPPER = "Upper";
+
+ String LOWER = "Lower";
+
+ String NACK = "Nack";
+
+ String SEQUENCE_ACK = "SequenceAcknowledgement";
+
+ String IDENTIFIER = "Identifier";
+
+ String ACCEPT = "Accept";
+
+ String NONE = "None";
+
+ String FINAL = "Final";
+ }
+
+ public interface WSA {
+
+ String NS_PREFIX_ADDRESSING = "wsa";
+
+ String ADDRESS = "Address";
+
+// String SOAP_FAULT_ACTION = "http://schemas.xmlsoap.org/ws/2004/08/addressing/fault";
+
+ }
+
+ public interface MessageTypes {
+ int UNKNOWN = 0;
+
+ int CREATE_SEQ = 1;
+
+ int CREATE_SEQ_RESPONSE = 2;
+
+ int APPLICATION = 3;
+
+ int ACK = 4;
+
+ int CLOSE_SEQUENCE = 5;
+
+ int CLOSE_SEQUENCE_RESPONSE = 6;
+
+ int TERMINATE_SEQ = 7;
+
+ int ACK_REQUEST = 8;
+
+ int TERMINATE_SEQ_RESPONSE = 9;
+
+ int FAULT_MSG = 10;
+
+ int MAX_MESSAGE_TYPE = 10;
+ }
+
+ public interface MessageParts {
+ int UNKNOWN = 0;
+
+ int SEQUENCE = 6;
+
+ int SEQ_ACKNOWLEDGEMENT = 7;
+
+ int ADDR_HEADERS = 8;
+
+ int CREATE_SEQ = 9;
+
+ int CREATE_SEQ_RESPONSE = 10;
+
+ int TERMINATE_SEQ = 11;
+
+ int CLOSE_SEQUENCE = 12;
+
+ int CLOSE_SEQUENCE_RESPONSE = 13;
+
+ int TERMINATE_SEQ_RESPONSE = 14;
+
+ int ACK_REQUEST = 15;
+
+ int MAX_MSG_PART_ID = 15;
+ }
+
+ public interface SequenceProperties {
+
+ String RM_SPEC_VERSION = "WSRMSpecVersion";
+
+ String ALL_SEQUENCES = "AllSequences"; //this is not a sequence
+ // property. This is used as the
+ // sequenceId to share data b/w
+ // sequences
+
+ //Addressing version of a sequence. All messages of a sequence should have this addressing versio
+ String ADDRESSING_NAMESPACE_VALUE = "AddressingNamespaceValue";
+
+ //For incoming sequences this gives the msg no's of the messages that were
+ //received (may be an ack was sent - depending on the policy)
+ //For out going sequences this gives the messages that were sent and that were successfully
+ //acked by the other end point.
+ String CLIENT_COMPLETED_MESSAGES = "ClientCompletedMessages";
+ String SERVER_COMPLETED_MESSAGES = "ServerCompletedMessages";
+
+ String TO_EPR = "ToEPR";
+
+ String ACKS_TO_EPR = "acksToEPR";
+
+ String OUT_SEQUENCE_ID = "OutSequenceId";
+
+ String INTERNAL_SEQUENCE_ID = "TempSequenceId";
+
+ String REPLY_TO_EPR = "ReplyToEPR";
+
+ String APP_MSG_PROCESSOR_LIST = "AppMsgProcessorList";
+
+ String OUT_CREATE_SEQUENCE_SENT = "OutCreateSeqSent";
+
+ String NEXT_MESSAGE_NUMBER = "NextMsgNo";
+
+ String INCOMING_SEQUENCE_LIST = "IncomingSequenceList";
+
+ String CHECK_RESPONSE = "CheckResponse";
+
+ String OFFERED_SEQUENCE = "OfferedSequence";
+
+ String TERMINATE_ADDED = "TerminateAdded";
+
+ String TERMINATE_RECEIVED = "TerminateReceived";
+
+ String LAST_ACTIVATED_TIME = "LastActivatedTime";
+
+ String NO_OF_OUTGOING_MSGS_ACKED = "NoOfOutGoingMessagesAcked";
+
+ String TRANSPORT_TO = "TransportTo";
+
+ String OUT_SEQ_ACKSTO = "OutSequenceAcksTo";
+
+ String SEQUENCE_CLOSED = "SequenceClosed";
+
+ String SEQUENCE_TERMINATED = "SequenceTerminated";
+
+ String SEQUENCE_TIMED_OUT = "SequenceTimedOut";
+
+// String LAST_MESSAGE = "LastMessage";
+
+ String REQUEST_SIDE_SEQUENCE_ID = "RequestSideSequenceID"; //used only at the server side
+
+ String HIGHEST_IN_MSG_NUMBER = "HighestInMsgNumber";
+
+ String HIGHEST_IN_MSG_KEY = "HighestInMsgKey";
+
+ String HIGHEST_OUT_MSG_NUMBER = "HighestOutMsgNumber";
+
+ String HIGHEST_OUT_MSG_KEY = "HighestOutMsgKey";
+
+ String LAST_OUT_MESSAGE_NO = "LastOutMessage";
+
+ String LAST_IN_MESSAGE_NO = "LastInMessage";
+ }
+
+ public interface SOAPVersion {
+ int v1_1 = 1;
+
+ int v1_2 = 2;
+ }
+
+ public interface QOS {
+
+ public interface DeliveryAssurance {
+
+ String IN_ORDER = "InOrder";
+
+ String NOT_IN_ORDER = "NotInOrder";
+
+ String DEFAULT_DELIVERY_ASSURANCE = IN_ORDER;
+ }
+
+ public interface InvocationType {
+
+ //invocation types
+ String EXACTLY_ONCE = "ExactlyOnce";
+
+ String MORE_THAN_ONCE = "MoreThanOnce";
+
+ String DEFAULT_INVOCATION_TYPE = EXACTLY_ONCE;
+ }
+
+ }
+
+ public interface BeanMAPs {
+ String CREATE_SEQUECE = "CreateSequenceBeanMap";
+
+ String RETRANSMITTER = "RetransmitterBeanMap";
+
+ String SEQUENCE_PROPERTY = "SequencePropertyBeanMap";
+
+ String STORAGE_MAP = "StorageMapBeanMap";
+
+ String NEXT_MESSAGE = "NextMsgBeanMap";
+ }
+
+ public interface SOAPFaults {
+
+ public interface Subcodes {
+
+ String SEQUENCE_TERMINATED = "wsrm:SequenceTerminated";
+
+ String SEQUENCE_CLOSED = "wsrm:SequenceClosed";
+
+ String UNKNOWN_SEQUENCE = "wsrm:UnknownSequence";
+
+ String INVALID_ACKNOWLEDGEMENT = "wsrm:InvalidAcknowledgement";
+
+ String MESSAGE_NUMBER_ROLEOVER = "wsrm:MessageNumberRollover";
+
+ String LAST_MESSAGE_NO_EXCEEDED = "wsrm:LastMessageNumberExceeded";
+
+ String CREATE_SEQUENCE_REFUSED = "wsrm:CreateSequenceRefused";
+
+
+ }
+
+ public interface FaultType {
+
+ public static final int UNKNOWN_SEQUENCE = 1;
+
+ public static final int MESSAGE_NUMBER_ROLLOVER = 2;
+
+ public static final int INVALID_ACKNOWLEDGEMENT = 3;
+
+ public static final int CREATE_SEQUENCE_REFUSED = 4;
+
+ public static final int LAST_MESSAGE_NO_EXCEEDED = 5;
+ }
+ }
+
+ public interface Properties {
+
+ String RetransmissionInterval = "RetransmissionInterval";
+
+ String AcknowledgementInterval = "AcknowledgementInterval";
+
+ String ExponentialBackoff = "ExponentialBackoff";
+
+ String InactivityTimeout = "InactivityTimeout";
+
+ String InactivityTimeoutMeasure = "InactivityTimeoutMeasure";
+
+// String StorageManager = "StorageManager";
+
+ String InMemoryStorageManager = "InMemoryStorageManager";
+
+ String PermanentStorageManager = "PermanentStorageManager";
+
+ String InOrderInvocation = "InvokeInOrder";
+
+ String MessageTypesToDrop = "MessageTypesToDrop";
+
+ String RetransmissionCount = "RetransmissionCount";
+
+ public interface DefaultValues {
+
+ int RetransmissionInterval = 20000;
+
+ int AcknowledgementInterval = 4000;
+
+ boolean ExponentialBackoff = true;
+
+ int InactivityTimeout = -1;
+
+ String InactivityTimeoutMeasure = "seconds"; //this can be - seconds,minutes,hours,days
+
+// String StorageManager = "org.apache.sandesha2.storage.inmemory.InMemoryStorageManager";
+
+ String InMemoryStorageManager = "org.apache.sandesha2.storage.inmemory.InMemoryStorageManager";
+
+ String PermanentStorageManager = "org.apache.sandesha2.storage.inmemory.InMemoryStorageManager";
+
+ boolean InvokeInOrder = true;
+
+ String MessageTypesToDrop=VALUE_NONE;
+
+ int RetransmissionCount = 8;
+
+ int MaximumRetransmissionCount = 10;
+ }
+ }
+
+ public interface DatabaseParams {
+
+ }
+
+ String IN_HANDLER_NAME = "SandeshaInHandler";
+
+ String OUT_HANDLER_NAME = "SandeshaOutHandler";
+
+ String GLOBAL_IN_HANDLER_NAME = "GlobalInHandler";
+
+ String APPLICATION_PROCESSING_DONE = "Sandesha2AppProcessingDone";
+
+ String ACK_WRITTEN = "AckWritten";
+
+ int INVOKER_SLEEP_TIME = 1000;
+
+ int SENDER_SLEEP_TIME = 500;
+
+ int CLIENT_SLEEP_TIME = 10000;
+
+ int TERMINATE_DELAY = 100;
+
+ String TEMP_SEQUENCE_ID = "uuid:tempID";
+
+ String ACK_PROCSSED = "AckProcessed";
+
+ String RM_ENABLE_KEY = "RMEnabled";
+
+ int MAXIMUM_RETRANSMISSION_ATTEMPTS = 5;
+
+ String PROPERTY_FILE = "sandesha2.properties";
+
+ String VALUE_NONE = "none";
+
+ String VALUE_EMPTY = "empty";
+
+ String VALUE_TRUE = "true";
+
+ String VALUE_FALSE = "false";
+
+ String MESSAGE_STORE_KEY = "Sandesha2MessageStoreKey";
+
+ String ORIGINAL_TRANSPORT_OUT_DESC = "Sandesha2OriginalTransportSender";
+
+ String SET_SEND_TO_TRUE = "Sandesha2SetSendToTrue";
+
+ String MESSAGE_TYPE = "Sandesha2MessageType";
+
+ String QUALIFIED_FOR_SENDING = "Sandesha2QualifiedForSending"; //Sender will send messages only if this property is null (not set) or true.
+
+ String QNAME_SEPERATOR = ",";
+
+ String EXECUTIN_CHAIN_SEPERATOR = ".";
+
+ String INTERNAL_SEQUENCE_PREFIX = "Sandesha2InternalSequence";
+
+ String SANDESHA_PROPERTY_BEAN = "Sandesha2PropertyBean";
+
+ String LIST_SEPERATOR = ",";
+
+ String LIST_PART_SEPERATOR = "-";
+
+ String INMEMORY_STORAGE_MANAGER = "inmemory";
+
+ String PERMANENT_STORAGE_MANAGER = "persistent";
+
+ String DEFAULT_STORAGE_MANAGER = INMEMORY_STORAGE_MANAGER;
+
+ String SENDER = "Sender";
+
+ String INVOKER = "Invoker";
+
+ String WITHIN_TRANSACTION = "WithinTransaction";
+
+ String STORAGE_MANAGER_PARAMETER = "Sandesha2StorageManager";
+
+ String POST_FAILURE_MESSAGE = "PostFailureMessage";
+
+ String REINJECTED_MESSAGE = "ReinjectedMessage";
+
+ String MODULE_CLASS_LOADER = "Sandesha2ModuleClassLoader";
+
+}
\ No newline at end of file
Added: webservices/sandesha/trunk/java/src/org/apache/sandesha2/SandeshaException.java
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/java/src/org/apache/sandesha2/SandeshaException.java?rev=414476&view=auto
==============================================================================
--- webservices/sandesha/trunk/java/src/org/apache/sandesha2/SandeshaException.java (added)
+++ webservices/sandesha/trunk/java/src/org/apache/sandesha2/SandeshaException.java Wed Jun 14 22:51:15 2006
@@ -0,0 +1,43 @@
+/*
+ * Copyright 1999-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.sandesha2;
+
+import org.apache.axis2.AxisFault;
+
+/**
+ * Exception class of Sandesa2.
+ *
+ * @author Chamikara Jayalath <ch...@gmail.com>
+ * @author Sanka Samaranayaka <ss...@gmail.com>
+ */
+
+public class SandeshaException extends AxisFault {
+
+ public SandeshaException (String message) {
+ super (message);
+ }
+
+ public SandeshaException (Exception e) {
+ super (e);
+ }
+
+ public SandeshaException (String message,Exception e) {
+ super (message,e);
+ }
+
+}
Added: webservices/sandesha/trunk/java/src/org/apache/sandesha2/SandeshaModule.java
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/java/src/org/apache/sandesha2/SandeshaModule.java?rev=414476&view=auto
==============================================================================
--- webservices/sandesha/trunk/java/src/org/apache/sandesha2/SandeshaModule.java (added)
+++ webservices/sandesha/trunk/java/src/org/apache/sandesha2/SandeshaModule.java Wed Jun 14 22:51:15 2006
@@ -0,0 +1,149 @@
+/*
+ * Copyright 1999-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.sandesha2;
+
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.context.ConfigurationContext;
+import org.apache.axis2.description.AxisDescription;
+import org.apache.axis2.description.AxisModule;
+import org.apache.axis2.description.Parameter;
+import org.apache.axis2.modules.Module;
+import org.apache.axis2.modules.ModulePolicyExtension;
+import org.apache.axis2.modules.PolicyExtension;
+import org.apache.log4j.Logger;
+import org.apache.sandesha2.policy.RMPolicyExtension;
+import org.apache.sandesha2.storage.SandeshaStorageException;
+import org.apache.sandesha2.storage.StorageManager;
+import org.apache.sandesha2.util.PropertyManager;
+import org.apache.sandesha2.util.SandeshaPropertyBean;
+import org.apache.sandesha2.util.SandeshaUtil;
+
+/**
+ * The Module class of Sandesha2.
+ *
+ * @author Chamikara Jayalath <ch...@gmail.com>
+ */
+
+public class SandeshaModule implements Module, ModulePolicyExtension {
+
+ private Logger log = Logger.getLogger(SandeshaModule.class);
+
+ // initialize the module
+ public void init(ConfigurationContext configContext,
+ AxisModule module) throws AxisFault {
+
+ //storing the Sadesha module as a property.
+ configContext.setProperty(Sandesha2Constants.MODULE_CLASS_LOADER,module.getModuleClassLoader());
+
+ // continueUncompletedSequences (storageManager,configCtx);
+
+ SandeshaPropertyBean constantPropertyBean = PropertyManager.loadPropertiesFromDefaultValues();
+ SandeshaPropertyBean propertyBean = PropertyManager.loadPropertiesFromModuleDescPolicy(module,constantPropertyBean);
+ if (propertyBean==null) {
+ propertyBean = PropertyManager.loadPropertiesFromDefaultValues();
+ }
+
+ Parameter parameter = new Parameter ();
+ parameter.setName(Sandesha2Constants.SANDESHA_PROPERTY_BEAN);
+ parameter.setValue(propertyBean);
+ configContext.getAxisConfiguration().addParameter(parameter);;
+
+ configContext.setProperty(Sandesha2Constants.INMEMORY_STORAGE_MANAGER,null); // this must be resetted by the module settings.
+ configContext.setProperty(Sandesha2Constants.PERMANENT_STORAGE_MANAGER,null);
+
+ try {
+ StorageManager inMemorytorageManager = SandeshaUtil.getInMemoryStorageManager(configContext);
+ inMemorytorageManager.initStorage(module);
+ } catch (SandeshaStorageException e) {
+ String message = "Cannot initialize the given in-memory storage manager.";
+ log.debug(message,e);
+ }
+
+ try {
+ StorageManager permanentStorageManager = SandeshaUtil.getPermanentStorageManager(configContext);
+ permanentStorageManager.initStorage(module);
+ } catch (SandeshaStorageException e) {
+ String message = "Cannot initialize the given persistent storage manager.";
+ log.debug(message,e);
+ }
+ }
+
+ public void engageNotify(AxisDescription axisDescription) throws AxisFault {
+
+ SandeshaPropertyBean parentPropertyBean = SandeshaUtil.getPropertyBean(axisDescription);
+ if (parentPropertyBean==null)
+ throw new AxisFault ("Default Property Bean is not set");
+
+ SandeshaPropertyBean axisDescPropertyBean = PropertyManager.loadPropertiesFromAxisDescription(axisDescription,parentPropertyBean);
+
+ if (axisDescPropertyBean!=null) {
+ Parameter parameter = new Parameter ();
+ parameter.setName(Sandesha2Constants.SANDESHA_PROPERTY_BEAN);
+ parameter.setValue(axisDescPropertyBean);
+ axisDescription.addParameter(parameter);
+ }
+ }
+
+ private void continueUncompletedSequences(StorageManager storageManager,
+ ConfigurationContext configCtx) {
+ // server side continues
+ // SandeshaUtil.startInvokerIfStopped(configCtx);
+
+ // server side re-injections
+
+ // reinject everything that has been acked within the in-handler but
+ // have not been invoked.
+
+ // client side continues
+ // SandeshaUtil.startSenderIfStopped(configCtx);
+
+ // client side re-injections
+
+ }
+
+ public PolicyExtension getPolicyExtension() {
+ return new RMPolicyExtension();
+ }
+
+ public void shutdown(ConfigurationContext configurationContext) throws AxisFault {
+ //removing the threads started by Sandesha2.
+ SandeshaUtil.stopSender (configurationContext);
+ SandeshaUtil.stopInvoker(configurationContext);
+ }
+
+ // Removing data of uncontinuuable sequences so that the sandesha2 system
+ // will not be confused
+ private void cleanStorage(StorageManager storageManager) throws AxisFault {
+
+
+
+ // server side cleaning
+
+ // cleaning NextMsgData
+ // Cleaning InvokerData
+
+ // client side cleaning
+
+ // cleaning RetransmitterData
+ // cleaning CreateSequenceData
+
+ // cleaning sequence properties
+
+ }
+
+}
\ No newline at end of file
---------------------------------------------------------------------
To unsubscribe, e-mail: sandesha-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: sandesha-dev-help@ws.apache.org