webApp = new JettyWebAppContext(); String cp = webApp.getContextPath(); if (cp == null || "".equals(cp)) webApp.setContextPath(cp); if (webApp.getTempDirectory() == null) if (!tmp.exists()) tmp.mkdirs(); webApp.setTempDirectory(tmp); getLog().info("Context path = " + webApp.getContextPath()); getLog().info("Tmp directory = "+ (webApp.getTempDirectory()== null? " determined at runtime": webApp.getTempDirectory())); getLog().info("Web defaults = "+(webApp.getDefaultsDescriptor()==null?" jetty default":webApp.getDefaultsDescriptor())); getLog().info("Web overrides = "+(webApp.getOverrideDescriptor()==null?" none":webApp.getOverrideDescriptor()));
private void addServlet(JettyWebAppContext webAppContext, ServletHolder servletHolder, String pathSpec) { webAppContext.addServlet(servletHolder, pathSpec); if (ROOT_PATH_SPEC.equals(pathSpec)) { hasRootPathServlet = true; } }
getLog().info("restarting "+webApp); getLog().debug("Stopping webapp ..."); webApp.stop(); getLog().debug("Reconfiguring webapp ..."); if (webApp.getDescriptor() != null) scanList.add(new File(webApp.getDescriptor())); if (webApp.getJettyEnvXml() != null) scanList.add(new File(webApp.getJettyEnvXml())); scanList.add(project.getFile()); if (webApp.getTestClasses() != null) scanList.add(webApp.getTestClasses()); if (webApp.getClasses() != null) scanList.add(webApp.getClasses()); scanList.addAll(webApp.getWebInfLib()); scanner.setScanDirs(scanList); webApp.start(); getLog().info("Restart completed at " + new Date().toString());
private JettyWebAppContext createHandler() throws JettyWrapperException { try { JettyWebAppContext handler = new JettyWebAppContext(); handler.setInitParameter("org.eclipse.jetty.servlet.Default.useFileMappedBuffer", "false"); handler.setBaseResource(new ResourceCollection(baseResources.toArray(new Resource[0]))); getLog().info("Using base resources " + baseResources);
if (webApp == null || webApp.getContextPath() == null) { if (contextPath != null) { getLog().warn("Please use `webApp/contextPath` configuration parameter in place of the deprecated `contextPath` parameter"); if (webApp == null) { try { webApp = new JettyWebAppContext(); } catch (Exception e) { throw new MojoExecutionException("Failed to initialize webApp configuration", e); webApp.setContextPath(contextPath);
public void configureWebApplication() throws Exception { // Jetty tries to do this in WebAppContext.resolveWebApp but it failed to delete the directory. File t = webApp.getTempDirectory(); if (t==null) t = new File(getProject().getBuild().getDirectory(),"tmp"); File extractedWebAppDir= new File(t, "webapp"); if (isExtractedWebAppDirStale(extractedWebAppDir, webAppFile)) { FileUtils.deleteDirectory(extractedWebAppDir); } super.configureWebApplication(); getWebAppConfig().setWar(webAppFile.getCanonicalPath()); for (Artifact a : (Set<Artifact>) project.getArtifacts()) { if (a.getGroupId().equals("org.jenkins-ci.main") && a.getArtifactId().equals("jenkins-core")) { File coreBasedir = pluginWorkspaceMap.read(a.getId()); if (coreBasedir != null) { String extraCP = new File(coreBasedir, "src/main/resources").toURI() + "," + new File(coreBasedir, "target/classes").toURI(); getLog().info("Will load directly from " + extraCP); getWebAppConfig().setExtraClasspath(extraCP); } } } // cf. https://wiki.jenkins-ci.org/display/JENKINS/Jetty HashLoginService hashLoginService = (new HashLoginService("Jenkins Realm")); hashLoginService.setConfig(System.getProperty("jetty.home", "work") + "/etc/realm.properties"); getWebAppConfig().getSecurityHandler().setLoginService(hashLoginService); }
private void addDefaultServlet(JettyWebAppContext webAppContext, StaticResourcesServletConfig config) { ServletHolder servletHolder = new ServletHolder(DefaultServlet.class); servletHolder.setInitParameter("relativeResourceBase", config.getRelativeResourceBase()); servletHolder.setInitParameter("cacheControl", "no-store, no-cache, must-revalidate, max-age=0"); webAppContext.addAliasCheck(new AllowSymLinkAliasChecker()); addServlet(webAppContext, servletHolder, config.getPathSpec()); getLog().info(String.format("Serving static resources: %s -> %s", config.getPathSpec(), config.getRelativeResourceBase())); }