Return-Path: Delivered-To: apmail-geronimo-scm-archive@www.apache.org Received: (qmail 8647 invoked from network); 25 Feb 2011 08:52:07 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 25 Feb 2011 08:52:07 -0000 Received: (qmail 69509 invoked by uid 500); 25 Feb 2011 08:52:06 -0000 Delivered-To: apmail-geronimo-scm-archive@geronimo.apache.org Received: (qmail 69286 invoked by uid 500); 25 Feb 2011 08:52:04 -0000 Mailing-List: contact scm-help@geronimo.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: Reply-To: dev@geronimo.apache.org List-Id: Delivered-To: mailing list scm@geronimo.apache.org Received: (qmail 69273 invoked by uid 99); 25 Feb 2011 08:52:03 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 25 Feb 2011 08:52:03 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 25 Feb 2011 08:52:00 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 438F62388A40; Fri, 25 Feb 2011 08:51:40 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1074440 - in /geronimo/server/trunk/plugins: axis2/geronimo-axis2-builder/src/main/java/org/apache/geronimo/axis2/builder/ j2ee/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/ j2ee/geronimo-web-2.5-builder/src/main... Date: Fri, 25 Feb 2011 08:51:40 -0000 To: scm@geronimo.apache.org From: xuhaihong@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20110225085140.438F62388A40@eris.apache.org> Author: xuhaihong Date: Fri Feb 25 08:51:39 2011 New Revision: 1074440 URL: http://svn.apache.org/viewvc?rev=1074440&view=rev Log: Fix forked mode wsgen and webservice annotation scanning, might need refract later Added: geronimo/server/trunk/plugins/jaxws/geronimo-jaxws-builder/src/main/java/org/apache/geronimo/jaxws/builder/AbstractWebServiceFinder.java Modified: geronimo/server/trunk/plugins/axis2/geronimo-axis2-builder/src/main/java/org/apache/geronimo/axis2/builder/Axis2Builder.java geronimo/server/trunk/plugins/j2ee/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/WebServiceBuilder.java geronimo/server/trunk/plugins/j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web25/deployment/AbstractWebModuleBuilder.java geronimo/server/trunk/plugins/jaxws/geronimo-jaxws-builder/pom.xml geronimo/server/trunk/plugins/jaxws/geronimo-jaxws-builder/src/main/java/org/apache/geronimo/jaxws/builder/AdvancedWARWebServiceFinder.java geronimo/server/trunk/plugins/jaxws/geronimo-jaxws-builder/src/main/java/org/apache/geronimo/jaxws/builder/JAXWSServiceBuilder.java geronimo/server/trunk/plugins/jaxws/geronimo-jaxws-builder/src/main/java/org/apache/geronimo/jaxws/builder/SimpleWARWebServiceFinder.java geronimo/server/trunk/plugins/jaxws/geronimo-jaxws-builder/src/main/java/org/apache/geronimo/jaxws/builder/WARWebServiceFinder.java geronimo/server/trunk/plugins/jaxws/geronimo-jaxws-builder/src/main/java/org/apache/geronimo/jaxws/builder/WebServiceFinder.java geronimo/server/trunk/plugins/jaxws/geronimo-jaxws-builder/src/main/java/org/apache/geronimo/jaxws/builder/wsdl/WsdlGeneratorUtils.java geronimo/server/trunk/plugins/jaxws/geronimo-jaxws-sun-tools/src/main/java/org/apache/geronimo/jaxws/sun/tools/JAXWSTools.java geronimo/server/trunk/plugins/jaxws/geronimo-jaxws-sun-tools/src/main/java/org/apache/geronimo/jaxws/sun/tools/WsdlGenerator.java Modified: geronimo/server/trunk/plugins/axis2/geronimo-axis2-builder/src/main/java/org/apache/geronimo/axis2/builder/Axis2Builder.java URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/axis2/geronimo-axis2-builder/src/main/java/org/apache/geronimo/axis2/builder/Axis2Builder.java?rev=1074440&r1=1074439&r2=1074440&view=diff ============================================================================== --- geronimo/server/trunk/plugins/axis2/geronimo-axis2-builder/src/main/java/org/apache/geronimo/axis2/builder/Axis2Builder.java (original) +++ geronimo/server/trunk/plugins/axis2/geronimo-axis2-builder/src/main/java/org/apache/geronimo/axis2/builder/Axis2Builder.java Fri Feb 25 08:51:39 2011 @@ -84,15 +84,17 @@ public class Axis2Builder extends JAXWSS return defaultContainerFactoryGBeanInfo; } + @Override protected Map parseWebServiceDescriptor(InputStream in, URL wsDDUrl, Deployable deployable, boolean isEJB, - Map correctedPortLocations) + Map correctedPortLocations) throws DeploymentException { - log.debug("Parsing descriptor " + wsDDUrl); - + if (log.isDebugEnabled()) { + log.debug("Parsing descriptor " + wsDDUrl); + } Map map = null; try { @@ -147,7 +149,7 @@ public class Axis2Builder extends JAXWSS portInfo.setWsdlService(port.getWsdlService()); } - String location = (String) correctedPortLocations.get(serviceLink); + String location = correctedPortLocations.get(serviceLink); portInfo.setLocation(location); if (map == null) { @@ -162,7 +164,7 @@ public class Axis2Builder extends JAXWSS // } return map; - + } catch (JAXBException e) { //we hope it's jax-rpc log.debug("Descriptor ignored (not a Java EE 5 descriptor)"); Modified: geronimo/server/trunk/plugins/j2ee/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/WebServiceBuilder.java URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/j2ee/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/WebServiceBuilder.java?rev=1074440&r1=1074439&r2=1074440&view=diff ============================================================================== --- geronimo/server/trunk/plugins/j2ee/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/WebServiceBuilder.java (original) +++ geronimo/server/trunk/plugins/j2ee/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/WebServiceBuilder.java Fri Feb 25 08:51:39 2011 @@ -30,7 +30,7 @@ import org.osgi.framework.Bundle; public interface WebServiceBuilder { /** - * Introspects on the module file to locate web service for deployment. + * Introspect on the module file to locate web service for deployment. * * @param moduleFile J2EE module * @param isEJB is this an EJB archive? @@ -41,7 +41,7 @@ public interface WebServiceBuilder { * to all except the WebServiceBuilder itself. * @throws DeploymentException if error encountered while introspecting the module. */ - void findWebServices(Module module, boolean isEJB, Map correctedPortLocations, Environment environment, Map sharedContext) throws DeploymentException; + void findWebServices(Module module, boolean isEJB, Map correctedPortLocations, Environment environment, Map sharedContext) throws DeploymentException; //obviously these need the deployment descriptors, but I'm not sure in what form yet. /** Modified: geronimo/server/trunk/plugins/j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web25/deployment/AbstractWebModuleBuilder.java URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web25/deployment/AbstractWebModuleBuilder.java?rev=1074440&r1=1074439&r2=1074440&view=diff ============================================================================== --- geronimo/server/trunk/plugins/j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web25/deployment/AbstractWebModuleBuilder.java (original) +++ geronimo/server/trunk/plugins/j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web25/deployment/AbstractWebModuleBuilder.java Fri Feb 25 08:51:39 2011 @@ -382,7 +382,7 @@ public abstract class AbstractWebModuleB // any classes exist. This must be searched BEFORE the WEB-INF/lib jar files, // per the servlet specifications. moduleContext.addToClassPath(module.resolve("WEB-INF/classes").getPath()); - manifestcp.add("WEB-INF/classes"); // NOTE: Spec requires there be no trailing "/" on this. + manifestcp.add("WEB-INF/classes"); // NOTE: Spec requires there be no trailing "/" on this. // install the libs for (ZipEntry entry : libs) { URI targetPath = module.resolve(entry.getName()); @@ -470,7 +470,7 @@ public abstract class AbstractWebModuleB //web.xml should now list all the classes we need to create instances of. //Process Web Service - Map servletNameToPathMap = buildServletNameToPathMap(webModule.getSpecDD(), webModule.getContextRoot()); + Map servletNameToPathMap = buildServletNameToPathMap(webModule.getSpecDD(), webModule.getContextRoot()); Map sharedContext = webModule.getSharedContext(); for (WebServiceBuilder serviceBuilder : webServiceBuilder) { serviceBuilder.findWebServices(webModule, false, servletNameToPathMap, webModule.getEnvironment(), sharedContext); Modified: geronimo/server/trunk/plugins/jaxws/geronimo-jaxws-builder/pom.xml URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/jaxws/geronimo-jaxws-builder/pom.xml?rev=1074440&r1=1074439&r2=1074440&view=diff ============================================================================== --- geronimo/server/trunk/plugins/jaxws/geronimo-jaxws-builder/pom.xml (original) +++ geronimo/server/trunk/plugins/jaxws/geronimo-jaxws-builder/pom.xml Fri Feb 25 08:51:39 2011 @@ -45,6 +45,12 @@ geronimo-naming-builder ${project.version} + + + org.apache.xbean + xbean-classloader + + org.apache.openejb openejb-jee Added: geronimo/server/trunk/plugins/jaxws/geronimo-jaxws-builder/src/main/java/org/apache/geronimo/jaxws/builder/AbstractWebServiceFinder.java URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/jaxws/geronimo-jaxws-builder/src/main/java/org/apache/geronimo/jaxws/builder/AbstractWebServiceFinder.java?rev=1074440&view=auto ============================================================================== --- geronimo/server/trunk/plugins/jaxws/geronimo-jaxws-builder/src/main/java/org/apache/geronimo/jaxws/builder/AbstractWebServiceFinder.java (added) +++ geronimo/server/trunk/plugins/jaxws/geronimo-jaxws-builder/src/main/java/org/apache/geronimo/jaxws/builder/AbstractWebServiceFinder.java Fri Feb 25 08:51:39 2011 @@ -0,0 +1,196 @@ +/** + * 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.jaxws.builder; + +import java.io.File; +import java.io.IOException; +import java.net.MalformedURLException; +import java.net.URL; +import java.util.ArrayList; +import java.util.Collections; +import java.util.Enumeration; +import java.util.List; +import java.util.jar.JarEntry; +import java.util.jar.JarFile; + +import javax.jws.WebService; +import javax.xml.ws.WebServiceProvider; + +import org.apache.geronimo.common.DeploymentException; +import org.apache.geronimo.deployment.Deployable; +import org.apache.geronimo.deployment.DeployableBundle; +import org.apache.geronimo.deployment.DeployableJarFile; +import org.apache.geronimo.j2ee.deployment.Module; +import org.apache.geronimo.kernel.util.FileUtils; +import org.apache.geronimo.kernel.util.JarUtils; +import org.apache.geronimo.kernel.util.NestedJarFile; +import org.apache.geronimo.kernel.util.UnpackedJarFile; +import org.apache.xbean.classloader.JarFileClassLoader; +import org.apache.xbean.finder.BundleAnnotationFinder; +import org.apache.xbean.finder.ClassFinder; +import org.osgi.framework.Bundle; +import org.osgi.framework.ServiceReference; +import org.osgi.service.packageadmin.PackageAdmin; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * @version $Rev$ $Date$ + */ +public abstract class AbstractWebServiceFinder implements WebServiceFinder { + + private static final Logger logger = LoggerFactory.getLogger(AbstractWebServiceFinder.class); + + /** + * Returns a list of any classes annotated with @WebService or + * @WebServiceProvider annotation. + */ + protected List> discoverWebServices(Module module, boolean isEJB) throws DeploymentException { + Deployable deployable = module.getDeployable(); + if (deployable instanceof DeployableJarFile) { + return discoverWebServices(((DeployableJarFile) deployable).getJarFile(), isEJB, AbstractWebServiceFinder.class.getClassLoader()); + } else if (deployable instanceof DeployableBundle) { + return discoverWebServices(((DeployableBundle) deployable).getBundle(), isEJB); + } else { + throw new DeploymentException("Unsupported deployable: " + deployable.getClass()); + } + } + + /** + * Returns a list of any classes annotated with @WebService or + * @WebServiceProvider annotation. + */ + private List> discoverWebServices(Bundle bundle, boolean isEJB) throws DeploymentException { + logger.debug("Discovering web service classes"); + + ServiceReference sr = bundle.getBundleContext().getServiceReference(PackageAdmin.class.getName()); + PackageAdmin packageAdmin = (PackageAdmin) bundle.getBundleContext().getService(sr); + try { + BundleAnnotationFinder classFinder = new BundleAnnotationFinder(packageAdmin, bundle); + List> classes = new ArrayList>(); + classes.addAll(classFinder.findAnnotatedClasses(WebService.class)); + classes.addAll(classFinder.findAnnotatedClasses(WebServiceProvider.class)); + return classes; + } catch (Exception e) { + throw new DeploymentException("Error scanning for web service annotations in bundle", e); + } finally { + bundle.getBundleContext().ungetService(sr); + } + } + + /** + * Returns a list of any classes annotated with @WebService or + * @WebServiceProvider annotation. + */ + @Deprecated + private List> discoverWebServices(JarFile moduleFile, boolean isEJB, ClassLoader parentClassLoader) throws DeploymentException { + logger.debug("Discovering web service classes"); + + File tmpDir = null; + List urlList = new ArrayList(); + if (isEJB) { + File jarFile = new File(moduleFile.getName()); + try { + urlList.add(jarFile.toURI().toURL()); + } catch (MalformedURLException e) { + // this should not happen + throw new DeploymentException(e); + } + } else { + File baseDir; + + if (moduleFile instanceof UnpackedJarFile) { + // war directory is being deployed (--inPlace) + baseDir = ((UnpackedJarFile) moduleFile).getBaseDir(); + } else if (moduleFile instanceof NestedJarFile && ((NestedJarFile) moduleFile).isUnpacked()) { + // ear directory is being deployed (--inPlace) + baseDir = new File(moduleFile.getName()); + } else { + // war file or ear file is being deployed + /* + * Can't get ClassLoader to load nested Jar files, so + * unpack the module Jar file and discover all nested Jar files + * within it and the classes/ directory. + */ + try { + tmpDir = FileUtils.createTempDir(); + /* + * This is needed becuase JarUtils.unzipToDirectory() + * always closes the passed JarFile. + */ + JarFile module = new JarFile(moduleFile.getName()); + JarUtils.unzipToDirectory(module, tmpDir); + } catch (IOException e) { + if (tmpDir != null) { + FileUtils.recursiveDelete(tmpDir); + } + throw new DeploymentException("Failed to expand the module archive", e); + } + + baseDir = tmpDir; + } + + // create URL list + Enumeration jarEnum = moduleFile.entries(); + while (jarEnum.hasMoreElements()) { + JarEntry entry = jarEnum.nextElement(); + String name = entry.getName(); + if (name.equals("WEB-INF/classes/")) { + // ensure it is first + File classesDir = new File(baseDir, "WEB-INF/classes/"); + try { + urlList.add(0, classesDir.toURI().toURL()); + } catch (MalformedURLException e) { + // this should not happen, ignore + } + } else if (name.startsWith("WEB-INF/lib/") && name.endsWith(".jar")) { + File jarFile = new File(baseDir, name); + try { + urlList.add(jarFile.toURI().toURL()); + } catch (MalformedURLException e) { + // this should not happen, ignore + } + } + } + } + + URL[] urls = urlList.toArray(new URL[urlList.size()]); + JarFileClassLoader tempClassLoader = null; + try { + tempClassLoader = new JarFileClassLoader(null, urls, parentClassLoader); + List> classes = new ArrayList>(); + for (URL url : urlList) { + try { + ClassFinder classFinder = new ClassFinder(tempClassLoader, Collections.singletonList(url)); + classes.addAll(classFinder.findAnnotatedClasses(WebService.class)); + classes.addAll(classFinder.findAnnotatedClasses(WebServiceProvider.class)); + } catch (Exception e) { + logger.warn("Fail to search Web Service in jar [" + url + "]", e); + } + } + return classes; + } finally { + if (tempClassLoader != null) { + tempClassLoader.destroy(); + } + if (tmpDir != null) { + FileUtils.recursiveDelete(tmpDir); + } + } + } +} Modified: geronimo/server/trunk/plugins/jaxws/geronimo-jaxws-builder/src/main/java/org/apache/geronimo/jaxws/builder/AdvancedWARWebServiceFinder.java URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/jaxws/geronimo-jaxws-builder/src/main/java/org/apache/geronimo/jaxws/builder/AdvancedWARWebServiceFinder.java?rev=1074440&r1=1074439&r2=1074440&view=diff ============================================================================== --- geronimo/server/trunk/plugins/jaxws/geronimo-jaxws-builder/src/main/java/org/apache/geronimo/jaxws/builder/AdvancedWARWebServiceFinder.java (original) +++ geronimo/server/trunk/plugins/jaxws/geronimo-jaxws-builder/src/main/java/org/apache/geronimo/jaxws/builder/AdvancedWARWebServiceFinder.java Fri Feb 25 08:51:39 2011 @@ -34,23 +34,25 @@ import org.osgi.framework.Bundle; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -public class AdvancedWARWebServiceFinder implements WebServiceFinder { +public class AdvancedWARWebServiceFinder extends AbstractWebServiceFinder { private static final Logger LOG = LoggerFactory.getLogger(AdvancedWARWebServiceFinder.class); + @Override public Map discoverWebServices(Module module, boolean isEJB, - Map correctedPortLocations) + Map correctedPortLocations) throws DeploymentException { - Map map = new HashMap(); - discoverPOJOWebServices(module, correctedPortLocations, map); - return map; + Map servletNamePortInfoMap = new HashMap(); + discoverPOJOWebServices(module, correctedPortLocations, servletNamePortInfoMap); + return servletNamePortInfoMap; } private void discoverPOJOWebServices(Module module, - Map portLocations, - Map map) + Map portLocations, + Map servletNamePortInfoMap) throws DeploymentException { + Bundle bundle = module.getEarContext().getDeploymentBundle(); WebApp webApp = (WebApp) module.getSpecDD(); @@ -62,8 +64,10 @@ public class AdvancedWARWebServiceFinder String servletName = servletType.getServletName().trim(); PortInfo portInfo = getPortInfo(servletType, bundle, portLocations); if (portInfo != null) { - LOG.debug("Found POJO Web Service: {}", servletName); - map.put(servletName, portInfo); + if (LOG.isDebugEnabled()) { + LOG.debug("Found POJO Web Service: {}", servletName); + } + servletNamePortInfoMap.put(servletName, portInfo); } } @@ -71,28 +75,29 @@ public class AdvancedWARWebServiceFinder // partial web.xml, discover all web service classes Map> classServletMap = createClassServetMap(webApp); - List> services = WARWebServiceFinder.discoverWebServices(module, bundle, false); + List> services = discoverWebServices(module, false); String contextRoot = ((WebModule) module).getContextRoot(); - for (Class service : services) { + for (Class service : services) { // skip interfaces and such if (!JAXWSUtils.isWebService(service)) { continue; } - LOG.debug("Discovered POJO Web Service class: {}", service.getName()); - + if (LOG.isDebugEnabled()) { + LOG.debug("Discovered POJO Web Service class: {}", service.getName()); + } List mappedServlets = classServletMap.get(service.getName()); if (mappedServlets == null) { // no entry, add one - - LOG.debug("POJO Web Service class {} is not mapped to any servlet", service.getName()); - + if (LOG.isDebugEnabled()) { + LOG.debug("POJO Web Service class {} is not mapped to any servlet", service.getName()); + } Servlet servlet = new Servlet(); servlet.setServletName(service.getName()); servlet.setServletClass(service.getName()); webApp.getServlet().add(servlet); - String location = (String)portLocations.get(service.getName()); + String location = portLocations.get(service.getName()); if (location == null) { // add new element location = "/" + JAXWSUtils.getServiceName(service); @@ -109,13 +114,15 @@ public class AdvancedWARWebServiceFinder // map service PortInfo portInfo = new PortInfo(); portInfo.setLocation(contextRoot + location); - map.put(service.getName(), portInfo); + servletNamePortInfoMap.put(service.getName(), portInfo); } else { // found at least one mapped entry for (String servlet : mappedServlets) { - LOG.debug("POJO Web Service class {} is mapped to {} servlet", service.getName(), servlet); + if (LOG.isDebugEnabled()) { + LOG.debug("POJO Web Service class {} is mapped to {} servlet", service.getName(), servlet); + } PortInfo portInfo = createPortInfo(servlet, portLocations); - map.put(servlet, portInfo); + servletNamePortInfoMap.put(servlet, portInfo); } } } @@ -124,11 +131,13 @@ public class AdvancedWARWebServiceFinder List servletTypes = webApp.getServlet(); for (Servlet servletType : servletTypes) { String servletName = servletType.getServletName().trim(); - if (map.get(servletName) == null) { + if (servletNamePortInfoMap.get(servletName) == null) { PortInfo portInfo = getPortInfo(servletType, bundle, portLocations); if (portInfo != null) { - LOG.debug("Found POJO Web Service: {}", servletName); - map.put(servletName, portInfo); + if (LOG.isDebugEnabled()) { + LOG.debug("Found POJO Web Service: {}", servletName); + } + servletNamePortInfoMap.put(servletName, portInfo); } } } @@ -137,12 +146,12 @@ public class AdvancedWARWebServiceFinder private PortInfo getPortInfo(Servlet servletType, Bundle bundle, - Map portLocations) throws DeploymentException { + Map portLocations) throws DeploymentException { PortInfo portInfo = null; if (servletType.getServletClass() != null) { String servletClassName = servletType.getServletClass().trim(); try { - Class servletClass = bundle.loadClass(servletClassName); + Class servletClass = bundle.loadClass(servletClassName); if (JAXWSUtils.isWebService(servletClass)) { String servletName = servletType.getServletName().trim(); portInfo = createPortInfo(servletName, portLocations); @@ -155,9 +164,9 @@ public class AdvancedWARWebServiceFinder return portInfo; } - private PortInfo createPortInfo(String servlet, Map portLocations) { + private PortInfo createPortInfo(String servlet, Map portLocations) { PortInfo portInfo = new PortInfo(); - String location = (String)portLocations.get(servlet); + String location = portLocations.get(servlet); if (location != null) { portInfo.setLocation(location); } @@ -168,25 +177,23 @@ public class AdvancedWARWebServiceFinder * Create servlet-class to servlet-names mapping */ private Map> createClassServetMap(WebApp webApp) { - Map> map = new HashMap>(); - + Map> classServletNameMap = new HashMap>(); List servletTypes = webApp.getServlet(); if (servletTypes != null) { for (Servlet servletType : servletTypes) { String servletName = servletType.getServletName().trim(); if (servletType.getServletClass() != null) { String servletClassName = servletType.getServletClass().trim(); - List servlets = map.get(servletClassName); + List servlets = classServletNameMap.get(servletClassName); if (servlets == null) { servlets = new ArrayList(); - map.put(servletClassName, servlets); + classServletNameMap.put(servletClassName, servlets); } servlets.add(servletName); } } } - - return map; + return classServletNameMap; } } Modified: geronimo/server/trunk/plugins/jaxws/geronimo-jaxws-builder/src/main/java/org/apache/geronimo/jaxws/builder/JAXWSServiceBuilder.java URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/jaxws/geronimo-jaxws-builder/src/main/java/org/apache/geronimo/jaxws/builder/JAXWSServiceBuilder.java?rev=1074440&r1=1074439&r2=1074440&view=diff ============================================================================== --- geronimo/server/trunk/plugins/jaxws/geronimo-jaxws-builder/src/main/java/org/apache/geronimo/jaxws/builder/JAXWSServiceBuilder.java (original) +++ geronimo/server/trunk/plugins/jaxws/geronimo-jaxws-builder/src/main/java/org/apache/geronimo/jaxws/builder/JAXWSServiceBuilder.java Fri Feb 25 08:51:39 2011 @@ -43,6 +43,7 @@ import org.apache.geronimo.jaxws.annotat import org.apache.geronimo.kernel.GBeanAlreadyExistsException; import org.apache.geronimo.kernel.GBeanNotFoundException; import org.apache.geronimo.kernel.repository.Environment; +import org.apache.geronimo.kernel.util.IOUtils; import org.osgi.framework.Bundle; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -65,23 +66,26 @@ public abstract class JAXWSServiceBuilde return getClass().getName(); } + @Override public void findWebServices(Module module, boolean isEJB, - Map servletLocations, + Map servletLocations, Environment environment, Map sharedContext) throws DeploymentException { - Map portMap = null; + Map portMap = null; String path = isEJB ? "META-INF/webservices.xml" : "WEB-INF/webservices.xml"; Deployable deployable = module.getDeployable(); URL wsDDUrl = deployable.getResource(path); if (wsDDUrl != null) { - InputStream in; + InputStream in = null; try { in = wsDDUrl.openStream(); + portMap = parseWebServiceDescriptor(in, wsDDUrl, deployable, isEJB, servletLocations); } catch (IOException e) { throw new DeploymentException("Failed to parse " + path, e); + } finally { + IOUtils.close(in); } - portMap = parseWebServiceDescriptor(in, wsDDUrl, deployable, isEJB, servletLocations); } else { // webservices.xml does not exist portMap = discoverWebServices(module, isEJB, servletLocations); @@ -96,21 +100,22 @@ public abstract class JAXWSServiceBuilde private Map discoverWebServices(Module module, boolean isEJB, - Map correctedPortLocations) + Map correctedPortLocations) throws DeploymentException { - if (this.webServiceFinder == null) { + if (webServiceFinder == null) { throw new DeploymentException("WebServiceFinder not configured"); } - return this.webServiceFinder.discoverWebServices(module, isEJB, correctedPortLocations); + return webServiceFinder.discoverWebServices(module, isEJB, correctedPortLocations); } protected abstract Map parseWebServiceDescriptor(InputStream in, URL wsDDUrl, Deployable deployable, boolean isEJB, - Map correctedPortLocations) + Map correctedPortLocations) throws DeploymentException; + @Override public boolean configurePOJO(GBeanData targetGBean, String servletName, Module module, @@ -118,12 +123,12 @@ public abstract class JAXWSServiceBuilde DeploymentContext context) throws DeploymentException { Map sharedContext = ((WebModule) module).getSharedContext(); - Map portInfoMap = (Map) sharedContext.get(getKey()); + Map portInfoMap = (Map) sharedContext.get(getKey()); if (portInfoMap == null) { // not ours return false; } - PortInfo portInfo = (PortInfo) portInfoMap.get(servletName); + PortInfo portInfo = portInfoMap.get(servletName); if (portInfo == null) { // not ours return false; @@ -186,6 +191,7 @@ public abstract class JAXWSServiceBuilde protected abstract GBeanInfo getContainerFactoryGBeanInfo(); + @Override public boolean configureEJB(GBeanData targetGBean, String ejbName, Module module, Modified: geronimo/server/trunk/plugins/jaxws/geronimo-jaxws-builder/src/main/java/org/apache/geronimo/jaxws/builder/SimpleWARWebServiceFinder.java URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/jaxws/geronimo-jaxws-builder/src/main/java/org/apache/geronimo/jaxws/builder/SimpleWARWebServiceFinder.java?rev=1074440&r1=1074439&r2=1074440&view=diff ============================================================================== --- geronimo/server/trunk/plugins/jaxws/geronimo-jaxws-builder/src/main/java/org/apache/geronimo/jaxws/builder/SimpleWARWebServiceFinder.java (original) +++ geronimo/server/trunk/plugins/jaxws/geronimo-jaxws-builder/src/main/java/org/apache/geronimo/jaxws/builder/SimpleWARWebServiceFinder.java Fri Feb 25 08:51:39 2011 @@ -33,17 +33,17 @@ import org.osgi.framework.Bundle; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -public class SimpleWARWebServiceFinder implements WebServiceFinder { +public class SimpleWARWebServiceFinder extends AbstractWebServiceFinder { private static final Logger LOG = LoggerFactory.getLogger(SimpleWARWebServiceFinder.class); public Map discoverWebServices(Module module, boolean isEJB, - Map correctedPortLocations) + Map correctedPortLocations) throws DeploymentException { - - Map map = new HashMap(); - + + Map servletNamePortInfoMap = new HashMap(); + Bundle bundle = module.getEarContext().getDeploymentBundle(); WebApp webApp = (WebApp) module.getSpecDD(); @@ -53,16 +53,17 @@ public class SimpleWARWebServiceFinder i if (webApp.getServlet().size() == 0) { // web.xml not present (empty really), discover annotated // classes and update DD - List> services = WARWebServiceFinder.discoverWebServices(module.getModuleFile(), false, this.getClass().getClassLoader()); + List> services = discoverWebServices(module, false); String contextRoot = ((WebModule) module).getContextRoot(); - for (Class service : services) { + for (Class service : services) { // skip interfaces and such if (!JAXWSUtils.isWebService(service)) { continue; } - LOG.debug("Discovered POJO Web Service: " + service.getName()); - + if (LOG.isDebugEnabled()) { + LOG.debug("Discovered POJO Web Service: " + service.getName()); + } // add new element Servlet servlet = new Servlet(); servlet.setServletName(service.getName()); @@ -77,7 +78,7 @@ public class SimpleWARWebServiceFinder i // map service PortInfo portInfo = new PortInfo(); portInfo.setLocation(contextRoot + location); - map.put(service.getName(), portInfo); + servletNamePortInfoMap.put(service.getName(), portInfo); } } else { // web.xml present, examine servlet classes and check for web @@ -87,11 +88,13 @@ public class SimpleWARWebServiceFinder i if (servletType.getServletClass() != null) { String servletClassName = servletType.getServletClass().trim(); try { - Class servletClass = bundle.loadClass(servletClassName); + Class servletClass = bundle.loadClass(servletClassName); if (JAXWSUtils.isWebService(servletClass)) { - LOG.debug("Found POJO Web Service: " + servletName); + if (LOG.isDebugEnabled()) { + LOG.debug("Found POJO Web Service: " + servletName); + } PortInfo portInfo = new PortInfo(); - map.put(servletName, portInfo); + servletNamePortInfoMap.put(servletName, portInfo); } } catch (Exception e) { throw new DeploymentException("Failed to load servlet class " @@ -101,20 +104,17 @@ public class SimpleWARWebServiceFinder i } // update web service locations - for (Map.Entry entry : map.entrySet()) { - String servletName = (String) entry.getKey(); - PortInfo portInfo = (PortInfo) entry.getValue(); + for (Map.Entry entry : servletNamePortInfoMap.entrySet()) { + String servletName = entry.getKey(); + PortInfo portInfo = entry.getValue(); - String location = (String) correctedPortLocations.get(servletName); + String location = correctedPortLocations.get(servletName); if (location != null) { portInfo.setLocation(location); } } } - - return map; - } - - + return servletNamePortInfoMap; + } } Modified: geronimo/server/trunk/plugins/jaxws/geronimo-jaxws-builder/src/main/java/org/apache/geronimo/jaxws/builder/WARWebServiceFinder.java URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/jaxws/geronimo-jaxws-builder/src/main/java/org/apache/geronimo/jaxws/builder/WARWebServiceFinder.java?rev=1074440&r1=1074439&r2=1074440&view=diff ============================================================================== --- geronimo/server/trunk/plugins/jaxws/geronimo-jaxws-builder/src/main/java/org/apache/geronimo/jaxws/builder/WARWebServiceFinder.java (original) +++ geronimo/server/trunk/plugins/jaxws/geronimo-jaxws-builder/src/main/java/org/apache/geronimo/jaxws/builder/WARWebServiceFinder.java Fri Feb 25 08:51:39 2011 @@ -17,38 +17,10 @@ package org.apache.geronimo.jaxws.builder; -import java.io.File; -import java.io.IOException; -import java.net.MalformedURLException; -import java.net.URL; -import java.util.ArrayList; -import java.util.Collections; -import java.util.Enumeration; -import java.util.List; import java.util.Map; -import java.util.jar.JarEntry; -import java.util.jar.JarFile; - -import javax.jws.WebService; -import javax.xml.ws.WebServiceProvider; - import org.apache.geronimo.common.DeploymentException; -import org.apache.geronimo.deployment.Deployable; -import org.apache.geronimo.deployment.DeployableBundle; -import org.apache.geronimo.deployment.DeployableJarFile; import org.apache.geronimo.j2ee.deployment.Module; import org.apache.geronimo.jaxws.PortInfo; -import org.apache.geronimo.kernel.classloader.TemporaryClassLoader; -import org.apache.xbean.finder.BundleAnnotationFinder; -import org.apache.xbean.osgi.bundle.util.BundleClassLoader; -import org.apache.geronimo.kernel.util.FileUtils; -import org.apache.geronimo.kernel.util.JarUtils; -import org.apache.geronimo.kernel.util.NestedJarFile; -import org.apache.geronimo.kernel.util.UnpackedJarFile; -import org.apache.xbean.finder.ClassFinder; -import org.osgi.framework.Bundle; -import org.osgi.framework.ServiceReference; -import org.osgi.service.packageadmin.PackageAdmin; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -73,153 +45,11 @@ public class WARWebServiceFinder impleme return webServiceFinder; } + @Override public Map discoverWebServices(Module module, boolean isEJB, - Map correctedPortLocations) + Map correctedPortLocations) throws DeploymentException { return webServiceFinder.discoverWebServices(module, isEJB, correctedPortLocations); } - - /** - * Returns a list of any classes annotated with @WebService or - * @WebServiceProvider annotation. - */ - static List> discoverWebServices(Module module, - Bundle bundle, - boolean isEJB) - throws DeploymentException { - Deployable deployable = module.getDeployable(); - if (deployable instanceof DeployableJarFile) { - return discoverWebServices( ((DeployableJarFile) deployable).getJarFile(), isEJB, new BundleClassLoader(bundle)); - } else if (deployable instanceof DeployableBundle) { - return discoverWebServices( ((DeployableBundle) deployable).getBundle(), isEJB); - } else { - throw new DeploymentException("Unsupported deployable: " + deployable.getClass()); - } - } - - /** - * Returns a list of any classes annotated with @WebService or - * @WebServiceProvider annotation. - */ - static List> discoverWebServices(Bundle bundle, - boolean isEJB) - throws DeploymentException { - LOG.debug("Discovering web service classes"); - - ServiceReference sr = bundle.getBundleContext().getServiceReference(PackageAdmin.class.getName()); - PackageAdmin packageAdmin = (PackageAdmin) bundle.getBundleContext().getService(sr); - try { - BundleAnnotationFinder classFinder = new BundleAnnotationFinder(packageAdmin, bundle); - List> classes = new ArrayList>(); - classes.addAll(classFinder.findAnnotatedClasses(WebService.class)); - classes.addAll(classFinder.findAnnotatedClasses(WebServiceProvider.class)); - return classes; - } catch (Exception e) { - throw new DeploymentException("Error scanning for web service annotations in bundle", e); - } finally { - bundle.getBundleContext().ungetService(sr); - } - } - - /** - * Returns a list of any classes annotated with @WebService or - * @WebServiceProvider annotation. - */ - static List> discoverWebServices(JarFile moduleFile, - boolean isEJB, - ClassLoader parentClassLoader) - throws DeploymentException { - LOG.debug("Discovering web service classes"); - - File tmpDir = null; - List urlList = new ArrayList(); - if (isEJB) { - File jarFile = new File(moduleFile.getName()); - try { - urlList.add(jarFile.toURI().toURL()); - } catch (MalformedURLException e) { - // this should not happen - throw new DeploymentException(e); - } - } else { - File baseDir; - - if (moduleFile instanceof UnpackedJarFile) { - // war directory is being deployed (--inPlace) - baseDir = ((UnpackedJarFile)moduleFile).getBaseDir(); - } else if (moduleFile instanceof NestedJarFile && ((NestedJarFile)moduleFile).isUnpacked()) { - // ear directory is being deployed (--inPlace) - baseDir = new File(moduleFile.getName()); - } else { - // war file or ear file is being deployed - /* - * Can't get ClassLoader to load nested Jar files, so - * unpack the module Jar file and discover all nested Jar files - * within it and the classes/ directory. - */ - try { - tmpDir = FileUtils.createTempDir(); - /* - * This is needed becuase JarUtils.unzipToDirectory() - * always closes the passed JarFile. - */ - JarFile module = new JarFile(moduleFile.getName()); - JarUtils.unzipToDirectory(module, tmpDir); - } catch (IOException e) { - if (tmpDir != null) { - FileUtils.recursiveDelete(tmpDir); - } - throw new DeploymentException("Failed to expand the module archive", e); - } - - baseDir = tmpDir; - } - - // create URL list - Enumeration jarEnum = moduleFile.entries(); - while (jarEnum.hasMoreElements()) { - JarEntry entry = jarEnum.nextElement(); - String name = entry.getName(); - if (name.equals("WEB-INF/classes/")) { - // ensure it is first - File classesDir = new File(baseDir, "WEB-INF/classes/"); - try { - urlList.add(0, classesDir.toURI().toURL()); - } catch (MalformedURLException e) { - // this should not happen, ignore - } - } else if (name.startsWith("WEB-INF/lib/") - && name.endsWith(".jar")) { - File jarFile = new File(baseDir, name); - try { - urlList.add(jarFile.toURI().toURL()); - } catch (MalformedURLException e) { - // this should not happen, ignore - } - } - } - } - - URL[] urls = urlList.toArray(new URL[urlList.size()]); - TemporaryClassLoader tempClassLoader; - try { - tempClassLoader = new TemporaryClassLoader(urls, parentClassLoader); - List> classes = new ArrayList>(); - for (URL url : urlList) { - try { - ClassFinder classFinder = new ClassFinder(tempClassLoader, Collections.singletonList(url)); - classes.addAll(classFinder.findAnnotatedClasses(WebService.class)); - classes.addAll(classFinder.findAnnotatedClasses(WebServiceProvider.class)); - } catch (Exception e) { - LOG.warn("Fail to search Web Service in jar [" + url + "]", e); - } - } - return classes; - } finally { - if (tmpDir != null) { - FileUtils.recursiveDelete(tmpDir); - } - } - } } Modified: geronimo/server/trunk/plugins/jaxws/geronimo-jaxws-builder/src/main/java/org/apache/geronimo/jaxws/builder/WebServiceFinder.java URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/jaxws/geronimo-jaxws-builder/src/main/java/org/apache/geronimo/jaxws/builder/WebServiceFinder.java?rev=1074440&r1=1074439&r2=1074440&view=diff ============================================================================== --- geronimo/server/trunk/plugins/jaxws/geronimo-jaxws-builder/src/main/java/org/apache/geronimo/jaxws/builder/WebServiceFinder.java (original) +++ geronimo/server/trunk/plugins/jaxws/geronimo-jaxws-builder/src/main/java/org/apache/geronimo/jaxws/builder/WebServiceFinder.java Fri Feb 25 08:51:39 2011 @@ -27,7 +27,7 @@ public interface WebServiceFinder { Map discoverWebServices(Module module, boolean isEJB, - Map correctedPortLocations) + Map correctedPortLocations) throws DeploymentException; } Modified: geronimo/server/trunk/plugins/jaxws/geronimo-jaxws-builder/src/main/java/org/apache/geronimo/jaxws/builder/wsdl/WsdlGeneratorUtils.java URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/jaxws/geronimo-jaxws-builder/src/main/java/org/apache/geronimo/jaxws/builder/wsdl/WsdlGeneratorUtils.java?rev=1074440&r1=1074439&r2=1074440&view=diff ============================================================================== --- geronimo/server/trunk/plugins/jaxws/geronimo-jaxws-builder/src/main/java/org/apache/geronimo/jaxws/builder/wsdl/WsdlGeneratorUtils.java (original) +++ geronimo/server/trunk/plugins/jaxws/geronimo-jaxws-builder/src/main/java/org/apache/geronimo/jaxws/builder/wsdl/WsdlGeneratorUtils.java Fri Feb 25 08:51:39 2011 @@ -22,7 +22,6 @@ import java.io.FileFilter; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; -import java.net.MalformedURLException; import java.net.URL; import java.net.URLClassLoader; import java.util.ArrayList; @@ -34,9 +33,6 @@ import java.util.Set; import org.apache.geronimo.deployment.DeploymentContext; import org.apache.geronimo.j2ee.deployment.Module; import org.apache.geronimo.kernel.config.Configuration; -import org.apache.geronimo.kernel.config.ConfigurationResolver; -// import org.apache.geronimo.kernel.config.MultiParentClassLoader; -import org.apache.geronimo.kernel.config.NoSuchConfigException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -44,10 +40,10 @@ public class WsdlGeneratorUtils { private static final Logger LOG = LoggerFactory.getLogger(WsdlGeneratorUtils.class); - public static void getModuleClasspath(Module module, DeploymentContext context, StringBuilder classpath) throws Exception { + public static void getModuleClasspath(Module module, DeploymentContext context, StringBuilder classPathBuilder) throws Exception { LinkedHashSet jars = new LinkedHashSet(); getModuleClasspath(module, context, jars); - buildClasspath(jars, classpath); + buildClasspath(jars, classPathBuilder); } public static void getModuleClasspath(Module module, DeploymentContext context, LinkedHashSet classpath) throws Exception { @@ -58,8 +54,10 @@ public class WsdlGeneratorUtils { } public static void getModuleClasspath(DeploymentContext deploymentContext, LinkedHashSet classpath) throws Exception { - Configuration configuration = deploymentContext.getConfiguration(); - getModuleClasspath(configuration, classpath); + File configurationBaseDir = deploymentContext.getBaseDir(); + for (String bundleClassPath : deploymentContext.getBundleClassPath()) { + classpath.add(new File(configurationBaseDir, bundleClassPath).toURI().toURL()); + } } public static void getModuleClasspath(Configuration configuration, LinkedHashSet classpath) throws Exception { Modified: geronimo/server/trunk/plugins/jaxws/geronimo-jaxws-sun-tools/src/main/java/org/apache/geronimo/jaxws/sun/tools/JAXWSTools.java URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/jaxws/geronimo-jaxws-sun-tools/src/main/java/org/apache/geronimo/jaxws/sun/tools/JAXWSTools.java?rev=1074440&r1=1074439&r2=1074440&view=diff ============================================================================== --- geronimo/server/trunk/plugins/jaxws/geronimo-jaxws-sun-tools/src/main/java/org/apache/geronimo/jaxws/sun/tools/JAXWSTools.java (original) +++ geronimo/server/trunk/plugins/jaxws/geronimo-jaxws-sun-tools/src/main/java/org/apache/geronimo/jaxws/sun/tools/JAXWSTools.java Fri Feb 25 08:51:39 2011 @@ -73,6 +73,11 @@ public class JAXWSTools { "javax.xml.ws" }; + private final static String[][] ENDORSED_ARTIFACTS = { + { "org.apache.geronimo.specs", "geronimo-jaxws_2.2_spec" }, + { "org.apache.geronimo.specs", "geronimo-jaxb_2.2_spec" } + }; + private final static Artifact SUN_SAAJ_IMPL_ARTIFACT = new Artifact("org.apache.geronimo.bundles","saaj-impl", (Version)null, "jar"); private final static Artifact AXIS2_SAAJ_IMPL_ARTIFACT = new Artifact("org.apache.geronimo.bundles","axis2", (Version)null, "jar"); private final static String TOOLS = "tools.jar"; @@ -191,10 +196,25 @@ public class JAXWSTools { } } + public String getEndorsedDirectory(Collection repositories) throws Exception { + StringBuilder endorsedDirectories = new StringBuilder(); + for (String[] lib : ENDORSED_ARTIFACTS) { + Artifact artifact = new Artifact(lib[0], lib[1], (Version) null, "jar"); + if (endorsedDirectories.length() > 0) { + endorsedDirectories.append(File.pathSeparator); + } + endorsedDirectories.append(getLocation(repositories, artifact).getParent()); + } + String defaultEndorsedDirectory = System.getProperty("java.home") + File.separator + "lib" + File.separator + "endorsed"; + endorsedDirectories.append(File.pathSeparator).append(defaultEndorsedDirectory); + return endorsedDirectories.toString(); + } + public boolean invokeWsgen(URL[] jars, OutputStream os, String[] arguments) throws Exception { return invoke("wsgen", jars, os, arguments); } + public boolean invokeWsimport(URL[] jars, OutputStream os, String[] arguments) throws Exception { return invoke("wsimport", jars, os, arguments); } Modified: geronimo/server/trunk/plugins/jaxws/geronimo-jaxws-sun-tools/src/main/java/org/apache/geronimo/jaxws/sun/tools/WsdlGenerator.java URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/jaxws/geronimo-jaxws-sun-tools/src/main/java/org/apache/geronimo/jaxws/sun/tools/WsdlGenerator.java?rev=1074440&r1=1074439&r2=1074440&view=diff ============================================================================== --- geronimo/server/trunk/plugins/jaxws/geronimo-jaxws-sun-tools/src/main/java/org/apache/geronimo/jaxws/sun/tools/WsdlGenerator.java (original) +++ geronimo/server/trunk/plugins/jaxws/geronimo-jaxws-sun-tools/src/main/java/org/apache/geronimo/jaxws/sun/tools/WsdlGenerator.java Fri Feb 25 08:51:39 2011 @@ -29,12 +29,12 @@ import java.util.List; import javax.xml.namespace.QName; import org.apache.geronimo.common.DeploymentException; -import org.apache.geronimo.deployment.DeploymentConfigurationManager; import org.apache.geronimo.deployment.DeploymentContext; import org.apache.geronimo.j2ee.deployment.Module; import org.apache.geronimo.jaxws.PortInfo; import org.apache.geronimo.jaxws.builder.wsdl.WsdlGeneratorOptions; import org.apache.geronimo.jaxws.builder.wsdl.WsdlGeneratorUtils; +import org.apache.geronimo.kernel.config.ConfigurationManager; import org.apache.geronimo.kernel.repository.Repository; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -59,15 +59,20 @@ public class WsdlGenerator { } private URL[] getWsgenClasspath(DeploymentContext context) throws Exception { - DeploymentConfigurationManager cm = (DeploymentConfigurationManager)context.getConfigurationManager(); + ConfigurationManager cm = context.getConfigurationManager(); Collection repositories = cm.getRepositories(); File[] jars = this.jaxwsTools.getClasspath(repositories); return JAXWSTools.toURL(jars); } - private String[] buildArguments(String sei, String classPath, File moduleBaseDir, PortInfo portInfo) { - List arguments = new ArrayList(); + private String getEndorsedPath(DeploymentContext context) throws Exception { + ConfigurationManager cm = context.getConfigurationManager(); + Collection repositories = cm.getRepositories(); + return jaxwsTools.getEndorsedDirectory(repositories); + } + private String[] buildArguments(String sei, String classPath, File moduleBaseDir, PortInfo portInfo) throws Exception{ + List arguments = new ArrayList(11); arguments.add("-cp"); arguments.add(classPath); arguments.add("-keep"); @@ -118,33 +123,36 @@ public class WsdlGenerator { } URL[] urls; - StringBuilder classPath = new StringBuilder(); + StringBuilder classPathBuilder = new StringBuilder(); //let's figure out the classpath for wsgen tools try { urls = getWsgenClasspath(context); } catch (Exception e) { throw new DeploymentException("Failed to generate the wsdl file using wsgen: unable to get the location of the required artifact(s).", e); } + //let's figure out the classpath string for the module and wsgen tools. if (urls != null && urls.length > 0) { for (URL url : urls) { - classPath.append(WsdlGeneratorUtils.toFile(url).getAbsolutePath()).append(File.pathSeparator); + classPathBuilder.append(WsdlGeneratorUtils.toFile(url).getAbsolutePath()).append(File.pathSeparator); } } + String wsgenToolClassPath = classPathBuilder.toString(); + try { - WsdlGeneratorUtils.getModuleClasspath(module, context, classPath); + WsdlGeneratorUtils.getModuleClasspath(module, context, classPathBuilder); } catch (Exception e) { throw new DeploymentException("WSDL generation failed: unable to determine module classpath", e); } - //create arguments; - String[] arguments = buildArguments(serviceClass, classPath.toString(), baseDir, portInfo); - try { - boolean result = false; + //create arguments; + String[] arguments = buildArguments(serviceClass, classPathBuilder.toString(), baseDir, portInfo); + boolean result = false; if (this.options.getFork()) { - result = forkWsgen(classPath, arguments); + String endorsedPath = getEndorsedPath(context); + result = forkWsgen(wsgenToolClassPath, endorsedPath, arguments); } else { result = invokeWsgen(urls, arguments); } @@ -190,10 +198,11 @@ public class WsdlGenerator { return new String(arr, 0, arr.length); } - private boolean forkWsgen(StringBuilder classPath, String[] arguments) throws Exception { - List cmd = new ArrayList(); + private boolean forkWsgen(String classPath, String endorsedPath, String[] arguments) throws Exception { + List cmd = new ArrayList(4 + arguments.length); + cmd.add("-Djava.endorsed.dirs=\"" + endorsedPath + "\""); cmd.add("-classpath"); - cmd.add(classPath.toString()); + cmd.add(classPath); cmd.add("com.sun.tools.ws.WsGen"); cmd.addAll(Arrays.asList(arguments));