cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From e..@apache.org
Subject svn commit: r557586 - in /incubator/cxf/trunk/tools/wsdlto: frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/generators/ frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/template/ test/src/test/java/org/apa...
Date Thu, 19 Jul 2007 11:51:18 GMT
Author: ema
Date: Thu Jul 19 04:51:17 2007
New Revision: 557586

URL: http://svn.apache.org/viewvc?view=rev&rev=557586
Log:
[CXF-810]Fixed ant script generated by wsdl2java

Modified:
    incubator/cxf/trunk/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/generators/AntGenerator.java
    incubator/cxf/trunk/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/template/build.vm
    incubator/cxf/trunk/tools/wsdlto/test/src/test/java/org/apache/cxf/tools/wsdlto/jaxws/CodeGenBugTest.java

Modified: incubator/cxf/trunk/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/generators/AntGenerator.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/generators/AntGenerator.java?view=diff&rev=557586&r1=557585&r2=557586
==============================================================================
--- incubator/cxf/trunk/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/generators/AntGenerator.java
(original)
+++ incubator/cxf/trunk/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/generators/AntGenerator.java
Thu Jul 19 04:51:17 2007
@@ -19,12 +19,20 @@
 
 package org.apache.cxf.tools.wsdlto.frontend.jaxws.generators;
 
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+
 import org.apache.cxf.common.i18n.Message;
 import org.apache.cxf.service.model.ServiceInfo;
 import org.apache.cxf.tools.common.ToolConstants;
 import org.apache.cxf.tools.common.ToolContext;
 import org.apache.cxf.tools.common.ToolException;
+import org.apache.cxf.tools.common.model.JavaInterface;
 import org.apache.cxf.tools.common.model.JavaModel;
+import org.apache.cxf.tools.common.model.JavaPort;
+import org.apache.cxf.tools.common.model.JavaServiceClass;
+import org.apache.cxf.tools.util.NameUtil;
 
 public class AntGenerator extends AbstractJAXWSGenerator {
 
@@ -60,9 +68,50 @@
             }
             return;
         }
+        
+        Map<String, String> clientClassNamesMap = new HashMap<String, String>();
+        Map<String, String> serverClassNamesMap = new HashMap<String, String>();
+        
+        Map<String, JavaInterface> interfaces = javaModel.getInterfaces();
+        int index = 1;
+        Iterator it = javaModel.getServiceClasses().values().iterator();
+        while (it.hasNext()) {
+            JavaServiceClass js = (JavaServiceClass)it.next();
+            Iterator i = js.getPorts().iterator();
+            while (i.hasNext()) {
+                JavaPort jp = (JavaPort)i.next();
+                String interfaceName = jp.getPortType();
+                JavaInterface intf = interfaces.get(interfaceName);
+                
+                String clientClassName = intf.getPackageName() + "." + interfaceName + "_"
+                                         + NameUtil.mangleNameToClassName(jp.getPortName())
+ "_Client";
+
+                String serverClassName = intf.getPackageName() + "." + interfaceName + "_"
+                                         + NameUtil.mangleNameToClassName(jp.getPortName())
+ "_Server";
+                String clientTargetName = interfaceName + "Client";
+                boolean collison = false;
+                if (clientClassNamesMap.keySet().contains(clientTargetName)) {
+                    clientTargetName = clientTargetName + index;
+                    collison = true;
+                }
+                String serverTargetName = interfaceName + "Server";
+                if (serverClassNamesMap.keySet().contains(serverTargetName)) {
+                    serverTargetName = serverTargetName + index;
+                    collison = true;
+                }
+                
+                if (collison) {
+                    index++;
+                }
+                clientClassNamesMap.put(clientTargetName, clientClassName);
+                serverClassNamesMap.put(serverTargetName, serverClassName);
+                
+            }
+        }
 
         clearAttributes();
-        setAttributes("intfs", javaModel.getInterfaces().values());
+        setAttributes("clientClassNamesMap", clientClassNamesMap);
+        setAttributes("serverClassNamesMap", serverClassNamesMap);
         setAttributes("wsdlLocation", javaModel.getLocation());
         setCommonAttributes();
 

Modified: incubator/cxf/trunk/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/template/build.vm
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/template/build.vm?view=diff&rev=557586&r1=557585&r2=557586
==============================================================================
--- incubator/cxf/trunk/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/template/build.vm
(original)
+++ incubator/cxf/trunk/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/template/build.vm
Thu Jul 19 04:51:17 2007
@@ -91,20 +91,23 @@
 	<pathelement location="${cxf-manifest-incubator.jar.file}"/>
     </path>
 
-#foreach ($interface in $intfs)
-    <target name="${interface.Name}.Client" description="Run ${interface.Name} client"
depends="compile">
+#foreach ($targetName in $clientClassNamesMap.keySet())
+    <target name="$targetName" description="Run $clientClassNamesMap.get($targetName)"
depends="compile">
 	<property name="param" value=""/>
-	<cxfrun classname="${interface.PackageName}.${interface.Name}Client"
+	<cxfrun classname="$clientClassNamesMap.get($targetName)"
 		   param1="$wsdlLocation"
 		   param2="${op}" 
 		   param3="${param}"/>
     </target> 
+#end
 
-    <target name="${interface.Name}.Server" description="Run ${interface.Name} server"
depends="compile">
-	<cxfrun classname="${interface.PackageName}.${interface.Name}Server" 
+#foreach ($target in $serverClassNamesMap.keySet())
+    <target name="${target}" description="Run $serverClassNamesMap.get($target)" depends="compile">
+	<cxfrun classname="$serverClassNamesMap.get($target)" 
 		   param1="$wsdlLocation"/>
     </target>
 #end
+
 
 
     <target name="compile">

Modified: incubator/cxf/trunk/tools/wsdlto/test/src/test/java/org/apache/cxf/tools/wsdlto/jaxws/CodeGenBugTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/wsdlto/test/src/test/java/org/apache/cxf/tools/wsdlto/jaxws/CodeGenBugTest.java?view=diff&rev=557586&r1=557585&r2=557586
==============================================================================
--- incubator/cxf/trunk/tools/wsdlto/test/src/test/java/org/apache/cxf/tools/wsdlto/jaxws/CodeGenBugTest.java
(original)
+++ incubator/cxf/trunk/tools/wsdlto/test/src/test/java/org/apache/cxf/tools/wsdlto/jaxws/CodeGenBugTest.java
Thu Jul 19 04:51:17 2007
@@ -611,4 +611,21 @@
     }
     
     
-}
+    @Test
+    public void testAntFile() throws Exception {
+        env.put(ToolConstants.CFG_WSDLURL, getLocation("/wsdl2java_wsdl/hello_world.wsdl"));
+        env.put(ToolConstants.CFG_ANT, ToolConstants.CFG_ANT);
+        env.put(ToolConstants.CFG_SERVICENAME, "SOAPService_Test1");
+        processor.setContext(env);
+        
+        processor.execute();
+        File file = new File(output.getCanonicalPath() + "/build.xml");
+        String str = getStringFromFile(file);
+        assertTrue(str.indexOf("org.apache.hello_world_soap_http.Greeter_SoapPortTest1_Client")
> -1);
+        assertTrue(str.indexOf("org.apache.hello_world_soap_http.Greeter_SoapPortTest2_Client")
> -1);
+        assertTrue(str.indexOf("org.apache.hello_world_soap_http.Greeter_SoapPortTest1_Server")
> -1);
+        assertTrue(str.indexOf("org.apache.hello_world_soap_http.Greeter_SoapPortTest2_Server")
> -1);        
+    }
+    
+    
+}
\ No newline at end of file



Mime
View raw message