You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-commits@axis.apache.org by sa...@apache.org on 2012/01/14 10:05:21 UTC
svn commit: r1231466 - in /axis/axis2/java/core/branches/1_6: ./
modules/samples/userguide/src/userguide/clients/EchoNonBlockingClient.java
modules/samples/userguide/src/userguide/clients/EchoNonBlockingDualClient.java
Author: sagara
Date: Sat Jan 14 09:05:21 2012
New Revision: 1231466
URL: http://svn.apache.org/viewvc?rev=1231466&view=rev
Log:
Merged r1231465 to the 1.6 branch.
Modified:
axis/axis2/java/core/branches/1_6/ (props changed)
axis/axis2/java/core/branches/1_6/modules/samples/userguide/src/userguide/clients/EchoNonBlockingClient.java
axis/axis2/java/core/branches/1_6/modules/samples/userguide/src/userguide/clients/EchoNonBlockingDualClient.java
Propchange: axis/axis2/java/core/branches/1_6/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Sat Jan 14 09:05:21 2012
@@ -1 +1 @@
-/axis/axis2/java/core/trunk:1068985,1069659,1069898,1070439,1072077,1072271,1072296,1072499,1072510,1075057,1078242,1081563,1081587,1081590,1082316,1082322,1082600,1082702,1082726,1082738,1083180,1083192,1083379,1083381,1083425,1083433,1083446,1084753,1085157,1085173,1085514,1085889,1085927,1085931,1087073,1088239,1088248-1088249,1088251,1088268,1088730,1088904,1089225,1089989,1090429,1090457,1091178,1091191,1094117,1096530,1096557,1099385,1099389,1100628,1101037,1103013,1103336,1103606,1103760,1128580,1128584,1128618,1128645,1130590,1131425,1134438,1134616,1136156,1136159,1136177,1137153,1137159,1138144,1138203,1139448,1139484,1147485,1149224,1149491,1149578,1150055,1154615,1156305,1156382,1157211,1157265,1157373,1157415,1157424,1157501,1157517,1157522,1157535,1157767,1163389,1166038,1166040,1166132,1167045,1174618,1184808,1184810,1184816,1185504,1190469,1190499,1195893,1195972,1195982,1198288,1201467,1201863,1201957,1202867,1203424,1205716,1205939,1208901,1209034,1213639,1
214118,1220630,1220888,1221716,1222510,1225161
+/axis/axis2/java/core/trunk:1068985,1069659,1069898,1070439,1072077,1072271,1072296,1072499,1072510,1075057,1078242,1081563,1081587,1081590,1082316,1082322,1082600,1082702,1082726,1082738,1083180,1083192,1083379,1083381,1083425,1083433,1083446,1084753,1085157,1085173,1085514,1085889,1085927,1085931,1087073,1088239,1088248-1088249,1088251,1088268,1088730,1088904,1089225,1089989,1090429,1090457,1091178,1091191,1094117,1096530,1096557,1099385,1099389,1100628,1101037,1103013,1103336,1103606,1103760,1128580,1128584,1128618,1128645,1130590,1131425,1134438,1134616,1136156,1136159,1136177,1137153,1137159,1138144,1138203,1139448,1139484,1147485,1149224,1149491,1149578,1150055,1154615,1156305,1156382,1157211,1157265,1157373,1157415,1157424,1157501,1157517,1157522,1157535,1157767,1163389,1166038,1166040,1166132,1167045,1174618,1184808,1184810,1184816,1185504,1190469,1190499,1195893,1195972,1195982,1198288,1201467,1201863,1201957,1202867,1203424,1205716,1205939,1208901,1209034,1213639,1
214118,1220630,1220888,1221716,1222510,1225161,1231465
Modified: axis/axis2/java/core/branches/1_6/modules/samples/userguide/src/userguide/clients/EchoNonBlockingClient.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/branches/1_6/modules/samples/userguide/src/userguide/clients/EchoNonBlockingClient.java?rev=1231466&r1=1231465&r2=1231466&view=diff
==============================================================================
--- axis/axis2/java/core/branches/1_6/modules/samples/userguide/src/userguide/clients/EchoNonBlockingClient.java (original)
+++ axis/axis2/java/core/branches/1_6/modules/samples/userguide/src/userguide/clients/EchoNonBlockingClient.java Sat Jan 14 09:05:21 2012
@@ -25,16 +25,15 @@ 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.client.async.AsyncResult;
-import org.apache.axis2.client.async.Callback;
+import org.apache.axis2.client.async.AxisCallback;
/**
* Sample for asynchronous single channel non-blocking service invocation.
- * Message Exchage Pattern IN-OUT
+ * Message Exchange Pattern IN-OUT
*/
public class EchoNonBlockingClient {
private static EndpointReference targetEPR = new EndpointReference("http://127.0.0.1:8080/axis2/services/MyService");
-
+
public static void main(String[] args) {
ServiceClient sender = null;
try {
@@ -43,38 +42,58 @@ public class EchoNonBlockingClient {
options.setTo(targetEPR);
options.setAction("urn:echo");
- //Callback to handle the response
- Callback callback = new Callback() {
- public void onComplete(AsyncResult result) {
- System.out.println(result.getResponseEnvelope());
- }
-
- public void onError(Exception e) {
- e.printStackTrace();
- }
- };
-
+ TestCallback axisCallback = new TestCallback("CallBack1") ;
+
//Non-Blocking Invocation
sender = new ServiceClient();
sender.setOptions(options);
- sender.sendReceiveNonBlocking(payload, callback);
-
- //Wait till the callback receives the response.
- while (!callback.isComplete()) {
- Thread.sleep(1000);
+ sender.sendReceiveNonBlocking(payload, axisCallback);
+
+ while ( ! axisCallback.isComplete( ) ) {
+ Thread.sleep(100);
}
- } catch (AxisFault axisFault) {
- axisFault.printStackTrace();
} catch (Exception ex) {
ex.printStackTrace();
} finally {
try {
sender.cleanup();
} catch (AxisFault axisFault) {
- //
+ axisFault.printStackTrace();
}
}
}
+
+ static class TestCallback implements AxisCallback {
+
+ private String name = null;
+ private boolean complete = false;
+
+ public TestCallback (String name) {
+ this.name = name;
+ }
+
+ public void onError (Exception e) {
+ e.printStackTrace();
+ }
+
+ public void onComplete() {
+ System.out.println( "Message transmission complete") ;
+ complete = true;
+ }
+
+ public boolean isComplete() {
+ return complete;
+ }
+
+ public void onMessage(org.apache.axis2.context.MessageContext arg0) {
+ System.out.println( "Call Back " + name + " got Result: " + arg0.getEnvelope() ) ;
+ }
+
+ public void onFault(org.apache.axis2.context.MessageContext arg0) {
+ System.out.println( "Call Back " + name + " got Fault: " + arg0.getEnvelope() ) ;
+ }
+ }
+
}
Modified: axis/axis2/java/core/branches/1_6/modules/samples/userguide/src/userguide/clients/EchoNonBlockingDualClient.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/branches/1_6/modules/samples/userguide/src/userguide/clients/EchoNonBlockingDualClient.java?rev=1231466&r1=1231465&r2=1231466&view=diff
==============================================================================
--- axis/axis2/java/core/branches/1_6/modules/samples/userguide/src/userguide/clients/EchoNonBlockingDualClient.java (original)
+++ axis/axis2/java/core/branches/1_6/modules/samples/userguide/src/userguide/clients/EchoNonBlockingDualClient.java Sat Jan 14 09:05:21 2012
@@ -23,13 +23,11 @@ package userguide.clients;
import org.apache.axiom.om.OMElement;
import org.apache.axis2.AxisFault;
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 javax.xml.namespace.QName;
+import org.apache.axis2.client.async.AxisCallback;
/**
* Sample for asynchronous dual channel non-blocking service invocation.
@@ -51,40 +49,59 @@ public class EchoNonBlockingDualClient {
options.setUseSeparateListener(true);
options.setAction("urn:echo"); // this is the action mapping we put within the service.xml
- //Callback to handle the response
- Callback callback = new Callback() {
- public void onComplete(AsyncResult result) {
- System.out.println(result.getResponseEnvelope());
- }
-
- public void onError(Exception e) {
- e.printStackTrace();
- }
- };
-
+ TestCallback axisCallback = new TestCallback("CallBack1") ;
+
//Non-Blocking Invocation
sender = new ServiceClient();
sender.engageModule(Constants.MODULE_ADDRESSING);
sender.setOptions(options);
- sender.sendReceiveNonBlocking(payload, callback);
+ sender.sendReceiveNonBlocking(payload, axisCallback);
//Wait till the callback receives the response.
- while (!callback.isComplete()) {
- Thread.sleep(1000);
+ while ( ! axisCallback.isComplete( ) ) {
+ Thread.sleep(100);
}
- //Need to close the Client Side Listener.
-
- } catch (AxisFault axisFault) {
- axisFault.printStackTrace();
+
} catch (Exception ex) {
ex.printStackTrace();
} finally {
try {
sender.cleanup();
} catch (AxisFault axisFault) {
- //have to ignore this
+ axisFault.printStackTrace();
}
+
}
+ }
+
+ static class TestCallback implements AxisCallback {
+ private String name = null;
+ private boolean complete = false;
+
+ public TestCallback (String name) {
+ this.name = name;
+ }
+
+ public void onError (Exception e) {
+ e.printStackTrace();
+ }
+
+ public void onComplete() {
+ System.out.println( "Message transmission complete") ;
+ complete = true;
+ }
+
+ public boolean isComplete() {
+ return complete;
+ }
+
+ public void onMessage(org.apache.axis2.context.MessageContext arg0) {
+ System.out.println( "Call Back " + name + " got Result: " + arg0.getEnvelope() ) ;
+ }
+
+ public void onFault(org.apache.axis2.context.MessageContext arg0) {
+ System.out.println( "Call Back " + name + " got Fault: " + arg0.getEnvelope() ) ;
+ }
}
}