本文整理汇总了Java中org.eclipse.jetty.servlet.ServletContextHandler.insertHandler方法的典型用法代码示例。如果您正苦于以下问题:Java ServletContextHandler.insertHandler方法的具体用法?Java ServletContextHandler.insertHandler怎么用?Java ServletContextHandler.insertHandler使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.jetty.servlet.ServletContextHandler
的用法示例。
在下文中一共展示了ServletContextHandler.insertHandler方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: start
import org.eclipse.jetty.servlet.ServletContextHandler; //导入方法依赖的package包/类
public synchronized void start() {
if (started) {
return;
}
try {
QueuedThreadPool pool = new QueuedThreadPool(AppInfo.getInt("http.pool.maxThreads", 200),
AppInfo.getInt("http.pool.minThreads", 8), AppInfo.getInt("http.pool.idleTimeout", 60000),
new LinkedBlockingQueue<Runnable>(AppInfo.getInt("http.pool.queues", 1000)));
server = new Server(pool);
ServerConnector connector = new ServerConnector(server, null, null, null,
AppInfo.getInt("http.connector.acceptors", 0), AppInfo.getInt("http.connector.selectors", 5),
new HttpConnectionFactory());
Log.get("HttpServer").info("listen port:" + port);
String host = AppInfo.get("http.host");
if (host != null && host.length() > 0) {
connector.setHost(host);
}
connector.setPort(port);
connector.setReuseAddress(true);
server.setConnectors(new Connector[] { connector });
ServletContextHandler context = createServletContextHandler();
context.setContextPath(AppInfo.get("http.jetty.web.root", "/intf"));
context.addEventListener(new SumkLoaderListener());
addUserListener(context, Arrays.asList(ServletContextListener.class, ContextScopeListener.class));
String resourcePath = AppInfo.get("http.jetty.resource");
if (StringUtil.isNotEmpty(resourcePath)) {
ResourceHandler resourceHandler = createResourceHandler();
resourceHandler.setResourceBase(resourcePath);
context.insertHandler(resourceHandler);
}
if (AppInfo.getBoolean("http.jetty.session.enable", false)) {
SessionHandler h = createSessionHandler();
context.insertHandler(h);
}
server.setHandler(context);
server.start();
started = true;
} catch (Exception e) {
Log.printStack(e);
System.exit(-1);
}
}