Context aliases:
authorrjung <rjung@13f79535-47bb-0310-9956-ffa450edef68>
Fri, 23 Apr 2010 12:16:56 +0000 (12:16 +0000)
committerrjung <rjung@13f79535-47bb-0310-9956-ffa450edef68>
Fri, 23 Apr 2010 12:16:56 +0000 (12:16 +0000)
- add a little to the docs
- disallow an alias for "/"

git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@937264 13f79535-47bb-0310-9956-ffa450edef68

java/org/apache/naming/resources/BaseDirContext.java
java/org/apache/naming/resources/LocalStrings.properties
webapps/docs/config/context.xml

index 89e50b3..f28412b 100644 (file)
@@ -57,6 +57,8 @@ import org.apache.naming.StringManager;
 
 public abstract class BaseDirContext implements DirContext {
 
+    private static final org.apache.juli.logging.Log log=
+        org.apache.juli.logging.LogFactory.getLog( BaseDirContext.class );
 
     // -------------------------------------------------------------- Constants
 
@@ -239,6 +241,10 @@ public abstract class BaseDirContext implements DirContext {
                 throw new IllegalArgumentException(
                         sm.getString("resources.invalidAliasMapping", kvp));
 
+            if (kv[0].equals("/")) {
+                throw new IllegalArgumentException(
+                        sm.getString("resources.invalidAliasNotAllowed", kv[0]));
+            }
             File aliasLoc = new File(kv[1]);
             if (!aliasLoc.exists()) {
                 throw new IllegalArgumentException(
@@ -1524,4 +1530,3 @@ public abstract class BaseDirContext implements DirContext {
         String aliasName;
     }
 }
-
index a586441..a3c0d13 100644 (file)
@@ -30,6 +30,7 @@ resources.bindFailed=Bind failed: {0}
 resources.unbindFailed=Unbind failed: {0}
 resources.invalidAliasPath=The alias path ''{0}'' must start with ''/''
 resources.invalidAliasMapping=The alias mapping ''{0}'' is not valid
+resources.invalidAliasNotAllowed=The alias location ''{0}'' is not allowed
 resources.invalidAliasNotExist=The alias location ''{0}'' does not exist
 resources.invalidAliasFile=The alias location ''{0}'' points to a file that is not a WAR file
 standardResources.alreadyStarted=Resources has already been started
index 679d253..2254253 100644 (file)
 
       <attribute name="aliases" required="false">
         <p>This attribute provides a list of external locations from which to
-        load resources for this context. These external locations will not be
-        emptied if the context is un-deployed. The list of aliases should be of
+        load resources for this context. The list of aliases should be of
         the form <code>"/aliasPath1=docBase1,/aliasPath2=docBase2"</code> where
         <code>aliasPathN</code> must include a leading '/' and
         <code>docBaseN</code> must be an absolute path to either a .war file or
         a directory.</p>
+        <p>A resource will be searched for in the first <code>docBaseN</code>
+        for which <code>aliasPathN</code> is a leading path segment of the
+        resource. If there is no such alias, then the resource will be searched
+        in the usual way.</p>
+        <p>Using '/' as an aliasPath is not allowed. Consider using
+        <code>docBase</code> instead.</p>
+        <p>These external locations will not be emptied if the context
+        is un-deployed.</p>
       </attribute>
 
       <attribute name="allowLinking" required="false">