You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@geronimo.apache.org by da...@apache.org on 2004/09/22 08:34:26 UTC
svn commit: rev 47031 - in geronimo/trunk/modules: client-builder/src/java/org/apache/geronimo/client/builder connector/src/java/org/apache/geronimo/connector/deployment deployment/src/java/org/apache/geronimo/deployment deployment/src/java/org/apache/geronimo/deployment/plugin/local deployment/src/java/org/apache/geronimo/deployment/util jetty/src/java/org/apache/geronimo/jetty/deployment
Author: dain
Date: Tue Sep 21 23:34:25 2004
New Revision: 47031
Modified:
geronimo/trunk/modules/client-builder/src/java/org/apache/geronimo/client/builder/AppClientModuleBuilder.java
geronimo/trunk/modules/connector/src/java/org/apache/geronimo/connector/deployment/ConnectorModuleBuilder.java
geronimo/trunk/modules/deployment/src/java/org/apache/geronimo/deployment/Deployer.java
geronimo/trunk/modules/deployment/src/java/org/apache/geronimo/deployment/DeploymentContext.java
geronimo/trunk/modules/deployment/src/java/org/apache/geronimo/deployment/plugin/local/DistributeCommand.java
geronimo/trunk/modules/deployment/src/java/org/apache/geronimo/deployment/util/FileUtil.java
geronimo/trunk/modules/deployment/src/java/org/apache/geronimo/deployment/util/JarUtil.java
geronimo/trunk/modules/deployment/src/java/org/apache/geronimo/deployment/util/NestedJarFile.java
geronimo/trunk/modules/deployment/src/java/org/apache/geronimo/deployment/util/UnpackedJarFile.java
geronimo/trunk/modules/jetty/src/java/org/apache/geronimo/jetty/deployment/JettyModuleBuilder.java
Log:
Fixed a lot of deployment problems that leaked back in during my last rewrite
Modified: geronimo/trunk/modules/client-builder/src/java/org/apache/geronimo/client/builder/AppClientModuleBuilder.java
==============================================================================
--- geronimo/trunk/modules/client-builder/src/java/org/apache/geronimo/client/builder/AppClientModuleBuilder.java (original)
+++ geronimo/trunk/modules/client-builder/src/java/org/apache/geronimo/client/builder/AppClientModuleBuilder.java Tue Sep 21 23:34:25 2004
@@ -200,7 +200,7 @@
}
public Module createModule(String name, JarFile moduleFile, XmlObject vendorDD) throws DeploymentException {
- return createModule(name, URI.create("/"), moduleFile, "connector", vendorDD, null);
+ return createModule(name, URI.create("/"), moduleFile, "app-client", vendorDD, null);
}
public Module createModule(String name, URI moduleURI, JarFile moduleFile, String targetPath, XmlObject vendorDD, URL specDD) throws DeploymentException {
@@ -395,7 +395,7 @@
Map resourceEnvRefMap = mapRefs(geronimoAppClient.getResourceEnvRefArray());
return ENCConfigBuilder.buildComponentContext(earContext,
- URI.create(appClientModule.getTargetPath()),
+ appClientModule.getModuleURI(),
null,
appClient.getEnvEntryArray(),
appClient.getEjbRefArray(), ejbRefMap,
Modified: geronimo/trunk/modules/connector/src/java/org/apache/geronimo/connector/deployment/ConnectorModuleBuilder.java
==============================================================================
--- geronimo/trunk/modules/connector/src/java/org/apache/geronimo/connector/deployment/ConnectorModuleBuilder.java (original)
+++ geronimo/trunk/modules/connector/src/java/org/apache/geronimo/connector/deployment/ConnectorModuleBuilder.java Tue Sep 21 23:34:25 2004
@@ -225,14 +225,18 @@
public void installModule(JarFile earFile, EARContext earContext, Module module) throws DeploymentException {
try {
- URI moduleBase = URI.create(module.getTargetPath());
+ String targetPath = module.getTargetPath();
+ if (!targetPath.endsWith("/")) {
+ targetPath += "/";
+ }
+ URI targetURI = URI.create(targetPath);
JarFile moduleFile = module.getModuleFile();
Enumeration entries = moduleFile.entries();
while (entries.hasMoreElements()) {
ZipEntry entry = (ZipEntry) entries.nextElement();
- URI target = moduleBase.resolve(entry.getName());
+ URI target = targetURI.resolve(entry.getName());
InputStream in = moduleFile.getInputStream(entry);
try {
if (entry.getName().endsWith(".jar")) {
Modified: geronimo/trunk/modules/deployment/src/java/org/apache/geronimo/deployment/Deployer.java
==============================================================================
--- geronimo/trunk/modules/deployment/src/java/org/apache/geronimo/deployment/Deployer.java (original)
+++ geronimo/trunk/modules/deployment/src/java/org/apache/geronimo/deployment/Deployer.java Tue Sep 21 23:34:25 2004
@@ -109,7 +109,7 @@
}
}
try {
- File carfile = File.createTempFile("deployer", ".car");
+ File carfile = FileUtil.createTempFile();
try {
Manifest manifest = new Manifest();
@@ -173,7 +173,7 @@
boolean saveOutput;
if (cmd.carfile == null) {
saveOutput = false;
- cmd.carfile = File.createTempFile("deployer", ".car");
+ cmd.carfile = FileUtil.createTempFile();
} else {
saveOutput = true;
}
Modified: geronimo/trunk/modules/deployment/src/java/org/apache/geronimo/deployment/DeploymentContext.java
==============================================================================
--- geronimo/trunk/modules/deployment/src/java/org/apache/geronimo/deployment/DeploymentContext.java (original)
+++ geronimo/trunk/modules/deployment/src/java/org/apache/geronimo/deployment/DeploymentContext.java Tue Sep 21 23:34:25 2004
@@ -201,6 +201,7 @@
URI uri = (URI) i.next();
urls[j++] = (URL) includes.get(uri);
}
+
return new URLClassLoader(urls, parentCL);
}
Modified: geronimo/trunk/modules/deployment/src/java/org/apache/geronimo/deployment/plugin/local/DistributeCommand.java
==============================================================================
--- geronimo/trunk/modules/deployment/src/java/org/apache/geronimo/deployment/plugin/local/DistributeCommand.java (original)
+++ geronimo/trunk/modules/deployment/src/java/org/apache/geronimo/deployment/plugin/local/DistributeCommand.java Tue Sep 21 23:34:25 2004
@@ -34,6 +34,7 @@
import org.apache.geronimo.kernel.KernelMBean;
import org.apache.geronimo.deployment.plugin.TargetModuleIDImpl;
+import org.apache.geronimo.deployment.util.FileUtil;
/**
* @version $Rev$ $Date$
@@ -72,11 +73,11 @@
try {
if (spool) {
if (moduleStream != null) {
- moduleArchive = File.createTempFile("deployer", ".tmp");
+ moduleArchive = FileUtil.createTempFile();
copyTo(moduleArchive, moduleStream);
}
if (deploymentStream != null) {
- deploymentPlan = File.createTempFile("deployer", ".tmp");
+ deploymentPlan = FileUtil.createTempFile();
copyTo(deploymentPlan, deploymentStream);
}
}
Modified: geronimo/trunk/modules/deployment/src/java/org/apache/geronimo/deployment/util/FileUtil.java
==============================================================================
--- geronimo/trunk/modules/deployment/src/java/org/apache/geronimo/deployment/util/FileUtil.java (original)
+++ geronimo/trunk/modules/deployment/src/java/org/apache/geronimo/deployment/util/FileUtil.java Tue Sep 21 23:34:25 2004
@@ -32,9 +32,14 @@
* @version $Rev$ $Date$
*/
public class FileUtil {
-
private static int i;
+ public static File createTempFile() throws IOException {
+ File tempFile = File.createTempFile("geronimodeployment" + i++, "tmp");
+ tempFile.deleteOnExit();
+ return tempFile;
+ }
+
public static File toTempFile(InputStream is) throws IOException {
return toTempFile(is, false);
}
@@ -42,7 +47,7 @@
public static File toTempFile(InputStream in, boolean close) throws IOException {
OutputStream out = null;
try {
- File tempFile = File.createTempFile("geronimodeployment" + i++, "tmp");
+ File tempFile = createTempFile();
out = new FileOutputStream(tempFile);
byte[] buffer = new byte[4096];
Modified: geronimo/trunk/modules/deployment/src/java/org/apache/geronimo/deployment/util/JarUtil.java
==============================================================================
--- geronimo/trunk/modules/deployment/src/java/org/apache/geronimo/deployment/util/JarUtil.java (original)
+++ geronimo/trunk/modules/deployment/src/java/org/apache/geronimo/deployment/util/JarUtil.java Tue Sep 21 23:34:25 2004
@@ -22,10 +22,10 @@
import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URL;
+import java.util.Enumeration;
import java.util.jar.JarFile;
import java.util.jar.JarOutputStream;
import java.util.jar.Manifest;
-import java.util.Enumeration;
import java.util.zip.ZipEntry;
import org.apache.geronimo.deployment.DeploymentException;
@@ -37,9 +37,8 @@
public static final File DUMMY_JAR_FILE;
static {
try {
- DUMMY_JAR_FILE = File.createTempFile("fake", null);
+ DUMMY_JAR_FILE = FileUtil.createTempFile();
new JarOutputStream(new FileOutputStream(DUMMY_JAR_FILE), new Manifest()).close();
- DUMMY_JAR_FILE.deleteOnExit();
} catch (IOException e) {
throw new ExceptionInInitializerError(e);
}
@@ -72,11 +71,20 @@
// this is a plain old jar... nothign special
return new File(inputJar.getName());
} else if (inputJar instanceof NestedJarFile && ((NestedJarFile)inputJar).isPacked()) {
- JarFile nestedBaseJar = ((NestedJarFile)inputJar).getBaseJar();
- return new File(nestedBaseJar.getName());
+ NestedJarFile nestedJarFile = (NestedJarFile)inputJar;
+ JarFile baseJar = nestedJarFile.getBaseJar();
+ String basePath = nestedJarFile.getBasePath();
+ if (baseJar instanceof UnpackedJarFile) {
+ // our target jar is just a file in upacked jar (a plain old directory)... now
+ // we just need to find where it is
+ return ((UnpackedJarFile)baseJar).getFile(basePath);
+ } else {
+ // out target is just a plain old jar file directly accessabel from the file system
+ return new File(baseJar.getName());
+ }
} else {
// copy out the module contents to a standalone jar file (entry by entry)
- File jarFile = File.createTempFile("geronimo", null);
+ File jarFile = FileUtil.createTempFile();
JarOutputStream out = new JarOutputStream(new FileOutputStream(jarFile));
try {
@@ -84,7 +92,6 @@
Enumeration entries = inputJar.entries();
while (entries.hasMoreElements()) {
ZipEntry entry = (ZipEntry) entries.nextElement();
-
InputStream in = inputJar.getInputStream(entry);
try {
out.putNextEntry(new ZipEntry(entry.getName()));
@@ -110,6 +117,41 @@
} catch (IOException e) {
}
}
+ }
+ }
+
+ public static final class EmptyInputStream extends InputStream {
+ public int read() {
+ return -1;
+ }
+
+ public int read(byte b[]) {
+ return -1;
+ }
+
+ public int read(byte b[], int off, int len) {
+ return -1;
+ }
+
+ public long skip(long n) {
+ return 0;
+ }
+
+ public int available() {
+ return 0;
+ }
+
+ public void close() {
+ }
+
+ public synchronized void mark(int readlimit) {
+ }
+
+ public synchronized void reset() {
+ }
+
+ public boolean markSupported() {
+ return false;
}
}
}
Modified: geronimo/trunk/modules/deployment/src/java/org/apache/geronimo/deployment/util/NestedJarFile.java
==============================================================================
--- geronimo/trunk/modules/deployment/src/java/org/apache/geronimo/deployment/util/NestedJarFile.java (original)
+++ geronimo/trunk/modules/deployment/src/java/org/apache/geronimo/deployment/util/NestedJarFile.java Tue Sep 21 23:34:25 2004
@@ -135,7 +135,7 @@
JarEntry baseEntry = (JarEntry) iterator.next();
String path = baseEntry.getName();
if (path.startsWith(basePath)) {
- entries.add(new NestedJarEntry(path.substring(path.length()), baseEntry, getManifestSafe()));
+ entries.add(new NestedJarEntry(path.substring(basePath.length()), baseEntry, getManifestSafe()));
}
}
return Collections.enumeration(entries);
@@ -152,7 +152,7 @@
if (baseEntry == null) {
throw new IOException("Entry not found: name=" + baseEntry.getName());
} else if (baseEntry.isDirectory()) {
- throw new IOException("Entry is a directory: name=" + baseEntry.getName());
+ return new JarUtil.EmptyInputStream();
}
return baseJar.getInputStream(baseEntry);
}
@@ -188,4 +188,5 @@
}
return manifest;
}
+
}
Modified: geronimo/trunk/modules/deployment/src/java/org/apache/geronimo/deployment/util/UnpackedJarFile.java
==============================================================================
--- geronimo/trunk/modules/deployment/src/java/org/apache/geronimo/deployment/util/UnpackedJarFile.java (original)
+++ geronimo/trunk/modules/deployment/src/java/org/apache/geronimo/deployment/util/UnpackedJarFile.java Tue Sep 21 23:34:25 2004
@@ -121,7 +121,7 @@
if (file == null) {
throw new IOException("Entry not found: name=" + file.getAbsolutePath());
} else if (file.isDirectory()) {
- throw new IOException("Entry is a directory: name=" + file.getAbsolutePath());
+ return new JarUtil.EmptyInputStream();
}
return new FileInputStream(file);
}
@@ -144,7 +144,7 @@
protected void finalize() throws IOException {
}
- private File getFile(String name) {
+ public File getFile(String name) {
File file = new File(baseDir, name);
if (!file.exists()) {
return null;
Modified: geronimo/trunk/modules/jetty/src/java/org/apache/geronimo/jetty/deployment/JettyModuleBuilder.java
==============================================================================
--- geronimo/trunk/modules/jetty/src/java/org/apache/geronimo/jetty/deployment/JettyModuleBuilder.java (original)
+++ geronimo/trunk/modules/jetty/src/java/org/apache/geronimo/jetty/deployment/JettyModuleBuilder.java Tue Sep 21 23:34:25 2004
@@ -23,12 +23,12 @@
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
+import java.util.Enumeration;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Properties;
import java.util.Set;
-import java.util.Enumeration;
import java.util.jar.JarEntry;
import java.util.jar.JarFile;
import java.util.zip.ZipEntry;
@@ -195,7 +195,7 @@
}
public Module createModule(String name, JarFile moduleFile, XmlObject vendorDD) throws DeploymentException {
- return createModule(name, URI.create("/"), moduleFile, "connector", vendorDD, null);
+ return createModule(name, URI.create(""), moduleFile, "war/", vendorDD, null);
}
public Module createModule(String name, URI moduleURI, JarFile moduleFile, String targetPath, XmlObject vendorDD, URL specDD) throws DeploymentException {
@@ -229,21 +229,24 @@
return module;
}
- public void installModule(JarFile earFile, EARContext earContext, Module webModule) throws DeploymentException {
+ public void installModule(JarFile earFile, EARContext earContext, Module module) throws DeploymentException {
try {
- URI targetURI = URI.create(webModule.getTargetPath());
+ String targetPath = module.getTargetPath();
+ if (!targetPath.endsWith("/")) {
+ targetPath += "/";
+ }
+ URI targetURI = URI.create(targetPath);
// add the warfile's content to the configuration
- JarFile warFile = webModule.getModuleFile();
+ JarFile warFile = module.getModuleFile();
Enumeration entries = warFile.entries();
while (entries.hasMoreElements()) {
ZipEntry entry = (ZipEntry) entries.nextElement();
URI target = targetURI.resolve(entry.getName());
-
- if ( entry.getName().equals("WEB-INF/web.xml")) {
+ if (entry.getName().equals("WEB-INF/web.xml")) {
// TODO gets rid of these tests when Jetty will use the serialized Geronimo DD.
WebAppDocument webAppDoc = WebAppDocument.Factory.newInstance();
- webAppDoc.setWebApp((WebAppType) webModule.getSpecDD());
+ webAppDoc.setWebApp((WebAppType) module.getSpecDD());
earContext.addFile(target, webAppDoc.newInputStream());
} else {
InputStream in = warFile.getInputStream(entry);
@@ -259,7 +262,7 @@
}
// add the dependencies declared in the geronimo-jetty.xml file
- JettyWebAppType jettyWebApp = (JettyWebAppType) webModule.getVendorDD();
+ JettyWebAppType jettyWebApp = (JettyWebAppType) module.getVendorDD();
JettyDependencyType[] dependencies = jettyWebApp.getDependencyArray();
for (int i = 0; i < dependencies.length; i++) {
earContext.addDependency(getDependencyURI(dependencies[i]));
@@ -351,7 +354,7 @@
Map resourceEnvRefMap = mapRefs(jettyWebApp.getResourceEnvRefArray());
return ENCConfigBuilder.buildComponentContext(earContext,
- URI.create(webModule.getTargetPath()),
+ webModule.getModuleURI(),
userTransaction,
webApp.getEnvEntryArray(),
webApp.getEjbRefArray(), ejbRefMap,