Package org.eclipse.jetty.webapp

Examples of org.eclipse.jetty.webapp.WebAppContext


        List<WARDeployable> wars = earDeployable.getWARDeployables();

        for (WARDeployable war : wars) {

            // Build a new instance of the webapp context
            WebAppContext webAppContext = new WebAppContext();

            // invoke setters
            // for the URL of the war file
            try {
                webAppContext.setWar(war.getArchive().getURL().getPath());
            } catch (ArchiveException e) {
                throw new DeployerException("Cannot get URL from the archive '" + war.getArchive() + "'.", e);
            }
            // Defines the name of the context
            webAppContext.setContextPath("/" + war.getContextRoot());
            // Java delegation model = true
            webAppContext.setParentLoaderPriority(true);

            // add the built context on the existing list
            this.contextHandlerCollection.addHandler(webAppContext);

            // set the thread context classloader to the parent classloader
            ClassLoader oldCl = Thread.currentThread().getContextClassLoader();
            Thread.currentThread().setContextClassLoader(parentClassLoader);
            // start context
            try {
                webAppContext.start();
            } catch (Exception e) {
                throw new DeployerException("Cannot start the context '" + war.getContextRoot() + "'", e);
            } finally {
                // reset classloader
                Thread.currentThread().setContextClassLoader(oldCl);
View Full Code Here


        // Get all handlers
        Handler[] handlers = this.contextHandlerCollection.getHandlers();

        // For each handler, check the name of the context root
        WebAppContext webAppContext = null;
        for (Handler handler : handlers) {
            // Handler is a webapp context ?
            if (handler.getClass().equals(WebAppContext.class)) {
                webAppContext = (WebAppContext) handler;
                // get context
                String foundCtx = webAppContext.getContextPath();
                if (contextRoot.equals(foundCtx) || ("/" + contextRoot).equals(foundCtx)) {
                    // found !
                    break;
               }
            }
        }

        // Context not found
        if (webAppContext == null) {
            throw new DeployerException("Unable to find a context with the name '" + contextRoot
                    + "' for the War deployable '" + warDeployable + "'.");
        }

        // Stop the context
        try {
            webAppContext.stop();
        } catch (Exception e) {
            logger.error("Unable to stop web app context", e);
        }

        // Remove the context
View Full Code Here

    SelectChannelConnector connector = new SelectChannelConnector();
    connector.setPort(8888);
    server.addConnector(connector);

    WebAppContext webApp = new WebAppContext();
    webApp.setContextPath("/");
    webApp.setWar("src/main/webapp");
    server.setHandler(webApp);
    server.start();
    return server;
  }
View Full Code Here

        connector.setMaxIdleTime(1000 * 60 * 60);
        connector.setSoLingerTime(-1);
        connector.setPort(8080);
        server.setConnectors(new Connector[]{connector});

        WebAppContext webapp = new WebAppContext("src/main/webapp", "/");
        HandlerCollection contexts = new ContextHandlerCollection();
        contexts.addHandler(webapp);
        contexts.addHandler(new DefaultHandler());
        server.setHandler(contexts);

View Full Code Here

      URL url = getClass().getClassLoader().getResource("org/nutz/mvc/testapp/Root/FLAG");
      String path = url.toExternalForm();
      System.err.println(url);
      server = new Server(8888);
      String warUrlString = path.substring(0,path.length() - 4);
      server.setHandler(new WebAppContext(warUrlString, getContextPath()));
      server.start();
    } catch (Throwable e) {
      if(server != null)
        server.stop();
      throw e;
View Full Code Here

    server.setStopAtShutdown( true );
   
    // Initialize the servlets
    ContextHandlerCollection contexts = new ContextHandlerCollection();
    server.setHandler(contexts);
    WebAppContext lcfCrawlerUI = new WebAppContext(crawlerWarPath,"/mcf-crawler-ui");
    // This can cause jetty to ignore all of the framework and jdbc jars in the war, which is what we
    // want in the single-process case.
    lcfCrawlerUI.setParentLoaderPriority(useParentLoader);
    contexts.addHandler(lcfCrawlerUI);
    WebAppContext lcfAuthorityService = new WebAppContext(authorityServiceWarPath,"/mcf-authority-service");
    // This can cause jetty to ignore all of the framework and jdbc jars in the war, which is what we
    // want in the single-process case.
    lcfAuthorityService.setParentLoaderPriority(useParentLoader);
    contexts.addHandler(lcfAuthorityService);
    WebAppContext lcfApi = new WebAppContext(apiWarPath,"/mcf-api-service");
    // This can cause jetty to ignore all of the framework and jdbc jars in the war, which is what we
    // want in the single-process case.
    lcfApi.setParentLoaderPriority(useParentLoader);
    contexts.addHandler(lcfApi);
  }
View Full Code Here

        if(webPort == null || webPort.isEmpty()) {
            webPort = "8080";
        }

        Server server = new Server(Integer.valueOf(webPort));
        WebAppContext root = new WebAppContext();

        root.setContextPath("/");
        root.setDescriptor(webappDirLocation+"/WEB-INF/web.xml");
        root.setResourceBase(webappDirLocation);
       
        //Parent loader priority is a class loader setting that Jetty accepts.
        //By default Jetty will behave like most web containers in that it will
        //allow your application to replace non-server libraries that are part of the
        //container. Setting parent loader priority to true changes this behavior.
        //Read more here: http://wiki.eclipse.org/Jetty/Reference/Jetty_Classloading
        root.setParentLoaderPriority(true);
       
        server.setHandler(root);
       
        server.start();
        server.join();  
View Full Code Here

            System.out.println("SSL access to the quickstart has been enabled on port 8443");
            System.out.println("You can access the application using SSL on https://localhost:8443");
            System.out.println();
        }

        WebAppContext bb = new WebAppContext();
        bb.setServer(server);
        bb.setContextPath("/");
        bb.setWar("src/main/webapp");

        // START JMX SERVER
        // MBeanServer mBeanServer = ManagementFactory.getPlatformMBeanServer();
        // MBeanContainer mBeanContainer = new MBeanContainer(mBeanServer);
        // server.getContainer().addEventListener(mBeanContainer);
View Full Code Here

    SelectChannelConnector connector = new SelectChannelConnector();
    connector.setHost(SERVER_HOST);
    connector.setPort(SERVER_PORT);
    server.addConnector(connector);

    context = new WebAppContext("src/test/webapp", "/");
    context.addServlet(ThymeleafServlet.class, "/thymeleaf/*");

    server.setHandler(context);
    server.setStopAtShutdown(true);

 
View Full Code Here

            System.out.println("SSL access to the quickstart has been enabled on port 8443");
            System.out.println("You can access the application using SSL on https://localhost:8443");
            System.out.println();
        }

        WebAppContext bb = new WebAppContext();
        bb.setServer(server);
        bb.setContextPath("/");
        bb.setWar("src/main/webapp");

        // START JMX SERVER
        // MBeanServer mBeanServer = ManagementFactory.getPlatformMBeanServer();
        // MBeanContainer mBeanContainer = new MBeanContainer(mBeanServer);
        // server.getContainer().addEventListener(mBeanContainer);
View Full Code Here

TOP

Related Classes of org.eclipse.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.