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


Java FilterHolder.setHeldClass方法代码示例

本文整理汇总了Java中org.eclipse.jetty.servlet.FilterHolder.setHeldClass方法的典型用法代码示例。如果您正苦于以下问题:Java FilterHolder.setHeldClass方法的具体用法?Java FilterHolder.setHeldClass怎么用?Java FilterHolder.setHeldClass使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.eclipse.jetty.servlet.FilterHolder的用法示例。


在下文中一共展示了FilterHolder.setHeldClass方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: main

import org.eclipse.jetty.servlet.FilterHolder; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
	
	org.eclipse.jetty.server.Server server = new org.eclipse.jetty.server.Server(8080);
	
	final ErrorHandler errorHandler = new ErrorHandler();
       errorHandler.setServer(server);
       errorHandler.setShowStacks(false);
       server.addBean(errorHandler);
              
       server.setStopAtShutdown(true);
       server.setStopTimeout(30*1000l);
	        
       ServletContextHandler handler = new ServletContextHandler(ServletContextHandler.SESSIONS);

       handler.setClassLoader(Thread.currentThread().getContextClassLoader());
       handler.setContextPath("/");
       handler.setInitParameter("tapestry.app-package", "com.ckfce.tapfatjar");
       
       FilterHolder filterHolder = new FilterHolder();
       filterHolder.setHeldClass(TapestryFilter.class);
       filterHolder.setName("app");
       
       handler.addFilter(filterHolder, "/*", EnumSet.of(DispatcherType.REQUEST));
       								
	server.setHandler(handler);
					 
       server.start();        
       server.join();
}
 
开发者ID:cakeface,项目名称:tapestry-fat-jar,代码行数:30,代码来源:Server.java

示例2: run

import org.eclipse.jetty.servlet.FilterHolder; //导入方法依赖的package包/类
@Override
public void run(MonetaDropwizardConfiguration configuration,
		Environment environment) throws Exception {

	/*
	 * The ServletHolder allows you to specify init parameters and other
	 * servlet configuration itmes in the web.xml. Setting the order means
	 * that the servlet is initialized on startup; by default it is not.
	 */
	ServletHolder topicHolder = new ServletHolder(Source.EMBEDDED);
	topicHolder.setHeldClass(MonetaServlet.class);
	topicHolder.setInitOrder(0);
	topicHolder.setInitParameter(
			MonetaServlet.CONFIG_IGNORED_CONTEXT_PATH_NODES, "moneta,topic");
	environment.getApplicationContext()
	.getServletHandler()
	.addServletWithMapping(topicHolder, "/moneta/topic/*");

	// Will be initialized on first use by default.
	environment.getApplicationContext()
	.addServlet(MonetaTopicListServlet.class, "/moneta/topics/*");

	/*
	 * Install thread contention monitoring -- withdrawn after issue with
	 * Jetty discovered.
	 */
	// ServletHolder threadContentionHolder = new
	// ServletHolder(Source.EMBEDDED);
	// threadContentionHolder.setHeldClass(ThreadMonitorStartupServlet.class);
	// threadContentionHolder.setInitOrder(0);
	// environment.getApplicationContext()
	// .getServletHandler()
	// .addServlet(threadContentionHolder);

	/*
	 * Install memory alert monitoring
	 */
	ServletHolder memoryAlertHolder = new ServletHolder(Source.EMBEDDED);
	memoryAlertHolder.setHeldClass(MemoryMonitorStartupServlet.class);
	memoryAlertHolder.setInitOrder(0);
	environment.getApplicationContext()
	.getServletHandler()
	.addServlet(memoryAlertHolder);

	/*
	 * Install the performance filter
	 */
	FilterHolder perfFilterHolder = new FilterHolder(Holder.Source.EMBEDDED);
	perfFilterHolder.setHeldClass(MonetaPerformanceFilter.class);
	perfFilterHolder.setInitParameter(
			MonetaPerformanceFilter.PARM_MAX_TRNASACTION_TIME_THRESHOLD_IN_MILLIS,
			"3000");
	environment.getApplicationContext()
	.addFilter(perfFilterHolder, "/moneta/*", null);

	/*
	 * Install RequestCorrelation filter so I can get a correlation id in
	 * the logs
	 */
	FilterHolder correlationFilterHolder = new FilterHolder(
			Holder.Source.EMBEDDED);
	correlationFilterHolder.setHeldClass(RequestCorrelationFilter.class);

	// Install healthchecks
	MonetaConfiguration config = new MonetaConfiguration();
	for (String checkName : config.getHealthChecks()
			.keySet()) {
		environment.healthChecks()
		.register(checkName, config.getHealthChecks()
				.get(checkName));
	}

	final JmxReporter jmxReporter = JmxReporter.forRegistry(
			environment.metrics())
			.build();
	jmxReporter.start();
}
 
开发者ID:Derek-Ashmore,项目名称:moneta,代码行数:78,代码来源:MonetaDropwizardApplication.java


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