You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@beehive.apache.org by cs...@apache.org on 2006/06/12 19:03:54 UTC

svn commit: r413707 - in /beehive/trunk/system-controls: src/webservice/control/org/apache/beehive/controls/system/webservice/generator/ src/webservice/control/org/apache/beehive/controls/system/webservice/wsdl/ src/webservice/jaxrpc-clients/axis/org/a...

Author: cschoett
Date: Mon Jun 12 10:03:51 2006
New Revision: 413707

URL: http://svn.apache.org/viewvc?rev=413707&view=rev
Log:
Modifed AxisTypeGenerator Ant task to accept a file, URL or directory of wsdl files to process.  Updated attribute name to 'wsdlSrc'.

Some minor javadoc cleanup to WebServiceControlGeneratorTask.
Fixed a minor problem with 'any' type mapping in WsdlOpParameter.

Tests: WSC DRT's passed.

Modified:
    beehive/trunk/system-controls/src/webservice/control/org/apache/beehive/controls/system/webservice/generator/WebServiceControlGeneratorTask.java
    beehive/trunk/system-controls/src/webservice/control/org/apache/beehive/controls/system/webservice/wsdl/WsdlOpParameter.java
    beehive/trunk/system-controls/src/webservice/jaxrpc-clients/axis/org/apache/beehive/controls/system/jaxrpc/AxisTypeGeneratorTask.java
    beehive/trunk/system-controls/test/webservice/build.xml

Modified: beehive/trunk/system-controls/src/webservice/control/org/apache/beehive/controls/system/webservice/generator/WebServiceControlGeneratorTask.java
URL: http://svn.apache.org/viewvc/beehive/trunk/system-controls/src/webservice/control/org/apache/beehive/controls/system/webservice/generator/WebServiceControlGeneratorTask.java?rev=413707&r1=413706&r2=413707&view=diff
==============================================================================
--- beehive/trunk/system-controls/src/webservice/control/org/apache/beehive/controls/system/webservice/generator/WebServiceControlGeneratorTask.java (original)
+++ beehive/trunk/system-controls/src/webservice/control/org/apache/beehive/controls/system/webservice/generator/WebServiceControlGeneratorTask.java Mon Jun 12 10:03:51 2006
@@ -139,13 +139,13 @@
 
     /**
      * Set the wsdlSrc attribute value.  Value may be in a form of a URL, file or diectory.
-     * @param src wsdlSrc attribute value.
+     * @param wsdlSrc wsdlSrc attribute value.
      */
-    public void setWsdlSrc(String src) {
-        _wsdlSrc = src;
-        if (!isUrl(src) && !isFile(src)) {
-            throw new BuildException("Invalid src attribute value, src must be a URL, file or directory.");
+    public void setWsdlSrc(String wsdlSrc) {
+        if (!isUrl(wsdlSrc) && !isFile(wsdlSrc)) {
+            throw new BuildException("Invalid wsdlsrc attribute value, wsdlsrc must be a URL, file or directory.");
         }
+        _wsdlSrc = wsdlSrc;
     }
 
     /**
@@ -158,8 +158,9 @@
             _wsdlSrcURL = new URL(src);
         }
         catch (MalformedURLException e) {
+            // noop
         }
-        return (_wsdlSrcURL == null) ? false : true;
+        return (_wsdlSrcURL != null);
     }
 
     /**

Modified: beehive/trunk/system-controls/src/webservice/control/org/apache/beehive/controls/system/webservice/wsdl/WsdlOpParameter.java
URL: http://svn.apache.org/viewvc/beehive/trunk/system-controls/src/webservice/control/org/apache/beehive/controls/system/webservice/wsdl/WsdlOpParameter.java?rev=413707&r1=413706&r2=413707&view=diff
==============================================================================
--- beehive/trunk/system-controls/src/webservice/control/org/apache/beehive/controls/system/webservice/wsdl/WsdlOpParameter.java (original)
+++ beehive/trunk/system-controls/src/webservice/control/org/apache/beehive/controls/system/webservice/wsdl/WsdlOpParameter.java Mon Jun 12 10:03:51 2006
@@ -233,7 +233,7 @@
         }
         else {
             // no children / no type map to 'any'
-            return new QName("", "any");
+            return new QName("http://www.w3.org/2001/XMLSchema", "any");
         }
         throw new RuntimeException("Cannot determine type of element: " + getName());
     }

Modified: beehive/trunk/system-controls/src/webservice/jaxrpc-clients/axis/org/apache/beehive/controls/system/jaxrpc/AxisTypeGeneratorTask.java
URL: http://svn.apache.org/viewvc/beehive/trunk/system-controls/src/webservice/jaxrpc-clients/axis/org/apache/beehive/controls/system/jaxrpc/AxisTypeGeneratorTask.java?rev=413707&r1=413706&r2=413707&view=diff
==============================================================================
--- beehive/trunk/system-controls/src/webservice/jaxrpc-clients/axis/org/apache/beehive/controls/system/jaxrpc/AxisTypeGeneratorTask.java (original)
+++ beehive/trunk/system-controls/src/webservice/jaxrpc-clients/axis/org/apache/beehive/controls/system/jaxrpc/AxisTypeGeneratorTask.java Mon Jun 12 10:03:51 2006
@@ -18,33 +18,47 @@
 
 package org.apache.beehive.controls.system.jaxrpc;
 
-import org.apache.tools.ant.Task;
 import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.Task;
 
 import java.io.File;
 import java.io.FileFilter;
+import java.net.MalformedURLException;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.List;
 
 /**
- * Ant task for generating types using Axis type generation.  Basically just a wrapper around
- * the Axis Wsdl2Java task which only does type generation.
+ * Ant task for generating java classes from a WSDL using Axis type generation.
+ * Basically just a wrapper around the Axis Wsdl2Java task only performing type generation.
  */
 public class AxisTypeGeneratorTask extends Task {
 
-    private static final FileFilter WSDL_FILE_FILTER =  new AxisTypeGeneratorTask.WSDLFilter();
+    private static final FileFilter WSDL_FILE_FILTER = new AxisTypeGeneratorTask.WSDLFilter();
 
-    private File _wsdlDir;
+    private String _wsdlSrc;
+    private File _wsdlSrcFile;
+    private URL _wsdlSrcURL;
     private File _outDir;
 
     /**
-     * Set the directory which contains the wsdl file(s) to process.
-     * @param wsdl Directory.
+     * Set the wsdlSrc attribute value.
+     *
+     * @param wsdlSrc Location of the wsdl file(s) to process.
+     *                Must be either a URL, file or directory.
      */
-    public void setWSDLDir(File wsdl) {
-        _wsdlDir = wsdl;
+    public void setWsdlSrc(String wsdlSrc) {
+        if (!isUrl(wsdlSrc) && !isFile(wsdlSrc)) {
+            throw new BuildException("Invalid wsdlsrc attribute value, wsdlsrc must be a URL, file or directory.");
+        }
+        _wsdlSrc = wsdlSrc;
     }
 
     /**
      * Set the directory to output the generated types to.
+     *
      * @param outputDir Directory.
      */
     public void setOutputDir(File outputDir) {
@@ -53,24 +67,23 @@
 
     /**
      * Execute the task.
+     *
      * @throws BuildException
      */
     public void execute() throws BuildException {
 
-        if (_outDir == null && _wsdlDir == null) {
-            throw new BuildException("Both a WSDL directory and output directory must be provided.");
-        }
-
-        if (!_wsdlDir.isDirectory()) {
-            throw new BuildException("The provided WSDL directory is not a directory.");
+        if (_wsdlSrc == null) {
+            throw new BuildException("wsdlsrc is a required attribute for this task.");
         }
 
         String fileName = null;
         try {
             AxisTypeGenerator atg = new AxisTypeGenerator();
-            for (File f : _wsdlDir.listFiles(AxisTypeGeneratorTask.WSDL_FILE_FILTER)) {
-                fileName = f.getName();
-                atg.generateTypes(f.getPath(), _outDir.getPath());
+
+            List<URI> wsdlUris = buildUriList();
+            for (URI wsdlUri : wsdlUris) {
+                atg.generateTypes(wsdlUri.toString(), _outDir.getPath());
+
             }
         }
         catch (Exception e) {
@@ -79,6 +92,59 @@
         }
     }
 
+    /**
+     * Builds a list of WSDL URI's to generate java classes for.
+     *
+     * @return List of URI's
+     * @throws URISyntaxException
+     */
+    private List<URI> buildUriList() throws URISyntaxException {
+
+        List<URI> files = new ArrayList<URI>();
+        if (_wsdlSrcURL != null) {
+            files.add(_wsdlSrcURL.toURI());
+        }
+        else if (!_wsdlSrcFile.isDirectory()) {
+            files.add(_wsdlSrcFile.toURI());
+        }
+        else {
+            for (File f : _wsdlSrcFile.listFiles(AxisTypeGeneratorTask.WSDL_FILE_FILTER)) {
+                files.add(f.toURI());
+            }
+        }
+        return files;
+    }
+
+    /**
+     * Is the parameter a URL string?
+     *
+     * @param src Parameter to check.
+     * @return true if valid url.
+     */
+    private boolean isUrl(String src) {
+        try {
+            _wsdlSrcURL = new URL(src);
+        }
+        catch (MalformedURLException e) {
+            // noop
+        }
+        return (_wsdlSrcURL != null);
+    }
+
+    /**
+     * Is the parameter a file or directory?
+     *
+     * @param src Parameter to check.
+     * @return true if file or directory.
+     */
+    private boolean isFile(String src) {
+        _wsdlSrcFile = new File(src);
+        return (_wsdlSrcFile.isFile() || _wsdlSrcFile.isDirectory());
+    }
+
+    /**
+     * Filter for wsdl files.
+     */
     private static class WSDLFilter implements FileFilter {
         public boolean accept(File f) {
             return (f.isFile() && (f.getName().endsWith("wsdl") || f.getName().endsWith("WSDL")));

Modified: beehive/trunk/system-controls/test/webservice/build.xml
URL: http://svn.apache.org/viewvc/beehive/trunk/system-controls/test/webservice/build.xml?rev=413707&r1=413706&r2=413707&view=diff
==============================================================================
--- beehive/trunk/system-controls/test/webservice/build.xml (original)
+++ beehive/trunk/system-controls/test/webservice/build.xml Mon Jun 12 10:03:51 2006
@@ -292,7 +292,7 @@
                  classpathref="client.classpath"/>
 
         <!-- currently, rpc encoded must be generated from the axis bean generator -->
-        <axisbeanbuild wsdldir="${axisgen.wsdls.dir}" outputdir="${client.axisgen}"/>
+        <axisbeanbuild wsdlsrc="${axisgen.wsdls.dir}" outputdir="${client.axisgen}"/>
         <javac srcdir="${client.axisgen}" destdir="${client.classes}" classpathref="client.classpath" debug="true"/>
 
         <webservice-control-gen wsdlsrc="${axisgen.wsdls.dir}" destdir="${client.wscgensrc}"