tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fha...@apache.org
Subject svn commit: r752651 - in /tomcat/trunk: java/org/apache/catalina/Host.java java/org/apache/catalina/core/StandardHost.java java/org/apache/catalina/startup/HostConfig.java webapps/docs/config/host.xml
Date Wed, 11 Mar 2009 22:05:12 GMT
Author: fhanik
Date: Wed Mar 11 22:05:12 2009
New Revision: 752651

URL: http://svn.apache.org/viewvc?rev=752651&view=rev
Log:
Allow xmlBase to be configurable, just like appBase. 

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/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=752651&r1=752650&r2=752651&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/Host.java (original)
+++ tomcat/trunk/java/org/apache/catalina/Host.java Wed Mar 11 22:05:12 2009
@@ -68,6 +68,22 @@
 
 
     /**
+     * Return the XML root for this Host.  This can be an absolute
+     * pathname, a relative pathname, or a URL.
+     * If null, defaults to ${catalina.base}/conf/ directory
+     */
+    public String getXmlBase();
+    
+    /**
+     * Set the Xml root for this Host.  This can be an absolute
+     * pathname, a relative pathname, or a URL.
+     * If null, defaults to ${catalina.base}/conf/ directory
+     *
+     * @param xmlBase The new XML root
+     */
+    public void setXmlBase(String xmlBase);
+
+        /**
      * Return the application root for this Host.  This can be an absolute
      * pathname, a relative pathname, or a URL.
      */

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=752651&r1=752650&r2=752651&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/core/StandardHost.java (original)
+++ tomcat/trunk/java/org/apache/catalina/core/StandardHost.java Wed Mar 11 22:05:12 2009
@@ -79,6 +79,10 @@
      */
     private String appBase = ".";
 
+    /**
+     * The XML root for this Host.
+     */
+    private String xmlBase = null;
 
     /**
      * The auto deploy flag for this Host.
@@ -170,6 +174,16 @@
 
     }
 
+    /**
+     * Return the XML root for this Host.  This can be an absolute
+     * pathname, a relative pathname, or a URL.
+     * If null, defaults to ${catalina.base}/conf/ directory
+     */
+    public String getXmlBase() {
+
+        return (this.xmlBase);
+
+    }
 
     /**
      * Set the application root for this Host.  This can be an absolute
@@ -184,6 +198,21 @@
         support.firePropertyChange("appBase", oldAppBase, this.appBase);
 
     }
+    
+    /**
+     * Set the Xml root for this Host.  This can be an absolute
+     * pathname, a relative pathname, or a URL.
+     * If null, defaults to ${catalina.base}/conf/ directory
+     *
+     * @param xmlBase The new XML root
+     */
+    public void setXmlBase(String xmlBase) {
+
+        String oldXmlBase = this.xmlBase;
+        this.xmlBase = xmlBase;
+        support.firePropertyChange("xmlBase", oldXmlBase, this.xmlBase);
+
+    }
 
 
     /**

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=752651&r1=752650&r2=752651&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/startup/HostConfig.java (original)
+++ tomcat/trunk/java/org/apache/catalina/startup/HostConfig.java Wed Mar 11 22:05:12 2009
@@ -304,6 +304,9 @@
                 setUnpackWARs(((StandardHost) host).isUnpackWARs());
                 setXmlNamespaceAware(((StandardHost) host).getXmlNamespaceAware());
                 setXmlValidation(((StandardHost) host).getXmlValidation());
+                if (((StandardHost) host).getXmlBase()!=null) {
+                    
+                }
             }
         } catch (ClassCastException e) {
             log.error(sm.getString("hostConfig.cce", event.getLifecycle()), e);
@@ -394,6 +397,18 @@
         return (digester);
     }
     
+    protected File returnCanonicalPath(String path) {
+        File file = new File(path);
+        File base = new File(System.getProperty("catalina.base"));
+        if (!file.isAbsolute())
+            file = new File(base,path);
+        try {
+            return file.getCanonicalFile();
+        } catch (IOException e) {
+            return file;
+        }
+    }
+    
 
     /**
      * Return a File object representing the "application root" directory
@@ -404,17 +419,9 @@
         if (appBase != null) {
             return appBase;
         }
-
-        File file = new File(host.getAppBase());
-        if (!file.isAbsolute())
-            file = new File(System.getProperty("catalina.base"),
-                            host.getAppBase());
-        try {
-            appBase = file.getCanonicalFile();
-        } catch (IOException e) {
-            appBase = file;
-        }
-        return (appBase);
+        
+        appBase = returnCanonicalPath(host.getAppBase());
+        return appBase;
 
     }
 
@@ -428,17 +435,11 @@
         if (configBase != null) {
             return configBase;
         }
-
-        File file = new File(System.getProperty("catalina.base"), "conf");
-        Container parent = host.getParent();
-        if ((parent != null) && (parent instanceof Engine)) {
-            file = new File(file, parent.getName());
-        }
-        file = new File(file, host.getName());
-        try {
-            configBase = file.getCanonicalFile();
-        } catch (IOException e) {
-            configBase = file;
+        
+        if (host.getXmlBase()!=null) {
+            configBase = returnCanonicalPath(host.getXmlBase());
+        } else {
+            configBase = returnCanonicalPath("conf");
         }
         return (configBase);
 
@@ -748,7 +749,7 @@
         InputStream istream = null;
         BufferedOutputStream ostream = null;
         File xml = new File
-            (configBase, file.substring(0, file.lastIndexOf(".")) + ".xml");
+            (configBase(), file.substring(0, file.lastIndexOf(".")) + ".xml");
         if (deployXML && !xml.exists()) {
             try {
                 jar = new JarFile(war);
@@ -756,7 +757,7 @@
                 if (entry != null) {
                     istream = jar.getInputStream(entry);
                     
-                    configBase.mkdirs();
+                    configBase().mkdirs();
                     
                     ostream =
                         new BufferedOutputStream
@@ -950,8 +951,8 @@
                         digester.reset();
                     }
                 }
-                configBase.mkdirs();
-                File xmlCopy = new File(configBase, file + ".xml");
+                configBase().mkdirs();
+                File xmlCopy = new File(configBase(), file + ".xml");
                 InputStream is = null;
                 OutputStream os = null;
                 try {

Modified: tomcat/trunk/webapps/docs/config/host.xml
URL: http://svn.apache.org/viewvc/tomcat/trunk/webapps/docs/config/host.xml?rev=752651&r1=752650&r2=752651&view=diff
==============================================================================
--- tomcat/trunk/webapps/docs/config/host.xml (original)
+++ tomcat/trunk/webapps/docs/config/host.xml Wed Mar 11 22:05:12 2009
@@ -85,6 +85,17 @@
         Deployment</a> for more information on automatic recognition and
         deployment of web applications to be deployed automatically.</p>
       </attribute>
+      
+      <attribute name="xmlBase" required="false">
+        <p>The <em>XML Base</em> directory for this virtual host.
+        This is the pathname of a directory that may contain context XML descriptors
+        to be deployed on this virtual host.  You may specify an
+        absolute pathname for this directory, or a pathname that is relative
+        to the <code>$CATALINA_BASE</code> directory.  See
+        <a href="#Automatic Application Deployment">Automatic Application
+        Deployment</a> for more information on automatic recognition and
+        deployment of web applications to be deployed automatically.</p>
+      </attribute>
 
       <attribute name="autoDeploy" required="false">
         <p>This flag value indicates if new web applications, dropped in to
@@ -155,7 +166,7 @@
         applications from interacting with the container's configuration. The 
         administrator will then be responsible for providing an external context 
         configuration file, and put it in 
-        <code>$CATALINA_BASE/conf/[enginename]/[hostname]/</code>.
+        <code>$CATALINA_BASE/conf/[enginename]/[hostname]/</code> unless the
attribute <code>xmlBase</code> is specified.
         The flag's value defaults to <code>true</code>.</p>
       </attribute>
 



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


Mime
View raw message