本文整理汇总了Java中org.mortbay.jetty.handler.ContextHandler.setHandler方法的典型用法代码示例。如果您正苦于以下问题:Java ContextHandler.setHandler方法的具体用法?Java ContextHandler.setHandler怎么用?Java ContextHandler.setHandler使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.mortbay.jetty.handler.ContextHandler
的用法示例。
在下文中一共展示了ContextHandler.setHandler方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: init
import org.mortbay.jetty.handler.ContextHandler; //导入方法依赖的package包/类
public void init() {
server = new Server(PORT);
activeHandlers = new HandlerList();
server.setHandler(activeHandlers);
ContextHandler contextHandler = new ContextHandler();
contextHandler.setContextPath("/rpc");
contextHandler.setHandler(servletHandler);
contextHandler.setServer(server);
addHandler(contextHandler, "/rpc");
try {
server.start();
} catch (Exception e) {
throw new RuntimeException("Can't start jetty server", e);
}
}
示例2: newExitHandler
import org.mortbay.jetty.handler.ContextHandler; //导入方法依赖的package包/类
protected ContextHandler newExitHandler() {
ContextHandler ctx = new ContextHandler();
ctx.setContextPath("/exit");
ctx.setHandler(new AbstractHandler() {
public void handle(String target, HttpServletRequest request, HttpServletResponse response, int dispatch)
throws IOException, ServletException {
System.exit(1);
}
});
return ctx;
}
示例3: newCounterHandler
import org.mortbay.jetty.handler.ContextHandler; //导入方法依赖的package包/类
protected ContextHandler newCounterHandler() {
WadiSessionManager wadiManager = new WadiSessionManager(wadiCluster, 2, 24, 10);
wadiManager.setMaxInactiveInterval(120);
WadiSessionHandler wadiHandler = new WadiSessionHandler(wadiManager);
wadiHandler.setHandler(new CounterHandler());
ContextHandler ctx = new ContextHandler();
ctx.setContextPath("/counter");
ctx.setHandler(wadiHandler);
return ctx;
}
示例4: createJettyServer
import org.mortbay.jetty.handler.ContextHandler; //导入方法依赖的package包/类
protected Server createJettyServer(Site site){
Server server = new Server();
//FIXME
server.setStopAtShutdown(true);
Connector defaultConnector = createConnector(null, port);
server.setConnectors( new Connector[] { defaultConnector } );
String root = site.getRoot();
String resourceBase = site.getDestination().getPath();
getLog().info("Server resource base: " + resourceBase);
if("".equals(root)){
ResourceHandler resourceHandler = new ResourceHandler();
//resourceHandler.setDirectoriesListed(true);
resourceHandler.setWelcomeFiles(new String[]{"index.html"});
resourceHandler.setResourceBase(resourceBase/*site.getDestination().getPath()*/);
HandlerList handlers = new HandlerList();
handlers.setHandlers(new Handler[] { resourceHandler, new DefaultHandler()});
server.setHandler(handlers);
//server.setHandlers(new Handler[]{handlers, logHandler});
//getLog().info( "Startisng preview server on http://localhost:" + port + "/" );
} else {
getLog().info("Using " + ContextHandler.class.getName());
ContextHandler contextHandler = new ContextHandler();
contextHandler.setContextPath(root);
contextHandler.setHandler(new ResourceHandler());
contextHandler.setResourceBase(resourceBase/*site.getDestination().getPath()*/);
//server.setHandler(contextHandler);
server.setHandlers(new Handler[]{contextHandler, new DefaultHandler()});
//server.setHandlers(new Handler[]{contextHandler, logHandler});
//log.info( "Starting preview server on http://localhost:" + port + root );
}
return server;
}