Package org.mortbay.jetty.plugin

Examples of org.mortbay.jetty.plugin.JettyWebAppContext


    getLog().info("The tests.html file '" + testsHtml + "' could not be found. Skipping.");
    return false;
  }

  protected Server jettyRunTest(boolean tryPortRange) throws MojoExecutionException {
    JettyWebAppContext handler;
    try {
      handler = new JettyWebAppContext();
      handler.setWebInfLib(findJars());
      handler.setInitParameter("org.eclipse.jetty.servlet.Default.useFileMappedBuffer", "false");
      List<Resource> baseResources = new ArrayList<Resource>();
      baseResources.add(toResource(new File(outputDirectory, "META-INF/resources")));
      baseResources.add(toResource(testOutputDirectory));
      for (org.apache.maven.model.Resource r : testResources) {
        File testResourceDirectory = new File(r.getDirectory());
        if (testResourceDirectory.exists()) {
           baseResources.add(toResource(testResourceDirectory));
        }
      }
      handler.setBaseResource(new ResourceCollection(baseResources.toArray(new Resource[baseResources.size()])));
      getLog().info("Using base resources " + baseResources);
      ServletHolder servletHolder = new ServletHolder("default", DefaultServlet.class);
      servletHolder.setInitParameter("cacheControl", "no-store, no-cache, must-revalidate, max-age=0");
      handler.addServlet(servletHolder, "/");
      getLog().info("Set servlet cache control to 'do not cache'.");
    } catch (Exception e) {
      throw wrap(e);
    }
    return startJetty(handler, tryPortRange);
View Full Code Here


                public boolean apply(File file) {
                    return file.isDirectory();
                }
            });

            JettyWebAppContext context = new JettyWebAppContext();
            context.setWebInfLib(ImmutableList.copyOf(jars));
            Configuration[] contextConfigs = {new WebXmlConfiguration(), new WebInfConfiguration()};
            context.setConfigurations(contextConfigs);
            context.setDescriptor(webXml);
            context.setResourceBases(new String[] {sourcePath});
            context.setContextPath(contextPath);
            context.setParentLoaderPriority(true);

            // lets try disable the memory mapped file which causes issues
            // on Windows when using mvn -Pwatch
            // see http://docs.codehaus.org/display/JETTY/Files+locked+on+Windows
            // https://github.com/hawtio/hawtio/issues/22
            if (System.getProperty("jettyUseFileLock", "").toLowerCase().equals("false")) {
                //LOG.info("Disabling the use of the Jetty file lock for static content to try fix incremental grunt compilation on Windows");
                //context.setCopyWebDir(true);
                //context.setInitParameter("useFileMappedBuffer", "false");
                LOG.info("Setting maxCachedFiles to 0");
                context.setInitParameter("org.eclipse.jetty.servlet.Default.maxCachedFiles", "0");
            }

            Server server = new Server(port);
            server.setHandler(context);
View Full Code Here

TOP

Related Classes of org.mortbay.jetty.plugin.JettyWebAppContext

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.