cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject svn commit: r1461980 - in /cxf/trunk/tools: common/src/main/java/org/apache/cxf/tools/common/ wadlto/jaxrs/src/main/java/org/apache/cxf/tools/wadlto/ wadlto/jaxrs/src/main/java/org/apache/cxf/tools/wadlto/jaxrs/ wadlto/jaxrs/src/test/resources/wadl/
Date Thu, 28 Mar 2013 08:39:06 GMT
Author: sergeyb
Date: Thu Mar 28 08:39:05 2013
New Revision: 1461980

URL: http://svn.apache.org/r1461980
Log:
[CXF-4932] Updating SourceGenerator to check for more illegal Java parameter names, patch
on behalf of Emmanuel Texier applies; plus minor update to the way a verbose flag is checked
and adding 'encoding' option

Modified:
    cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/common/ToolContext.java
    cxf/trunk/tools/wadlto/jaxrs/src/main/java/org/apache/cxf/tools/wadlto/WadlToolConstants.java
    cxf/trunk/tools/wadlto/jaxrs/src/main/java/org/apache/cxf/tools/wadlto/jaxrs/SourceGenerator.java
    cxf/trunk/tools/wadlto/jaxrs/src/main/java/org/apache/cxf/tools/wadlto/jaxrs/jaxrs-toolspec.xml
    cxf/trunk/tools/wadlto/jaxrs/src/test/resources/wadl/bookstore.xml

Modified: cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/common/ToolContext.java
URL: http://svn.apache.org/viewvc/cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/common/ToolContext.java?rev=1461980&r1=1461979&r2=1461980&view=diff
==============================================================================
--- cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/common/ToolContext.java (original)
+++ cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/common/ToolContext.java Thu
Mar 28 08:39:05 2013
@@ -160,10 +160,11 @@ public class ToolContext {
     }
 
     public boolean isVerbose() {
-        if (get(ToolConstants.CFG_VERBOSE) == null) {
+        Object verboseProperty = get(ToolConstants.CFG_VERBOSE);
+        if (verboseProperty == null) {
             return false;
         } else {
-            return get(ToolConstants.CFG_VERBOSE) == ToolConstants.CFG_VERBOSE;
+            return ToolConstants.CFG_VERBOSE.equals(verboseProperty);
         }
     }
 

Modified: cxf/trunk/tools/wadlto/jaxrs/src/main/java/org/apache/cxf/tools/wadlto/WadlToolConstants.java
URL: http://svn.apache.org/viewvc/cxf/trunk/tools/wadlto/jaxrs/src/main/java/org/apache/cxf/tools/wadlto/WadlToolConstants.java?rev=1461980&r1=1461979&r2=1461980&view=diff
==============================================================================
--- cxf/trunk/tools/wadlto/jaxrs/src/main/java/org/apache/cxf/tools/wadlto/WadlToolConstants.java
(original)
+++ cxf/trunk/tools/wadlto/jaxrs/src/main/java/org/apache/cxf/tools/wadlto/WadlToolConstants.java
Thu Mar 28 08:39:05 2013
@@ -27,6 +27,8 @@ public final class WadlToolConstants {
     public static final String CFG_COMPILE = ToolConstants.CFG_COMPILE;
     public static final String CFG_CLASSDIR = ToolConstants.CFG_CLASSDIR;
     public static final String CFG_XJC_ARGS = ToolConstants.CFG_XJC_ARGS;
+    public static final String CFG_VERBOSE = ToolConstants.CFG_VERBOSE;
+    public static final String CFG_ENCODING = ToolConstants.CFG_ENCODING;
     
     /**
      * Default

Modified: cxf/trunk/tools/wadlto/jaxrs/src/main/java/org/apache/cxf/tools/wadlto/jaxrs/SourceGenerator.java
URL: http://svn.apache.org/viewvc/cxf/trunk/tools/wadlto/jaxrs/src/main/java/org/apache/cxf/tools/wadlto/jaxrs/SourceGenerator.java?rev=1461980&r1=1461979&r2=1461980&view=diff
==============================================================================
--- cxf/trunk/tools/wadlto/jaxrs/src/main/java/org/apache/cxf/tools/wadlto/jaxrs/SourceGenerator.java
(original)
+++ cxf/trunk/tools/wadlto/jaxrs/src/main/java/org/apache/cxf/tools/wadlto/jaxrs/SourceGenerator.java
Thu Mar 28 08:39:05 2013
@@ -90,6 +90,7 @@ import org.apache.cxf.common.xmlschema.S
 import org.apache.cxf.common.xmlschema.XmlSchemaConstants;
 import org.apache.cxf.helpers.CastUtils;
 import org.apache.cxf.helpers.DOMUtils;
+import org.apache.cxf.helpers.JavaUtils;
 import org.apache.cxf.jaxrs.model.wadl.WadlGenerator;
 import org.apache.cxf.jaxrs.utils.JAXRSUtils;
 import org.apache.cxf.jaxrs.utils.ResourceUtils;
@@ -957,7 +958,12 @@ public class SourceGenerator {
                 addImport(imports, List.class.getName());
                 type = "List<" + type + ">";
             }
-            String paramName = name.replaceAll("[\\.\\-]", "_");
+            String paramName;
+            if (JavaUtils.isJavaKeyword(name)) {
+                paramName = name.concat("_arg");
+            } else {
+                paramName = name.replaceAll("[:\\.\\-]", "_");
+            }
             sbCode.append(type).append(" ").append(paramName);
             if (i + 1 < inParamEls.size()) {
                 sbCode.append(", ");

Modified: cxf/trunk/tools/wadlto/jaxrs/src/main/java/org/apache/cxf/tools/wadlto/jaxrs/jaxrs-toolspec.xml
URL: http://svn.apache.org/viewvc/cxf/trunk/tools/wadlto/jaxrs/src/main/java/org/apache/cxf/tools/wadlto/jaxrs/jaxrs-toolspec.xml?rev=1461980&r1=1461979&r2=1461980&view=diff
==============================================================================
--- cxf/trunk/tools/wadlto/jaxrs/src/main/java/org/apache/cxf/tools/wadlto/jaxrs/jaxrs-toolspec.xml
(original)
+++ cxf/trunk/tools/wadlto/jaxrs/src/main/java/org/apache/cxf/tools/wadlto/jaxrs/jaxrs-toolspec.xml
Thu Mar 28 08:39:05 2013
@@ -220,85 +220,35 @@ Examples:
                 </associatedArgument>
                 <switch>async</switch>
             </option>           
-<!-- 
 
-TODO: consider implementing most of the following options
-
-            <option id="reserveClass" maxOccurs="unbounded">
+            <option id="xjc" maxOccurs="unbounded">
                 <annotation>
-                    Reserve a class name to keep the code generator from generating
-                    a class of the given name.   In name cases, a binding file or 
-                    use of -autoNameResolution flag may be necessary for the 
-                    code generator to completely generate usable code.
+                    Specifies a comma separated list of arguments that are passed directly
to XJC when the
+                    JAXB data binding  is used. This option causes XJC to load additional
plugins that
+                    augment code generation. For example to load the toString(ts) plugin
that will add a toString()
+                    method to all generated types the following &lt;xjc arguments&gt;
would
+                    be used:
+                          -xjc-Xts
+                    A list of available XJC plugins can be obtained by using -xjc-X.
                 </annotation>
-                <switch>reserveClass</switch>
-                <associatedArgument placement="afterSpace">
-                    <annotation>class-name</annotation>
+                <associatedArgument placement="immediate">
+                    <annotation>xjc-arguments</annotation>
                 </associatedArgument>
-            </option>
-            <option id="autoNameResolution" maxOccurs="1">
-                <annotation>
-                    Specifies that the tool will attempt to resolve class naming conflicts

-                    without requiring the use of binding customizations.
-                </annotation>
-                <switch>autoNameResolution</switch>
+                <switch>xjc</switch>
             </option>
             
-
-            <option id="server" maxOccurs="1">
-                <annotation>
-                    Specifies that server code is generated.
-                </annotation>
-                <switch>server</switch>
-            </option>
-
-            <option id="client" maxOccurs="1">
+            <option id="encoding" maxOccurs="1">
                 <annotation>
-                    Specifies that client code is generated.
+                    Specifies the charset encoding to use when generating java sources 
                 </annotation>
-                <switch>client</switch>
-            </option>
-
-            <option id="all" maxOccurs="1">
-                <annotation>
-                    Specifies that interfaces, types , service, server , dummy impl, client
-                    and ant script are generated.
-                </annotation>
-                <switch>all</switch>
-            </option>
-
-            <option id="nexclude" maxOccurs="unbounded">
-                <annotation>
-                    Specifies a WSDL namespace to exclude when generating code. This
-                    option can be specified multiple times. Optionally
-                    specify the Java package name to use for the WSDL namespace.
-                </annotation>
-                <switch>nexclude</switch>
+                <switch>encoding</switch>
                 <associatedArgument placement="afterSpace">
-                    <annotation>schema-namespace [= java-package-name]</annotation>
-                </associatedArgument>
-            </option>
-            <option id="defaultns" maxOccurs="1">
-                <annotation>
-                    Enables loading the default namespace package name mapping. The default
is true.
-                </annotation>
-                <switch>dns</switch>
-                <associatedArgument placement="afterSpace">
-                    <annotation>Default value is true</annotation>
-                    <valueenum>true|false</valueenum>
+                    <annotation>encoding</annotation>
                 </associatedArgument>
             </option>
+            
+            <!-- 
 
-            <option id="defaultex" maxOccurs="1">
-                <annotation>
-                    Enable loading the default excludes namespace mapping. The default is
true.</annotation>
-                <switch>dex</switch>
-                <associatedArgument placement="afterSpace">
-                    <annotation>(true, false)</annotation>
-                    <valueenum>true|false</valueenum>
-                </associatedArgument>
-            </option>
-        
             <option id="validate" maxOccurs="1">
                 <annotation>
                     Specifies that the WADL is validated before generating the code. Using

@@ -307,29 +257,8 @@ TODO: consider implementing most of the 
                 <switch>validate</switch>
             </option>
             
-            <option id="newonly" maxOccurs="1">
-                <annotation>
-                    Specifies that existing code will not be over written. NOTE: You will
have to solve any resulting compilation problems by yourself
-                </annotation>
-                <switch>keep</switch>
-            </option>
--->
-            <option id="xjc" maxOccurs="unbounded">
-                <annotation>
-                    Specifies a comma separated list of arguments that are passed directly
to XJC when the
-                    JAXB data binding  is used. This option causes XJC to load additional
plugins that
-                    augment code generation. For example to load the toString(ts) plugin
that will add a toString()
-                    method to all generated types the following &lt;xjc arguments&gt;
would
-                    be used:
-                          -xjc-Xts
-                    A list of available XJC plugins can be obtained by using -xjc-X.
-                </annotation>
-                <associatedArgument placement="immediate">
-                    <annotation>xjc-arguments</annotation>
-                </associatedArgument>
-                <switch>xjc</switch>
-            </option>
-
+            -->
+            
         </optionGroup>
         <optionGroup id="common_options">
             <option id="help" maxOccurs="1">

Modified: cxf/trunk/tools/wadlto/jaxrs/src/test/resources/wadl/bookstore.xml
URL: http://svn.apache.org/viewvc/cxf/trunk/tools/wadlto/jaxrs/src/test/resources/wadl/bookstore.xml?rev=1461980&r1=1461979&r2=1461980&view=diff
==============================================================================
--- cxf/trunk/tools/wadlto/jaxrs/src/test/resources/wadl/bookstore.xml (original)
+++ cxf/trunk/tools/wadlto/jaxrs/src/test/resources/wadl/bookstore.xml Thu Mar 28 08:39:05
2013
@@ -128,7 +128,7 @@ required="true">
        </param>
        <param name="provider.bar" style="query" required="true" type="xs:int"/>
        <param name="a" style="query" repeating="true" type="xs:string"/>
-       <param name="b" style="query" repeating="true" type="xs:long"/> 
+       <param name="b:c" style="query" repeating="true" type="xs:long"/> 
        <representation mediaType="application/xml" element="prefix1:theBook2">
         <doc>InputBook</doc>
        </representation>



Mime
View raw message