Package org.eclipse.jetty.webapp

Examples of org.eclipse.jetty.webapp.WebAppContext$Context


      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");

    // uncomment next line if you want to test with JSESSIONID encoded in the urls
    // ((AbstractSessionManager)
    // bb.getSessionHandler().getSessionManager()).setUsingCookies(false);
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/test/webapp");


    WebSocketServerContainerInitializer.configureContext(bb);

    // START JMX SERVER
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

    server = new Server(0);
    SelectChannelConnector connector = new SelectChannelConnector();
    server.setConnectors(new Connector[] { connector });

    WebAppContext web = new WebAppContext();
    if (contextPath == null)
      web.setContextPath("/wicket-examples");
    else
      web.setContextPath(contextPath);

    if (webappLocation == null)
    {
      String basedir = System.getProperty("basedir");
      String path = "";
      if (basedir != null)
        path = basedir + "/";
      path += "src/main/webapp";

      web.setWar(path);
    }
    else
    {
      web.setWar(webappLocation);
    }
    server.setHandler(web);

    server.start();
    localPort = connector.getLocalPort();
View Full Code Here

        context.setContextPath("/api");
        ServletHolder servletHolder = new ServletHolder(createJerseyServlet());
        servletHolder.setInitOrder(1);
        context.addServlet(servletHolder, "/*");

        WebAppContext webAppContext = new WebAppContext();
        webAppContext.setServer(server);
        webAppContext.setContextPath("/");

        String resourceBase = System.getProperty("resourceBase");
        if(resourceBase != null){
            webAppContext.setResourceBase(resourceBase);
        } else {
            webAppContext.setResourceBase(Main.class.getResource("/webapp").toExternalForm());
        }

        HandlerList handlers = new HandlerList();
        handlers.setHandlers(new Handler[]{context, webAppContext});
        server.setHandler(handlers);
View Full Code Here

      LOG.severe("No valid http end point address provided!");
    }
    for (Connector connector : connectors) {
      httpServer.addConnector(connector);
    }
    final WebAppContext context = new WebAppContext();

    context.setParentLoaderPriority(true);

    if (jettySessionManager != null) {
      // This disables JSessionIDs in URLs redirects
      // see: http://stackoverflow.com/questions/7727534/how-do-you-disable-jsessionid-for-jetty-running-with-the-eclipse-jetty-maven-plu
      // and: http://jira.codehaus.org/browse/JETTY-467?focusedCommentId=114884&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-114884
      jettySessionManager.setSessionIdPathParameterName(null);

      context.getSessionHandler().setSessionManager(jettySessionManager);
    }
    final ResourceCollection resources = new ResourceCollection(resourceBases);
    context.setBaseResource(resources);

    addWebSocketServlets();

    try {
      final Injector parentInjector = injector;

      final ServletModule servletModule = getServletModule(parentInjector);

      ServletContextListener contextListener = new GuiceServletContextListener() {

        private final Injector childInjector = parentInjector.createChildInjector(servletModule);

        @Override
        protected Injector getInjector() {
          return childInjector;
        }
      };

      context.addEventListener(contextListener);
      context.addFilter(GuiceFilter.class, "/*", EnumSet.allOf(DispatcherType.class));
      context.addFilter(GzipFilter.class, "/webclient/*", EnumSet.allOf(DispatcherType.class));
      httpServer.setHandler(context);

      httpServer.start();
      restoreSessions();

View Full Code Here

       
        server = new Server();
        SelectChannelConnector connector = new SelectChannelConnector();
        connector.setPort(8080);
        connector.setServer(server);
        WebAppContext context = new WebAppContext();

        context.setResourceBase("src/main/webapp");
        context.setContextPath("/");
        context.setServer(server);
        server.setHandler(context);
        server.setConnectors(new Connector[] {
            connector
        });
        server.start();
View Full Code Here

    connector.setPort(port);
    // 解决Windows下重复启动Jetty居然不报告端口冲突的问题.
    connector.setReuseAddress(false);
    server.setConnectors(new Connector[] { connector });

    WebAppContext webContext = new WebAppContext(DEFAULT_WEBAPP_PATH, contextPath);
    server.setHandler(webContext);

    return server;
  }
View Full Code Here

  /**
   * 设置除jstl-*.jar外其他含tld文件的jar包的名称.
   * jar名称不需要版本号,如sitemesh, shiro-web
   */
  public static void setTldJarNames(Server server, String... jarNames) {
    WebAppContext context = (WebAppContext) server.getHandler();
    List<String> jarNameExprssions = Lists.newArrayList(".*/jstl-[^/]*\\.jar$", ".*/.*taglibs[^/]*\\.jar$");
    for (String jarName : jarNames) {
      jarNameExprssions.add(".*/" + jarName + "-[^/]*\\.jar$");
    }

    context.setAttribute("org.eclipse.jetty.server.webapp.ContainerIncludeJarPattern",
        StringUtils.join(jarNameExprssions, '|'));

  }
View Full Code Here

  /**
   * 快速重新启动application,重载target/classes与target/test-classes.
   */
  public static void reloadContext(Server server) throws Exception {
    WebAppContext context = (WebAppContext) server.getHandler();

    System.out.println("[INFO] Application reloading");
    context.stop();

    WebAppClassLoader classLoader = new WebAppClassLoader(context);
    classLoader.addClassPath("target/classes");
    classLoader.addClassPath("target/test-classes");
    context.setClassLoader(classLoader);

    context.start();

    System.out.println("[INFO] Application reloaded");
  }
View Full Code Here

TOP

Related Classes of org.eclipse.jetty.webapp.WebAppContext$Context

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.