You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by dk...@apache.org on 2011/08/26 22:04:14 UTC

svn commit: r1162231 - in /cxf/branches/2.4.x-fixes: ./ 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/fro...

Author: dkulp
Date: Fri Aug 26 20:04:14 2011
New Revision: 1162231

URL: http://svn.apache.org/viewvc?rev=1162231&view=rev
Log:
Merged revisions 1162224 via svnmerge from 
https://svn.apache.org/repos/asf/cxf/trunk

........
  r1162224 | dkulp | 2011-08-26 15:56:35 -0400 (Fri, 26 Aug 2011) | 2 lines
  
  [CXF-3762] Support a flag to set the exception superclass
  Modified patch from Aaron Pieper applied
........

Modified:
    cxf/branches/2.4.x-fixes/   (props changed)
    cxf/branches/2.4.x-fixes/api/src/main/java/org/apache/cxf/tools/common/ToolConstants.java
    cxf/branches/2.4.x-fixes/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/Option.java
    cxf/branches/2.4.x-fixes/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/WsdlOption.java
    cxf/branches/2.4.x-fixes/tools/wsdlto/core/src/main/java/org/apache/cxf/tools/wsdlto/wsdlto.xml
    cxf/branches/2.4.x-fixes/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/generators/FaultGenerator.java
    cxf/branches/2.4.x-fixes/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/jaxws-toolspec.xml
    cxf/branches/2.4.x-fixes/tools/wsdlto/test/src/test/java/org/apache/cxf/tools/wsdlto/jaxws/CodeGenTest.java

Propchange: cxf/branches/2.4.x-fixes/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.

Modified: cxf/branches/2.4.x-fixes/api/src/main/java/org/apache/cxf/tools/common/ToolConstants.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.4.x-fixes/api/src/main/java/org/apache/cxf/tools/common/ToolConstants.java?rev=1162231&r1=1162230&r2=1162231&view=diff
==============================================================================
--- cxf/branches/2.4.x-fixes/api/src/main/java/org/apache/cxf/tools/common/ToolConstants.java (original)
+++ cxf/branches/2.4.x-fixes/api/src/main/java/org/apache/cxf/tools/common/ToolConstants.java Fri Aug 26 20:04:14 2011
@@ -96,6 +96,7 @@ public final class ToolConstants {
     public static final String CFG_ALLOW_ELEMENT_REFS = "allowElementReferences";
     public static final String CFG_RESERVE_NAME = "reserveClass";
     public static final String CFG_FAULT_SERIAL_VERSION_UID = "faultSerialVersionUID";
+    public static final String CFG_EXCEPTION_SUPER = "exceptionSuper";
     public static final String CFG_MARK_GENERATED = "mark-generated";
 
 

Modified: cxf/branches/2.4.x-fixes/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/Option.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.4.x-fixes/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/Option.java?rev=1162231&r1=1162230&r2=1162231&view=diff
==============================================================================
--- cxf/branches/2.4.x-fixes/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/Option.java (original)
+++ cxf/branches/2.4.x-fixes/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/Option.java Fri Aug 26 20:04:14 2011
@@ -151,6 +151,11 @@ public class Option {
     String faultSerialVersionUID;
 
     /**
+     * The superclass to use for generated exceptions, default is java.lang.Exception
+     */
+    String exceptionSuper;
+
+    /**
      * Uses @Generated annotation in all generated java classes if the flag is set to true.
      */
     Boolean markGenerated;
@@ -359,6 +364,14 @@ public class Option {
     public void setFaultSerialVersionUID(String faultSerialVersionUID) {
         this.faultSerialVersionUID = faultSerialVersionUID;
     }
+    
+    public String getExceptionSuper() {
+        return exceptionSuper;
+    }
+    
+    public void setExceptionSuper(String exceptionSuper) {
+        this.exceptionSuper = exceptionSuper;
+    }
 
     public Boolean isMarkGenerated() {
         return markGenerated;
@@ -446,6 +459,7 @@ public class Option {
         destination.setMimeMethods(getMimeMethods());
         destination.setAsyncMethods(getAsyncMethods());
         destination.setBareMethods(getBareMethods());
+        destination.setExceptionSuper(getExceptionSuper());
     }
     
     private <T> T setIfNull(T dest, T source) {
@@ -457,6 +471,7 @@ public class Option {
     
     public void merge(Option defaultOptions) {
         wsdlList = setIfNull(wsdlList, defaultOptions.wsdlList);
+        exceptionSuper = setIfNull(exceptionSuper, defaultOptions.exceptionSuper);
         extendedSoapHeaders = setIfNull(extendedSoapHeaders, defaultOptions.extendedSoapHeaders);
         noTypes = setIfNull(noTypes, defaultOptions.noTypes);
         validateWsdl = setIfNull(validateWsdl, defaultOptions.validateWsdl);

Modified: cxf/branches/2.4.x-fixes/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/WsdlOption.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.4.x-fixes/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/WsdlOption.java?rev=1162231&r1=1162230&r2=1162231&view=diff
==============================================================================
--- cxf/branches/2.4.x-fixes/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/WsdlOption.java (original)
+++ cxf/branches/2.4.x-fixes/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/WsdlOption.java Fri Aug 26 20:04:14 2011
@@ -156,6 +156,7 @@ public class WsdlOption extends Option {
         addIfNotNull(list, getDefaultNamespacePackageMapping(), "-dns");
         addIfNotNull(list, getServiceName(), "-sn");
         addIfNotNull(list, getFaultSerialVersionUID(), "-faultSerialVersionUID");
+        addIfNotNull(list, getExceptionSuper(), "-exceptionSuper");
         addIfTrue(list, isAutoNameResolution(), "-autoNameResolution");
         addIfTrue(list, isNoAddressBinding(), "-noAddressBinding");
         addList(list, "-xjc", false, getXJCargs());

Modified: cxf/branches/2.4.x-fixes/tools/wsdlto/core/src/main/java/org/apache/cxf/tools/wsdlto/wsdlto.xml
URL: http://svn.apache.org/viewvc/cxf/branches/2.4.x-fixes/tools/wsdlto/core/src/main/java/org/apache/cxf/tools/wsdlto/wsdlto.xml?rev=1162231&r1=1162230&r2=1162231&view=diff
==============================================================================
--- cxf/branches/2.4.x-fixes/tools/wsdlto/core/src/main/java/org/apache/cxf/tools/wsdlto/wsdlto.xml (original)
+++ cxf/branches/2.4.x-fixes/tools/wsdlto/core/src/main/java/org/apache/cxf/tools/wsdlto/wsdlto.xml Fri Aug 26 20:04:14 2011
@@ -208,6 +208,16 @@ under the License.
                 </associatedArgument>
             </option>
 
+            <option id="exceptionSuper" maxOccurs="1">
+                <annotation>
+                    Specifies the superclass to use for generated exceptions, the default is java.lang.Exception.
+                </annotation>
+                <switch>exceptionSuper</switch>
+                <associatedArgument placement="afterSpace">
+                    <annotation>exceptionSuper</annotation>
+                </associatedArgument>
+            </option>
+
         </optionGroup>
         <optionGroup id="common_options">
             <option id="help" maxOccurs="1">

Modified: cxf/branches/2.4.x-fixes/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/generators/FaultGenerator.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.4.x-fixes/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/generators/FaultGenerator.java?rev=1162231&r1=1162230&r2=1162231&view=diff
==============================================================================
--- cxf/branches/2.4.x-fixes/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/generators/FaultGenerator.java (original)
+++ cxf/branches/2.4.x-fixes/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/generators/FaultGenerator.java Fri Aug 26 20:04:14 2011
@@ -105,24 +105,33 @@ public class FaultGenerator extends Abst
                     setAttributes("suid", "");
                 }
                 setAttributes("expClass", expClz);
-                String exceptionSuperclass = "Exception";
+                String exceptionSuperclass;
+                if (penv.containsKey(ToolConstants.CFG_EXCEPTION_SUPER)) {
+                    exceptionSuperclass = penv.get(ToolConstants.CFG_EXCEPTION_SUPER).toString();
+                } else {
+                    exceptionSuperclass = "java.lang.Exception";
+                }
+                String simpleName = exceptionSuperclass.indexOf('.') == -1 ? exceptionSuperclass 
+                    : exceptionSuperclass.substring(exceptionSuperclass.lastIndexOf('.') + 1);
+                String exceptionSuperclassString = simpleName;
                 for (JavaField jf : expClz.getFields()) {
                     String jfClassName = jf.getClassName();
-                    if (jfClassName.substring(jfClassName.lastIndexOf(".") + 1).equals("Exception")) {
-                        exceptionSuperclass = "java.lang.Exception";
+                    if (jfClassName.substring(jfClassName.lastIndexOf(".") + 1)
+                        .equals(simpleName)) {
+                        exceptionSuperclassString = exceptionSuperclass;
                     }
                     setAttributes("paraName", ProcessorUtil.mangleNameToVariableName(jf.getName()));
                 }
                 ClassCollector collector = penv.get(ClassCollector.class);
                 for (String pkg : collector.getTypesPackages()) {
-                    if (collector.containTypesClass(pkg, "Exception")) {
-                        exceptionSuperclass = "java.lang.Exception";
+                    if (collector.containTypesClass(pkg, simpleName)) {
+                        exceptionSuperclassString = exceptionSuperclass;
                     }
                 }
-                if (expClz.getName().equals(exceptionSuperclass)) {
-                    exceptionSuperclass = "java.lang.Exception";
+                if (expClz.getName().equals(exceptionSuperclassString)) {
+                    exceptionSuperclassString = exceptionSuperclass;
                 }
-                setAttributes("exceptionSuperclass", exceptionSuperclass);
+                setAttributes("exceptionSuperclass", exceptionSuperclassString);
 
                 setCommonAttributes();
                 doWrite(FAULT_TEMPLATE, parseOutputName(expClz.getPackageName(),

Modified: cxf/branches/2.4.x-fixes/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/jaxws-toolspec.xml
URL: http://svn.apache.org/viewvc/cxf/branches/2.4.x-fixes/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/jaxws-toolspec.xml?rev=1162231&r1=1162230&r2=1162231&view=diff
==============================================================================
--- cxf/branches/2.4.x-fixes/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/jaxws-toolspec.xml (original)
+++ cxf/branches/2.4.x-fixes/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/jaxws-toolspec.xml Fri Aug 26 20:04:14 2011
@@ -354,6 +354,16 @@ Examples:
                 </associatedArgument>
             </option>
 
+            <option id="exceptionSuper" maxOccurs="1">
+                <annotation>
+                    Specifies the superclass to use for generated exceptions, the default is java.lang.Exception.
+                </annotation>
+                <switch>exceptionSuper</switch>
+                <associatedArgument placement="afterSpace">
+                    <annotation>exceptionSuper</annotation>
+                </associatedArgument>
+            </option>
+
             <option id="mark-generated" maxOccurs="1">
                 <annotation>
                     Adds @Generated annotation in all java files that are generated.

Modified: cxf/branches/2.4.x-fixes/tools/wsdlto/test/src/test/java/org/apache/cxf/tools/wsdlto/jaxws/CodeGenTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.4.x-fixes/tools/wsdlto/test/src/test/java/org/apache/cxf/tools/wsdlto/jaxws/CodeGenTest.java?rev=1162231&r1=1162230&r2=1162231&view=diff
==============================================================================
--- cxf/branches/2.4.x-fixes/tools/wsdlto/test/src/test/java/org/apache/cxf/tools/wsdlto/jaxws/CodeGenTest.java (original)
+++ cxf/branches/2.4.x-fixes/tools/wsdlto/test/src/test/java/org/apache/cxf/tools/wsdlto/jaxws/CodeGenTest.java Fri Aug 26 20:04:14 2011
@@ -1542,6 +1542,36 @@ public class CodeGenTest extends Abstrac
         assertEquals(123456789L, l.longValue());
     }
     @Test
+    public void testNoExceptionSuper() throws Exception {
+        env.put(ToolConstants.CFG_WSDLURL, getLocation("/wsdl2java_wsdl/hello_world.wsdl"));
+        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(Exception.class, fault.getSuperclass());
+    }
+    @Test
+    public void testExceptionSuper() throws Exception {
+        env.put(ToolConstants.CFG_WSDLURL, getLocation("/wsdl2java_wsdl/hello_world.wsdl"));
+        env.put(ToolConstants.CFG_EXCEPTION_SUPER, "java.lang.RuntimeException");
+        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(RuntimeException.class, fault.getSuperclass());
+    }
+
+    @Test
     public void testExtensionWrapper() throws Exception {
         env.put(ToolConstants.CFG_WSDLURL,
                 getLocation("/wsdl2java_wsdl/cxf2193/hello_world_extension_wrapped.wsdl"));