Return-Path: Delivered-To: apmail-geronimo-scm-archive@www.apache.org Received: (qmail 32656 invoked from network); 8 Feb 2008 07:20:12 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 8 Feb 2008 07:20:12 -0000 Received: (qmail 26966 invoked by uid 500); 8 Feb 2008 07:20:05 -0000 Delivered-To: apmail-geronimo-scm-archive@geronimo.apache.org Received: (qmail 26925 invoked by uid 500); 8 Feb 2008 07:20:05 -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 26914 invoked by uid 99); 8 Feb 2008 07:20:05 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 07 Feb 2008 23:20:05 -0800 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO eris.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 08 Feb 2008 07:19:56 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 0AEBC1A9832; Thu, 7 Feb 2008 23:19:47 -0800 (PST) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r619787 - in /geronimo/server/branches/2.1/plugins/jaxws/geronimo-jaxws-builder/src/main/java/org/apache/geronimo/jaxws/builder: JAXWSTools.java WsdlGenerator.java Date: Fri, 08 Feb 2008 07:19:47 -0000 To: scm@geronimo.apache.org From: djencks@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20080208071948.0AEBC1A9832@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: djencks Date: Thu Feb 7 23:19:45 2008 New Revision: 619787 URL: http://svn.apache.org/viewvc?rev=619787&view=rev Log: GERONIMO-3831 Make wsgen work on macs(don't fail if tools.jar is missing). Look in both the ear and web app for classes for wsgen. Port from trunk Modified: geronimo/server/branches/2.1/plugins/jaxws/geronimo-jaxws-builder/src/main/java/org/apache/geronimo/jaxws/builder/JAXWSTools.java geronimo/server/branches/2.1/plugins/jaxws/geronimo-jaxws-builder/src/main/java/org/apache/geronimo/jaxws/builder/WsdlGenerator.java Modified: geronimo/server/branches/2.1/plugins/jaxws/geronimo-jaxws-builder/src/main/java/org/apache/geronimo/jaxws/builder/JAXWSTools.java URL: http://svn.apache.org/viewvc/geronimo/server/branches/2.1/plugins/jaxws/geronimo-jaxws-builder/src/main/java/org/apache/geronimo/jaxws/builder/JAXWSTools.java?rev=619787&r1=619786&r2=619787&view=diff ============================================================================== --- geronimo/server/branches/2.1/plugins/jaxws/geronimo-jaxws-builder/src/main/java/org/apache/geronimo/jaxws/builder/JAXWSTools.java (original) +++ geronimo/server/branches/2.1/plugins/jaxws/geronimo-jaxws-builder/src/main/java/org/apache/geronimo/jaxws/builder/JAXWSTools.java Thu Feb 7 23:19:45 2008 @@ -33,6 +33,7 @@ import org.apache.geronimo.kernel.repository.ListableRepository; import org.apache.geronimo.kernel.repository.Repository; import org.apache.geronimo.kernel.repository.Version; +import org.apache.geronimo.common.DeploymentException; public class JAXWSTools { @@ -106,7 +107,7 @@ return buf.toString(); } - public File[] getClasspath(Collection repositories) throws Exception { + public File[] getClasspath(Collection repositories) throws DeploymentException { ArrayList jars = new ArrayList(); for (String[] lib : LIBS) { Artifact artifact = new Artifact(lib[0], lib[1], (Version)null, "jar"); @@ -115,12 +116,12 @@ if (this.saajImpl != null) { jars.add(getLocation(repositories, this.saajImpl)); } - jars.add(getToolsJarLocation()); + addToolsJarLocation(jars); return jars.toArray(new File[jars.size()]); } - private static File getLocation(Collection repositories, Artifact artifactQuery) throws Exception { + private static File getLocation(Collection repositories, Artifact artifactQuery) throws DeploymentException { File file = null; for (Repository arepository : repositories) { @@ -138,10 +139,10 @@ } } - throw new Exception("Missing artifact in repositories: " + artifactQuery.toString()); + throw new DeploymentException("Missing artifact in repositories: " + artifactQuery.toString()); } - private static File getToolsJarLocation() throws Exception { + private static void addToolsJarLocation(ArrayList jars) { //create a new File then check exists() String jreHomePath = System.getProperty("java.home"); String javaHomePath = ""; @@ -152,16 +153,16 @@ } File jdkhomelib = new File(javaHomePath, "lib"); if (!jdkhomelib.exists()) { - throw new Exception("Missing " + jdkhomelib.getAbsolutePath() - + ". This is required for wsgen to run. "); + LOG.warn("Missing " + jdkhomelib.getAbsolutePath() + + ". This may be required for wsgen to run. "); } else { File tools = new File(jdkhomelib, TOOLS); if (!tools.exists()) { - throw new Exception("Missing tools.jar in" + jdkhomelib.getAbsolutePath() - + ". This is required for wsgen to run. "); + LOG.warn("Missing tools.jar in" + jdkhomelib.getAbsolutePath() + + ". This may be required for wsgen to run. "); } else { - return tools.getAbsoluteFile(); + jars.add(tools.getAbsoluteFile()); } } } Modified: geronimo/server/branches/2.1/plugins/jaxws/geronimo-jaxws-builder/src/main/java/org/apache/geronimo/jaxws/builder/WsdlGenerator.java URL: http://svn.apache.org/viewvc/geronimo/server/branches/2.1/plugins/jaxws/geronimo-jaxws-builder/src/main/java/org/apache/geronimo/jaxws/builder/WsdlGenerator.java?rev=619787&r1=619786&r2=619787&view=diff ============================================================================== --- geronimo/server/branches/2.1/plugins/jaxws/geronimo-jaxws-builder/src/main/java/org/apache/geronimo/jaxws/builder/WsdlGenerator.java (original) +++ geronimo/server/branches/2.1/plugins/jaxws/geronimo-jaxws-builder/src/main/java/org/apache/geronimo/jaxws/builder/WsdlGenerator.java Thu Feb 7 23:19:45 2008 @@ -22,11 +22,13 @@ import java.io.FileFilter; import java.io.IOException; import java.net.URL; +import java.net.MalformedURLException; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; import java.util.List; import java.util.Random; +import java.util.Set; import javax.xml.namespace.QName; @@ -37,6 +39,9 @@ import org.apache.geronimo.deployment.DeploymentContext; import org.apache.geronimo.j2ee.deployment.Module; import org.apache.geronimo.jaxws.PortInfo; +import org.apache.geronimo.kernel.config.Configuration; +import org.apache.geronimo.kernel.config.ConfigurationResolver; +import org.apache.geronimo.kernel.config.NoSuchConfigException; import org.apache.geronimo.kernel.repository.Repository; public class WsdlGenerator { @@ -109,47 +114,61 @@ return this.wsdlPort; } - private URL[] getWsgenClasspath(DeploymentContext context) throws Exception { + private URL[] getWsgenClasspath(DeploymentContext context) throws Exception { DeploymentConfigurationManager cm = (DeploymentConfigurationManager)context.getConfigurationManager(); Collection repositories = cm.getRepositories(); File[] jars = this.jaxwsTools.getClasspath(repositories); return JAXWSTools.toURL(jars); } - private static String getModuleClasspath(Module module, DeploymentContext context) throws DeploymentException { - File moduleBase = module.getEarContext().getBaseDir(); - File moduleBaseDir = (moduleBase.isFile()) ? moduleBase.getParentFile() : moduleBase; - String baseDir = moduleBaseDir.getAbsolutePath(); - List moduleClassPath = context.getConfiguration().getClassPath(); - StringBuilder classpath = new StringBuilder(); - for (String s : moduleClassPath) { - s = s.replace("/", File.separator); - - classpath.append(baseDir); - classpath.append(File.separator); - classpath.append(s); - classpath.append(File.pathSeparator); + private static void getModuleClasspath(Module module, DeploymentContext context, StringBuilder classpath) throws DeploymentException { + getModuleClasspath(classpath, module.getEarContext()); + if (module.getRootEarContext() != module.getEarContext()) { + getModuleClasspath(classpath, module.getRootEarContext()); } - return classpath.toString(); } - + + private static void getModuleClasspath(StringBuilder classpath, DeploymentContext deploymentContext) throws DeploymentException { + Configuration configuration = deploymentContext.getConfiguration(); + ConfigurationResolver resolver = configuration.getConfigurationResolver(); + List moduleClassPath = configuration.getClassPath(); + for (String pattern : moduleClassPath) { + try { + Set files = resolver.resolve(pattern); + for (URL url: files) { + String path = toFileName(url); + classpath.append(path).append(File.pathSeparator); + } + } catch (MalformedURLException e) { + throw new DeploymentException("Could not resolve pattern: " + pattern, e); + } catch (NoSuchConfigException e) { + throw new DeploymentException("Could not resolve pattern: " + pattern, e); + } + } + } + private static File toFile(URL url) { if (url == null || !url.getProtocol().equals("file")) { return null; } else { - String filename = url.getFile().replace('/', File.separatorChar); - int pos =0; - while ((pos = filename.indexOf('%', pos)) >= 0) { - if (pos + 2 < filename.length()) { - String hexStr = filename.substring(pos + 1, pos + 3); - char ch = (char) Integer.parseInt(hexStr, 16); - filename = filename.substring(0, pos) + ch + filename.substring(pos + 3); - } - } + String filename = toFileName(url); return new File(filename); } } - + + private static String toFileName(URL url) { + String filename = url.getFile().replace('/', File.separatorChar); + int pos =0; + while ((pos = filename.indexOf('%', pos)) >= 0) { + if (pos + 2 < filename.length()) { + String hexStr = filename.substring(pos + 1, pos + 3); + char ch = (char) Integer.parseInt(hexStr, 16); + filename = filename.substring(0, pos) + ch + filename.substring(pos + 3); + } + } + return filename; + } + private String[] buildArguments(String sei, String classPath, File moduleBaseDir, PortInfo portInfo) { List arguments = new ArrayList(); @@ -257,7 +276,7 @@ } catch (IOException e) { throw new DeploymentException(e); } - + URL[] urls; StringBuilder classPath = new StringBuilder(); //let's figure out the classpath for wsgen tools @@ -268,11 +287,11 @@ } //let's figure out the classpath string for the module and wsgen tools. if (urls != null && urls.length > 0) { - for (int i = 0; i< urls.length; i++) { - classPath.append(toFile(urls[i]).getAbsolutePath() + File.pathSeparator); + for (URL url : urls) { + classPath.append(toFile(url).getAbsolutePath()).append(File.pathSeparator); } } - classPath.append(getModuleClasspath(module, context)); + getModuleClasspath(module, context, classPath); //create arguments; String[] arguments = buildArguments(serviceClass, classPath.toString(), baseDir, portInfo);