Search in sources :

Example 1 with JettyWebAppContext

use of org.mortbay.jetty.plugin.JettyWebAppContext in project jangaroo-tools by CoreMedia.

the class JooTestMojoBase method jettyRunTest.

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);
}
Also used : ServletHolder(org.eclipse.jetty.servlet.ServletHolder) JettyWebAppContext(org.mortbay.jetty.plugin.JettyWebAppContext) ArrayList(java.util.ArrayList) Resource(org.eclipse.jetty.util.resource.Resource) File(java.io.File) IOException(java.io.IOException) MojoExecutionException(org.apache.maven.plugin.MojoExecutionException) DependencyResolutionRequiredException(org.apache.maven.artifact.DependencyResolutionRequiredException) ResourceCollection(org.eclipse.jetty.util.resource.ResourceCollection)

Aggregations

File (java.io.File)1 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 DependencyResolutionRequiredException (org.apache.maven.artifact.DependencyResolutionRequiredException)1 MojoExecutionException (org.apache.maven.plugin.MojoExecutionException)1 ServletHolder (org.eclipse.jetty.servlet.ServletHolder)1 Resource (org.eclipse.jetty.util.resource.Resource)1 ResourceCollection (org.eclipse.jetty.util.resource.ResourceCollection)1 JettyWebAppContext (org.mortbay.jetty.plugin.JettyWebAppContext)1