This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/tomcat.git

commit 9e6f3b7328b89259a222e85c838e6104c9eb2a22
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Thu Feb 11 12:27:30 2021 +0000

    Add legacyAppBase property with default of "webapps-javaee"
---
 build.xml                                          |  1 +
 java/org/apache/catalina/Host.java                 | 24 ++++++++
 .../apache/catalina/core/LocalStrings.properties   |  1 +
 java/org/apache/catalina/core/StandardHost.java    | 65 +++++++++++++++++-----
 .../apache/catalina/core/mbeans-descriptors.xml    |  4 ++
 test/org/apache/tomcat/unittest/TesterHost.java    | 15 +++++
 6 files changed, 96 insertions(+), 14 deletions(-)

diff --git a/build.xml b/build.xml
index 455edf9..98d180e 100644
--- a/build.xml
+++ b/build.xml
@@ -808,6 +808,7 @@
     <mkdir dir="${tomcat.build}/logs"/>
     <mkdir dir="${tomcat.build}/temp"/>
     <mkdir dir="${tomcat.build}/webapps"/>
+    <mkdir dir="${tomcat.build}/webapps-javaee"/>
 
     <!-- Property that determines if manifests need updating -->
     <uptodate property="manifests.uptodate"
diff --git a/java/org/apache/catalina/Host.java 
b/java/org/apache/catalina/Host.java
index 3659240..ba585f0 100644
--- a/java/org/apache/catalina/Host.java
+++ b/java/org/apache/catalina/Host.java
@@ -114,6 +114,30 @@ public interface Host extends Container {
 
 
     /**
+     * @return the legacy (Java EE) application root for this Host.  This can 
be
+     * an absolute pathname, a relative pathname, or a URL.
+     */
+    public String getLegacyAppBase();
+
+
+    /**
+     * @return an absolute {@link File} for the legacy (Java EE) appBase of 
this
+     * Host. The file will be canonical if possible. There is no guarantee that
+     * that the appBase exists.
+     */
+    public File getLegacyAppBaseFile();
+
+
+    /**
+     * Set the legacy (Java EE) application root for this Host.  This can be an
+     * absolute pathname, a relative pathname, or a URL.
+     *
+     * @param legacyAppBase The new legacy application root
+     */
+    public void setLegacyAppBase(String legacyAppBase);
+
+
+    /**
      * @return the value of the auto deploy flag.  If true, it indicates that
      * this host's child webapps should be discovered and automatically
      * deployed dynamically.
diff --git a/java/org/apache/catalina/core/LocalStrings.properties 
b/java/org/apache/catalina/core/LocalStrings.properties
index f1ede08..bcc97e2 100644
--- a/java/org/apache/catalina/core/LocalStrings.properties
+++ b/java/org/apache/catalina/core/LocalStrings.properties
@@ -248,6 +248,7 @@ standardHost.noContext=No Context configured to process 
this request
 standardHost.notContext=Child of a Host must be a Context
 standardHost.nullName=Host name is required
 standardHost.problematicAppBase=Using an empty string for appBase on host 
[{0}] will set it to CATALINA_BASE, which is a bad idea
+standardHost.problematicLegacyAppBase=Using an empty string for legacyAppBase 
on host [{0}] will set it to CATALINA_BASE, which is a bad idea
 
 standardHostValue.customStatusFailed=Custom error page [{0}] could not be 
dispatched correctly
 
diff --git a/java/org/apache/catalina/core/StandardHost.java 
b/java/org/apache/catalina/core/StandardHost.java
index bf8a096..31bdc94 100644
--- a/java/org/apache/catalina/core/StandardHost.java
+++ b/java/org/apache/catalina/core/StandardHost.java
@@ -90,6 +90,14 @@ public class StandardHost extends ContainerBase implements 
Host {
     private String appBase = "webapps";
     private volatile File appBaseFile = null;
 
+
+    /**
+     * The legacy (Java EE) application root for this Host.
+     */
+    private String legacyAppBase = "webapps-javaee";
+    private volatile File legacyAppBaseFile = null;
+
+
     /**
      * The XML root for this Host.
      */
@@ -209,19 +217,12 @@ public class StandardHost extends ContainerBase 
implements Host {
     }
 
 
-    /**
-     * Return the application root for this Host.  This can be an absolute
-     * pathname, a relative pathname, or a URL.
-     */
     @Override
     public String getAppBase() {
         return this.appBase;
     }
 
 
-    /**
-     * ({@inheritDoc}
-     */
     @Override
     public File getAppBaseFile() {
 
@@ -248,15 +249,8 @@ public class StandardHost extends ContainerBase implements 
Host {
     }
 
 
-    /**
-     * Set the application root for this Host.  This can be an absolute
-     * pathname, a relative pathname, or a URL.
-     *
-     * @param appBase The new application root
-     */
     @Override
     public void setAppBase(String appBase) {
-
         if (appBase.trim().equals("")) {
             log.warn(sm.getString("standardHost.problematicAppBase", 
getName()));
         }
@@ -267,6 +261,49 @@ public class StandardHost extends ContainerBase implements 
Host {
     }
 
 
+    @Override
+    public String getLegacyAppBase() {
+        return this.legacyAppBase;
+    }
+
+
+    @Override
+    public File getLegacyAppBaseFile() {
+        if (legacyAppBaseFile != null) {
+            return legacyAppBaseFile;
+        }
+
+        File file = new File(getLegacyAppBase());
+
+        // If not absolute, make it absolute
+        if (!file.isAbsolute()) {
+            file = new File(getCatalinaBase(), file.getPath());
+        }
+
+        // Make it canonical if possible
+        try {
+            file = file.getCanonicalFile();
+        } catch (IOException ioe) {
+            // Ignore
+        }
+
+        this.legacyAppBaseFile = file;
+        return file;
+    }
+
+
+    @Override
+    public void setLegacyAppBase(String legacyAppBase) {
+        if (legacyAppBase.trim().equals("")) {
+            log.warn(sm.getString("standardHost.problematicLegacyAppBase", 
getName()));
+        }
+        String oldLegacyAppBase = this.legacyAppBase;
+        this.legacyAppBase = legacyAppBase;
+        support.firePropertyChange("legacyAppBase", oldLegacyAppBase, 
this.legacyAppBase);
+        this.legacyAppBaseFile = null;
+    }
+
+
     /**
      * ({@inheritDoc}
      */
diff --git a/java/org/apache/catalina/core/mbeans-descriptors.xml 
b/java/org/apache/catalina/core/mbeans-descriptors.xml
index c02cff3..bcef191 100644
--- a/java/org/apache/catalina/core/mbeans-descriptors.xml
+++ b/java/org/apache/catalina/core/mbeans-descriptors.xml
@@ -1129,6 +1129,10 @@
                type="java.lang.String"
                writeable="false" />
 
+    <attribute name="legacyAppBase"
+               description="The legacy (Java EE) application root for this 
Host"
+               type="java.lang.String"/>
+
     <attribute name="managedResource"
                description="The managed resource this MBean is associated with"
                type="java.lang.Object"/>
diff --git a/test/org/apache/tomcat/unittest/TesterHost.java 
b/test/org/apache/tomcat/unittest/TesterHost.java
index ae3379e..b194879 100644
--- a/test/org/apache/tomcat/unittest/TesterHost.java
+++ b/test/org/apache/tomcat/unittest/TesterHost.java
@@ -291,6 +291,21 @@ public class TesterHost implements Host {
     }
 
     @Override
+    public String getLegacyAppBase() {
+        return null;
+    }
+
+    @Override
+    public File getLegacyAppBaseFile() {
+        return null;
+    }
+
+    @Override
+    public void setLegacyAppBase(String legacyAppBase) {
+        // NO-OP
+    }
+
+    @Override
     public boolean getAutoDeploy() {
         return false;
     }


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

Reply via email to