本文整理汇总了Java中org.apache.catalina.deploy.FilterMap类的典型用法代码示例。如果您正苦于以下问题:Java FilterMap类的具体用法?Java FilterMap怎么用?Java FilterMap使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
FilterMap类属于org.apache.catalina.deploy包,在下文中一共展示了FilterMap类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: remove
import org.apache.catalina.deploy.FilterMap; //导入依赖的package包/类
/**
* Remove a filter mapping.
*
* @param filterMap
* The filter mapping to be removed
*/
public void remove(FilterMap filterMap) {
synchronized (lock) {
// Make sure this filter mapping is currently present
int n = -1;
for (int i = 0; i < array.length; i++) {
if (array[i] == filterMap) {
n = i;
break;
}
}
if (n < 0)
return;
// Remove the specified filter mapping
FilterMap results[] = new FilterMap[array.length - 1];
System.arraycopy(array, 0, results, 0, n);
System.arraycopy(array, n + 1, results, n, (array.length - 1) - n);
array = results;
if (n < insertPoint) {
insertPoint--;
}
}
}
示例2: remove
import org.apache.catalina.deploy.FilterMap; //导入依赖的package包/类
/**
* Remove a filter mapping.
*
* @param filterMap The filter mapping to be removed
*/
public void remove(FilterMap filterMap) {
synchronized (lock) {
// Make sure this filter mapping is currently present
int n = -1;
for (int i = 0; i < array.length; i++) {
if (array[i] == filterMap) {
n = i;
break;
}
}
if (n < 0)
return;
// Remove the specified filter mapping
FilterMap results[] = new FilterMap[array.length - 1];
System.arraycopy(array, 0, results, 0, n);
System.arraycopy(array, n + 1, results, n, (array.length - 1)
- n);
array = results;
if (n < insertPoint) {
insertPoint--;
}
}
}
示例3: matchFiltersURL
import org.apache.catalina.deploy.FilterMap; //导入依赖的package包/类
/**
* Return <code>true</code> if the context-relative request path
* matches the requirements of the specified filter mapping;
* otherwise, return <code>false</code>.
*
* @param filterMap Filter mapping being checked
* @param requestPath Context-relative request path of this request
*/
private boolean matchFiltersURL(FilterMap filterMap, String requestPath) {
// Check the specific "*" special URL pattern, which also matches
// named dispatches
if (filterMap.getMatchAllUrlPatterns())
return (true);
if (requestPath == null)
return (false);
// Match on context relative request path
String[] testPaths = filterMap.getURLPatterns();
for (int i = 0; i < testPaths.length; i++) {
if (matchFiltersURL(testPaths[i], requestPath)) {
return (true);
}
}
// No match
return (false);
}
示例4: testRemoteIpFilter
import org.apache.catalina.deploy.FilterMap; //导入依赖的package包/类
private MockFilterChain testRemoteIpFilter(FilterDef filterDef, Request request)
throws LifecycleException, IOException, ServletException {
Tomcat tomcat = getTomcatInstance();
Context root = tomcat.addContext("", TEMP_DIR);
RemoteIpFilter remoteIpFilter = new RemoteIpFilter();
filterDef.setFilterClass(RemoteIpFilter.class.getName());
filterDef.setFilter(remoteIpFilter);
filterDef.setFilterName(RemoteIpFilter.class.getName());
root.addFilterDef(filterDef);
FilterMap filterMap = new FilterMap();
filterMap.setFilterName(RemoteIpFilter.class.getName());
filterMap.addURLPattern("*");
root.addFilterMap(filterMap);
getTomcatInstance().start();
MockFilterChain filterChain = new MockFilterChain();
// TEST
TesterResponse response = new TesterResponse();
response.setRequest(request);
remoteIpFilter.doFilter(request, response, filterChain);
return filterChain;
}
示例5: configureTest46243Context
import org.apache.catalina.deploy.FilterMap; //导入依赖的package包/类
private static void configureTest46243Context(Context context, boolean fail) {
// Add a test filter that fails
FilterDef filterDef = new FilterDef();
filterDef.setFilterClass(Bug46243Filter.class.getName());
filterDef.setFilterName("Bug46243");
filterDef.addInitParameter("fail", Boolean.toString(fail));
context.addFilterDef(filterDef);
FilterMap filterMap = new FilterMap();
filterMap.setFilterName("Bug46243");
filterMap.addURLPattern("*");
context.addFilterMap(filterMap);
// Add a test servlet so there is something to generate a response if
// it works (although it shouldn't)
Tomcat.addServlet(context, "Bug46243", new HelloWorldServlet());
context.addServletMapping("/", "Bug46243");
}
示例6: matchFiltersServlet
import org.apache.catalina.deploy.FilterMap; //导入依赖的package包/类
/**
* Return <code>true</code> if the specified servlet name matches the
* requirements of the specified filter mapping; otherwise return
* <code>false</code>.
*
* @param filterMap
* Filter mapping being checked
* @param servletName
* Servlet name being checked
*/
private boolean matchFiltersServlet(FilterMap filterMap, String servletName) {
if (servletName == null) {
return (false);
}
// Check the specific "*" special servlet name
else if (filterMap.getMatchAllServletNames()) {
return (true);
} else {
String[] servletNames = filterMap.getServletNames();
for (int i = 0; i < servletNames.length; i++) {
if (servletName.equals(servletNames[i])) {
return (true);
}
}
return false;
}
}
示例7: matchFiltersServlet
import org.apache.catalina.deploy.FilterMap; //导入依赖的package包/类
/**
* Return <code>true</code> if the specified servlet name matches
* the requirements of the specified filter mapping; otherwise
* return <code>false</code>.
*
* @param filterMap Filter mapping being checked
* @param servletName Servlet name being checked
*/
private boolean matchFiltersServlet(FilterMap filterMap,
String servletName) {
if (servletName == null) {
return (false);
}
// Check the specific "*" special servlet name
else if (filterMap.getMatchAllServletNames()) {
return (true);
} else {
String[] servletNames = filterMap.getServletNames();
for (int i = 0; i < servletNames.length; i++) {
if (servletName.equals(servletNames[i])) {
return (true);
}
}
return false;
}
}
开发者ID:sunmingshuai,项目名称:apache-tomcat-7.0.73-with-comment,代码行数:29,代码来源:ApplicationFilterFactory.java
示例8: startTomcat
import org.apache.catalina.deploy.FilterMap; //导入依赖的package包/类
protected void startTomcat() throws Exception {
tomcat = new Tomcat();
File base = new File(System.getProperty("java.io.tmpdir"));
org.apache.catalina.Context ctx =
tomcat.addContext("/foo",base.getAbsolutePath());
FilterDef fd = new FilterDef();
fd.setFilterClass(TestFilter.class.getName());
fd.setFilterName("TestFilter");
FilterMap fm = new FilterMap();
fm.setFilterName("TestFilter");
fm.addURLPattern("/*");
fm.addServletName("/bar");
ctx.addFilterDef(fd);
ctx.addFilterMap(fm);
tomcat.addServlet(ctx, "/bar", TestServlet.class.getName());
ctx.addServletMapping("/bar", "/bar");
host = "localhost";
port = getLocalPort();
tomcat.setHostname(host);
tomcat.setPort(port);
tomcat.start();
}
示例9: validateFilterMap
import org.apache.catalina.deploy.FilterMap; //导入依赖的package包/类
/**
* Validate the supplied FilterMap.
*/
private void validateFilterMap(FilterMap filterMap) {
// Validate the proposed filter mapping
String filterName = filterMap.getFilterName();
String[] servletNames = filterMap.getServletNames();
String[] urlPatterns = filterMap.getURLPatterns();
if (findFilterDef(filterName) == null)
throw new IllegalArgumentException(sm.getString("standardContext.filterMap.name", filterName));
if (!filterMap.getMatchAllServletNames() && !filterMap.getMatchAllUrlPatterns() && (servletNames.length == 0)
&& (urlPatterns.length == 0))
throw new IllegalArgumentException(sm.getString("standardContext.filterMap.either"));
// FIXME: Older spec revisions may still check this
/*
* if ((servletNames.length != 0) && (urlPatterns.length != 0)) throw
* new IllegalArgumentException
* (sm.getString("standardContext.filterMap.either"));
*/
for (int i = 0; i < urlPatterns.length; i++) {
if (!validateURLPattern(urlPatterns[i])) {
throw new IllegalArgumentException(sm.getString("standardContext.filterMap.pattern", urlPatterns[i]));
}
}
}
示例10: validateFilterMap
import org.apache.catalina.deploy.FilterMap; //导入依赖的package包/类
/**
* Validate the supplied FilterMap.
*/
private void validateFilterMap(FilterMap filterMap) {
// Validate the proposed filter mapping
String filterName = filterMap.getFilterName();
String[] servletNames = filterMap.getServletNames();
String[] urlPatterns = filterMap.getURLPatterns();
if (findFilterDef(filterName) == null)
throw new IllegalArgumentException
(sm.getString("standardContext.filterMap.name", filterName));
if (!filterMap.getMatchAllServletNames() &&
!filterMap.getMatchAllUrlPatterns() &&
(servletNames.length == 0) && (urlPatterns.length == 0))
throw new IllegalArgumentException
(sm.getString("standardContext.filterMap.either"));
// FIXME: Older spec revisions may still check this
/*
if ((servletNames.length != 0) && (urlPatterns.length != 0))
throw new IllegalArgumentException
(sm.getString("standardContext.filterMap.either"));
*/
for (int i = 0; i < urlPatterns.length; i++) {
if (!validateURLPattern(urlPatterns[i])) {
throw new IllegalArgumentException
(sm.getString("standardContext.filterMap.pattern",
urlPatterns[i]));
}
}
}
示例11: removeFilterMap
import org.apache.catalina.deploy.FilterMap; //导入依赖的package包/类
/**
* Remove a filter mapping from this Context.
*
* @param filterMap The filter mapping to be removed
*/
@Override
public void removeFilterMap(FilterMap filterMap) {
filterMaps.remove(filterMap);
// Inform interested listeners
fireContainerEvent("removeFilterMap", filterMap);
}
示例12: add
import org.apache.catalina.deploy.FilterMap; //导入依赖的package包/类
/**
* Add a filter mapping at the end of the current set of filter
* mappings.
*
* @param filterMap
* The filter mapping to be added
*/
public void add(FilterMap filterMap) {
synchronized (lock) {
FilterMap results[] = Arrays.copyOf(array, array.length + 1);
results[array.length] = filterMap;
array = results;
}
}
示例13: addBefore
import org.apache.catalina.deploy.FilterMap; //导入依赖的package包/类
/**
* Add a filter mapping before the mappings defined in the deployment
* descriptor but after any other mappings added via this method.
*
* @param filterMap
* The filter mapping to be added
*/
public void addBefore(FilterMap filterMap) {
synchronized (lock) {
FilterMap results[] = new FilterMap[array.length + 1];
System.arraycopy(array, 0, results, 0, insertPoint);
System.arraycopy(array, insertPoint, results, insertPoint + 1,
array.length - insertPoint);
results[insertPoint] = filterMap;
array = results;
insertPoint++;
}
}
示例14: add
import org.apache.catalina.deploy.FilterMap; //导入依赖的package包/类
/**
* Add a filter mapping at the end of the current set of filter
* mappings.
*
* @param filterMap
* The filter mapping to be added
*/
public void add(FilterMap filterMap) {
synchronized (lock) {
FilterMap results[] = Arrays.copyOf(array, array.length + 1);
results[array.length] = filterMap;
array = results;
}
}
示例15: matchDispatcher
import org.apache.catalina.deploy.FilterMap; //导入依赖的package包/类
/**
* Convenience method which returns true if the dispatcher type
* matches the dispatcher types specified in the FilterMap
*/
private boolean matchDispatcher(FilterMap filterMap, DispatcherType type) {
switch (type) {
case FORWARD : {
if ((filterMap.getDispatcherMapping() & FilterMap.FORWARD) > 0) {
return true;
}
break;
}
case INCLUDE : {
if ((filterMap.getDispatcherMapping() & FilterMap.INCLUDE) > 0) {
return true;
}
break;
}
case REQUEST : {
if ((filterMap.getDispatcherMapping() & FilterMap.REQUEST) > 0) {
return true;
}
break;
}
case ERROR : {
if ((filterMap.getDispatcherMapping() & FilterMap.ERROR) > 0) {
return true;
}
break;
}
case ASYNC : {
if ((filterMap.getDispatcherMapping() & FilterMap.ASYNC) > 0) {
return true;
}
break;
}
}
return false;
}