From 41e5629a8be4f84ff522de2b202924c580815826 Mon Sep 17 00:00:00 2001
From: fhanik
Date: Tue, 2 Jun 2009 14:04:42 +0000
Subject: [PATCH] Consolidate directory creation from doing it in multiple
places with no indication of failure and only for xmlBase to create
directories during the startup phase for both appBase and xmlBase
git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@781036 13f79535-47bb-0310-9956-ffa450edef68
---
java/org/apache/catalina/Host.java | 11 ++++++++++
java/org/apache/catalina/core/StandardHost.java | 25 +++++++++++++++++++---
java/org/apache/catalina/startup/HostConfig.java | 12 ++++++++---
.../catalina/startup/LocalStrings.properties | 1 +
webapps/docs/config/host.xml | 8 +++++++
5 files changed, 51 insertions(+), 6 deletions(-)
diff --git a/java/org/apache/catalina/Host.java b/java/org/apache/catalina/Host.java
index 2527c439c..a9413d30e 100644
--- a/java/org/apache/catalina/Host.java
+++ b/java/org/apache/catalina/Host.java
@@ -232,5 +232,16 @@ public interface Host extends Container {
*/
public void removeAlias(String alias);
+ /**
+ * Returns true if the Host will attempt to create directories for appBase and xmlBase
+ * unless they already exist.
+ * @return
+ */
+ public boolean getCreateDirs();
+ /**
+ * Set to true if the Host should attempt to create directories for xmlBase and appBase upon startup
+ * @param createDirs
+ */
+ public void setCreateDirs(boolean createDirs);
}
diff --git a/java/org/apache/catalina/core/StandardHost.java b/java/org/apache/catalina/core/StandardHost.java
index 951d632e0..9bb6ef0dc 100644
--- a/java/org/apache/catalina/core/StandardHost.java
+++ b/java/org/apache/catalina/core/StandardHost.java
@@ -161,7 +161,11 @@ public class StandardHost
* Attribute value used to turn on/off XML namespace awarenes.
*/
private boolean xmlNamespaceAware = false;
-
+
+ /**
+ * Should we create directories upon startup for appBase and xmlBase
+ */
+ private boolean createDirs = true;
// ------------------------------------------------------------- Properties
@@ -216,6 +220,22 @@ public class StandardHost
}
+ /**
+ * Returns true if the Host will attempt to create directories for appBase and xmlBase
+ * unless they already exist.
+ * @return
+ */
+ public boolean getCreateDirs() {
+ return createDirs;
+ }
+
+ /**
+ * Set to true if the Host should attempt to create directories for xmlBase and appBase upon startup
+ * @param createDirs
+ */
+ public void setCreateDirs(boolean createDirs) {
+ this.createDirs = createDirs;
+ }
/**
* Return the value of the auto deploy flag. If true, it indicates that
@@ -680,8 +700,7 @@ public class StandardHost
return (sb.toString());
}
-
-
+
/**
* Start this host.
*
diff --git a/java/org/apache/catalina/startup/HostConfig.java b/java/org/apache/catalina/startup/HostConfig.java
index 12581ced6..07b46eb96 100644
--- a/java/org/apache/catalina/startup/HostConfig.java
+++ b/java/org/apache/catalina/startup/HostConfig.java
@@ -762,8 +762,6 @@ public class HostConfig
if (entry != null) {
istream = jar.getInputStream(entry);
- configBase().mkdirs();
-
ostream =
new BufferedOutputStream
(new FileOutputStream(xml), 1024);
@@ -956,7 +954,6 @@ public class HostConfig
digester.reset();
}
}
- configBase().mkdirs();
File xmlCopy = new File(configBase(), file + ".xml");
InputStream is = null;
OutputStream os = null;
@@ -1212,6 +1209,15 @@ public class HostConfig
} catch (Exception e) {
log.error(sm.getString("hostConfig.jmx.register", oname), e);
}
+
+ if (host.getCreateDirs()) {
+ File[] dirs = new File[] {appBase(),configBase()};
+ for (int i=0; i for more information on automatic recognition and
deployment of web applications to be deployed automatically.
+
+
+ If set to true, Tomcat will attempt to create the directories defined by the
+ attributes appBase and xmlBase during the startup phase.
+ The default value is true.
+ If set to true, and directory creation fails, an error message will be printed out but will not halt
+ the startup sequence.
+
This flag value indicates if new web applications, dropped in to
--
2.11.0