Package org.mortbay.jetty.webapp

Examples of org.mortbay.jetty.webapp.WebAppContext


        final Connector connector = jettyServer.getConnectors()[0];
        final String scheme = "http";
        final String host = ArrayExtensions.coalesce(connector.getHost(), "localhost");
        final int port = connector.getPort();

        final WebAppContext handler = (WebAppContext) jettyServer.getHandler();
        final String contextPath = handler.getContextPath();

        final StringBuilder buf = new StringBuilder();
        final Formatter formatter = new Formatter(buf);
        formatter.format("%s://%s:%d/%s", scheme, host, port, contextPath);
        return appendSlashIfRequired(buf).toString();
View Full Code Here


        jettyServer = new Server(port);
        Connector[] connectors = jettyServer.getConnectors();
        Connector connector = connectors[0];
        connector.setHeaderBufferSize(8192);
        final WebAppContext context = new WebAppContext(SRC_MAIN_WEBAPP, webappContextPath);

        copyConfigurationPrimersIntoServletContext(context);

        jettyServer.setHandler(context);
View Full Code Here

   public ContainerMethodExecutor deploy(Context context, Archive<?> archive) throws DeploymentException
   {
      try
      {
         WebAppContext wctx = archive.as(ShrinkWrapWebAppContext.class);
         // Jetty plus is required to support in-container invocation and enrichment
         if (containerConfig.isJettyPlus())
         {
            wctx.setConfigurationClasses(JETTY_PLUS_CONFIGURATION_CLASSES);
         }
         // HACK this needs to be rethought, perhaps another auxiliary archive appender to guarantee uniqueness and a static check for run mode?
//         if (archive.contains(ArchivePaths.create("/WEB-INF/lib/arquillian-protocol.jar")))
//         {
//            // wctx.setOverrideDescriptor("jar:file:" + wctx.getTempDirectory() + "/webapp/WEB-INF/lib/arquillian-protocol.jar!/META-INF/web-fragment.xml");
//            // NOTE go on faith there is only one META-INF/web-fragment.xml
//            wctx.setOverrideDescriptor("META-INF/web-fragment.xml");
//         }
         // possible configuration parameters
         wctx.setExtractWAR(true);
         wctx.setLogUrlOnStart(true);
        
         /*
          * ARQ-242 Without this set we result in failure on loading Configuration in container.
          * ServiceLoader finds service file from AppClassLoader, tried to load JettyContainerConfiguration from AppClassLoader
          * as a ContainerConfiguration from WebAppClassContext. ClassCastException.
          */
         wctx.setParentLoaderPriority(true);
        
         server.addHandler(wctx);
         wctx.start();
         context.add(WebAppContext.class, wctx);
      }
      catch (Exception e)
      {
         throw new DeploymentException("Could not deploy " + archive.getName(), e);
View Full Code Here

      }
   }

   public void undeploy(Context context, Archive<?> archive) throws DeploymentException
   {
      WebAppContext wctx = context.get(WebAppContext.class);
      if (wctx != null)
      {
         try
         {
            wctx.stop();
         }
         catch (Exception e)
         {
            e.printStackTrace();
            log.severe("Could not stop context " + wctx.getContextPath() + ": " + e.getMessage());
         }
         // NOTE work around a bug in Jetty where removeHandler is ignored if only one handler is set
         if (server.getHandlers() == null)
         {
            server.setHandler(null);
View Full Code Here

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

    webAppContext = new WebAppContext();
    webAppContext.setContextPath("/");
    webAppContext.setWar(appDir + "/" + name);
    webAppContext.getServletContext().setAttribute(CONF_CONTEXT_ATTRIBUTE, conf);
    webServer.addHandler(webAppContext);
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

    Server server = new Server();
    server.addConnector(connector);

    // Create a new web app in the war directory.
    WebAppContext wac = new WebAppContextWithReload(logger,
        appRootDir.getAbsolutePath(), "/");

    RequestLogHandler logHandler = new RequestLogHandler();
    logHandler.setRequestLog(new JettyRequestLogger(logger, getBaseLogLevel()));
    logHandler.setHandler(wac);
View Full Code Here

    Server server = new Server();
    server.addConnector(connector);

    // Create a new web app in the war directory.
    WebAppContext wac = new WebAppContextWithReload(logger,
        appRootDir.getAbsolutePath(), "/");

    RequestLogHandler logHandler = new RequestLogHandler();
    logHandler.setRequestLog(new JettyRequestLogger(logger));
    logHandler.setHandler(wac);
View Full Code Here

        "false");
    try {
      System.setProperty("org.mortbay.xml.XmlParser.Validating", "false");
      WebXmlConfiguration wxc = new WebXmlConfiguration();
      ServletHandler myServletHandler = new ServletHandler();
      wxc.setWebAppContext(new WebAppContext(null, null, myServletHandler, null));
      wxc.configure(webXmlUrlString);
      ServletMapping[] mappings = myServletHandler.getServletMappings();
      ServletHolder[] servlets = myServletHandler.getServlets();
      Map<String, String> servletNameToClassName = new HashMap<String, String>();
      Map<String, Set<String>> classNameToPaths = new HashMap<String, Set<String>>();
View Full Code Here

        connector.setPort(8080);
        connector.setHost("localhost");
        server.addConnector(connector);

        // add our web context path
        WebAppContext wac = new WebAppContext();
        wac.setContextPath("/unittest");
        // set the location of the exploded webapp where WEB-INF is located
        // this is a nice feature of Jetty where we can point to src/main/webapp
        wac.setWar("./src/main/webapp");
        server.setHandler(wac);

        // then start Jetty
        server.setStopAtShutdown(true);
        server.start();
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.