cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r834740 - in /cxf/trunk/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin: Option.java WSDL2JavaMojo.java WsdlOption.java
Date Wed, 11 Nov 2009 01:45:05 GMT
Author: dkulp
Date: Wed Nov 11 01:45:05 2009
New Revision: 834740

URL: http://svn.apache.org/viewvc?rev=834740&view=rev
Log:
[CXF-2368, CXF-2508] Merge default options into configured options
Add a flag to disable directory scanning

Modified:
    cxf/trunk/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/Option.java
    cxf/trunk/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/WSDL2JavaMojo.java
    cxf/trunk/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/WsdlOption.java

Modified: cxf/trunk/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/Option.java
URL: http://svn.apache.org/viewvc/cxf/trunk/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/Option.java?rev=834740&r1=834739&r2=834740&view=diff
==============================================================================
--- cxf/trunk/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/Option.java
(original)
+++ cxf/trunk/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/Option.java
Wed Nov 11 01:45:05 2009
@@ -23,6 +23,7 @@
 import java.util.ArrayList;
 import java.util.List;
 
+
 public class Option {
 
     /**
@@ -99,7 +100,7 @@
      * Specifies that the wsdlurl contains a plain text, new line delimited,
      * list of wsdlurls instead of the wsdl itself.
      */
-    boolean wsdlList;
+    Boolean wsdlList;
 
     /**
      * Specifies the frontend. Default is JAXWS. Currently supports only JAXWS frontend.
@@ -125,12 +126,12 @@
      * Enables or disables processing of implicit SOAP headers (i.e. SOAP headers defined
in the 
      * wsdl:binding but not wsdl:portType section.) Default is false.
      */
-    boolean extendedSoapHeaders;
+    Boolean extendedSoapHeaders;
 
     /**
      * Enables validating the WSDL before generating the code. 
      */
-    boolean validateWsdl;
+    Boolean validateWsdl;
 
     /**
      * The WSDL service name to use for the generated code
@@ -140,17 +141,17 @@
     /**
      * Automatically resolve naming conflicts without requiring the use of binding customizations
      */
-    boolean autoNameResolution;
+    Boolean autoNameResolution;
 
     /**
      * Disable generation of service address binding in the generated Java classes
      */
-    boolean noAddressBinding;
+    Boolean noAddressBinding;
     
     /**
      * Allow element references when determining if an operation can be unwrapped or not

      */
-    boolean allowElementRefs;
+    Boolean allowElementRefs;
 
 
     public Option() {
@@ -240,7 +241,7 @@
     }
 
     public boolean isWsdlList() {
-        return wsdlList;
+        return wsdlList == null ? false : wsdlList;
     }
 
     public void setWsdlList(boolean wsdlList) {
@@ -280,7 +281,7 @@
     }
 
     public boolean isExtendedSoapHeaders() {
-        return extendedSoapHeaders;
+        return extendedSoapHeaders == null ? false : extendedSoapHeaders;
     }
 
     public void setExtendedSoapHeaders(boolean extendedSoapHeaders) {
@@ -288,7 +289,7 @@
     }
 
     public boolean isValidateWsdl() {
-        return validateWsdl;
+        return validateWsdl == null ? false : validateWsdl;
     }
 
     public void setValidateWsdl(boolean validateWsdl) {
@@ -320,7 +321,7 @@
     }
 
     public boolean isAutoNameResolution() {
-        return autoNameResolution;
+        return autoNameResolution == null ? false : autoNameResolution;
     }
 
     public void setAutoNameResolution(boolean autoNameResolution) {
@@ -328,7 +329,7 @@
     }
 
     public boolean isNoAddressBinding() {
-        return noAddressBinding;
+        return noAddressBinding == null ? false : noAddressBinding;
     }
 
     public void setNoAddressBinding(boolean noAddressBinding) {
@@ -336,7 +337,7 @@
     }
 
     public boolean isAllowElementRefs() {
-        return allowElementRefs;
+        return allowElementRefs == null ? false : allowElementRefs;
     }
 
     public void setAllowElementRefs(boolean allowElementRefs) {
@@ -368,4 +369,78 @@
         }
         destination.setWsdlVersion(getWsdlVersion());
     }
+    public void merge(Option defaultOptions) {
+        if (wsdlList == null) {
+            wsdlList = defaultOptions.wsdlList;
+        }
+        if (extendedSoapHeaders == null) {
+            extendedSoapHeaders = defaultOptions.extendedSoapHeaders;
+        }
+        if (validateWsdl == null) {
+            validateWsdl = defaultOptions.validateWsdl;
+        }
+        if (autoNameResolution == null) {
+            autoNameResolution = defaultOptions.autoNameResolution;
+        }
+        if (noAddressBinding == null) {
+            noAddressBinding = defaultOptions.noAddressBinding;
+        }
+        if (allowElementRefs == null) {
+            allowElementRefs = defaultOptions.allowElementRefs;
+        }
+        if (defaultExcludesNamespace == null) {
+            defaultExcludesNamespace = defaultOptions.defaultExcludesNamespace;
+        }
+        if (defaultNamespacePackageMapping == null) {
+            defaultNamespacePackageMapping = defaultOptions.defaultNamespacePackageMapping;
+        }
+        if (frontEnd == null) {
+            frontEnd = defaultOptions.frontEnd;
+        }
+        if (dataBinding == null) {
+            dataBinding = defaultOptions.dataBinding;
+        }
+        if (wsdlVersion == null) {
+            wsdlVersion = defaultOptions.wsdlVersion;
+        }
+        if (catalog == null) {
+            catalog = defaultOptions.catalog;
+        }
+        if (serviceName == null) {
+            serviceName = defaultOptions.serviceName;
+        }
+        if (outputDir == null) {
+            outputDir = defaultOptions.outputDir;
+        }
+        extraargs.addAll(defaultOptions.extraargs);
+        xjcargs.addAll(defaultOptions.xjcargs);
+        
+        bindingFiles = mergeList(bindingFiles, defaultOptions.bindingFiles, String.class);
+        dependencies = mergeList(dependencies, defaultOptions.dependencies, File.class);
+        redundantDirs = mergeList(redundantDirs, defaultOptions.redundantDirs, File.class);
+        if (packagenames == null) {
+            packagenames = defaultOptions.packagenames;
+        } else {
+            packagenames.addAll(defaultOptions.packagenames);
+        }
+        if (namespaceExcludes == null) {
+            namespaceExcludes = defaultOptions.namespaceExcludes;
+        } else {
+            namespaceExcludes.addAll(defaultOptions.namespaceExcludes);
+        }
+    }
+    
+    @SuppressWarnings("unchecked")
+    private <T> T[] mergeList(T[] l1, T[] l2, Class<T> cls) {
+        if (l1 == null) {
+            return l2;
+        } else if (l2 == null) {
+            return l1;
+        }
+        int len = l1.length + l2.length;
+        T ret[] = (T[])java.lang.reflect.Array.newInstance(cls, len);
+        System.arraycopy(l1, 0, ret, 0, l1.length);
+        System.arraycopy(l2, 0, ret, l1.length, l2.length);
+        return ret;
+    }
 }

Modified: cxf/trunk/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/WSDL2JavaMojo.java
URL: http://svn.apache.org/viewvc/cxf/trunk/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/WSDL2JavaMojo.java?rev=834740&r1=834739&r2=834740&view=diff
==============================================================================
--- cxf/trunk/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/WSDL2JavaMojo.java
(original)
+++ cxf/trunk/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/WSDL2JavaMojo.java
Wed Nov 11 01:45:05 2009
@@ -114,6 +114,16 @@
      * @parameter expression="${cxf.useCompileClasspath}" default-value="false"
      */
     boolean useCompileClasspath;
+    
+    
+    /**
+     * Disables the scanning of the wsdlRoot/testWsdlRoot directories configured above.
+     * By default, we scan for *.wsdl (see include/exclude params as well) in the wsdlRoot
+     * directories and run wsdl2java on all the wsdl's we find.    This disables that scan
+     * and requires an explicit wsdlOption to be set for each wsdl that needs to be processed.
+     * @parameter expression="${cxf.disableDirectoryScan}" default-value="false"
+     */
+    boolean disableDirectoryScan;
 
     /**
      * A list of wsdl files to include. Can contain ant-style wildcards and double wildcards.
Defaults to
@@ -240,9 +250,15 @@
      * 
      * @param options
      */
-    private void mergeOptions(List<WsdlOption> effectiveWsdlOptions, WsdlOption[] explicitWsdlOptions)
{
+    private void mergeOptions(List<WsdlOption> effectiveWsdlOptions) {
+        if (wsdlOptions == null) {
+            return;
+        }
         File outputDirFile = testSourceRoot == null ? sourceRoot : testSourceRoot;
-        for (WsdlOption o : explicitWsdlOptions) {
+        for (WsdlOption o : wsdlOptions) {
+            if (defaultOptions != null) {
+                o.merge(defaultOptions);
+            }
             if (o.getOutputDir() == null) {
                 o.setOutputDir(outputDirFile);
             }
@@ -259,7 +275,7 @@
                     }
                 }
             }
-            effectiveWsdlOptions.add(0, o);
+            effectiveWsdlOptions.add(o);
         }
     }
 
@@ -270,16 +286,13 @@
     private List<WsdlOption> createWsdlOptionsFromWsdlFilesAndExplicitWsdlOptions()
         throws MojoExecutionException {
         List<WsdlOption> effectiveWsdlOptions = new ArrayList<WsdlOption>();
-        if (wsdlRoot != null && wsdlRoot.exists()) {
+        if (wsdlRoot != null && wsdlRoot.exists() && !disableDirectoryScan)
{
             effectiveWsdlOptions.addAll(getWsdlOptionsFromDir(wsdlRoot, sourceRoot));
         }
-        if (testWsdlRoot != null && testWsdlRoot.exists()) {
+        if (testWsdlRoot != null && testWsdlRoot.exists() && !disableDirectoryScan)
{
             effectiveWsdlOptions.addAll(getWsdlOptionsFromDir(testWsdlRoot, testSourceRoot));
         }
-
-        if (wsdlOptions != null) {
-            mergeOptions(effectiveWsdlOptions, wsdlOptions);
-        }
+        mergeOptions(effectiveWsdlOptions);
         downloadRemoteWsdls(effectiveWsdlOptions);
         return effectiveWsdlOptions;
     }

Modified: cxf/trunk/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/WsdlOption.java
URL: http://svn.apache.org/viewvc/cxf/trunk/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/WsdlOption.java?rev=834740&r1=834739&r2=834740&view=diff
==============================================================================
--- cxf/trunk/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/WsdlOption.java
(original)
+++ cxf/trunk/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/WsdlOption.java
Wed Nov 11 01:45:05 2009
@@ -74,4 +74,5 @@
         builder.append('\n');
         return builder.toString();
     }
+
 }



Mime
View raw message