当前位置: 首页>>代码示例>>Java>>正文


Java FilterMap类代码示例

本文整理汇总了Java中org.apache.tomcat.util.descriptor.web.FilterMap的典型用法代码示例。如果您正苦于以下问题:Java FilterMap类的具体用法?Java FilterMap怎么用?Java FilterMap使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


FilterMap类属于org.apache.tomcat.util.descriptor.web包,在下文中一共展示了FilterMap类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: deployConfig

import org.apache.tomcat.util.descriptor.web.FilterMap; //导入依赖的package包/类
@Override
public void deployConfig(WebApplicationContext wac, Filter... filters) {
	Assert.state(this.port != -1, "setup() was never called.");
	this.context = this.tomcatServer.addContext("", System.getProperty("java.io.tmpdir"));
       this.context.addApplicationListener(WsContextListener.class.getName());
	Tomcat.addServlet(this.context, "dispatcherServlet", new DispatcherServlet(wac)).setAsyncSupported(true);
	this.context.addServletMapping("/", "dispatcherServlet");
	for (Filter filter : filters) {
		FilterDef filterDef = new FilterDef();
		filterDef.setFilterName(filter.getClass().getName());
		filterDef.setFilter(filter);
		filterDef.setAsyncSupported("true");
		this.context.addFilterDef(filterDef);
		FilterMap filterMap = new FilterMap();
		filterMap.setFilterName(filter.getClass().getName());
		filterMap.addURLPattern("/*");
		filterMap.setDispatcher("REQUEST,FORWARD,INCLUDE,ASYNC");
		this.context.addFilterMap(filterMap);
	}
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:21,代码来源:TomcatWebSocketTestServer.java

示例2: dispatchMap

import org.apache.tomcat.util.descriptor.web.FilterMap; //导入依赖的package包/类
private FilterMap dispatchMap(String name, String dispatcher)
{
	FilterMap filterMap = new FilterMap();
	filterMap.setFilterName(name);
	filterMap.setDispatcher(dispatcher);
	filterMap.addURLPattern("/*");
	return filterMap;
}
 
开发者ID:equella,项目名称:Equella,代码行数:9,代码来源:TomcatServiceImpl.java

示例3: setUpTomcat

import org.apache.tomcat.util.descriptor.web.FilterMap; //导入依赖的package包/类
public static void setUpTomcat(String dataSourceFactory) throws LifecycleException, ServletException {
    // create a tomcat instance
    tomcat = new Tomcat();
    tomcat.setBaseDir(".");
    tomcat.setPort(0);
    tomcat.enableNaming();

    // create a context with our test servlet
    Context ctx = tomcat.addContext(CONTEXT_PATH, new File(".").getAbsolutePath());
    Tomcat.addServlet(ctx, SERVLET_NAME, new TestServlet());
    ctx.addServletMappingDecoded("/*", SERVLET_NAME);

    // add our metrics filter
    FilterDef def = new FilterDef();
    def.setFilterClass(TomcatServletMetricsFilter.class.getName());
    def.setFilterName("metricsFilter");
    def.addInitParameter("buckets",".01, .05, .1, .25, .5, 1, 2.5, 5, 10, 30");
    ctx.addFilterDef(def);
    FilterMap map = new FilterMap();
    map.setFilterName("metricsFilter");
    map.addURLPattern("/*");
    ctx.addFilterMap(map);

    // create a datasource
    ContextResource resource = new ContextResource();
    resource.setName("jdbc/db");
    resource.setAuth("Container");
    resource.setType("javax.sql.DataSource");
    resource.setScope("Sharable");
    resource.setProperty("name", "foo");
    resource.setProperty("factory", dataSourceFactory);
    resource.setProperty("driverClassName", "org.h2.Driver");
    resource.setProperty("url", "jdbc:h2:mem:dummy");
    resource.setProperty("jdbcInterceptors", "nl.nlighten.prometheus.tomcat.TomcatJdbcInterceptor(logFailed=true,logSlow=true,threshold=0,buckets=.01|.05|.1|1|10,slowQueryBuckets=1|10|30)");
    ctx.getNamingResources().addResource(resource);

    // start instance
    tomcat.init();
    tomcat.start();
}
 
开发者ID:nlighten,项目名称:tomcat_exporter,代码行数:41,代码来源:AbstractTomcatMetricsTest.java

示例4: setupContext

import org.apache.tomcat.util.descriptor.web.FilterMap; //导入依赖的package包/类
protected void setupContext() throws ServletException {
    Context context = tomcat.addWebapp("/", ".");
    Tomcat.addServlet(context, "dummy", new DummyServlet());
    context.addServletMappingDecoded("/dummy", "dummy");
    FilterDef filterDef = new FilterDef();
    filterDef.setDisplayName("ipBlocker");
    filterDef.setFilter(new IpBlockerFilter());
    filterDef.setFilterName("ipBlocker");
    context.addFilterDef(filterDef);
    FilterMap filterMap = new FilterMap();
    filterMap.addURLPattern("/*");
    filterMap.setFilterName("ipBlocker");
    context.addFilterMap(filterMap);
}
 
开发者ID:makotan,项目名称:IpBlockFilter,代码行数:15,代码来源:IpBlockTest.java

示例5: getFilterMappings

import org.apache.tomcat.util.descriptor.web.FilterMap; //导入依赖的package包/类
/**
 * Gets the filter mappings.
 *
 * @param fmap the fmap
 * @param dm the dm
 * @param filterClass the filter class
 * @return the filter mappings
 */
protected List<FilterMapping> getFilterMappings(FilterMap fmap, String dm, String filterClass) {
  String[] urls = fmap.getURLPatterns();
  String[] servlets = fmap.getServletNames();
  List<FilterMapping> results = new ArrayList<>(urls.length + servlets.length);
  addFilterMapping(fmap.getFilterName(), dm, filterClass, urls, results, FilterMapType.URL);
  addFilterMapping(fmap.getFilterName(), dm, filterClass, servlets, results,
      FilterMapType.SERVLET_NAME);
  return results;
}
 
开发者ID:psi-probe,项目名称:psi-probe,代码行数:18,代码来源:Tomcat80ContainerAdapter.java

示例6: getApplicationFilterMaps

import org.apache.tomcat.util.descriptor.web.FilterMap; //导入依赖的package包/类
@Override
public List<FilterMapping> getApplicationFilterMaps(Context context) {
  FilterMap[] fms = context.findFilterMaps();
  List<FilterMapping> filterMaps = new ArrayList<>(fms.length);
  for (FilterMap filterMap : fms) {
    if (filterMap != null) {
      String dm;
      switch (filterMap.getDispatcherMapping()) {
        case FilterMap.ASYNC:
          dm = "ASYNC";
          break;
        case FilterMap.ERROR:
          dm = "ERROR";
          break;
        case FilterMap.FORWARD:
          dm = "FORWARD";
          break;
        case FilterMap.INCLUDE:
          dm = "INCLUDE";
          break;
        case FilterMap.REQUEST:
          dm = "REQUEST";
          break;
        default:
          dm = "";
      }

      String filterClass = "";
      FilterDef fd = context.findFilterDef(filterMap.getFilterName());
      if (fd != null) {
        filterClass = fd.getFilterClass();
      }

      List<FilterMapping> filterMappings = getFilterMappings(filterMap, dm, filterClass);
      filterMaps.addAll(filterMappings);
    }
  }
  return filterMaps;
}
 
开发者ID:psi-probe,项目名称:psi-probe,代码行数:40,代码来源:Tomcat80ContainerAdapter.java

示例7: filterMappings

import org.apache.tomcat.util.descriptor.web.FilterMap; //导入依赖的package包/类
/**
 * Filter mappings.
 */
@Test
public void filterMappings() {
  final Tomcat80ContainerAdapter adapter = new Tomcat80ContainerAdapter();
  FilterMap map = new FilterMap();
  map.addServletName("psi-probe");
  map.addURLPattern("/psi-probe");
  assertEquals(2, adapter.getFilterMappings(map, "dispatcherMap", "filterClass").size());
}
 
开发者ID:psi-probe,项目名称:psi-probe,代码行数:12,代码来源:Tomcat80ContainerAdapterTest.java

示例8: applicationFilterMaps

import org.apache.tomcat.util.descriptor.web.FilterMap; //导入依赖的package包/类
/**
 * Gets the application filter maps.
 */
@Test
public void applicationFilterMaps() {
  Assert.assertNotNull(new Expectations() {
    {
      context.findFilterMaps();
      result = new FilterMap();
    }
  });

  final Tomcat80ContainerAdapter adapter = new Tomcat80ContainerAdapter();
  assertEquals(0, adapter.getApplicationFilterMaps(context).size());
}
 
开发者ID:psi-probe,项目名称:psi-probe,代码行数:16,代码来源:Tomcat80ContainerAdapterTest.java

示例9: filterMappings

import org.apache.tomcat.util.descriptor.web.FilterMap; //导入依赖的package包/类
/**
 * Filter mappings.
 */
@Test
public void filterMappings() {
  final Tomcat90ContainerAdapter adapter = new Tomcat90ContainerAdapter();
  FilterMap map = new FilterMap();
  map.addServletName("psi-probe");
  map.addURLPattern("/psi-probe");
  assertEquals(2, adapter.getFilterMappings(map, "dispatcherMap", "filterClass").size());
}
 
开发者ID:psi-probe,项目名称:psi-probe,代码行数:12,代码来源:Tomcat90ContainerAdapterTest.java

示例10: applicationFilterMaps

import org.apache.tomcat.util.descriptor.web.FilterMap; //导入依赖的package包/类
/**
 * Gets the application filter maps.
 */
@Test
public void applicationFilterMaps() {
  Assert.assertNotNull(new Expectations() {
    {
      context.findFilterMaps();
      result = new FilterMap();
    }
  });

  final Tomcat90ContainerAdapter adapter = new Tomcat90ContainerAdapter();
  assertEquals(0, adapter.getApplicationFilterMaps(context).size());
}
 
开发者ID:psi-probe,项目名称:psi-probe,代码行数:16,代码来源:Tomcat90ContainerAdapterTest.java

示例11: filterMappings

import org.apache.tomcat.util.descriptor.web.FilterMap; //导入依赖的package包/类
/**
 * Filter mappings.
 */
@Test
public void filterMappings() {
  final Tomcat85ContainerAdapter adapter = new Tomcat85ContainerAdapter();
  FilterMap map = new FilterMap();
  map.addServletName("psi-probe");
  map.addURLPattern("/psi-probe");
  assertEquals(2, adapter.getFilterMappings(map, "dispatcherMap", "filterClass").size());
}
 
开发者ID:psi-probe,项目名称:psi-probe,代码行数:12,代码来源:Tomcat85ContainerAdapterTest.java

示例12: applicationFilterMaps

import org.apache.tomcat.util.descriptor.web.FilterMap; //导入依赖的package包/类
/**
 * Gets the application filter maps.
 */
@Test
public void applicationFilterMaps() {
  Assert.assertNotNull(new Expectations() {
    {
      context.findFilterMaps();
      result = new FilterMap();
    }
  });

  final Tomcat85ContainerAdapter adapter = new Tomcat85ContainerAdapter();
  assertEquals(0, adapter.getApplicationFilterMaps(context).size());
}
 
开发者ID:psi-probe,项目名称:psi-probe,代码行数:16,代码来源:Tomcat85ContainerAdapterTest.java

示例13: createGuiceFilter

import org.apache.tomcat.util.descriptor.web.FilterMap; //导入依赖的package包/类
private void createGuiceFilter(Context context) {
	FilterDef filterDefinition = new FilterDef();
	filterDefinition.setFilterName(GuiceFilter.class.getSimpleName());
	filterDefinition.setFilterClass(GuiceFilter.class.getName());
	context.addFilterDef(filterDefinition);

	FilterMap filterMapping = new FilterMap();
	filterMapping.setFilterName(GuiceFilter.class.getSimpleName());
	filterMapping.addURLPattern("/*");
	context.addFilterMap(filterMapping);
}
 
开发者ID:jerolba,项目名称:funsteroid,代码行数:12,代码来源:TomcatServer.java

示例14: getApplicationFilterMaps

import org.apache.tomcat.util.descriptor.web.FilterMap; //导入依赖的package包/类
public List getApplicationFilterMaps(Context context) {
	FilterMap[] fms = context.findFilterMaps();
	List filterMaps = new ArrayList(fms.length);
	for (int i = 0; i < fms.length; i++) {
		if (fms[i] != null) {
			String dm;
			switch(fms[i].getDispatcherMapping()) {
			case FilterMap.ERROR: dm = "ERROR"; break;
			case FilterMap.FORWARD: dm = "FORWARD"; break;
			// case FilterMap.FORWARD_ERROR: dm = "FORWARD,ERROR"; break;
			case FilterMap.INCLUDE: dm = "INCLUDE"; break;
			// case FilterMap.INCLUDE_ERROR: dm = "INCLUDE,ERROR"; break;
			// case FilterMap.INCLUDE_ERROR_FORWARD: dm = "INCLUDE,ERROR,FORWARD"; break;
			//case FilterMap.INCLUDE_FORWARD: dm = "INCLUDE,FORWARD"; break;
			case FilterMap.REQUEST: dm = "REQUEST"; break;
			// case FilterMap.REQUEST_ERROR: dm = "REQUEST,ERROR"; break;
			//case FilterMap.REQUEST_ERROR_FORWARD: dm = "REQUEST,ERROR,FORWARD"; break;
			//case FilterMap.REQUEST_ERROR_FORWARD_INCLUDE: dm = "REQUEST,ERROR,FORWARD,INCLUDE"; break;
			//case FilterMap.REQUEST_ERROR_INCLUDE: dm = "REQUEST,ERROR,INCLUDE"; break;
			//case FilterMap.REQUEST_FORWARD: dm = "REQUEST,FORWARD"; break;
			//case FilterMap.REQUEST_INCLUDE: dm = "REQUEST,INCLUDE"; break;
			//case FilterMap.REQUEST_FORWARD_INCLUDE: dm = "REQUEST,FORWARD,INCLUDE"; break;
			default: dm = "";
			}

			String filterClass = "";
			org.apache.tomcat.util.descriptor.web.FilterDef fd = context.findFilterDef(fms[i].getFilterName());
			if (fd != null) {
				filterClass = fd.getFilterClass();
			}

			List filterMappings = getFilterMappings(fms[i], dm, filterClass);
			filterMaps.addAll(filterMappings);
		}
	}
	return filterMaps;
}
 
开发者ID:andresol,项目名称:psi-probe-plus,代码行数:38,代码来源:Tomcat80ContainerAdaptor.java

示例15: addFilterMapping

import org.apache.tomcat.util.descriptor.web.FilterMap; //导入依赖的package包/类
@Override
public void addFilterMapping(final FilterMap filterMap) {
    // we need to add this one before the mapping cause of tomcat validation (ie dont make deployment fail)
    if ("CDI Conversation Filter".equals(filterMap.getFilterName()) && !cdiConversation) {
        final FilterDef conversationFilter = new FilterDef();
        conversationFilter.setAsyncSupported("true");
        conversationFilter.setDescription("CDI Conversation Filter");
        conversationFilter.setDisplayName("CDI Conversation Filter");
        conversationFilter.setFilterName("CDI Conversation Filter");
        conversationFilter.setFilterClass(WebConversationFilter.class.getName());
        addFilter(conversationFilter);
        cdiConversation = true;
    }
    super.addFilterMapping(filterMap);
}
 
开发者ID:apache,项目名称:tomee,代码行数:16,代码来源:OpenEJBContextConfig.java


注:本文中的org.apache.tomcat.util.descriptor.web.FilterMap类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。