本文整理汇总了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();
}
示例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();
}