You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by cr...@locus.apache.org on 2000/07/28 20:03:21 UTC
cvs commit: jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/startup HostConfig.java
craigmcc 00/07/28 11:03:20
Modified: proposals/catalina/src/share/org/apache/tomcat/startup
HostConfig.java
Log:
When auto-expanding WAR files, correctly look for the "*.war" extension (case
insensitive) instead of the "*.jar" extension (case sensitive).
Also, switch from ZipFile/ZipEntry to JarFile/JarEntry since we know we are
in a Java2 environment, and future enhancements may require access to the
additional information available through these interfaces.
Revision Changes Path
1.3 +24 -17 jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/startup/HostConfig.java
Index: HostConfig.java
===================================================================
RCS file: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/startup/HostConfig.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- HostConfig.java 2000/05/21 02:39:57 1.2
+++ HostConfig.java 2000/07/28 18:03:16 1.3
@@ -1,7 +1,7 @@
/*
- * $Header: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/startup/HostConfig.java,v 1.2 2000/05/21 02:39:57 craigmcc Exp $
- * $Revision: 1.2 $
- * $Date: 2000/05/21 02:39:57 $
+ * $Header: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/startup/HostConfig.java,v 1.3 2000/07/28 18:03:16 craigmcc Exp $
+ * $Revision: 1.3 $
+ * $Date: 2000/07/28 18:03:16 $
*
* ====================================================================
*
@@ -76,8 +76,8 @@
import java.net.MalformedURLException;
import java.net.URL;
import java.util.Enumeration;
-import java.util.zip.ZipEntry;
-import java.util.zip.ZipFile;
+import java.util.jar.JarEntry;
+import java.util.jar.JarFile;
import org.apache.tomcat.Context;
import org.apache.tomcat.Host;
import org.apache.tomcat.Lifecycle;
@@ -92,7 +92,7 @@
* of that Host, and the associated defined contexts.
*
* @author Craig R. McClanahan
- * @version $Revision: 1.2 $ $Date: 2000/05/21 02:39:57 $
+ * @version $Revision: 1.3 $ $Date: 2000/07/28 18:03:16 $
*/
public final class HostConfig
@@ -311,7 +311,7 @@
if (debug >= 1)
log(sm.getString("hostConfig.expanding"));
- // Discover and expand JAR files as necessary
+ // Discover and expand WAR files as necessary
File appBase = appBase();
if (!appBase.exists() || !appBase.isDirectory())
return;
@@ -319,22 +319,29 @@
for (int i = 0; i < files.length; i++) {
- if (!files[i].endsWith(".jar"))
+ // Is this file a WAR that needs to be expanded?
+ File file = new File(appBase, files[i]);
+ if (file.isDirectory())
continue;
+ String filename = files[i].toLowerCase();
+ if (!filename.endsWith(".war"))
+ continue;
+
+ // Has this WAR been expanded previously?
File dir = new File(appBase,
files[i].substring(0, files[i].length() - 4));
if (dir.exists())
continue;
log(sm.getString("hostConfig.expand", files[i]));
- ZipFile zipFile = null;
+ JarFile jarFile = null;
try {
dir.mkdirs();
- zipFile = new ZipFile(new File(appBase, files[i]));
- Enumeration zipEntries = zipFile.entries();
- while (zipEntries.hasMoreElements()) {
- ZipEntry zipEntry = (ZipEntry) zipEntries.nextElement();
- String name = zipEntry.getName();
+ jarFile = new JarFile(new File(appBase, files[i]));
+ Enumeration jarEntries = jarFile.entries();
+ while (jarEntries.hasMoreElements()) {
+ JarEntry jarEntry = (JarEntry) jarEntries.nextElement();
+ String name = jarEntry.getName();
int slash = name.lastIndexOf("/");
if (slash >= 0) {
File parent = new File(dir,
@@ -347,14 +354,14 @@
continue;
if (debug >= 2)
log(" Creating expanded file " + name);
- InputStream input = zipFile.getInputStream(zipEntry);
+ InputStream input = jarFile.getInputStream(jarEntry);
expand(input, dir, name);
}
} catch (Exception e) {
log(sm.getString("hostConfig.expand.error", files[i]), e);
- if (zipFile != null) {
+ if (jarFile != null) {
try {
- zipFile.close();
+ jarFile.close();
} catch (Exception f) {
;
}