cxf-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Daniel Kulp <dk...@apache.org>
Subject Re: svn commit: r1079780 - in /cxf/trunk: api/src/main/java/org/apache/cxf/tools/common/ maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/ tools/wsdlto/core/src/main/java/org/apache/cxf/tools/wsdlto/ tools/wsdlto/frontend/jaxws/src/ma...
Date Wed, 09 Mar 2011 14:54:18 GMT


I think for a boolean argument like this, it would make a lot more sense to 
not have it be a parameter thing.   I personally think the ONLY time anyone 
would use this would be with  the false parameter, like "-gt false".   No one 
would ever really use -gt true as that's the default.   

Thus, my suggestion would be to change it to just:

<option id="notypes" maxOccurs="1">
      <annotation>Turns off generating types</annotation>
      <switch>notypes</switch>
</option>

You can then just use the context.optionSet(...) method to see if the user 
specified it or not.



Dan



On Wednesday 09 March 2011 7:54:16 AM ningjiang@apache.org wrote:
> Author: ningjiang
> Date: Wed Mar  9 12:54:15 2011
> New Revision: 1079780
> 
> URL: http://svn.apache.org/viewvc?rev=1079780&view=rev
> Log:
> CXF-3385 Add a new option in WSD2Java to skip the generate the type classes
> from schema
> 
> Modified:
>    
> cxf/trunk/api/src/main/java/org/apache/cxf/tools/common/ToolConstants.java
> 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/WsdlOption.java
> cxf/trunk/tools/wsdlto/core/src/main/java/org/apache/cxf/tools/wsdlto/WSDL
> ToJavaContainer.java
> cxf/trunk/tools/wsdlto/core/src/main/java/org/apache/cxf/tools/wsdlto/wsdl
> to.xml
> cxf/trunk/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/w
> sdlto/frontend/jaxws/jaxws-toolspec.xml
> cxf/trunk/tools/wsdlto/test/src/test/java/org/apache/cxf/tools/wsdlto/jaxw
> s/CodeGenTest.java
> 
> Modified:
> cxf/trunk/api/src/main/java/org/apache/cxf/tools/common/ToolConstants.java
> URL:
> http://svn.apache.org/viewvc/cxf/trunk/api/src/main/java/org/apache/cxf/to
> ols/common/ToolConstants.java?rev=1079780&r1=1079779&r2=1079780&view=diff
> ==========================================================================
> ==== ---
> cxf/trunk/api/src/main/java/org/apache/cxf/tools/common/ToolConstants.java
> (original) +++
> cxf/trunk/api/src/main/java/org/apache/cxf/tools/common/ToolConstants.java
> Wed Mar  9 12:54:15 2011 @@ -63,6 +63,7 @@ public final class
> ToolConstants {
>      public static final String CFG_EXTRA_SOAPHEADER = "exsoapheader";
>      public static final String CFG_DEFAULT_NS = "defaultns";
>      public static final String CFG_DEFAULT_EX = "defaultex";
> +    public static final String CXF_GENERATE_TYPES = "generatetypes";
>      public static final String CFG_XJC_ARGS = "xjc";
>      public static final String CFG_CATALOG = "catalog";
>      public static final String CFG_DEFAULT_VALUES = "defaultValues";
> 
> 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/ma
> in/java/org/apache/cxf/maven_plugin/Option.java?rev=1079780&r1=1079779&r2=1
> 079780&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 Mar  9 12:54:15 2011 @@ -134,6 +134,12 @@ public
> class Option {
>       * Enables validating the WSDL before generating the code.
>       */
>      Boolean validateWsdl;
> +
> +
> +    /**
> +     * Enables or disables generation of the type classes. Default value
> is true. +     */
> +    Boolean generateTypes;
> 
>      /**
>       * Enables generation of fault Exception's SUID based on hash of
> classname. @@ -314,6 +320,14 @@ public class Option {
>      public void setValidateWsdl(boolean validateWsdl) {
>          this.validateWsdl = validateWsdl;
>      }
> +
> +    public boolean isGenerateTypes() {
> +        return generateTypes == null ? true : generateTypes;
> +    }
> +
> +    public void setGenerateTypes(boolean generateTypes) {
> +        this.generateTypes = generateTypes;
> +    }
> 
>      public boolean isUseFQCNForFaultSerialVersionUID() {
>          return useFQCNForFaultSerialVersionUID == null ? false :
> useFQCNForFaultSerialVersionUID; @@ -398,6 +412,7 @@ public class Option {
>          destination.setPackagenames(getPackagenames());
>          destination.setServiceName(getServiceName());
>          destination.setValidateWsdl(isValidateWsdl());
> +        destination.setGenerateTypes(isGenerateTypes());
>         
> destination.setUseFQCNForFaultSerialVersionUID(isUseFQCNForFaultSerialVers
> ionUID()); destination.setMarkGenerated(isMarkGenerated());
>          destination.setAllowElementRefs(isAllowElementRefs());
> @@ -417,6 +432,7 @@ public class Option {
>      public void merge(Option defaultOptions) {
>          wsdlList = setIfNull(wsdlList, defaultOptions.wsdlList);
>          extendedSoapHeaders = setIfNull(extendedSoapHeaders,
> defaultOptions.extendedSoapHeaders); +        generateTypes =
> setIfNull(generateTypes, defaultOptions.generateTypes); validateWsdl =
> setIfNull(validateWsdl, defaultOptions.validateWsdl);
> useFQCNForFaultSerialVersionUID =
> setIfNull(useFQCNForFaultSerialVersionUID,
> defaultOptions.useFQCNForFaultSerialVersionUID);
> 
> 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/ma
> in/java/org/apache/cxf/maven_plugin/WsdlOption.java?rev=1079780&r1=1079779&
> r2=1079780&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 Mar  9 12:54:15 2011 @@ -148,6 +148,10 @@ public
> class WsdlOption extends Option {
>              list.add("-exsh");
>              list.add("true");
>          }
> +        if (!isGenerateTypes()) {
> +            list.add("-gt");
> +            list.add("false");
> +        }
>          addIfTrue(list, isAllowElementRefs(), "-allowElementRefs");
>          addIfTrue(list, isValidateWsdl(), "-validate");
>          addIfTrue(list, isUseFQCNForFaultSerialVersionUID(),
> "-useFQCNForFaultSerialVersionUID");
> 
> Modified:
> cxf/trunk/tools/wsdlto/core/src/main/java/org/apache/cxf/tools/wsdlto/WSDL
> ToJavaContainer.java URL:
> http://svn.apache.org/viewvc/cxf/trunk/tools/wsdlto/core/src/main/java/org
> /apache/cxf/tools/wsdlto/WSDLToJavaContainer.java?rev=1079780&r1=1079779&r2
> =1079780&view=diff
> ==========================================================================
> ==== ---
> cxf/trunk/tools/wsdlto/core/src/main/java/org/apache/cxf/tools/wsdlto/WSDL
> ToJavaContainer.java (original) +++
> cxf/trunk/tools/wsdlto/core/src/main/java/org/apache/cxf/tools/wsdlto/WSDL
> ToJavaContainer.java Wed Mar  9 12:54:15 2011 @@ -237,6 +237,13 @@ public
> class WSDLToJavaContainer extends
>                  context.put(ServiceInfo.class, null);
>              }
>          }
> +
> +        if (!context.getBooleanValue(ToolConstants.CXF_GENERATE_TYPES,
> "true")) { +            context.remove(ToolConstants.CFG_TYPES);
> +            context.remove(ToolConstants.CFG_ALL);
> +            context.remove(ToolConstants.CFG_COMPILE);
> +        }
> +
>          generateTypes();
> 
>          for (ServiceInfo service : serviceList) {
> @@ -573,6 +580,9 @@ public class WSDLToJavaContainer extends
> 
>              || context.optionSet(ToolConstants.CFG_GEN_FAULT)) {
> 
>              return true;
>          }
> +        if (!context.getBooleanValue(ToolConstants.CXF_GENERATE_TYPES,
> "true")) { +            return true;
> +        }
>          return false;
>      }
> 
> 
> Modified:
> cxf/trunk/tools/wsdlto/core/src/main/java/org/apache/cxf/tools/wsdlto/wsdl
> to.xml URL:
> http://svn.apache.org/viewvc/cxf/trunk/tools/wsdlto/core/src/main/java/org
> /apache/cxf/tools/wsdlto/wsdlto.xml?rev=1079780&r1=1079779&r2=1079780&view=
> diff
> ==========================================================================
> ==== ---
> cxf/trunk/tools/wsdlto/core/src/main/java/org/apache/cxf/tools/wsdlto/wsdl
> to.xml (original) +++
> cxf/trunk/tools/wsdlto/core/src/main/java/org/apache/cxf/tools/wsdlto/wsdl
> to.xml Wed Mar  9 12:54:15 2011 @@ -173,6 +173,16 @@ under the License.
>                      <valueenum>true|false</valueenum>
>                  </associatedArgument>
>              </option>
> +
> +            <option id="generatetypes" maxOccurs="1">
> +                <annotation>Enables the processing of generating the type
> class from schema. The default is true. +                </annotation>
> +                <switch>gt</switch>
> +                <associatedArgument placement="afterSpace">
> +                    <annotation>(true, false)</annotation>
> +                    <valueenum>true|false</valueenum>
> +                </associatedArgument>
> +            </option>
> 
>              <option id="validate" maxOccurs="1">
>                  <annotation>
> 
> Modified:
> cxf/trunk/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/w
> sdlto/frontend/jaxws/jaxws-toolspec.xml URL:
> http://svn.apache.org/viewvc/cxf/trunk/tools/wsdlto/frontend/jaxws/src/mai
> n/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/jaxws-toolspec.xml?rev=10
> 79780&r1=1079779&r2=1079780&view=diff
> ==========================================================================
> ==== ---
> cxf/trunk/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/w
> sdlto/frontend/jaxws/jaxws-toolspec.xml (original) +++
> cxf/trunk/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/w
> sdlto/frontend/jaxws/jaxws-toolspec.xml Wed Mar  9 12:54:15 2011 @@ -235,6
> +235,16 @@ Examples:
>                      <valueenum>true|false</valueenum>
>                  </associatedArgument>
>              </option>
> +
> +            <option id="generatetypes" maxOccurs="1">
> +                <annotation>Enables the processing of generating the type
> class from schema. The default is true. +                </annotation>
> +                <switch>gt</switch>
> +                <associatedArgument placement="afterSpace">
> +                    <annotation>(true, false)</annotation>
> +                    <valueenum>true|false</valueenum>
> +                </associatedArgument>
> +            </option>
> 
>              <option id="defaultns" maxOccurs="1">
>                  <annotation>
> 
> Modified:
> cxf/trunk/tools/wsdlto/test/src/test/java/org/apache/cxf/tools/wsdlto/jaxw
> s/CodeGenTest.java URL:
> http://svn.apache.org/viewvc/cxf/trunk/tools/wsdlto/test/src/test/java/org
> /apache/cxf/tools/wsdlto/jaxws/CodeGenTest.java?rev=1079780&r1=1079779&r2=1
> 079780&view=diff
> ==========================================================================
> ==== ---
> cxf/trunk/tools/wsdlto/test/src/test/java/org/apache/cxf/tools/wsdlto/jaxw
> s/CodeGenTest.java (original) +++
> cxf/trunk/tools/wsdlto/test/src/test/java/org/apache/cxf/tools/wsdlto/jaxw
> s/CodeGenTest.java Wed Mar  9 12:54:15 2011 @@ -45,6 +45,7 @@ import
> org.apache.cxf.tools.common.ToolC
>  import org.apache.cxf.tools.common.ToolException;
>  import org.apache.cxf.tools.util.AnnotationUtil;
>  import org.apache.cxf.tools.wsdlto.AbstractCodeGenTest;
> +
>  import org.junit.Test;
> 
>  public class CodeGenTest extends AbstractCodeGenTest {
> @@ -1332,6 +1333,14 @@ public class CodeGenTest extends Abstrac
>          WebParam wp = (WebParam)m[0].getParameterAnnotations()[1][0];
>          assertTrue(wp.header());
>      }
> +
> +    @Test
> +    public void testCXFNotType() throws Exception {
> +        env.put(ToolConstants.CFG_WSDLURL,
> getLocation("/wsdl2java_wsdl/hello_world.wsdl")); +       
> env.put(ToolConstants.CXF_GENERATE_TYPES, "false");
> +        processor.setContext(env);
> +        processor.execute();
> +    }
> 
>      @Test
>      public void testCXF2808() throws Exception {

-- 
Daniel Kulp
dkulp@apache.org
http://dankulp.com/blog
Talend - http://www.talend.com

Mime
View raw message