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


Java ContextHandler.setContextPath方法代码示例

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


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

示例1: setUp

import org.mortbay.jetty.handler.ContextHandler; //导入方法依赖的package包/类
@Before
public void setUp() throws Exception {

  ContextHandler context = new ContextHandler();
  context.setContextPath("/");
  context.setResourceBase(RES_DIR);
  ServletHandler sh = new ServletHandler();
  sh.addServletWithMapping("org.apache.jasper.servlet.JspServlet", "*.jsp");
  context.addHandler(sh);
  context.addHandler(new SessionHandler());

  server = new Server();
  server.addHandler(context);

  conf = new Configuration();
  conf.addResource("nutch-default.xml");
  conf.addResource("nutch-site-test.xml");

  http = new Http();
  http.setConf(conf);
}
 
开发者ID:jorcox,项目名称:GeoCrawler,代码行数:22,代码来源:TestProtocolHttpClient.java

示例2: setUp

import org.mortbay.jetty.handler.ContextHandler; //导入方法依赖的package包/类
protected void setUp() throws Exception {

    ContextHandler context = new ContextHandler();
    context.setContextPath("/");
    context.setResourceBase(RES_DIR);
    ServletHandler sh = new ServletHandler();
    sh.addServlet("org.apache.jasper.servlet.JspServlet", "*.jsp");
    context.addHandler(sh);
    context.addHandler(new SessionHandler());

    server = new Server();
    server.addHandler(context);

    conf = new Configuration();
    conf.addResource("nutch-default.xml");
    conf.addResource("nutch-site-test.xml");
    
    http = new Http();
    http.setConf(conf);
  }
 
开发者ID:yahoo,项目名称:anthelion,代码行数:21,代码来源:TestProtocolHttpClient.java

示例3: 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);
  }
}
 
开发者ID:code-orchestra,项目名称:colt-core,代码行数:19,代码来源:CodeOrchestraRPCHttpServer.java

示例4: main

import org.mortbay.jetty.handler.ContextHandler; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
    Server server = new Server();

    SelectChannelConnector connector = new SelectChannelConnector();
    connector.setPort(PORT);
    server.addConnector(connector);
    server.setStopAtShutdown(true);

    // the orders of handlers is very important!
    ContextHandler contextHandler = new ContextHandler();
    contextHandler.setContextPath("/reports");
    contextHandler.setResourceBase("./reports/");
    contextHandler.addHandler(new ResourceHandler());
    server.addHandler(contextHandler);

    server.addHandler(new WebAppContext("webapp", "/nextreports-server"));

    long t = System.currentTimeMillis();
    server.start();
    t = System.currentTimeMillis() - t;
    String version = server.getClass().getPackage().getImplementationVersion();
    System.out.println("Started Jetty Server " + version + " on port " + PORT + " in " + t / 1000 + "s");
    
    server.join();
}
 
开发者ID:nextreports,项目名称:nextreports-server,代码行数:26,代码来源:JettyLauncher.java

示例5: getServer

import org.mortbay.jetty.handler.ContextHandler; //导入方法依赖的package包/类
/**
 * Creates a new JettyServer with one static root context
 * 
 * @param port
 *          port to listen to
 * @param staticContent
 *          folder where static content lives
 * @throws UnknownHostException
 */
public static Server getServer(int port, String staticContent)
    throws UnknownHostException {
  Server webServer = new org.mortbay.jetty.Server();
  SocketConnector listener = new SocketConnector();
  listener.setPort(port);
  listener.setHost("127.0.0.1");
  webServer.addConnector(listener);
  ContextHandler staticContext = new ContextHandler();
  staticContext.setContextPath("/");
  staticContext.setResourceBase(staticContent);
  staticContext.addHandler(new ResourceHandler());
  webServer.addHandler(staticContext);
  return webServer;
}
 
开发者ID:jorcox,项目名称:GeoCrawler,代码行数:24,代码来源:CrawlDBTestUtil.java

示例6: 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;
}
 
开发者ID:iMartinezMateu,项目名称:openbravo-pos,代码行数:12,代码来源:WADITestServer.java

示例7: 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;
}
 
开发者ID:iMartinezMateu,项目名称:openbravo-pos,代码行数:14,代码来源:WADITestServer.java

示例8: getServer

import org.mortbay.jetty.handler.ContextHandler; //导入方法依赖的package包/类
/**
 * Creates a new JettyServer with one static root context
 * 
 * @param port port to listen to
 * @param staticContent folder where static content lives
 * @throws UnknownHostException 
 */
public static Server getServer(int port, String staticContent) throws UnknownHostException{
  Server webServer = new org.mortbay.jetty.Server();
  SocketConnector listener = new SocketConnector();
  listener.setPort(port);
  listener.setHost("127.0.0.1");
  webServer.addConnector(listener);
  ContextHandler staticContext = new ContextHandler();
  staticContext.setContextPath("/");
  staticContext.setResourceBase(staticContent);
  staticContext.addHandler(new ResourceHandler());
  webServer.addHandler(staticContext);
  return webServer;
}
 
开发者ID:yahoo,项目名称:anthelion,代码行数:21,代码来源:CrawlDBTestUtil.java

示例9: 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;
}
 
开发者ID:opoo,项目名称:opoopress,代码行数:38,代码来源:AbstractServerMojo.java

示例10: getContextHandler

import org.mortbay.jetty.handler.ContextHandler; //导入方法依赖的package包/类
private static ContextHandler getContextHandler(String contextPath, Handler handler) {
    ContextHandler contextHandler = new ContextHandler();
    contextHandler.setContextPath(contextPath);
    contextHandler.addHandler(handler);
    return contextHandler;
}
 
开发者ID:code-orchestra,项目名称:colt-core,代码行数:7,代码来源:CodeOrchestraResourcesHttpServer.java


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