Methods Summary |
---|
public static org.apache.catalina.core.AlternateDocBase | findMatch(java.lang.String path, java.util.ArrayList alternateDocBases)Attempts to match the given request path against one of the given
alternate doc bases.
if (alternateDocBases == null) {
return null;
}
AlternateDocBase match = null;
AlternateDocBase wildcardMatch = null;
AlternateDocBase extensionMatch = null;
int maxSlashCountMatch = 0;
int pathSlashCount = getSlashCount(path);
for (int i=0; i<alternateDocBases.size(); i++) {
AlternateDocBase alternateDocBase = alternateDocBases.get(i);
String pattern = alternateDocBase.getUrlPattern();
int patternSlashCount = alternateDocBase.getUrlPatternSlashCount();
AlternateDocBase.UrlPatternType type =
alternateDocBase.getUrlPatternType();
String wildcardPath = alternateDocBase.getUrlPatternWildcardPath();
if (type == UrlPatternType.EXACT && path.equals(pattern)) {
// Exact match found
match = alternateDocBase;
break;
} else if (type == UrlPatternType.WILDCARD
&& pathSlashCount >= patternSlashCount
&& patternSlashCount > maxSlashCountMatch
&& path.startsWith(wildcardPath)) {
// We've found a longer wildcard match
wildcardMatch = alternateDocBase;
maxSlashCountMatch = patternSlashCount;
} else if (type == UrlPatternType.EXTENSION
&& path.endsWith(alternateDocBase.getUrlPatternSuffix())) {
extensionMatch = alternateDocBase;
}
}
if (match == null) {
if (wildcardMatch != null) {
match = wildcardMatch;
} else {
match = extensionMatch;
}
}
return match;
|
public java.lang.String | getBasePath()Gets the absolute doc base path of this AlternateDocBase.
return basePath;
|
public java.lang.String | getDocBase()Gets the (possibly relative) doc base path of this AlternateDocBase.
return docBase;
|
public org.apache.naming.resources.ProxyDirContext | getResources()Gets the proxied resources of this AlternateDocBase.
return resources;
|
private static int | getSlashCount(java.lang.String s)Determines the number for forward slashes in the given string.
int count = 0;
if (s != null) {
int index = s.indexOf('/");
while (index >= 0) {
count++;
index = s.indexOf('/", index+1);
}
}
return count;
|
public java.lang.String | getUrlPattern()Gets the url pattern of this AlternateDocBase.
return pattern;
|
public int | getUrlPatternSlashCount()Gets the number of slashes in the url pattern of this AlternateDocBase.
return patternSlashCount;
|
public java.lang.String | getUrlPatternSuffix()Gets the extension suffix of the url pattern of this AlternateDocBase.
return this.patternSuffix;
|
public org.apache.catalina.core.AlternateDocBase$UrlPatternType | getUrlPatternType()Gets the url pattern type (exact, wildcard, extension) of this
AlternateDocBase.
return patternType;
|
public java.lang.String | getUrlPatternWildcardPath()Gets the wildcard path of this AlternateDocBase (this is the path
specified by the wildcard pattern, minus the trailing '*').
return this.wildcardPath;
|
public javax.naming.directory.DirContext | getWebappResources()Gets the non-proxied resources of this AlternateDocBase.
return webappResources;
|
public void | setBasePath(java.lang.String basePath)Sets the absolute doc base path of this AlternateDocBase.
this.basePath = basePath;
|
public void | setDocBase(java.lang.String docBase)Sets the (possibly relative) doc base path of this AlternateDocBase.
this.docBase = docBase;
|
public void | setResources(org.apache.naming.resources.ProxyDirContext resources)Sets the proxied resources of this AlternateDocBase.
this.resources = resources;
|
public void | setUrlPattern(java.lang.String urlPattern)Sets the url pattern of this AlternateDocBase.
this.pattern = urlPattern;
this.patternSlashCount = getSlashCount(urlPattern);
if (urlPattern.endsWith("/*")) {
this.patternType = UrlPatternType.WILDCARD;
this.wildcardPath = urlPattern.substring(
0, urlPattern.length()-1);
} else if (urlPattern.startsWith("*.")) {
this.patternType = UrlPatternType.EXTENSION;
this.patternSuffix = urlPattern.substring(1);
} else {
this.patternType = UrlPatternType.EXACT;
}
|
public void | setWebappResources(javax.naming.directory.DirContext webappResources)Sets the non-proxied resources of this AlternateDocBase.
this.webappResources = webappResources;
|