cxf-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Keith Halligan (JIRA)" <j...@apache.org>
Subject [jira] [Created] (CXF-6071) CXF's WSDL2Java tool can generate impl classes that jdk compiler will refuse to compile
Date Wed, 29 Oct 2014 16:39:34 GMT
Keith Halligan created CXF-6071:
-----------------------------------

             Summary: CXF's WSDL2Java tool can generate impl classes that jdk compiler will
refuse to compile
                 Key: CXF-6071
                 URL: https://issues.apache.org/jira/browse/CXF-6071
             Project: CXF
          Issue Type: Bug
          Components: Tooling
    Affects Versions: 3.0.2, 3.0.1
         Environment: All
            Reporter: Keith Halligan
             Fix For: 3.0.3


When using Apache CXF 3.0.1 and above the following WSDL (attached) will compile with the
wsdl2java tool, however the code cannot be compiled as the implementation class cannot be
compiled with any JDK.

The issue is that the generated implementation class has a "." in the class name.

eg:
D:\programming\artix\apache-cxf-3.0.1-bin\bin\test>dir /b com\iona\schemas\idl\iacc_idl\*Impl.java
CORBAPortImpl.java
IACC.ServerCORBAPortImpl.java

Below is a patch that works around the issue, while still keeping the current functionality
in place, only switching back to the old functionality (changed in: CXF-5456) when the port
name contains non-valid characters as far as a JVM compiler is concerned.

{noformat}
diff --git a/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/generators/ImplGenerator.java
b/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/generators/ImplGenerator.java
index 5fe090d..63dc84d 100644
--- a/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/generators/ImplGenerator.java
+++ b/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/generators/ImplGenerator.java
@@ -21,6 +21,8 @@ package org.apache.cxf.tools.wsdlto.frontend.jaxws.generators;

 import java.util.HashMap;
 import java.util.Map;
+import java.util.regex.Pattern;
+import java.util.regex.Matcher;

 import javax.xml.namespace.QName;

@@ -126,12 +128,17 @@ public class ImplGenerator extends AbstractJAXWSGenerator {
         }
         String name = nm.get(service + "/" + port);
         if (name == null) {
-            name = port + "Impl";
+            name = (isPortNameCompliant(port)) ? port : intf.getName() + "Impl";
             name = mapClassName(intf.getPackageName(), name, penv);
             nm.put(service + "/" + port, name);
         }
         return name;
     }
+
+    private boolean isPortNameCompliant(String port) {
+        return Pattern.matches("[a-zA-Z]\\w*", port);
+    }
+
     private String mapClassName(String packageName, String name, ToolContext context) {
         ClassCollector collector = context.get(ClassCollector.class);
         int count = 0;
{noformat}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Mime
View raw message