geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d...@apache.org
Subject svn commit: r528250 - in /geronimo/server/trunk/modules/geronimo-axis2-builder/src/main/java/org/apache/geronimo/axis2/builder: Axis2Builder.java Axis2BuilderUtil.java
Date Thu, 12 Apr 2007 21:58:24 GMT
Author: dims
Date: Thu Apr 12 14:58:20 2007
New Revision: 528250

URL: http://svn.apache.org/viewvc?view=rev&rev=528250
Log:
Fix for GERONIMO-3092 - Axis2: after wsgen tool, need to scan the directory for the generated
wsdl file

Modified:
    geronimo/server/trunk/modules/geronimo-axis2-builder/src/main/java/org/apache/geronimo/axis2/builder/Axis2Builder.java
    geronimo/server/trunk/modules/geronimo-axis2-builder/src/main/java/org/apache/geronimo/axis2/builder/Axis2BuilderUtil.java

Modified: geronimo/server/trunk/modules/geronimo-axis2-builder/src/main/java/org/apache/geronimo/axis2/builder/Axis2Builder.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-axis2-builder/src/main/java/org/apache/geronimo/axis2/builder/Axis2Builder.java?view=diff&rev=528250&r1=528249&r2=528250
==============================================================================
--- geronimo/server/trunk/modules/geronimo-axis2-builder/src/main/java/org/apache/geronimo/axis2/builder/Axis2Builder.java
(original)
+++ geronimo/server/trunk/modules/geronimo-axis2-builder/src/main/java/org/apache/geronimo/axis2/builder/Axis2Builder.java
Thu Apr 12 14:58:20 2007
@@ -17,6 +17,26 @@
 
 package org.apache.geronimo.axis2.builder;
 
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.StringWriter;
+import java.lang.reflect.Method;
+import java.net.MalformedURLException;
+import java.net.URI;
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.jar.JarFile;
+
+import javax.xml.namespace.QName;
+import javax.xml.ws.soap.SOAPBinding;
+
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.geronimo.axis2.client.Axis2ServiceReference;
@@ -48,25 +68,6 @@
 import org.apache.xmlbeans.XmlCursor;
 import org.apache.xmlbeans.XmlObject;
 
-import javax.xml.namespace.QName;
-import javax.xml.ws.WebServiceException;
-import javax.xml.ws.soap.SOAPBinding;
-import java.io.ByteArrayOutputStream;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.io.StringWriter;
-import java.lang.reflect.Method;
-import java.net.MalformedURLException;
-import java.net.URI;
-import java.net.URL;
-import java.net.URLClassLoader;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.jar.JarFile;
-
 /**
  * @version $Rev$ $Date$
  */
@@ -220,7 +221,7 @@
                     && !JAXWSUtils.containsWsdlLocation(clazz, context.getClassLoader()))
{
                     //let's use the wsgen tool to create a wsdl file
                     //todo: pass the correct bindingtype, use the default binding for now
-                    String fileName = generateWsdl(module, seiClassName, SOAPBinding.SOAP11HTTP_BINDING,
context);
+                    String fileName = generateWsdl(module, seiClassName, SOAPBinding.SOAP11HTTP_BINDING,
context, portInfo);
                     //set the wsdlFile property on portInfo.
                     portInfo.setWsdlFile(fileName);
                 }
@@ -311,14 +312,11 @@
         portInfo.setLocation(oldup);
     }
     
-    private String generateWsdl(Module module, String sei, String bindingType, DeploymentContext
context) throws DeploymentException {
+    private String generateWsdl(Module module, String sei, String bindingType, DeploymentContext
context, PortInfo portInfo) throws DeploymentException {
         //call wsgen tool to generate the wsdl file based on the bindingtype.
-        //let's put the outputDir in the module wsdl directory in repository.
-        String outputDir;
-
-        EARContext moduleContext = module.getEarContext();
-        outputDir = moduleContext.getBaseDir().getAbsolutePath();
-
+        //let's set the outputDir as the module base directory in server repository.
+        File moduleBaseDir = module.getEarContext().getBaseDir();
+        
         URL[] urls;
         String classPath = "";
         //let's figure out the classpath for wsgen tools
@@ -337,26 +335,8 @@
         classPath += Axis2BuilderUtil.getModuleClasspath(module, context);
 
         //create arguments;
-        String[] arguments = null;       
-        if(bindingType == null || bindingType.equals("") || bindingType.equals(
-                SOAPBinding.SOAP11HTTP_BINDING) || bindingType.equals(
-                        SOAPBinding.SOAP11HTTP_MTOM_BINDING)) {
-            log.info("wsgen - Generating WSDL with SOAP 1.1 binding type, based on type "
+ bindingType);
-            log.info("outputDir is " + outputDir);
-            arguments = new String[]{"-cp", classPath, sei, "-keep", "-wsdl:soap1.1", "-d",
-                    outputDir};
-        } else if (bindingType.equals(SOAPBinding.SOAP12HTTP_BINDING) || bindingType.equals(
-                SOAPBinding.SOAP12HTTP_MTOM_BINDING)) { 
-            //Xsoap1.2 is not standard and can only be
-            //used in conjunction with the -extension option
-            log.info("wsgen - Generating WSDL with SOAP 1.2 binding type, based on type "
+ bindingType);
-            log.info("outputDir is " + outputDir);
-            arguments =  new String[]{"-cp", classPath, sei, "-keep", "-extension",
-                    "-wsdl:Xsoap1.2", "-d", outputDir};
-        } else {
-            throw new WebServiceException("The bindingType specified by " + sei 
-                    + " is not supported and cannot be used to generate a wsdl");
-        }
+        String[] arguments = Axis2BuilderUtil.buildArguments(classPath, sei, bindingType,
moduleBaseDir, portInfo);
+        log.info("wsgen - Generating WSDL with SOAP 1.1 binding type, based on type " + bindingType);
         
         try {
             URLClassLoader loader = new URLClassLoader(urls, ClassLoader.getSystemClassLoader());
@@ -368,8 +348,8 @@
             Boolean result = (Boolean) method2.invoke(factory, os, arguments);
             os.close();
             if (result) //check to see if the file is created.
-                return "SOAPService.wsdl"; //this is the default name of the wsdl file. 
TODO: can we overwrite it?
-            else
+                return Axis2BuilderUtil.getWsdlFileLoc(moduleBaseDir, portInfo);
+            else //file isn't created.
                 return "";
         } catch (Exception e) {
             log.warn("unable to generate the wsdl file using wsgen.", e);

Modified: geronimo/server/trunk/modules/geronimo-axis2-builder/src/main/java/org/apache/geronimo/axis2/builder/Axis2BuilderUtil.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-axis2-builder/src/main/java/org/apache/geronimo/axis2/builder/Axis2BuilderUtil.java?view=diff&rev=528250&r1=528249&r2=528250
==============================================================================
--- geronimo/server/trunk/modules/geronimo-axis2-builder/src/main/java/org/apache/geronimo/axis2/builder/Axis2BuilderUtil.java
(original)
+++ geronimo/server/trunk/modules/geronimo-axis2-builder/src/main/java/org/apache/geronimo/axis2/builder/Axis2BuilderUtil.java
Thu Apr 12 14:58:20 2007
@@ -17,21 +17,26 @@
 
 package org.apache.geronimo.axis2.builder;
 
+import java.io.File;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+import javax.xml.namespace.QName;
+import javax.xml.ws.WebServiceException;
+import javax.xml.ws.soap.SOAPBinding;
+
 import org.apache.geronimo.common.DeploymentException;
 import org.apache.geronimo.deployment.DeploymentConfigurationManager;
 import org.apache.geronimo.deployment.DeploymentContext;
 import org.apache.geronimo.j2ee.deployment.EARContext;
 import org.apache.geronimo.j2ee.deployment.Module;
+import org.apache.geronimo.jaxws.PortInfo;
 import org.apache.geronimo.kernel.repository.Artifact;
 import org.apache.geronimo.kernel.repository.Repository;
 
-import java.io.File;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-
 public class Axis2BuilderUtil {
 
     //TODO: need to update to released jars when they are avail.
@@ -140,5 +145,77 @@
             }
             return new File(filename);
         }
+    }
+    
+    protected static String[] buildArguments(String classPath, String sei, String bindingType,
File moduleBaseDir, PortInfo portInfo) {
+        String[] arguments = null; 
+        QName serviceName = portInfo.getWsdlService();
+        QName portName = portInfo.getWsdlPort();
+        
+        if(bindingType == null || bindingType.equals("") || bindingType.equals(
+        SOAPBinding.SOAP11HTTP_BINDING) || bindingType.equals(
+                SOAPBinding.SOAP11HTTP_MTOM_BINDING)) {
+            if (serviceName == null && portName == null)
+                arguments = new String[]{"-cp", classPath, sei, "-keep", "-wsdl:soap1.1",
"-d",
+                    moduleBaseDir.getAbsolutePath()};
+            else if (serviceName == null)
+                arguments = new String[]{"-cp", classPath, sei, "-keep", "-wsdl:soap1.1",
"-d",
+                    moduleBaseDir.getAbsolutePath(), "-servicename", serviceName.toString()};
+            else if (portName == null)
+                arguments = new String[]{"-cp", classPath, sei, "-keep", "-wsdl:soap1.1",
"-d",
+                    moduleBaseDir.getAbsolutePath(), "-portname", portName.toString()};
+            else 
+                arguments = new String[]{"-cp", classPath, sei, "-keep", "-wsdl:soap1.1",
"-d",
+                    moduleBaseDir.getAbsolutePath(), "-servicename", serviceName.toString(),

+                    "-portname", portName.toString()};
+        } else if (bindingType.equals(SOAPBinding.SOAP12HTTP_BINDING) || bindingType.equals(
+            SOAPBinding.SOAP12HTTP_MTOM_BINDING)) { 
+            //Xsoap1.2 is not standard and can only be
+            //used in conjunction with the -extension option
+            if (serviceName == null && portName == null)
+                arguments =  new String[]{"-cp", classPath, sei, "-keep", "-extension",
+                    "-wsdl:Xsoap1.2", "-d", moduleBaseDir.getAbsolutePath()};
+            else if (serviceName == null)
+                arguments =  new String[]{"-cp", classPath, sei, "-keep", "-extension",
+                    "-wsdl:Xsoap1.2", "-d", moduleBaseDir.getAbsolutePath(), "-servicename",

+                    serviceName.toString()};  
+            else if (portName == null)
+                arguments =  new String[]{"-cp", classPath, sei, "-keep", "-extension",
+                    "-wsdl:Xsoap1.2", "-d", moduleBaseDir.getAbsolutePath(), "-portname",

+                    portName.toString()}; 
+            else
+                arguments =  new String[]{"-cp", classPath, sei, "-keep", "-extension",
+                    "-wsdl:Xsoap1.2", "-d", moduleBaseDir.getAbsolutePath(), "-servicename",

+                    serviceName.toString(), "-portname", portName.toString()}; 
+        } else {
+            throw new WebServiceException("The bindingType specified by " + sei 
+                + " is not supported and cannot be used to generate a wsdl");
+       }
+        
+        return arguments;
+    }
+    
+    protected static String getWsdlFileLoc(File moduleBaseDir, PortInfo portInfo) {
+        QName serviceName = portInfo.getWsdlService();
+
+        if (serviceName != null) {
+            //check if serviceName.wsdl locates at the moduleBaseDir, if so, return its path.
+            File wsdlFile = new File(moduleBaseDir.getAbsolutePath() + java.io.File.separator
+ 
+                    serviceName.getLocalPart() + ".wsdl");
+            if (wsdlFile.exists())
+                return serviceName.getLocalPart() + ".wsdl";
+        } else {//scan the moduleBaseDir and return the first wsdl file found
+            if(moduleBaseDir.isDirectory()) {
+                File[] files = moduleBaseDir.listFiles();
+                for(File file : files) {
+                    String fileName = file.getName();
+                    if(fileName.endsWith(".wsdl")) {
+                        return fileName;
+                    }
+                }
+            }
+        }
+       //unable to find the wsdl file.
+       return "";   
     }
 }



Mime
View raw message