cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bimargul...@apache.org
Subject svn commit: r602138 - in /incubator/cxf/trunk: api/src/main/java/org/apache/cxf/tools/common/ rt/javascript/src/main/java/org/apache/cxf/javascript/types/ tools/common/src/main/java/org/apache/cxf/tools/common/ tools/wsdlto/ tools/wsdlto/frontend/javas...
Date Fri, 07 Dec 2007 16:14:38 GMT
Author: bimargulies
Date: Fri Dec  7 08:14:37 2007
New Revision: 602138

URL: http://svn.apache.org/viewvc?rev=602138&view=rev
Log:
wsdl2js insides working to a first cut.

Added:
    incubator/cxf/trunk/tools/wsdlto/frontend/javascript/src/main/java/org/apache/cxf/tools/wsdlto/javascript/Messages.properties
  (with props)
    incubator/cxf/trunk/tools/wsdlto/frontend/javascript/src/test/resources/org/apache/cxf/tools/wsdlto/javascript/hello_world.wsdl
      - copied unchanged from r602118, incubator/cxf/trunk/tools/wsdlto/frontend/javascript/src/test/java/org/apache/cxf/tools/wsdlto/javascript/hello_world.wsdl
Removed:
    incubator/cxf/trunk/tools/wsdlto/frontend/javascript/src/test/java/org/apache/cxf/tools/wsdlto/javascript/hello_world.wsdl
Modified:
    incubator/cxf/trunk/api/src/main/java/org/apache/cxf/tools/common/ToolConstants.java
    incubator/cxf/trunk/rt/javascript/src/main/java/org/apache/cxf/javascript/types/SchemaJavascriptBuilder.java
    incubator/cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/common/ToolContext.java
    incubator/cxf/trunk/tools/wsdlto/frontend/javascript/pom.xml
    incubator/cxf/trunk/tools/wsdlto/frontend/javascript/src/main/java/org/apache/cxf/tools/wsdlto/javascript/JavaScriptContainer.java
    incubator/cxf/trunk/tools/wsdlto/frontend/javascript/src/main/java/org/apache/cxf/tools/wsdlto/javascript/WSDLToJavaScriptProcessor.java
    incubator/cxf/trunk/tools/wsdlto/frontend/javascript/src/main/java/org/apache/cxf/tools/wsdlto/javascript/javascript-toolspec.xml
    incubator/cxf/trunk/tools/wsdlto/frontend/javascript/src/test/java/org/apache/cxf/tools/wsdlto/javascript/WSDLToJavaScriptTest.java
    incubator/cxf/trunk/tools/wsdlto/pom.xml

Modified: incubator/cxf/trunk/api/src/main/java/org/apache/cxf/tools/common/ToolConstants.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/api/src/main/java/org/apache/cxf/tools/common/ToolConstants.java?rev=602138&r1=602137&r2=602138&view=diff
==============================================================================
--- incubator/cxf/trunk/api/src/main/java/org/apache/cxf/tools/common/ToolConstants.java (original)
+++ incubator/cxf/trunk/api/src/main/java/org/apache/cxf/tools/common/ToolConstants.java Fri
Dec  7 08:14:37 2007
@@ -49,6 +49,7 @@
     public static final String CFG_ALL = "all";
     public static final String CFG_IMPL = "impl";
     public static final String CFG_PACKAGENAME = "packagename";
+    public static final String CFG_JSPACKAGEPREFIX = "jspackageprefix";
     public static final String CFG_NINCLUDE = "ninclude";
     public static final String CFG_NEXCLUDE = "nexclude";
     public static final String CFG_CMD_ARG = "args";
@@ -238,4 +239,5 @@
 
     public static final String CLIENT_CLASS = "clientClass";
     public static final String SERVER_CLASS = "serverClass";
+    public static final String CFG_JSPREFIXMAP = "javascriptPrefixMap";
 }

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=602138&r1=602137&r2=602138&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
Fri Dec  7 08:14:37 2007
@@ -106,7 +106,7 @@
             if (xmlSchemaObject instanceof XmlSchemaElement) { // the alternative is too
wierd to contemplate.
                 try {
                     XmlSchemaElement element = (XmlSchemaElement)xmlSchemaObject;
-                    if (element.getSchemaTypeName() == null) {
+                    if (element.getSchemaTypeName() == null && element.getSchemaType()
== null) {
                         Message message = new Message("ELEMENT_MISSING_TYPE", LOG, 
                                                       element.getQName(),
                                                       element.getSchemaTypeName(),
@@ -114,7 +114,12 @@
                         LOG.warning(message.toString());
                         continue;
                     }
-                    XmlSchemaType type = schema.getSchema().getTypeByName(element.getSchemaTypeName());
+                    XmlSchemaType type;
+                    if (element.getSchemaType() != null) {
+                        type = element.getSchemaType();
+                    } else {
+                        type = schema.getSchema().getTypeByName(element.getSchemaTypeName());
+                    }
                     if (!(xmlSchemaObject instanceof XmlSchemaComplexType)) { 
                         // we never make classes for simple type.
                         continue;

Modified: incubator/cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/common/ToolContext.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/common/ToolContext.java?rev=602138&r1=602137&r2=602138&view=diff
==============================================================================
--- incubator/cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/common/ToolContext.java
(original)
+++ incubator/cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/common/ToolContext.java
Fri Dec  7 08:14:37 2007
@@ -104,6 +104,21 @@
             return get(key);
         }
     }
+    
+    /**
+     * avoid need to suppress warnings on string->object cases.
+     * @param <T>
+     * @param key
+     * @param clazz
+     * @return
+     */
+    public <T> T get(String key, Class<T> clazz) {
+        return clazz.cast(get(key));
+    }
+
+    public <T> T get(String key, Class<T> clazz, Object defaultValue) {
+        return clazz.cast(get(key, defaultValue));
+    }
 
     public <T> T get(Class<T> key) {
         return key.cast(get(key.getName()));

Modified: incubator/cxf/trunk/tools/wsdlto/frontend/javascript/pom.xml
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/wsdlto/frontend/javascript/pom.xml?rev=602138&r1=602137&r2=602138&view=diff
==============================================================================
--- incubator/cxf/trunk/tools/wsdlto/frontend/javascript/pom.xml (original)
+++ incubator/cxf/trunk/tools/wsdlto/frontend/javascript/pom.xml Fri Dec  7 08:14:37 2007
@@ -64,6 +64,12 @@
 
         <dependency>
             <groupId>org.apache.cxf</groupId>
+            <artifactId>cxf-tools-wsdlto-frontend-jaxws</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.cxf</groupId>
             <artifactId>cxf-rt-javascript</artifactId>
             <version>${project.version}</version>
         </dependency>

Modified: incubator/cxf/trunk/tools/wsdlto/frontend/javascript/src/main/java/org/apache/cxf/tools/wsdlto/javascript/JavaScriptContainer.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/wsdlto/frontend/javascript/src/main/java/org/apache/cxf/tools/wsdlto/javascript/JavaScriptContainer.java?rev=602138&r1=602137&r2=602138&view=diff
==============================================================================
--- incubator/cxf/trunk/tools/wsdlto/frontend/javascript/src/main/java/org/apache/cxf/tools/wsdlto/javascript/JavaScriptContainer.java
(original)
+++ incubator/cxf/trunk/tools/wsdlto/frontend/javascript/src/main/java/org/apache/cxf/tools/wsdlto/javascript/JavaScriptContainer.java
Fri Dec  7 08:14:37 2007
@@ -140,7 +140,9 @@
                     if (sysId == null) {
                         sysId = serviceInfo.getTargetNamespace();
                     }
-                    schemas.put(sysId, schemaInfo.getElement());
+                    if (sysId != null) {
+                        schemas.put(sysId, schemaInfo.getElement());
+                    }
                 }
                 if (schemaInfo.getElement() != null && schemaInfo.getSystemId() !=
null) {
                     schemas.put(schemaInfo.getSystemId(), schemaInfo.getElement());
@@ -189,8 +191,9 @@
             try {
                 pns = (String[])env.get(ToolConstants.CFG_JSPACKAGEPREFIX);
             } catch (ClassCastException e) {
-                pns = new String[1];
-                pns[0] = (String)env.get(ToolConstants.CFG_JSPACKAGEPREFIX);
+                Message msg = new Message("INVALID_PREFIX_MAPPING", LOG, 
+                                          env.get(ToolConstants.CFG_JSPACKAGEPREFIX));
+                throw new ToolException(msg);
             }
             for (int j = 0; j < pns.length; j++) {
                 int pos = pns[j].indexOf("=");
@@ -199,8 +202,6 @@
                     String ns = pns[j].substring(0, pos);
                     jsprefix = pns[j].substring(pos + 1);
                     nsPrefixMap.put(ns, jsprefix);
-                } else {
-                    nsPrefixMap.put("&tns&", jsprefix);
                 }
             }
             env.put(ToolConstants.CFG_JSPREFIXMAP, nsPrefixMap);
@@ -264,11 +265,6 @@
 
         if (context.get(ToolConstants.CFG_OUTPUTDIR) == null) {
             context.put(ToolConstants.CFG_OUTPUTDIR, ".");
-        }
-
-        if (context.containsKey(ToolConstants.CFG_ANT)) {
-            setAntProperties(context);
-            setLibraryReferences(context);
         }
 
         if (!context.containsKey(ToolConstants.CFG_WSDL_VERSION)) {

Added: incubator/cxf/trunk/tools/wsdlto/frontend/javascript/src/main/java/org/apache/cxf/tools/wsdlto/javascript/Messages.properties
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/wsdlto/frontend/javascript/src/main/java/org/apache/cxf/tools/wsdlto/javascript/Messages.properties?rev=602138&view=auto
==============================================================================
--- incubator/cxf/trunk/tools/wsdlto/frontend/javascript/src/main/java/org/apache/cxf/tools/wsdlto/javascript/Messages.properties
(added)
+++ incubator/cxf/trunk/tools/wsdlto/frontend/javascript/src/main/java/org/apache/cxf/tools/wsdlto/javascript/Messages.properties
Fri Dec  7 08:14:37 2007
@@ -0,0 +1,22 @@
+#
+#
+#    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.
+#
+#
+
+INVALID_PREFIX_MAPPING= JavaScript prefix mapping {0} was not of the form URI=prefix.

Propchange: incubator/cxf/trunk/tools/wsdlto/frontend/javascript/src/main/java/org/apache/cxf/tools/wsdlto/javascript/Messages.properties
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/cxf/trunk/tools/wsdlto/frontend/javascript/src/main/java/org/apache/cxf/tools/wsdlto/javascript/Messages.properties
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Propchange: incubator/cxf/trunk/tools/wsdlto/frontend/javascript/src/main/java/org/apache/cxf/tools/wsdlto/javascript/Messages.properties
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: incubator/cxf/trunk/tools/wsdlto/frontend/javascript/src/main/java/org/apache/cxf/tools/wsdlto/javascript/WSDLToJavaScriptProcessor.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/wsdlto/frontend/javascript/src/main/java/org/apache/cxf/tools/wsdlto/javascript/WSDLToJavaScriptProcessor.java?rev=602138&r1=602137&r2=602138&view=diff
==============================================================================
--- incubator/cxf/trunk/tools/wsdlto/frontend/javascript/src/main/java/org/apache/cxf/tools/wsdlto/javascript/WSDLToJavaScriptProcessor.java
(original)
+++ incubator/cxf/trunk/tools/wsdlto/frontend/javascript/src/main/java/org/apache/cxf/tools/wsdlto/javascript/WSDLToJavaScriptProcessor.java
Fri Dec  7 08:14:37 2007
@@ -29,6 +29,7 @@
 import java.nio.charset.Charset;
 import java.util.Collection;
 
+import org.apache.cxf.common.i18n.Message;
 import org.apache.cxf.javascript.BasicNameManager;
 import org.apache.cxf.javascript.JavascriptQueryHandler;
 import org.apache.cxf.javascript.NamespacePrefixAccumulator;
@@ -48,8 +49,7 @@
 
         ServiceInfo serviceInfo = context.get(ServiceInfo.class);
 
-        //File jsFile = getOutputFile(builder.getOutputFile(), serviceInfo.getName().getLocalPart()
+ ".js");
-        File jsFile = null;
+        File jsFile = getOutputFile(serviceInfo.getName().getLocalPart() + ".js");
 
         BasicNameManager nameManager = new BasicNameManager(serviceInfo, null);
         NamespacePrefixAccumulator prefixManager = new NamespacePrefixAccumulator(serviceInfo
@@ -83,6 +83,28 @@
         } catch (IOException e) {
             throw new ToolException(e);
         }
+    }
+    
+    private File getOutputFile(String defaultOutputFile) {
+        String output = (String)context.get(ToolConstants.CFG_OUTPUTFILE);
+        String dir = (String)context.get(ToolConstants.CFG_OUTPUTDIR);
+        if (dir == null) {
+            dir = "./";
+        }
 
+        File result;
+        if (output != null) {
+            result = new File(output);
+            if (!result.isAbsolute()) {
+                result = new File(new File(dir), output);
+            }
+        } else {
+            result = new File(new File(dir), defaultOutputFile);
+        }
+        // rename the exising js
+        if (result.exists() && !result.renameTo(new File(result.getParent(), result.getName())))
{
+            throw new ToolException(new Message("OUTFILE_EXISTS", LOG));
+        }
+        return result;
     }
 }

Modified: incubator/cxf/trunk/tools/wsdlto/frontend/javascript/src/main/java/org/apache/cxf/tools/wsdlto/javascript/javascript-toolspec.xml
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/wsdlto/frontend/javascript/src/main/java/org/apache/cxf/tools/wsdlto/javascript/javascript-toolspec.xml?rev=602138&r1=602137&r2=602138&view=diff
==============================================================================
--- incubator/cxf/trunk/tools/wsdlto/frontend/javascript/src/main/java/org/apache/cxf/tools/wsdlto/javascript/javascript-toolspec.xml
(original)
+++ incubator/cxf/trunk/tools/wsdlto/frontend/javascript/src/main/java/org/apache/cxf/tools/wsdlto/javascript/javascript-toolspec.xml
Fri Dec  7 08:14:37 2007
@@ -43,9 +43,8 @@
             <option id="jspackageprefix" maxOccurs="unbounded">
                 <annotation>
                     The JavaScript function name prefix to use for the generated code.
-					By default, this specifies the JavaScript prefix for use with the 
-					WSDL's TNS. You may optionally specify a namespace URI to specif
-					a prefix for other namespaces mentioned in the WSDL.
+					Specify each prefix mapping with with the format
+					URI=prefix.
                 </annotation>
                 <switch>p</switch>
                 <associatedArgument placement="afterSpace">

Modified: incubator/cxf/trunk/tools/wsdlto/frontend/javascript/src/test/java/org/apache/cxf/tools/wsdlto/javascript/WSDLToJavaScriptTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/wsdlto/frontend/javascript/src/test/java/org/apache/cxf/tools/wsdlto/javascript/WSDLToJavaScriptTest.java?rev=602138&r1=602137&r2=602138&view=diff
==============================================================================
--- incubator/cxf/trunk/tools/wsdlto/frontend/javascript/src/test/java/org/apache/cxf/tools/wsdlto/javascript/WSDLToJavaScriptTest.java
(original)
+++ incubator/cxf/trunk/tools/wsdlto/frontend/javascript/src/test/java/org/apache/cxf/tools/wsdlto/javascript/WSDLToJavaScriptTest.java
Fri Dec  7 08:14:37 2007
@@ -19,18 +19,15 @@
 
 package org.apache.cxf.tools.wsdlto.javascript;
 
-import java.net.URISyntaxException;
-
+import org.apache.cxf.tools.common.ProcessorTestBase;
 import org.apache.cxf.tools.common.ToolConstants;
 import org.apache.cxf.tools.common.ToolContext;
-import org.junit.Assert;
 import org.junit.Test;
 
 /**
  * 
  */
-@org.junit.Ignore
-public class WSDLToJavaScriptTest extends Assert {
+public class WSDLToJavaScriptTest extends ProcessorTestBase {
     
     // just run with a minimum of fuss.
     @Test
@@ -39,12 +36,8 @@
 
         ToolContext context = new ToolContext();
         context.put(ToolConstants.CFG_WSDLURL, getLocation("hello_world.wsdl"));
+        context.put(ToolConstants.CFG_OUTPUTDIR, output.toString()); 
         container.setContext(context); 
         container.execute();
-    }
-    
-
-    private String getLocation(String wsdlFile) throws URISyntaxException {
-        return this.getClass().getResource(wsdlFile).toURI().getPath();
     }
 }

Modified: incubator/cxf/trunk/tools/wsdlto/pom.xml
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/wsdlto/pom.xml?rev=602138&r1=602137&r2=602138&view=diff
==============================================================================
--- incubator/cxf/trunk/tools/wsdlto/pom.xml (original)
+++ incubator/cxf/trunk/tools/wsdlto/pom.xml Fri Dec  7 08:14:37 2007
@@ -34,6 +34,7 @@
     <modules>
         <module>core</module>
         <module>frontend/jaxws</module>
+        <module>frontend/javascript</module>
         <module>databinding/jaxb</module>
         <module>test</module>
         <module>misc</module>



Mime
View raw message