Parallel deployment
authormarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Fri, 5 Nov 2010 21:08:09 +0000 (21:08 +0000)
committermarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Fri, 5 Nov 2010 21:08:09 +0000 (21:08 +0000)
Additional Context.get[Name|Path]() clean up

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

java/org/apache/naming/resources/DirContextURLConnection.java
java/org/apache/naming/resources/ProxyDirContext.java

index e676221..76278f8 100644 (file)
@@ -140,17 +140,17 @@ public class DirContextURLConnection
                     ProxyDirContext proxyDirContext = 
                         (ProxyDirContext) context;
                     String hostName = proxyDirContext.getHostName();
-                    String contextName = proxyDirContext.getContextName();
+                    String contextPath = proxyDirContext.getContextPath();
                     if (hostName != null) {
                         if (!path.startsWith("/" + hostName + "/"))
                             return;
                         path = path.substring(hostName.length()+ 1);
                     }
-                    if (contextName != null) {
-                        if (!path.startsWith(contextName + "/")) {
+                    if (contextPath != null) {
+                        if (!path.startsWith(contextPath + "/")) {
                             return;
                         }
-                        path = path.substring(contextName.length());
+                        path = path.substring(contextPath.length());
                     }
                 }
                 object = context.lookup(path);
@@ -432,7 +432,7 @@ public class DirContextURLConnection
                 // Strip off the hostname and the contextpath
                 int start;
                 if(context instanceof ProxyDirContext &&
-                        "".equals(((ProxyDirContext)context).getContextName())){
+                        "".equals(((ProxyDirContext)context).getContextPath())){
                     start = file.indexOf('/',1);
                 }
                 else
index b8a3fdf..b86dabf 100644 (file)
@@ -97,6 +97,12 @@ public class ProxyDirContext implements DirContext {
         }
         hostName = env.get(HOST);
         contextName = env.get(CONTEXT);
+        int i = contextName.indexOf('#');
+        if (i == -1) {
+            contextPath = contextName;
+        } else {
+            contextPath = contextName.substring(0, i);
+        }
     }
 
 
@@ -147,6 +153,12 @@ public class ProxyDirContext implements DirContext {
 
 
     /**
+     * Context path.
+     */
+    protected String contextPath;
+
+
+    /**
      * Cache class.
      */
     protected String cacheClassName = 
@@ -223,6 +235,14 @@ public class ProxyDirContext implements DirContext {
     }
 
 
+    /**
+     * Return the context path.
+     */
+    public String getContextPath() {
+        return this.contextPath;
+    }
+
+
     // -------------------------------------------------------- Context Methods