cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bimargul...@apache.org
Subject svn commit: r606655 - in /incubator/cxf/trunk/rt/javascript/src: main/java/org/apache/cxf/javascript/types/ main/resources/org/apache/cxf/javascript/ test/java/org/apache/cxf/javascript/ test/resources/ test/resources/org/apache/cxf/javascript/
Date Mon, 24 Dec 2007 01:40:25 GMT
Author: bimargulies
Date: Sun Dec 23 17:40:23 2007
New Revision: 606655

URL: http://svn.apache.org/viewvc?rev=606655&view=rev
Log:
xs:any in both directions.

Added:
    incubator/cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/JsNamedNodeMap.java
  (with props)
Modified:
    incubator/cxf/trunk/rt/javascript/src/main/java/org/apache/cxf/javascript/types/SchemaJavascriptBuilder.java
    incubator/cxf/trunk/rt/javascript/src/main/resources/org/apache/cxf/javascript/cxf-utils.js
    incubator/cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/AnyTest.java
    incubator/cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/JavascriptTestUtilities.java
    incubator/cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/JsSimpleDomNode.java
    incubator/cxf/trunk/rt/javascript/src/test/resources/logging.properties
    incubator/cxf/trunk/rt/javascript/src/test/resources/org/apache/cxf/javascript/AnyTests.js

Modified: incubator/cxf/trunk/rt/javascript/src/main/java/org/apache/cxf/javascript/types/SchemaJavascriptBuilder.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/javascript/src/main/java/org/apache/cxf/javascript/types/SchemaJavascriptBuilder.java?rev=606655&r1=606654&r2=606655&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/javascript/src/main/java/org/apache/cxf/javascript/types/SchemaJavascriptBuilder.java
(original)
+++ incubator/cxf/trunk/rt/javascript/src/main/java/org/apache/cxf/javascript/types/SchemaJavascriptBuilder.java
Sun Dec 23 17:40:23 2007
@@ -476,7 +476,7 @@
                          + matchType
                          + ", '" + schemaInfo.getNamespaceURI() + "'"
                          + ", " + namespaceList
-                         + ", " + nextElement.getQName().getLocalPart()
+                         + ", '" + nextElement.getQName().getLocalPart() + "'"
                          + ");");
         
         if (array) {
@@ -499,12 +499,17 @@
         
         utils.appendLine("anyURI = cxfjsutils.getElementNamespaceURI(curElement);");
         utils.appendLine("anyLocalPart = cxfjsutils.getNodeLocalName(curElement);");
+        utils.appendLine("var anyQName = '{' + anyURI + '}' + anyLocalPart;");
+        utils.appendLine("cxfjsutils.trace('any match: ' + anyQName);"); 
         utils.appendLine("anyMatched = matcher.match(anyURI, anyLocalPart)");
+        utils.appendLine("cxfjsutils.trace(' --> ' + anyMatched);"); 
+
         utils.endBlock(); // curElement != null
         
         utils.startIf("anyMatched"); // if match
         utils.appendLine("anyDeserializer = "
-                         + "cxfjsutils.interfaceObject.globalElementDeserializers[anyURI];");
+                         + "cxfjsutils.interfaceObject.globalElementDeserializers[anyQName];");
+        utils.appendLine("cxfjsutils.trace(' deserializer: ' + anyDeserializer);");
         utils.startIf("anyDeserializer"); // if complex/serializer function
         utils.appendLine("var anyValue = anyDeserializer(cxfjsutils, curElement);");
         utils.appendElse(); // else complex/serializer function
@@ -530,8 +535,8 @@
         utils.endBlock(); // match/non-match.
         utils.endBlock(); // while
 
-        utils.appendLine("var anyHolder = new org_apache_cxf_any_holder(anyURI, anyObject);");
-        utils.appendLine("this._" + itemInfo.getJavascriptName() + " = anyHolder;");
+        utils.appendLine("var anyHolder = new org_apache_cxf_any_holder(anyURI, anyLocalPart,
anyValue);");
+        utils.appendLine("newobject.setAny(anyHolder);");
     }
 
     private void deserializeElement(XmlSchemaComplexType type, XmlSchemaObject thing) {

Modified: incubator/cxf/trunk/rt/javascript/src/main/resources/org/apache/cxf/javascript/cxf-utils.js
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/javascript/src/main/resources/org/apache/cxf/javascript/cxf-utils.js?rev=606655&r1=606654&r2=606655&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/javascript/src/main/resources/org/apache/cxf/javascript/cxf-utils.js
(original)
+++ incubator/cxf/trunk/rt/javascript/src/main/resources/org/apache/cxf/javascript/cxf-utils.js
Sun Dec 23 17:40:23 2007
@@ -71,6 +71,7 @@
     var attributes = elementNode.attributes;
     if ((attributes!=null) && (attributes.length > 0)) {
         for (var x=0; x<attributes.length; x++) {
+            var attributeNodeName = attributes.item(x).nodeName;
             var attributeNamespacePrefix = org_apache_cxf_getPrefix(attributes.item(x).nodeName);
             var attributeNamespaceSuffix = org_apache_cxf_getLocalName(attributes.item(x).nodeName);
 
@@ -88,8 +89,8 @@
 
 function org_apache_cxf_get_node_namespaceURI(elementNode) 
 {
-	var prefix = org_apache_cxf_get_prefix(elementNode.nodeName);
-	return org_apache_cxf_geNamespaceURI(elementNode, prefix);
+	var prefix = org_apache_cxf_getPrefix(elementNode.nodeName);
+	return org_apache_cxf_getNamespaceURI(elementNode, prefix);
 }
 
 CxfApacheOrgUtil.prototype.getElementNamespaceURI = org_apache_cxf_get_node_namespaceURI;
@@ -109,7 +110,7 @@
 
 function org_apache_cxf_any_ns_matcher_match(namespaceURI, localName)
 {
-	switch(style) {
+	switch(this.style) {
 		// should this match local elements?
 		case org_apache_cxf_any_ns_matcher.ANY:
 			return true;
@@ -134,11 +135,6 @@
 }
 
 org_apache_cxf_any_ns_matcher.prototype.match = org_apache_cxf_any_ns_matcher_match; 
-
-
-
-
-
 
 function org_apache_cxf_getPrefix(tagName)
 {

Modified: incubator/cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/AnyTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/AnyTest.java?rev=606655&r1=606654&r2=606655&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/AnyTest.java
(original)
+++ incubator/cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/AnyTest.java
Sun Dec 23 17:40:23 2007
@@ -23,6 +23,7 @@
 
 import org.apache.cxf.common.logging.LogUtils;
 import org.apache.cxf.javascript.JavascriptTestUtilities.JSRunnable;
+import org.apache.cxf.javascript.JavascriptTestUtilities.Notifier;
 import org.apache.cxf.javascript.fortest.AnyImpl;
 import org.junit.Before;
 import org.junit.Test;
@@ -82,6 +83,33 @@
         testUtilities.runInsideContext(Void.class, new JSRunnable<Void>() {
             public Void run(Context context) {
                 return acceptOneChalk(context);
+            }
+        });
+    }
+    
+    private Void returnAny1(Context context) {
+        Notifier notifier = 
+            testUtilities.rhinoCallConvert("testAny1ToClientChalk", Notifier.class, 
+                                           testUtilities.javaToJS(endpoint.getAddress()));
+        
+        boolean notified = notifier.waitForJavascript(1000 * 10);
+        assertTrue(notified);
+        Integer errorStatus = testUtilities.rhinoEvaluateConvert("globalErrorStatus", Integer.class);
+        assertNull(errorStatus);
+        String errorText = testUtilities.rhinoEvaluateConvert("globalErrorStatusText", String.class);
+        assertNull(errorText);
+
+        //This method returns a String
+        String chalk = (String)testUtilities.rhinoEvaluate("globalResponseObject._any.object._chalk");
+        assertEquals("dover", chalk);
+        return null;
+    }
+    
+    @Test
+    public void callReturnAny1() throws Exception {
+        testUtilities.runInsideContext(Void.class, new JSRunnable<Void>() {
+            public Void run(Context context) {
+                return returnAny1(context);
             }
         });
     }

Modified: incubator/cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/JavascriptTestUtilities.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/JavascriptTestUtilities.java?rev=606655&r1=606654&r2=606655&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/JavascriptTestUtilities.java
(original)
+++ incubator/cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/JavascriptTestUtilities.java
Sun Dec 23 17:40:23 2007
@@ -154,6 +154,7 @@
         }
         JsSimpleDomNode.register(rhinoScope);
         JsSimpleDomParser.register(rhinoScope);
+        JsNamedNodeMap.register(rhinoScope);
         JsXMLHttpRequest.register(rhinoScope);
     }
 

Added: incubator/cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/JsNamedNodeMap.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/JsNamedNodeMap.java?rev=606655&view=auto
==============================================================================
--- incubator/cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/JsNamedNodeMap.java
(added)
+++ incubator/cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/JsNamedNodeMap.java
Sun Dec 23 17:40:23 2007
@@ -0,0 +1,102 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.cxf.javascript;
+
+import java.lang.reflect.InvocationTargetException;
+
+import org.w3c.dom.NamedNodeMap;
+
+import org.mozilla.javascript.Context;
+import org.mozilla.javascript.Scriptable;
+import org.mozilla.javascript.ScriptableObject;
+
+/**
+ * 
+ */
+public class JsNamedNodeMap extends ScriptableObject {
+    
+    private NamedNodeMap wrappedMap;
+    
+    public JsNamedNodeMap() {
+        // just to make Rhino happy.
+    }
+    
+    @Override
+    public String getClassName() {
+        return "NamedNodeMap";
+    }
+    
+    public static void register(ScriptableObject scope) {
+        try {
+            ScriptableObject.defineClass(scope, JsNamedNodeMap.class);
+        } catch (IllegalAccessException e) {
+            throw new RuntimeException(e);
+        } catch (InstantiationException e) {
+            throw new RuntimeException(e);
+        } catch (InvocationTargetException e) {
+            throw new RuntimeException(e);
+        }
+    }
+
+    /** * @return Returns the wrappedMap.
+     */
+    public NamedNodeMap getWrappedMap() {
+        return wrappedMap;
+    }
+
+    /**
+     * @param wrappedMap The wrappedMap to set.
+     */
+    public void setWrappedMap(NamedNodeMap wrappedMap) {
+        this.wrappedMap = wrappedMap;
+    }
+    
+    // Rhino won't let us use a constructor.
+    void initialize(NamedNodeMap map) {
+        wrappedMap = map;
+    }
+    
+    public static JsNamedNodeMap wrapMap(Scriptable scope, NamedNodeMap map) {
+        Context cx = Context.enter();
+        JsNamedNodeMap newObject = (JsNamedNodeMap)cx.newObject(scope, "NamedNodeMap");
+        newObject.initialize(map);
+        return newObject;
+    }
+
+    // CHECKSTYLE:OFF
+    
+    public int jsGet_length() {
+        return wrappedMap.getLength();
+    }
+    
+    public Object jsFunction_getNamedItem(String name) {
+        return JsSimpleDomNode.wrapNode(getParentScope(), wrappedMap.getNamedItem(name));
+    }
+    
+    public Object jsFunction_getNamedItemNS(String uri, String local) {
+        return JsSimpleDomNode.wrapNode(getParentScope(), wrappedMap.getNamedItemNS(uri,
local));
+    }
+
+    public Object jsFunction_item(int index) {
+        return JsSimpleDomNode.wrapNode(getParentScope(), wrappedMap.item(index));
+    }
+    
+    // don't implement the 'modify' APIs.
+}

Propchange: incubator/cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/JsNamedNodeMap.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/JsNamedNodeMap.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: incubator/cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/JsSimpleDomNode.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/JsSimpleDomNode.java?rev=606655&r1=606654&r2=606655&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/JsSimpleDomNode.java
(original)
+++ incubator/cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/JsSimpleDomNode.java
Sun Dec 23 17:40:23 2007
@@ -36,9 +36,11 @@
 public class JsSimpleDomNode extends ScriptableObject {
     private Node wrappedNode;
     private boolean childrenWrapped;
+    private boolean attributesWrapped;
     private JsSimpleDomNode previousSibling;
     private JsSimpleDomNode nextSibling;
     private JsSimpleDomNode[] children;
+    private JsNamedNodeMap attributes;
 
     /**
      * Only exists to make Rhino happy. Should never be used.
@@ -92,6 +94,11 @@
         return previousSibling; 
     }
     
+    public Object jsGet_parentNode() {
+        // risk errors in object equality ...
+        return wrapNode(this, wrappedNode.getParentNode());
+    }
+    
     public int jsGet_nodeType() {
         return wrappedNode.getNodeType();
     }
@@ -100,6 +107,10 @@
         return wrappedNode.getNodeValue();
     }
     
+    public String jsGet_nodeName() {
+        return wrappedNode.getNodeName();
+    }
+    
     // in a more complete version of this, we'd use a different object type to wrap documents.
     public Object jsGet_documentElement() {
         if(9 /* Document */ != wrappedNode.getNodeType()) {
@@ -115,6 +126,11 @@
         return children;
     }
     
+    public Object jsGet_attributes() {
+        establishAttributes();
+        return attributes;
+    }
+    
     public String jsFunction_getAttributeNS(String namespaceURI, String localName) {
         NamedNodeMap attributes = wrappedNode.getAttributes();
         Node attrNode = attributes.getNamedItemNS(namespaceURI, localName);
@@ -140,6 +156,10 @@
     //CHECKSTYLE:ON
     
     public static JsSimpleDomNode wrapNode(Scriptable scope, Node node) {
+        if (node == null) {
+            return null;
+        }
+        
         Context cx = Context.enter();
         JsSimpleDomNode newObject = (JsSimpleDomNode)cx.newObject(scope, "Node");
         newObject.initialize(node, null);
@@ -172,6 +192,14 @@
                 children = new JsSimpleDomNode[0];
             }
             childrenWrapped = true;
+        }
+    }
+    
+    private void establishAttributes() {
+        if (!attributesWrapped) {
+            NamedNodeMap nodeAttributes = wrappedNode.getAttributes();
+            attributes = JsNamedNodeMap.wrapMap(getParentScope(), nodeAttributes);
+            attributesWrapped = true;
         }
     }
 

Modified: incubator/cxf/trunk/rt/javascript/src/test/resources/logging.properties
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/javascript/src/test/resources/logging.properties?rev=606655&r1=606654&r2=606655&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/javascript/src/test/resources/logging.properties (original)
+++ incubator/cxf/trunk/rt/javascript/src/test/resources/logging.properties Sun Dec 23 17:40:23
2007
@@ -23,7 +23,7 @@
 .level= INFO
 java.util.logging.ConsoleHandler.level = FINEST
 java.util.logging.ConsoleHandler.formatter = java.util.logging.SimpleFormatter
-#org.apache.cxf.javascript.JavascriptTestUtilities.level=FINEST
+#org.apache.cxf.javascript.JavascriptTestUtilities.level=FINE
 
 
 

Modified: incubator/cxf/trunk/rt/javascript/src/test/resources/org/apache/cxf/javascript/AnyTests.js
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/javascript/src/test/resources/org/apache/cxf/javascript/AnyTests.js?rev=606655&r1=606654&r2=606655&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/javascript/src/test/resources/org/apache/cxf/javascript/AnyTests.js
(original)
+++ incubator/cxf/trunk/rt/javascript/src/test/resources/org/apache/cxf/javascript/AnyTests.js
Sun Dec 23 17:40:23 2007
@@ -48,3 +48,30 @@
 	service.acceptAny1(param);
 }
 
+function errorCallback(httpStatus, httpStatusText) 
+{
+    org_apache_cxf_trace.trace("error");
+	globalErrorStatus = httpStatus;
+	globalStatusText = httpStatusText;
+	globalNotifier.notify();
+}
+
+function any1ToClientSuccessCallback(responseObject) 
+{
+    org_apache_cxf_trace.trace("any1ToClient success");
+	globalResponseObject = responseObject;
+	globalNotifier.notify();
+}
+
+function testAny1ToClientChalk(url)
+{
+	resetGlobals();
+	globalNotifier = new org_apache_cxf_notifier();
+	var service = new cxf_apache_org_jstest_any_AcceptAny();
+	service.url = url;
+	
+	var dummyParam = new cxf_apache_org_jstest_types_any_returnAny1();
+	service.url = url;
+	service.returnAny1(any1ToClientSuccessCallback, errorCallback, dummyParam);
+	return globalNotifier; 
+}
\ No newline at end of file



Mime
View raw message