cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r943613 - 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/mai...
Date Wed, 12 May 2010 18:19:21 GMT
Author: dkulp
Date: Wed May 12 18:19:20 2010
New Revision: 943613

URL: http://svn.apache.org/viewvc?rev=943613&view=rev
Log:
[CXF-2808] Add ability to use hash of fqcn for the suid for faults
Patch from Julien Jean Paul Sirocchi applied

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/wsdlto.xml
    cxf/trunk/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/generators/FaultGenerator.java
    cxf/trunk/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/jaxws-toolspec.xml
    cxf/trunk/tools/wsdlto/test/src/test/java/org/apache/cxf/tools/wsdlto/jaxws/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/tools/common/ToolConstants.java?rev=943613&r1=943612&r2=943613&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 May 12
18:19:20 2010
@@ -91,7 +91,7 @@ public final class ToolConstants {
     public static final String CFG_NO_ADDRESS_BINDING = "noAddressBinding";
     public static final String CFG_ALLOW_ELEMENT_REFS = "allowElementReferences";
     public static final String CFG_RESERVE_NAME = "reserveClass";
-
+    public static final String CFG_USE_FQCN_FAULT_SERIAL_VERSION_UID = "useFQCNForFaultSerialVersionUID";
 
 
     //Internal Flag to generate

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=943613&r1=943612&r2=943613&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 May 12 18:19:20 2010
@@ -136,6 +136,11 @@ public class Option {
     Boolean validateWsdl;
 
     /**
+     * Enables generation of fault Exception's SUID based on hash of classname.
+     */
+    Boolean useFQCNForFaultSerialVersionUID;
+
+    /**
      * The WSDL service name to use for the generated code
      */
     String serviceName;
@@ -305,6 +310,14 @@ public class Option {
         this.validateWsdl = validateWsdl;
     }
 
+    public boolean isUseFQCNForFaultSerialVersionUID() {
+        return useFQCNForFaultSerialVersionUID == null ? false : useFQCNForFaultSerialVersionUID;
+    }
+
+    public void setUseFQCNForFaultSerialVersionUID(boolean useFQCNForFaultSerialVersionUID)
{
+        this.useFQCNForFaultSerialVersionUID = useFQCNForFaultSerialVersionUID;
+    }
+
     public Boolean getDefaultExcludesNamespace() {
         return defaultExcludesNamespace;
     }
@@ -372,6 +385,7 @@ public class Option {
         destination.setPackagenames(getPackagenames());
         destination.setServiceName(getServiceName());
         destination.setValidateWsdl(isValidateWsdl());
+        destination.setUseFQCNForFaultSerialVersionUID(isUseFQCNForFaultSerialVersionUID());
         destination.setAllowElementRefs(isAllowElementRefs());
         if (isSetWsdlLocation()) {
             destination.setWsdlLocation(getWsdlLocation());
@@ -390,6 +404,8 @@ public class Option {
         wsdlList = setIfNull(wsdlList, defaultOptions.wsdlList);
         extendedSoapHeaders = setIfNull(extendedSoapHeaders, defaultOptions.extendedSoapHeaders);
         validateWsdl = setIfNull(validateWsdl, defaultOptions.validateWsdl);
+        useFQCNForFaultSerialVersionUID = setIfNull(useFQCNForFaultSerialVersionUID,
+            defaultOptions.useFQCNForFaultSerialVersionUID);
         autoNameResolution = setIfNull(autoNameResolution, defaultOptions.autoNameResolution);
         noAddressBinding = setIfNull(noAddressBinding, defaultOptions.noAddressBinding);
         allowElementRefs = setIfNull(allowElementRefs, defaultOptions.allowElementRefs);

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=943613&r1=943612&r2=943613&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 May 12 18:19:20 2010
@@ -150,6 +150,7 @@ public class WsdlOption extends Option {
         }
         addIfTrue(list, isAllowElementRefs(), "-allowElementRefs");
         addIfTrue(list, isValidateWsdl(), "-validate");
+        addIfTrue(list, isUseFQCNForFaultSerialVersionUID(), "-useFQCNForFaultSerialVersionUID");
         addIfNotNull(list, getDefaultExcludesNamespace(), "-dex");
         addIfNotNull(list, getDefaultNamespacePackageMapping(), "-dns");
         addIfNotNull(list, getServiceName(), "-sn");

Modified: cxf/trunk/tools/wsdlto/core/src/main/java/org/apache/cxf/tools/wsdlto/wsdlto.xml
URL: http://svn.apache.org/viewvc/cxf/trunk/tools/wsdlto/core/src/main/java/org/apache/cxf/tools/wsdlto/wsdlto.xml?rev=943613&r1=943612&r2=943613&view=diff
==============================================================================
--- cxf/trunk/tools/wsdlto/core/src/main/java/org/apache/cxf/tools/wsdlto/wsdlto.xml (original)
+++ cxf/trunk/tools/wsdlto/core/src/main/java/org/apache/cxf/tools/wsdlto/wsdlto.xml Wed May
12 18:19:20 2010
@@ -191,6 +191,14 @@ under the License.
                 </associatedArgument>
             </option>
 
+            <option id="useFQCNForFaultSerialVersionUID" maxOccurs="1">
+                <annotation>
+                    Enable generation of Serial Version UID in fault Exception(s) based on
hashcode
+                    of the fully qualified class name of the Exception.
+                </annotation>
+                <switch>useFQCNForFaultSerialVersionUID</switch>
+            </option>
+
         </optionGroup>
         <optionGroup id="common_options">
             <option id="help" maxOccurs="1">

Modified: cxf/trunk/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/generators/FaultGenerator.java
URL: http://svn.apache.org/viewvc/cxf/trunk/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/generators/FaultGenerator.java?rev=943613&r1=943612&r2=943613&view=diff
==============================================================================
--- cxf/trunk/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/generators/FaultGenerator.java
(original)
+++ cxf/trunk/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/generators/FaultGenerator.java
Wed May 12 18:19:20 2010
@@ -81,7 +81,11 @@ public class FaultGenerator extends Abst
                     exceptionClasses.get(expClassName);
     
                 clearAttributes();
-                setAttributes("suid", getSUID());
+                if (penv.containsKey(ToolConstants.CFG_USE_FQCN_FAULT_SERIAL_VERSION_UID))
{
+                    setAttributes("suid", generateHashSUID(expClz.getFullClassName()));
+                } else {
+                    setAttributes("suid", generateTimestampSUID());
+                }
                 setAttributes("expClass", expClz);
                 for (JavaField jf : expClz.getFields()) {
                     setAttributes("paraName", ProcessorUtil.mangleNameToVariableName(jf.getName()));
@@ -93,7 +97,11 @@ public class FaultGenerator extends Abst
         }
     }
 
-    private String getSUID() {
+    private String generateHashSUID(String className) {
+        return Long.toString(className.hashCode());
+    }
+
+    private String generateTimestampSUID() {
         return new SimpleDateFormat("yyyyMMddHHmmss").format(new Date());
     }
 

Modified: cxf/trunk/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/jaxws-toolspec.xml
URL: http://svn.apache.org/viewvc/cxf/trunk/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/jaxws-toolspec.xml?rev=943613&r1=943612&r2=943613&view=diff
==============================================================================
--- cxf/trunk/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/jaxws-toolspec.xml
(original)
+++ cxf/trunk/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/jaxws-toolspec.xml
Wed May 12 18:19:20 2010
@@ -306,6 +306,14 @@ Examples:
                 <switch>noAddressBinding</switch>
             </option>
 
+            <option id="useFQCNForFaultSerialVersionUID" maxOccurs="1">
+                <annotation>
+                    Enable generation of Serial Version UID in fault Exception(s) based on
hashcode
+                    of the fully qualified class name of the Exception.
+                </annotation>
+                <switch>useFQCNForFaultSerialVersionUID</switch>
+            </option>
+
         </optionGroup>
         <optionGroup id="common_options">
             <option id="help" maxOccurs="1">

Modified: cxf/trunk/tools/wsdlto/test/src/test/java/org/apache/cxf/tools/wsdlto/jaxws/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=943613&r1=943612&r2=943613&view=diff
==============================================================================
--- cxf/trunk/tools/wsdlto/test/src/test/java/org/apache/cxf/tools/wsdlto/jaxws/CodeGenTest.java
(original)
+++ cxf/trunk/tools/wsdlto/test/src/test/java/org/apache/cxf/tools/wsdlto/jaxws/CodeGenTest.java
Wed May 12 18:19:20 2010
@@ -19,6 +19,7 @@
 package org.apache.cxf.tools.wsdlto.jaxws;
 
 import java.io.File;
+import java.io.ObjectStreamClass;
 import java.lang.annotation.Annotation;
 import java.lang.reflect.Method;
 import java.lang.reflect.Modifier;
@@ -1332,4 +1333,22 @@ public class CodeGenTest extends Abstrac
         assertTrue(wp.header());
     }
 
+    @Test
+    public void testCXF2808() throws Exception {
+        env.put(ToolConstants.CFG_WSDLURL, getLocation("/wsdl2java_wsdl/hello_world.wsdl"));
+        env.put(ToolConstants.CFG_USE_FQCN_FAULT_SERIAL_VERSION_UID, Boolean.TRUE);
+        processor.setContext(env);
+        processor.execute();
+
+        File faultFile = new File(output, "org/apache/cxf/w2j/hello_world_soap_http/NoSuchCodeLitFault.java");
+        assertTrue(faultFile.exists());
+        faultFile = new File(output, "org/apache/cxf/w2j/hello_world_soap_http/BadRecordLitFault.java");
+        assertTrue(faultFile.exists());
+
+        Class<?> fault = classLoader.loadClass("org.apache.cxf.w2j.hello_world_soap_http.NoSuchCodeLitFault");
+        assertEquals(fault.getName().hashCode(), ObjectStreamClass.lookup(fault).getSerialVersionUID());
+        fault = classLoader.loadClass("org.apache.cxf.w2j.hello_world_soap_http.BadRecordLitFault");
+        assertEquals(fault.getName().hashCode(), ObjectStreamClass.lookup(fault).getSerialVersionUID());
+    }
+
 }



Mime
View raw message