Hey Dims, looks like we'll need to update the jaxws-tools and jaxws-rt from 2.0-snapshot to 2.0 in Axis2BuilderUtil.

Lin

[EMAIL PROTECTED] wrote:
Author: dims
Date: Tue Apr 10 10:38:54 2007
New Revision: 527215

URL: http://svn.apache.org/viewvc?view=rev&rev=527215
Log:
Fix for GERONIMO-2988 - Axis2: needs to support optional wsdl file

Added:
    
geronimo/server/trunk/modules/geronimo-axis2-builder/src/main/java/org/apache/geronimo/axis2/builder/Axis2BuilderUtil.java
    geronimo/server/trunk/repository/com/
    geronimo/server/trunk/repository/com/sun/
    geronimo/server/trunk/repository/com/sun/xml/
    geronimo/server/trunk/repository/com/sun/xml/ws/
    geronimo/server/trunk/repository/com/sun/xml/ws/jaxws-rt/
    geronimo/server/trunk/repository/com/sun/xml/ws/jaxws-rt/2.0/
    
geronimo/server/trunk/repository/com/sun/xml/ws/jaxws-rt/2.0/jaxws-rt-2.0.jar   
(with props)
    
geronimo/server/trunk/repository/com/sun/xml/ws/jaxws-rt/2.0/jaxws-rt-2.0.jar.md5
    geronimo/server/trunk/repository/com/sun/xml/ws/jaxws-tools/
    geronimo/server/trunk/repository/com/sun/xml/ws/jaxws-tools/2.0/
    
geronimo/server/trunk/repository/com/sun/xml/ws/jaxws-tools/2.0/jaxws-tools-2.0.jar
   (with props)
    
geronimo/server/trunk/repository/com/sun/xml/ws/jaxws-tools/2.0/jaxws-tools-2.0.jar.md5
Modified:
    geronimo/server/trunk/configs/axis2/pom.xml
    geronimo/server/trunk/modules/geronimo-axis2-builder/pom.xml
    
geronimo/server/trunk/modules/geronimo-axis2-builder/src/main/java/org/apache/geronimo/axis2/builder/Axis2Builder.java
    geronimo/server/trunk/pom.xml
    geronimo/server/trunk/repository/pom.xml

Modified: geronimo/server/trunk/configs/axis2/pom.xml
URL: 
http://svn.apache.org/viewvc/geronimo/server/trunk/configs/axis2/pom.xml?view=diff&rev=527215&r1=527214&r2=527215
==============================================================================
--- geronimo/server/trunk/configs/axis2/pom.xml (original)
+++ geronimo/server/trunk/configs/axis2/pom.xml Tue Apr 10 10:38:54 2007
@@ -172,6 +172,18 @@
             <groupId>xml-resolver</groupId>
             <artifactId>xml-resolver</artifactId>
         </dependency>
+       <dependency>
+           <groupId>com.sun.xml.ws</groupId>
+           <artifactId>jaxws-tools</artifactId>
+       </dependency>
+       <dependency>
+           <groupId>com.sun.xml.ws</groupId>
+           <artifactId>jaxws-rt</artifactId>
+       </dependency>
+       <dependency>
+           <groupId>com.sun.xml.bind</groupId>
+           <artifactId>jaxb-xjc</artifactId>
+       </dependency>
     </dependencies>
</project>

Modified: geronimo/server/trunk/modules/geronimo-axis2-builder/pom.xml
URL: 
http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-axis2-builder/pom.xml?view=diff&rev=527215&r1=527214&r2=527215
==============================================================================
--- geronimo/server/trunk/modules/geronimo-axis2-builder/pom.xml (original)
+++ geronimo/server/trunk/modules/geronimo-axis2-builder/pom.xml Tue Apr 10 
10:38:54 2007
@@ -69,6 +69,23 @@
             <artifactId>geronimo-ws-metadata_2.0_spec</artifactId>
        </dependency>
+ <!-- add the following for wsgen -->
+        <dependency>
+            <groupId>com.sun.xml.ws</groupId>
+            <artifactId>jaxws-tools</artifactId>
+        </dependency>
+
+        <dependency>
+            <groupId>com.sun.xml.ws</groupId>
+            <artifactId>jaxws-rt</artifactId>
+        </dependency>
+
+        <dependency>
+            <groupId>com.sun.xml.bind</groupId>
+            <artifactId>jaxb-xjc</artifactId>
+        </dependency>
+        <!--end add for wsgen-->
+
     </dependencies>
</project>

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=527215&r1=527214&r2=527215
==============================================================================
--- 
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
 Tue Apr 10 10:38:54 2007
@@ -17,9 +17,11 @@
package org.apache.geronimo.axis2.builder; +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.net.URI;
 import java.net.URL;
@@ -29,6 +31,8 @@
 import java.util.jar.JarFile;
import javax.xml.namespace.QName;
+import javax.xml.ws.WebServiceException;
+import javax.xml.ws.soap.SOAPBinding;
import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
@@ -39,15 +43,18 @@
 import org.apache.geronimo.gbean.GBeanData;
 import org.apache.geronimo.gbean.GBeanInfo;
 import org.apache.geronimo.gbean.GBeanInfoBuilder;
+import org.apache.geronimo.j2ee.deployment.EARContext;
 import org.apache.geronimo.j2ee.deployment.Module;
 import org.apache.geronimo.j2ee.deployment.WebModule;
 import org.apache.geronimo.j2ee.deployment.WebServiceBuilder;
 import org.apache.geronimo.j2ee.j2eeobjectnames.NameFactory;
+import org.apache.geronimo.jaxws.JAXWSUtils;
 import org.apache.geronimo.jaxws.PortInfo;
 import org.apache.geronimo.jaxws.builder.EndpointInfoBuilder;
 import org.apache.geronimo.jaxws.builder.JAXWSServiceBuilder;
 import org.apache.geronimo.jaxws.client.EndpointInfo;
 import org.apache.geronimo.kernel.repository.Environment;
+import org.apache.geronimo.kernel.repository.MultipleMatchesException;
 import org.apache.geronimo.xbeans.geronimo.naming.GerServiceRefType;
 import org.apache.geronimo.xbeans.javaee.PortComponentRefType;
 import org.apache.geronimo.xbeans.javaee.PortComponentType;
@@ -59,6 +66,11 @@
 import org.apache.xmlbeans.XmlCursor;
 import org.apache.xmlbeans.XmlObject;
+import com.sun.tools.ws.spi.WSToolsObjectFactory;
+
+/**
+ * @version $Rev$ $Date$
+ */
 public class Axis2Builder extends JAXWSServiceBuilder {
private static final Log log = LogFactory.getLog(Axis2Builder.class);
@@ -195,10 +207,27 @@
                Map sharedContext = ((WebModule) module).getSharedContext();
         String contextRoot = ((WebModule) module).getContextRoot();
         Map portInfoMap = (Map) sharedContext.get(getKey());
+        PortInfo portInfo;
if(portInfoMap != null && portInfoMap.get(servletName) != null){
-               PortInfo portInfo = (PortInfo) portInfoMap.get(servletName);
+               portInfo = (PortInfo) portInfoMap.get(servletName);
                processURLPattern(contextRoot, portInfo);
+ + try {
+                //hookup the wsgen tool here
+                //check to see if we need to generate a wsdl file first
+                Class clazz = context.getClassLoader().loadClass(seiClassName);
+                if ((portInfo.getWsdlFile() == null || 
portInfo.getWsdlFile().equals(""))
+                    && !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);
+                    //set the wsdlFile property on portInfo.
+                    portInfo.setWsdlFile(fileName);
+                }
+            } catch (ClassNotFoundException ex) {
+                log.warn("cannot load class " + seiClassName);
+            }
         }
return status;
@@ -283,6 +312,55 @@
         portInfo.setLocation(oldup);
     }
+ private String generateWsdl(Module module, String sei, String bindingType, DeploymentContext context) 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 figure out the classpath for wsgen tools
+        String classPath = Axis2BuilderUtil.getWsgenClasspath(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);
+            log.info("classPath is " + classPath);
+ 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);
+            log.info("classPath is " + classPath);
+ 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");
+        }
+ + try {
+            WSToolsObjectFactory factory = WSToolsObjectFactory.newInstance();
+            OutputStream os = new ByteArrayOutputStream();
+ boolean result = factory.wsgen(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 "";
+        } catch (IOException ex) {
+            log.warn("unable to generate the wsdl file using wsgen.");
+            return "";
+        }
+    }
     public static final GBeanInfo GBEAN_INFO;
static {

Added: 
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=auto&rev=527215
==============================================================================
--- 
geronimo/server/trunk/modules/geronimo-axis2-builder/src/main/java/org/apache/geronimo/axis2/builder/Axis2BuilderUtil.java
 (added)
+++ 
geronimo/server/trunk/modules/geronimo-axis2-builder/src/main/java/org/apache/geronimo/axis2/builder/Axis2BuilderUtil.java
 Tue Apr 10 10:38:54 2007
@@ -0,0 +1,130 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.geronimo.axis2.builder;
+
+import java.io.File;
+import java.util.Collection;
+import java.util.List;
+
+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.kernel.config.Configuration;
+import org.apache.geronimo.kernel.repository.Artifact;
+import org.apache.geronimo.kernel.repository.Repository;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class Axis2BuilderUtil {
+
+    //TODO: need to update to released jars when they are avail.
+    private final static Artifact AXIS2_JAXWS_API_ARTIFACT = new 
Artifact("org.apache.axis2","axis2-jaxws-api", "SNAPSHOT", "jar");
+    private final static Artifact AXIS2_SAAJ_API_ARTIFACT = new 
Artifact("org.apache.axis2","axis2-saaj-api", "SNAPSHOT", "jar");
+    private final static Artifact AXIS2_SAAJ_ARTIFACT = new 
Artifact("org.apache.axis2","axis2-saaj", "SNAPSHOT", "jar");
+    private final static Artifact JAXB_API_ARTIFACT = new Artifact("javax.xml.bind","jaxb-api", 
"2.0", "jar");
+    private final static Artifact JAXB_IMPL_ARTIFACT = new 
Artifact("com.sun.xml.bind","jaxb-impl", "2.0.3", "jar");
+ private final static Artifact JAXB_XJC_ARTIFACT = new Artifact("com.sun.xml.bind","jaxb-xjc", "2.0.3", "jar"); + private final static Artifact JAXWS_TOOLS_ARTIFACT = new Artifact("com.sun.xml.ws","jaxws-tools", "2.0-SNAPSHOT", "jar");
+    private final static Artifact JAXWS_RT_ARTIFACT = new Artifact("com.sun.xml.ws","jaxws-rt", 
"2.0-SNAPSHOT", "jar");
+ private final static Artifact GERONIMO_ACTIVATION_SPEC_ARTIFACT = new Artifact("org.apache.geronimo.specs","geronimo-activation_1.1_spec", "1.0-SNAPSHOT", "jar"); + private final static Artifact GERONIMO_ANNOTATION_ARTIFACT = new Artifact("org.apache.geronimo.specs","geronimo-annotation_1.0_spec", "1.0", "jar"); + private final static Artifact GERONIMO_WS_METADATA_ARTIFACT = new Artifact("org.apache.geronimo.specs","geronimo-ws-metadata_2.0_spec", "1.1-SNAPSHOT", "jar"); + private final static String TOOLS = "tools.jar"; + + protected static String getWsgenClasspath(Module module, DeploymentContext context) throws DeploymentException { + + EARContext moduleContext = module.getEarContext();
+        String baseDir = moduleContext.getBaseDir().getAbsolutePath();
+ List<String> moduleClassPath = context.getConfiguration().getClassPath(); + + DeploymentConfigurationManager cm = (DeploymentConfigurationManager)context.getConfigurationManager();
+        Collection<Repository> repositories = cm.getRepositories();
+
+        //start classpath with path to tools.jar
+        String classpath = getLocation(repositories, JAXB_API_ARTIFACT) + 
java.io.File.pathSeparator
+            + getLocation(repositories, JAXB_IMPL_ARTIFACT) + 
java.io.File.pathSeparator
+            + getLocation(repositories, JAXB_XJC_ARTIFACT) + 
java.io.File.pathSeparator
+            + getLocation(repositories, JAXWS_TOOLS_ARTIFACT) + 
java.io.File.pathSeparator
+            + getLocation(repositories, JAXWS_RT_ARTIFACT) + 
java.io.File.pathSeparator
+            + getLocation(repositories, AXIS2_JAXWS_API_ARTIFACT) + 
java.io.File.pathSeparator
+            + getLocation(repositories, AXIS2_SAAJ_API_ARTIFACT) + 
java.io.File.pathSeparator
+            + getLocation(repositories, AXIS2_SAAJ_ARTIFACT) + 
java.io.File.pathSeparator
+            + getLocation(repositories, GERONIMO_ACTIVATION_SPEC_ARTIFACT) + 
java.io.File.pathSeparator
+            + getLocation(repositories, GERONIMO_ANNOTATION_ARTIFACT) + 
java.io.File.pathSeparator
+            + getLocation(repositories, GERONIMO_WS_METADATA_ARTIFACT) + 
java.io.File.pathSeparator
+            + getToolsJarLoc() + java.io.File.pathSeparator
+            + getModuleClassPath(baseDir, moduleClassPath);
+ + return classpath; + + } + + private static String getLocation(Collection<Repository> repositories, Artifact artifact) throws DeploymentException {
+        File file = null;
+ + for (Repository repository : repositories) {
+            if (repository.contains(artifact)) {
+                file = repository.getLocation(artifact);
+                return file.getAbsolutePath();
+            }
+        }
+        if (file == null) {
+            throw new DeploymentException("Missing artifact in repositories: " 
+ artifact.toString());
+        }
+        return null;
+    }
+ + private static String getToolsJarLoc() throws DeploymentException {
+        //create a new File then check exists()
+        String jreHomePath = System.getProperty("java.home");
+        String javaHomePath = "";
+        int jreHomePathLength = jreHomePath.length();
+        if (jreHomePathLength > 0) {
+            int i = jreHomePath.substring(0, jreHomePathLength 
-1).lastIndexOf(java.io.File.separator);
+            javaHomePath = jreHomePath.substring(0, i);
+        }
+        File jdkhomelib = new File(javaHomePath + java.io.File.separator + 
"lib");
+        if (!jdkhomelib.exists()) {
+ throw new DeploymentException("Missing " + jdkhomelib.getAbsolutePath() + + ". This is required for wsgen to run. ");
+        }
+        else {
+            File tools = new File(jdkhomelib + java.io.File.separator + TOOLS);
+            if (!tools.exists()) {
+ throw new DeploymentException("Missing tools.jar in" + jdkhomelib.getAbsolutePath() + + ". This is required for wsgen to run. "); + } else {
+                return tools.getAbsolutePath();
+ } + }
+    }
+ + private static String getModuleClassPath(String baseDir, List<String> moduleClassPath) {
+        String classpath = "";
+        for (String s : moduleClassPath) {
+            if (s.contains("/"))
+                s = s.replace("/", java.io.File.separator);
+            classpath += baseDir + java.io.File.separator + s + 
java.io.File.pathSeparator;
+        }
+        System.out.println("getModuleClasspath: " + classpath);
+        return classpath;
+    }
+}

Modified: geronimo/server/trunk/pom.xml
URL: 
http://svn.apache.org/viewvc/geronimo/server/trunk/pom.xml?view=diff&rev=527215&r1=527214&r2=527215
==============================================================================
--- geronimo/server/trunk/pom.xml (original)
+++ geronimo/server/trunk/pom.xml Tue Apr 10 10:38:54 2007
@@ -1383,6 +1383,24 @@
                 <version>2.0</version>
             </dependency>
+ <dependency>
+               <groupId>com.sun.xml.ws</groupId>
+               <artifactId>jaxws-tools</artifactId>
+                <version>2.0</version>
+           </dependency>
+ + <dependency>
+               <groupId>com.sun.xml.ws</groupId>
+               <artifactId>jaxws-rt</artifactId>
+                <version>2.0</version>
+           </dependency>
+ + <dependency>
+               <groupId>com.sun.xml.bind</groupId>
+               <artifactId>jaxb-xjc</artifactId>
+                <version>2.0.3</version>
+           </dependency>
+
             <dependency>
                 <groupId>commons-httpclient</groupId>
                 <artifactId>commons-httpclient</artifactId>

Added: 
geronimo/server/trunk/repository/com/sun/xml/ws/jaxws-rt/2.0/jaxws-rt-2.0.jar
URL: 
http://svn.apache.org/viewvc/geronimo/server/trunk/repository/com/sun/xml/ws/jaxws-rt/2.0/jaxws-rt-2.0.jar?view=auto&rev=527215
==============================================================================
Binary file - no diff available.

Propchange: 
geronimo/server/trunk/repository/com/sun/xml/ws/jaxws-rt/2.0/jaxws-rt-2.0.jar
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: 
geronimo/server/trunk/repository/com/sun/xml/ws/jaxws-rt/2.0/jaxws-rt-2.0.jar.md5
URL: 
http://svn.apache.org/viewvc/geronimo/server/trunk/repository/com/sun/xml/ws/jaxws-rt/2.0/jaxws-rt-2.0.jar.md5?view=auto&rev=527215
==============================================================================
--- 
geronimo/server/trunk/repository/com/sun/xml/ws/jaxws-rt/2.0/jaxws-rt-2.0.jar.md5
 (added)
+++ 
geronimo/server/trunk/repository/com/sun/xml/ws/jaxws-rt/2.0/jaxws-rt-2.0.jar.md5
 Tue Apr 10 10:38:54 2007
@@ -0,0 +1 @@
+MD5 (jaxws-rt-2.0.jar) = 3424c1ce819714ff2be2dc4c2087e2c0

Added: 
geronimo/server/trunk/repository/com/sun/xml/ws/jaxws-tools/2.0/jaxws-tools-2.0.jar
URL: 
http://svn.apache.org/viewvc/geronimo/server/trunk/repository/com/sun/xml/ws/jaxws-tools/2.0/jaxws-tools-2.0.jar?view=auto&rev=527215
==============================================================================
Binary file - no diff available.

Propchange: 
geronimo/server/trunk/repository/com/sun/xml/ws/jaxws-tools/2.0/jaxws-tools-2.0.jar
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: 
geronimo/server/trunk/repository/com/sun/xml/ws/jaxws-tools/2.0/jaxws-tools-2.0.jar.md5
URL: 
http://svn.apache.org/viewvc/geronimo/server/trunk/repository/com/sun/xml/ws/jaxws-tools/2.0/jaxws-tools-2.0.jar.md5?view=auto&rev=527215
==============================================================================
--- 
geronimo/server/trunk/repository/com/sun/xml/ws/jaxws-tools/2.0/jaxws-tools-2.0.jar.md5
 (added)
+++ 
geronimo/server/trunk/repository/com/sun/xml/ws/jaxws-tools/2.0/jaxws-tools-2.0.jar.md5
 Tue Apr 10 10:38:54 2007
@@ -0,0 +1 @@
+MD5 (jaxws-tools-2.0.jar) = f5ce5d4951c0d5bf2bd7f199a5215a75

Modified: geronimo/server/trunk/repository/pom.xml
URL: 
http://svn.apache.org/viewvc/geronimo/server/trunk/repository/pom.xml?view=diff&rev=527215&r1=527214&r2=527215
==============================================================================
--- geronimo/server/trunk/repository/pom.xml (original)
+++ geronimo/server/trunk/repository/pom.xml Tue Apr 10 10:38:54 2007
@@ -68,6 +68,22 @@
             <artifactId>jasper</artifactId>
         </dependency>
+ <!-- add the following for wsgen -->
+        <dependency>
+            <groupId>com.sun.xml.ws</groupId>
+            <artifactId>jaxws-tools</artifactId>
+        </dependency>
+
+        <dependency>
+            <groupId>com.sun.xml.ws</groupId>
+            <artifactId>jaxws-rt</artifactId>
+        </dependency>
+
+        <dependency>
+            <groupId>com.sun.xml.bind</groupId>
+            <artifactId>jaxb-xjc</artifactId>
+        </dependency>
+        <!--end add for wsgen-->
</dependencies>



Reply via email to