cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bimargul...@apache.org
Subject svn commit: r678968 - in /cxf/trunk/rt/javascript/src: main/java/org/apache/cxf/javascript/service/ main/resources/org/apache/cxf/javascript/ test/java/org/apache/cxf/javascript/ test/resources/org/apache/cxf/javascript/
Date Wed, 23 Jul 2008 01:32:03 GMT
Author: bimargulies
Date: Tue Jul 22 18:32:02 2008
New Revision: 678968

URL: http://svn.apache.org/viewvc?rev=678968&view=rev
Log:
Repair CXF-1713.

Modified:
    cxf/trunk/rt/javascript/src/main/java/org/apache/cxf/javascript/service/ServiceJavascriptBuilder.java
    cxf/trunk/rt/javascript/src/main/resources/org/apache/cxf/javascript/cxf-utils.js
    cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/GreeterClientTest.java
    cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/MtoMTest.java
    cxf/trunk/rt/javascript/src/test/resources/org/apache/cxf/javascript/GreeterTests.js

Modified: cxf/trunk/rt/javascript/src/main/java/org/apache/cxf/javascript/service/ServiceJavascriptBuilder.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/javascript/src/main/java/org/apache/cxf/javascript/service/ServiceJavascriptBuilder.java?rev=678968&r1=678967&r2=678968&view=diff
==============================================================================
--- cxf/trunk/rt/javascript/src/main/java/org/apache/cxf/javascript/service/ServiceJavascriptBuilder.java
(original)
+++ cxf/trunk/rt/javascript/src/main/java/org/apache/cxf/javascript/service/ServiceJavascriptBuilder.java
Tue Jul 22 18:32:02 2008
@@ -167,10 +167,6 @@
         }
         utils.appendLine("this.client = null;");
         utils.appendLine("this.response = null;");
-        // the callback functions for a pending operation are stored in these.
-        // thus, only one pending operation at a time.
-        utils.appendLine("this._onsuccess = null;");
-        utils.appendLine("this._onerror = null;");
         generateGlobalElementDictionary();
         code.append("}\n\n");
     }
@@ -376,15 +372,17 @@
         // we need to pass the caller's callback functions to our callback
         // functions.
         if (!currentOperation.isOneWay()) {
-            utils.appendLine("this._onsuccess = successCallback;");
-            utils.appendLine("this._onerror = errorCallback;");
+            utils.appendLine("this.client.user_onsuccess = successCallback;");
+            utils.appendLine("this.client.user_onerror = errorCallback;");
             utils.appendLine("var closureThis = this;");
-            utils.appendLine("this.client.onsuccess = function(that) { closureThis." 
+            // client will pass itself and the response XML.
+            utils.appendLine("this.client.onsuccess = function(client, responseXml) { closureThis."

+                                 + opFunctionPropertyName
+                                 + "_onsuccess(client, responseXml); };");
+            // client will pass itself.
+            utils.appendLine("this.client.onerror = function(client) { closureThis."
                              + opFunctionPropertyName
-                             + "_onsuccess(that); };");
-            utils.appendLine("this.client.onerror = function(that) { closureThis."
-                             + opFunctionPropertyName
-                             + "_onerror(that); };");
+                             + "_onerror(client); };");
         }
         utils.appendLine("var requestHeaders = [];");
 
@@ -418,20 +416,20 @@
         String errorFunctionPropertyName = opFunctionPropertyName + "_onerror";
         String errorFunctionGlobalName = opFunctionGlobalName + "_onerror";
         
-        code.append("function " + errorFunctionGlobalName + "() {\n");
-        utils.startIf("this._onerror");
+        code.append("function " + errorFunctionGlobalName + "(client) {\n");
+        utils.startIf("client.user_onerror");
         // Is this a good set of parameters for the error function?
         // Not if we want to process faults, it isn't. To be revisited.
         utils.appendLine("var httpStatus;");
         utils.appendLine("var httpStatusText;");
         utils.appendLine("try {");
-        utils.appendLine(" httpStatus = this.client.req.status;");
-        utils.appendLine(" httpStatusText = this.client.req.statusText;");
+        utils.appendLine(" httpStatus = client.req.status;");
+        utils.appendLine(" httpStatusText = client.req.statusText;");
         utils.appendLine("} catch(e) {");
         utils.appendLine(" httpStatus = -1;");
         utils.appendLine(" httpStatusText = 'Error opening connection to server';");
         utils.appendLine("}");
-        utils.appendLine("this._onerror(httpStatus, httpStatusText);");
+        utils.appendLine("client.user_onerror(httpStatus, httpStatusText);");
         utils.endBlock();
         code.append("}\n\n");
         code.append(currentInterfaceClassName + ".prototype." 
@@ -449,15 +447,13 @@
         // parameters.
         String successFunctionGlobalName = opFunctionGlobalName + "_onsuccess"; 
         String successFunctionPropertyName = opFunctionPropertyName + "_onsuccess"; 
-        String arglist = "()";
+        String arglist = "(client)";
         if (nonVoidOutput) {
-            arglist = "(responseXml)";
+            arglist = "(client, responseXml)";
         }
         
         code.append("function " + successFunctionGlobalName + arglist + " {\n");
-        utils.appendLine("this.jsutils.trace('" + successFunctionGlobalName + " _onsuccess:
' " 
-                         + " + this._onsuccess);");
-        utils.startIf("this._onsuccess");
+        utils.startIf("client.user_onsuccess");
         utils.appendLine("var responseObject = null;");
         if (nonVoidOutput) {
             utils.appendLine("var element = responseXml.documentElement;");
@@ -481,7 +477,7 @@
             utils.appendLine("this.jsutils.trace('calling " + deserializerFunctionName +
"');");
             utils.appendLine("responseObject = " + deserializerFunctionName + "(this.jsutils,
element);");
         }
-        utils.appendLine("this._onsuccess(responseObject);");
+        utils.appendLine("client.user_onsuccess(responseObject);");
         utils.endBlock();
         code.append("}\n\n");
         code.append(currentInterfaceClassName + ".prototype." 

Modified: cxf/trunk/rt/javascript/src/main/resources/org/apache/cxf/javascript/cxf-utils.js
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/javascript/src/main/resources/org/apache/cxf/javascript/cxf-utils.js?rev=678968&r1=678967&r2=678968&view=diff
==============================================================================
--- cxf/trunk/rt/javascript/src/main/resources/org/apache/cxf/javascript/cxf-utils.js (original)
+++ cxf/trunk/rt/javascript/src/main/resources/org/apache/cxf/javascript/cxf-utils.js Tue
Jul 22 18:32:02 2008
@@ -859,7 +859,7 @@
 				// response.
 				if (!req.responseXML) {
 					if (this.parseMultipartRelated()) {
-						this.onsuccess(this.mpResponseXML);
+						this.onsuccess(this, this.mpResponseXML);
 						return;
 					}
 					if (this.onerror != null) {
@@ -867,7 +867,7 @@
 						return;
 					}
 				}
-				this.onsuccess(req.responseXML);
+				this.onsuccess(this, req.responseXML);
 			}
 		} else {
 			this.utils.trace("onreadystatechange DONE ERROR "

Modified: cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/GreeterClientTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/GreeterClientTest.java?rev=678968&r1=678967&r2=678968&view=diff
==============================================================================
--- cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/GreeterClientTest.java
(original)
+++ cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/GreeterClientTest.java
Tue Jul 22 18:32:02 2008
@@ -96,10 +96,12 @@
         String responseObject = testUtilities.rhinoEvaluateConvert("globalResponseObject.getResponseType()",

                                                                    String.class);
         assertEquals("Bonjour", responseObject);
+        responseObject = testUtilities.rhinoEvaluateConvert("globalSecondResponseObject.getResponseType()",

+                                                                   String.class);
+        assertEquals("Bonjour", responseObject);
         return null;
     }
     
-    @org.junit.Ignore
     @Test
     public void testRequestClosure() throws Exception {
         testUtilities.runInsideContext(Void.class, new JSRunnable<Void>() {

Modified: cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/MtoMTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/MtoMTest.java?rev=678968&r1=678967&r2=678968&view=diff
==============================================================================
--- cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/MtoMTest.java (original)
+++ cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/MtoMTest.java Tue Jul
22 18:32:02 2008
@@ -95,7 +95,6 @@
         assertNotNull(unpacked);
         return null;
     }
-
     
     @Test
     public void sendMtoMStringTest() {

Modified: cxf/trunk/rt/javascript/src/test/resources/org/apache/cxf/javascript/GreeterTests.js
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/javascript/src/test/resources/org/apache/cxf/javascript/GreeterTests.js?rev=678968&r1=678967&r2=678968&view=diff
==============================================================================
--- cxf/trunk/rt/javascript/src/test/resources/org/apache/cxf/javascript/GreeterTests.js (original)
+++ cxf/trunk/rt/javascript/src/test/resources/org/apache/cxf/javascript/GreeterTests.js Tue
Jul 22 18:32:02 2008
@@ -26,6 +26,7 @@
 var globalErrorStatus = null;
 var globalErrorStatusText = null;
 var globalResponseObject = null;
+var globalSecondResponseObject = null;
 
 function resetGlobals() {
 	globalNotifier = null;
@@ -52,10 +53,16 @@
 	globalNotifier.notify();
 }
 
-function dummy()
+function success1(responseObject)
 {
-	// for now, dummy. later, we'll want to verify correct operation
-	// of both requests.
+	globalResponseObject = responseObject;
+}
+
+
+function success2(responseObject)
+{
+	globalSecondResponseObject = responseObject;
+	globalNotifier.notify();
 }
 
 function sayHiTest(url)
@@ -83,8 +90,8 @@
     intf = new cxf_apache_org_jstest_Greeter();
 	  
 	intf.url = url;
-    intf.sayHi(testSuccessCallback, testErrorCallback);
-    intf.sayHi(null, null);
+    intf.sayHi(success1, testErrorCallback);
+    intf.sayHi(success2, testErrorCallback);
     // Return the notifier as a convenience to the Java code.
 	return globalNotifier;
 



Mime
View raw message