Author: fhanik Date: Tue Jun 2 14:04:42 2009 New Revision: 781036 URL: http://svn.apache.org/viewvc?rev=781036&view=rev Log: 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
Modified: tomcat/trunk/java/org/apache/catalina/Host.java tomcat/trunk/java/org/apache/catalina/core/StandardHost.java tomcat/trunk/java/org/apache/catalina/startup/HostConfig.java tomcat/trunk/java/org/apache/catalina/startup/LocalStrings.properties tomcat/trunk/webapps/docs/config/host.xml Modified: tomcat/trunk/java/org/apache/catalina/Host.java URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/Host.java?rev=781036&r1=781035&r2=781036&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/catalina/Host.java (original) +++ tomcat/trunk/java/org/apache/catalina/Host.java Tue Jun 2 14:04:42 2009 @@ -232,5 +232,16 @@ */ 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); } Modified: tomcat/trunk/java/org/apache/catalina/core/StandardHost.java URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/core/StandardHost.java?rev=781036&r1=781035&r2=781036&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/catalina/core/StandardHost.java (original) +++ tomcat/trunk/java/org/apache/catalina/core/StandardHost.java Tue Jun 2 14:04:42 2009 @@ -161,7 +161,11 @@ * 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 @@ } + /** + * 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 @@ return (sb.toString()); } - - + /** * Start this host. * Modified: tomcat/trunk/java/org/apache/catalina/startup/HostConfig.java URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/startup/HostConfig.java?rev=781036&r1=781035&r2=781036&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/catalina/startup/HostConfig.java (original) +++ tomcat/trunk/java/org/apache/catalina/startup/HostConfig.java Tue Jun 2 14:04:42 2009 @@ -762,8 +762,6 @@ if (entry != null) { istream = jar.getInputStream(entry); - configBase().mkdirs(); - ostream = new BufferedOutputStream (new FileOutputStream(xml), 1024); @@ -956,7 +954,6 @@ digester.reset(); } } - configBase().mkdirs(); File xmlCopy = new File(configBase(), file + ".xml"); InputStream is = null; OutputStream os = null; @@ -1212,6 +1209,15 @@ } 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<dirs.length; i++) { + if ( (!dirs[i].exists()) && (!dirs[i].mkdirs())) { + log.error(sm.getString("hostConfig.createDirs",dirs[i])); + } + } + } if (host.getDeployOnStartup()) deployApps(); Modified: tomcat/trunk/java/org/apache/catalina/startup/LocalStrings.properties URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/startup/LocalStrings.properties?rev=781036&r1=781035&r2=781036&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/catalina/startup/LocalStrings.properties (original) +++ tomcat/trunk/java/org/apache/catalina/startup/LocalStrings.properties Tue Jun 2 14:04:42 2009 @@ -97,3 +97,4 @@ userConfig.start=UserConfig: Processing START userConfig.stop=UserConfig: Processing STOP catalina.stopServer=No shutdown port configured. Shut down server through OS signal. Server not shut down. +hostConfig.createDirs=Unable to create directory for deployment: {0} Modified: tomcat/trunk/webapps/docs/config/host.xml URL: http://svn.apache.org/viewvc/tomcat/trunk/webapps/docs/config/host.xml?rev=781036&r1=781035&r2=781036&view=diff ============================================================================== --- tomcat/trunk/webapps/docs/config/host.xml (original) +++ tomcat/trunk/webapps/docs/config/host.xml Tue Jun 2 14:04:42 2009 @@ -96,6 +96,14 @@ Deployment</a> for more information on automatic recognition and deployment of web applications to be deployed automatically.</p> </attribute> + + <attribute name="createDirs" required="false"> + <p>If set to true, Tomcat will attempt to create the directories defined by the + attributes <code>appBase</code> and <code>xmlBase</code> during the startup phase. + The default value is <code>true</code>. + If set to true, and directory creation fails, an error message will be printed out but will not halt + the startup sequence.</p> + </attribute> <attribute name="autoDeploy" required="false"> <p>This flag value indicates if new web applications, dropped in to --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org