You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by re...@apache.org on 2003/08/04 21:02:30 UTC
cvs commit: jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/startup HostConfig.java
remm 2003/08/04 12:02:30
Modified: catalina/src/share/org/apache/catalina/startup
HostConfig.java
Log:
- Allow putting a /META-INF/context.xml inside any WAR file deployed
by the HostConfig.
Revision Changes Path
1.21 +74 -4 jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/startup/HostConfig.java
Index: HostConfig.java
===================================================================
RCS file: /home/cvs/jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/startup/HostConfig.java,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -r1.20 -r1.21
--- HostConfig.java 26 Jul 2003 14:24:52 -0000 1.20
+++ HostConfig.java 4 Aug 2003 19:02:30 -0000 1.21
@@ -436,6 +436,10 @@
*/
protected File configBase() {
+ if (configBase != null) {
+ return configBase;
+ }
+
File file = new File(System.getProperty("catalina.base"), "conf");
Container parent = host.getParent();
if ((parent != null) && (parent instanceof Engine)) {
@@ -562,6 +566,72 @@
contextPath = "";
if (host.findChild(contextPath) != null)
continue;
+
+ // Checking for a nested /META-INF/context.xml
+ JarFile jar = null;
+ JarEntry entry = null;
+ InputStream istream = null;
+ BufferedOutputStream ostream = null;
+ File xml = new File
+ (configBase, files[i].substring
+ (0, files[i].lastIndexOf(".")) + ".xml");
+ if (!xml.exists()) {
+ try {
+ jar = new JarFile(dir);
+ entry = jar.getJarEntry("META-INF/context.xml");
+ if (entry != null) {
+ istream = jar.getInputStream(entry);
+ ostream =
+ new BufferedOutputStream
+ (new FileOutputStream(xml), 1024);
+ byte buffer[] = new byte[1024];
+ while (true) {
+ int n = istream.read(buffer);
+ if (n < 0) {
+ break;
+ }
+ ostream.write(buffer, 0, n);
+ }
+ ostream.flush();
+ ostream.close();
+ ostream = null;
+ istream.close();
+ istream = null;
+ entry = null;
+ jar.close();
+ jar = null;
+ deployDescriptors(configBase(), configBase.list());
+ return;
+ }
+ } catch (Exception e) {
+ // Ignore and continue
+ if (ostream != null) {
+ try {
+ ostream.close();
+ } catch (Throwable t) {
+ ;
+ }
+ ostream = null;
+ }
+ if (istream != null) {
+ try {
+ istream.close();
+ } catch (Throwable t) {
+ ;
+ }
+ istream = null;
+ }
+ entry = null;
+ if (jar != null) {
+ try {
+ jar.close();
+ } catch (Throwable t) {
+ ;
+ }
+ jar = null;
+ }
+ }
+ }
if (isUnpackWARs()) {