本文整理匯總了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);
}
}