Package org.mortbay.jetty.webapp

Examples of org.mortbay.jetty.webapp.WebAppContext


     */
    protected ServletContext createWebServer() throws Exception {
        server = new Server();

        explodedWarDir = WarExploder.getExplodedDir();
        WebAppContext context = new WebAppContext(explodedWarDir.getPath(), contextPath);
        context.setClassLoader(getClass().getClassLoader());
        context.setConfigurations(new Configuration[]{new WebXmlConfiguration(), new NoListenerConfiguration()});
        server.setHandler(context);
        context.setMimeTypes(MIME_TYPES);
        if(Functions.isWindows()) {
            // this is only needed on Windows because of the file
            // locking issue as described in JENKINS-12647
            context.setCopyWebDir(true);
        }

        SocketConnector connector = new SocketConnector();
        connector.setHeaderBufferSize(12*1024); // use a bigger buffer as Stapler traces can get pretty large on deeply nested URL

        server.setThreadPool(new ThreadPoolImpl(new ThreadPoolExecutor(10, 10, 10L, TimeUnit.SECONDS, new LinkedBlockingQueue<Runnable>(),new ThreadFactory() {
            public Thread newThread(Runnable r) {
                Thread t = new Thread(r);
                t.setName("Jetty Thread Pool");
                return t;
            }
        })));
        server.addConnector(connector);
        server.addUserRealm(configureUserRealm());
        server.start();

        localPort = connector.getLocalPort();

        return context.getServletContext();
    }
View Full Code Here


      currentDir = currentDir.getParentFile();
    }
    File hoopDir = new File(currentDir, "hoop-webapp");
    Assert.assertTrue(hoopDir.exists(), "Could not locate hoop-webapp source dir: " + hoopDir.getAbsolutePath());
    String hoopWebAppDir = new File(new File(new File(hoopDir, "src"), "main"), "webapp").getAbsolutePath();
    WebAppContext context = new WebAppContext(hoopWebAppDir, "/");

    Server server = getJettyServer();
    server.addHandler(context);
    server.start();
  }
View Full Code Here

        Assert.fail("Could not locate hoop-webapp source dir");
      }
    }
    String hoopWebAppDir =
      new File(new File(new File(new File(dir, "hoop-webapp"), "src"), "main"), "webapp").getAbsolutePath();
    WebAppContext context = new WebAppContext(hoopWebAppDir, "/");

    Server server = getJettyServer();
    server.addHandler(context);
    server.start();
  }
View Full Code Here

    server.setThreadPool(threads);
    server.setConnectors(new SelectChannelConnector[] { conn });
    server.setStopAtShutdown(true);

    System.out.println("stormhome:"+stormhome);
    WebAppContext root = new WebAppContext(stormhome+"/webapp","/");
//    root.setContextPath("/");
//    root.setWar(warpath);
    WebAppContext context = new WebAppContext(stormhome+"/webapp","/higo");
//    context.setContextPath("/higo");
//    context.setWar(warpath);
    server.addHandler(context);
    server.addHandler(root);
    server.start();
View Full Code Here

    final String appDir = getWebAppsPath();
    ContextHandlerCollection contexts = new ContextHandlerCollection();
    webServer.setHandler(contexts);

    webAppContext = new WebAppContext();
    webAppContext.setDisplayName("WepAppsContext");
    webAppContext.setContextPath("/");
    webAppContext.setWar(appDir + "/" + name);
    webAppContext.getServletContext().setAttribute(CONF_CONTEXT_ATTRIBUTE, conf);
    webAppContext.getServletContext().setAttribute(ADMINS_ACL, adminsAcl);
View Full Code Here

   */
  protected void addContext(String pathSpec, String dir, boolean isFiltered) throws IOException {
    if (0 == webServer.getHandlers().length) {
      throw new RuntimeException("Couldn't find handler");
    }
    WebAppContext webAppCtx = new WebAppContext();
    webAppCtx.setContextPath(pathSpec);
    webAppCtx.setWar(dir);
    addContext(webAppCtx, true);
  }
View Full Code Here

        Random random = new Random(System.nanoTime());
        String contextPath = "/lightLoad";
        String servletMapping = "/server";
        int port1 = random.nextInt(50000) + 10000;
        Server server1 = new Server(port1);
        WebAppContext context1 = new WebAppContext(warDir.getCanonicalPath(), contextPath);
        context1.setSessionHandler(new SessionHandler());
        context1.addServlet(TestServlet.class, servletMapping);
        server1.setHandler(context1);
        server1.start();
        try
        {
            int port2 = random.nextInt(50000) + 10000;
            Server server2 = new Server(port2);
            WebAppContext context2 = new WebAppContext(warDir.getCanonicalPath(), contextPath);
            context2.setSessionHandler(new SessionHandler());
            context2.addServlet(TestServlet.class, servletMapping);
            server2.setHandler(context2);
            server2.start();
            try
            {
                HttpClient client = new HttpClient();
View Full Code Here

     * Sets up the JWebUnit WebTester, used by all Web tests
     */
    @BeforeClass
    public static void setUp() throws Exception {
        server = new org.mortbay.jetty.Server(8080);
        server.addHandler(new WebAppContext("./src/main/webapp", "/ultimate-roundtrip"));
        server.start();

        // Set up tester
        tester = new WebTester();
        tester.setTestingEngineKey(TestingEngineRegistry.TESTING_ENGINE_HTMLUNIT);
View Full Code Here

        server.stop();
    }

    public WebAppContext addWebAppContext(String warPath, String contextPath)
    {
        WebAppContext context = new WebAppContext(contexts, warPath, contextPath);

        TerracottaSessionManager sessionManager = new TestTerracottaSessionManager();
        sessionManager.setIdManager(sessionIdManager);
        sessionManager.setMaxInactiveInterval(maxInactivePeriod);
        sessionManager.setScavengePeriodMs(TimeUnit.SECONDS.toMillis(scavengePeriod));

        SessionHandler sessionHandler = new TerracottaSessionHandler(sessionManager);
        sessionManager.setSessionHandler(sessionHandler);
        context.setSessionHandler(sessionHandler);

        return context;
  }
View Full Code Here

public class JettyLauncher {
    public static void main(String[] args) {

        Server server = new Server(8080);
        server.addHandler(new WebAppContext("./src/main/webapp", "/ultimate-roundtrip"));
        try {
            server.start();
            Thread.sleep(100000); //Makes sure the server doesn't die
        } catch (Exception e) {
            e.printStackTrace();
View Full Code Here

TOP

Related Classes of org.mortbay.jetty.webapp.WebAppContext

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.