cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bimargul...@apache.org
Subject svn commit: r708035 - in /cxf/trunk/rt/javascript/src: main/java/org/apache/cxf/javascript/ main/java/org/apache/cxf/javascript/types/ test/java/org/apache/cxf/javascript/ test/resources/ test/resources/org/apache/cxf/javascript/
Date Sun, 26 Oct 2008 20:34:42 GMT
Author: bimargulies
Date: Sun Oct 26 13:34:42 2008
New Revision: 708035

URL: http://svn.apache.org/viewvc?rev=708035&view=rev
Log:
Incremental progress on inheritance.

Modified:
    cxf/trunk/rt/javascript/src/main/java/org/apache/cxf/javascript/XmlSchemaUtils.java
    cxf/trunk/rt/javascript/src/main/java/org/apache/cxf/javascript/types/SchemaJavascriptBuilder.java
    cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/DocLitWrappedClientTest.java
    cxf/trunk/rt/javascript/src/test/resources/DocLitWrappedClientTestBeans.xml
    cxf/trunk/rt/javascript/src/test/resources/org/apache/cxf/javascript/DocLitWrappedTests.js

Modified: cxf/trunk/rt/javascript/src/main/java/org/apache/cxf/javascript/XmlSchemaUtils.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/javascript/src/main/java/org/apache/cxf/javascript/XmlSchemaUtils.java?rev=708035&r1=708034&r2=708035&view=diff
==============================================================================
--- cxf/trunk/rt/javascript/src/main/java/org/apache/cxf/javascript/XmlSchemaUtils.java (original)
+++ cxf/trunk/rt/javascript/src/main/java/org/apache/cxf/javascript/XmlSchemaUtils.java Sun
Oct 26 13:34:42 2008
@@ -19,6 +19,8 @@
 
 package org.apache.cxf.javascript;
 
+import java.util.ArrayList;
+import java.util.List;
 import java.util.logging.Logger;
 
 import javax.xml.namespace.QName;
@@ -136,6 +138,31 @@
         return sequence;
     }
     
+    public static List<XmlSchemaObject> getContentElements(XmlSchemaComplexType type,

+                                                           SchemaCollection collection) {
+        List<XmlSchemaObject> results = new ArrayList<XmlSchemaObject>();
+        QName baseTypeName = getBaseType(type);
+        if (baseTypeName != null) {
+            XmlSchemaComplexType baseType = (XmlSchemaComplexType)collection.getTypeByQName(baseTypeName);
+            // recurse onto the base type ...
+            results.addAll(getContentElements(baseType, collection));
+            // and now process our sequence.
+            XmlSchemaSequence extSequence = getContentSequence(type);
+            for (int i = 0; i < extSequence.getItems().getCount(); i++) {
+                results.add(extSequence.getItems().getItem(i));
+            }
+            return results;
+        } else {
+            // no base type, the simple case.
+            XmlSchemaSequence sequence = getSequence(type);
+            for (int i = 0; i < sequence.getItems().getCount(); i++) {
+                results.add(sequence.getItems().getItem(i));
+            }
+            return results;
+        }
+
+    }
+    
     public static XmlSchemaSequence getSequence(XmlSchemaComplexType type) {
         XmlSchemaParticle particle = type.getParticle();
         XmlSchemaSequence sequence = null;

Modified: cxf/trunk/rt/javascript/src/main/java/org/apache/cxf/javascript/types/SchemaJavascriptBuilder.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/javascript/src/main/java/org/apache/cxf/javascript/types/SchemaJavascriptBuilder.java?rev=708035&r1=708034&r2=708035&view=diff
==============================================================================
--- cxf/trunk/rt/javascript/src/main/java/org/apache/cxf/javascript/types/SchemaJavascriptBuilder.java
(original)
+++ cxf/trunk/rt/javascript/src/main/java/org/apache/cxf/javascript/types/SchemaJavascriptBuilder.java
Sun Oct 26 13:34:42 2008
@@ -179,7 +179,7 @@
     public void complexTypeConstructorAndAccessors(QName name, XmlSchemaComplexType type)
{
         accessors = new StringBuilder();
         utils = new JavascriptUtils(code);
-        XmlSchemaSequence sequence = XmlSchemaUtils.getSequence(type);
+        List<XmlSchemaObject> items = XmlSchemaUtils.getContentElements(type, xmlSchemaCollection);
 
         final String elementPrefix = "this._";
 
@@ -190,16 +190,14 @@
         code.append("function " + typeObjectName + " () {\n");
         // to assist in debugging we put a type property into every object.
         utils.appendLine("this.typeMarker = '" + typeObjectName + "';");
-        for (int i = 0; i < sequence.getItems().getCount(); i++) {
-            XmlSchemaObject thing = sequence.getItems().getItem(i);
-            constructOneElement(type, sequence, elementPrefix, typeObjectName, thing);
+        for (XmlSchemaObject thing : items) {
+            constructOneElement(type, elementPrefix, typeObjectName, thing);
         }
         code.append("}\n\n");
         code.append(accessors.toString());
     }
 
     private void constructOneElement(XmlSchemaComplexType type, 
-                                     XmlSchemaSequence sequence,
                                      final String elementPrefix, 
                                      String typeObjectName, 
                                      XmlSchemaObject thing) {
@@ -347,23 +345,8 @@
      */
     protected void complexTypeSerializerBody(XmlSchemaComplexType type, String elementPrefix,
                                              JavascriptUtils bodyUtils) {
-        XmlSchemaSequence sequence = null;
-        // deal with type extension.
-        QName baseTypeName = XmlSchemaUtils.getBaseType(type);
-        if (baseTypeName !=  null) {
-            XmlSchemaType baseType = xmlSchemaCollection.getTypeByQName(baseTypeName);
-            XmlSchemaComplexType baseComplexType = (XmlSchemaComplexType) baseType;
-            // I think we can recurse ...?
-            complexTypeSerializerBody(baseComplexType, elementPrefix, bodyUtils);
-            sequence = XmlSchemaUtils.getContentSequence(type);
-        }
-
-        if (sequence == null) {
-            sequence = XmlSchemaUtils.getSequence(type);
-        }
-
-        for (int i = 0; i < sequence.getItems().getCount(); i++) {
-            XmlSchemaObject sequenceItem = (XmlSchemaObject)sequence.getItems().getItem(i);
+        List<XmlSchemaObject> items = XmlSchemaUtils.getContentElements(type, xmlSchemaCollection);
+        for (XmlSchemaObject sequenceItem : items) {
             ParticleInfo itemInfo = ParticleInfo.forLocalItem(sequenceItem, 
                                                               schemaInfo.getSchema(), 
                                                               xmlSchemaCollection, 

Modified: cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/DocLitWrappedClientTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/DocLitWrappedClientTest.java?rev=708035&r1=708034&r2=708035&view=diff
==============================================================================
--- cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/DocLitWrappedClientTest.java
(original)
+++ cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/DocLitWrappedClientTest.java
Sun Oct 26 13:34:42 2008
@@ -242,7 +242,6 @@
             
         });
     }
-
     
     @Test
     public void callTest2WithNullString() {

Modified: cxf/trunk/rt/javascript/src/test/resources/DocLitWrappedClientTestBeans.xml
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/javascript/src/test/resources/DocLitWrappedClientTestBeans.xml?rev=708035&r1=708034&r2=708035&view=diff
==============================================================================
--- cxf/trunk/rt/javascript/src/test/resources/DocLitWrappedClientTestBeans.xml (original)
+++ cxf/trunk/rt/javascript/src/test/resources/DocLitWrappedClientTestBeans.xml Sun Oct 26
13:34:42 2008
@@ -30,6 +30,7 @@
   <import resource="classpath:META-INF/cxf/cxf-extension-soap.xml" />
   <import resource="classpath:META-INF/cxf/cxf-extension-http.xml" />
   <import resource="classpath:META-INF/cxf/cxf-extension-http-jetty.xml" />
+  <import resource="classpath:META-INF/cxf/cxf-extension-javascript-client.xml" />
   
   <jaxws:server id="dlw-service-endpoint" 
     address="http://localhost:8808/SimpleDocLitWrapped" >

Modified: cxf/trunk/rt/javascript/src/test/resources/org/apache/cxf/javascript/DocLitWrappedTests.js
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/javascript/src/test/resources/org/apache/cxf/javascript/DocLitWrappedTests.js?rev=708035&r1=708034&r2=708035&view=diff
==============================================================================
--- cxf/trunk/rt/javascript/src/test/resources/org/apache/cxf/javascript/DocLitWrappedTests.js
(original)
+++ cxf/trunk/rt/javascript/src/test/resources/org/apache/cxf/javascript/DocLitWrappedTests.js
Sun Oct 26 13:34:42 2008
@@ -115,4 +115,23 @@
 	  intf.beanFunction(test1SuccessCallback, test1ErrorCallback, beanArg, beansArg); 
     // Return the notifier as a convenience to the Java code.
 	return globalNotifier;
+}
+
+function testInheritance(url) {
+	org_apache_cxf_trace.trace("inheritance test.");
+	resetGlobals();
+	globalNotifier = new org_apache_cxf_notifier();
+	
+	var intf;
+	
+    intf = new org_apache_cxf_javascript_fortest_SimpleDocLitWrapped();
+	intf.url = url;
+
+	var derived = new org_apache_cxf_javascript_testns_inheritanceTestDerived();
+	derived.setId(33);
+	derived.setDerived("arrived");
+	derived.setName("less");
+	intf.inheritanceTestFunction(derived);
+
+	return globalNotifier;
 }
\ No newline at end of file



Mime
View raw message