You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@geronimo.apache.org by dj...@apache.org on 2008/02/08 08:18:05 UTC
svn commit: r619786 - in
/geronimo/server/trunk/plugins/jaxws/geronimo-jaxws-builder/src/main/java/org/apache/geronimo/jaxws/builder:
JAXWSTools.java WsdlGenerator.java
Author: djencks
Date: Thu Feb 7 23:18:03 2008
New Revision: 619786
URL: http://svn.apache.org/viewvc?rev=619786&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
Modified:
geronimo/server/trunk/plugins/jaxws/geronimo-jaxws-builder/src/main/java/org/apache/geronimo/jaxws/builder/JAXWSTools.java
geronimo/server/trunk/plugins/jaxws/geronimo-jaxws-builder/src/main/java/org/apache/geronimo/jaxws/builder/WsdlGenerator.java
Modified: geronimo/server/trunk/plugins/jaxws/geronimo-jaxws-builder/src/main/java/org/apache/geronimo/jaxws/builder/JAXWSTools.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/jaxws/geronimo-jaxws-builder/src/main/java/org/apache/geronimo/jaxws/builder/JAXWSTools.java?rev=619786&r1=619785&r2=619786&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/jaxws/geronimo-jaxws-builder/src/main/java/org/apache/geronimo/jaxws/builder/JAXWSTools.java (original)
+++ geronimo/server/trunk/plugins/jaxws/geronimo-jaxws-builder/src/main/java/org/apache/geronimo/jaxws/builder/JAXWSTools.java Thu Feb 7 23:18:03 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<? extends Repository> repositories) throws Exception {
+ public File[] getClasspath(Collection<? extends Repository> repositories) throws DeploymentException {
ArrayList<File> jars = new ArrayList<File>();
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<? extends Repository> repositories, Artifact artifactQuery) throws Exception {
+ private static File getLocation(Collection<? extends Repository> 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<File> 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/trunk/plugins/jaxws/geronimo-jaxws-builder/src/main/java/org/apache/geronimo/jaxws/builder/WsdlGenerator.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/jaxws/geronimo-jaxws-builder/src/main/java/org/apache/geronimo/jaxws/builder/WsdlGenerator.java?rev=619786&r1=619785&r2=619786&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/jaxws/geronimo-jaxws-builder/src/main/java/org/apache/geronimo/jaxws/builder/WsdlGenerator.java (original)
+++ geronimo/server/trunk/plugins/jaxws/geronimo-jaxws-builder/src/main/java/org/apache/geronimo/jaxws/builder/WsdlGenerator.java Thu Feb 7 23:18:03 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<? extends Repository> 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<String> 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<String> moduleClassPath = configuration.getClassPath();
+ for (String pattern : moduleClassPath) {
+ try {
+ Set<URL> 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<String> arguments = new ArrayList<String>();
@@ -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);