private void dumpUrl() { Connector[] connectors = getServer().getConnectors(); for (int i=0;i<connectors.length;i++) { String displayName = getDisplayName(); if (displayName == null) displayName = "WebApp@"+Arrays.hashCode(connectors); LOG.info(displayName + " at http://" + connectors[i].toString() + getContextPath()); } }
@Override public void setClassLoader(ClassLoader classLoader) { super.setClassLoader(classLoader); String name = getDisplayName(); if (name==null) name=getContextPath(); if (classLoader!=null && classLoader instanceof WebAppClassLoader && getDisplayName()!=null) ((WebAppClassLoader)classLoader).setName(name); }
String contextPath = context.getContextPath(); contextPath=contextPath.replace('/','_'); contextPath=contextPath.replace('\\','_');
private void addDocsServlets(WebAppContext docsContext) { try { // Load the nifi/docs directory final File docsDir = getDocsDir("docs"); // load the component documentation working directory final File componentDocsDirPath = props.getComponentDocumentationWorkingDirectory(); final File workingDocsDirectory = getWorkingDocsDirectory(componentDocsDirPath); // Load the API docs final File webApiDocsDir = getWebApiDocsDir(); // Create the servlet which will serve the static resources ServletHolder defaultHolder = new ServletHolder("default", DefaultServlet.class); defaultHolder.setInitParameter("dirAllowed", "false"); ServletHolder docs = new ServletHolder("docs", DefaultServlet.class); docs.setInitParameter("resourceBase", docsDir.getPath()); ServletHolder components = new ServletHolder("components", DefaultServlet.class); components.setInitParameter("resourceBase", workingDocsDirectory.getPath()); ServletHolder restApi = new ServletHolder("rest-api", DefaultServlet.class); restApi.setInitParameter("resourceBase", webApiDocsDir.getPath()); docsContext.addServlet(docs, "/html/*"); docsContext.addServlet(components, "/components/*"); docsContext.addServlet(restApi, "/rest-api/*"); docsContext.addServlet(defaultHolder, "/"); logger.info("Loading documents web app with context path set to " + docsContext.getContextPath()); } catch (Exception ex) { logger.error("Unhandled Exception in createDocsWebApp: " + ex.getMessage()); startUpFailure(ex); } }
@Test public void shouldAddWebAppContextHandler() throws Exception { jetty9Server.configure(); jetty9Server.startHandlers(); WebAppContext webAppContext = (WebAppContext) getLoadedHandlers().get(WebAppContext.class); assertThat(webAppContext, instanceOf(WebAppContext.class)); List<String> configClasses = new ArrayList<>(Arrays.asList(webAppContext.getConfigurationClasses())); assertThat(configClasses.contains(WebInfConfiguration.class.getCanonicalName()), is(true)); assertThat(configClasses.contains(WebXmlConfiguration.class.getCanonicalName()), is(true)); assertThat(configClasses.contains(JettyWebXmlConfiguration.class.getCanonicalName()), is(true)); assertThat(webAppContext.getContextPath(), is("context")); assertThat(webAppContext.getWar(), is("cruise.war")); assertThat(webAppContext.isParentLoaderPriority(), is(true)); assertThat(webAppContext.getDefaultsDescriptor(), is("jar:file:cruise.war!/WEB-INF/webdefault.xml")); }
LOG.info("NO JSP Support for {}, did not find {}", context.getContextPath(), servlet_class); servlet_class = "org.eclipse.jetty.servlet.NoJspServlet";
/** * * @return a String containing the context path to the console web application * @throws Exception on failure */ public String getConsoleContextPath() throws Exception { return HttpServerHolder.WEBAPP.getContextPath(); }
/** * * @return a String containing the context path to the console web application * @throws Exception on failure */ public String getConsoleContextPath() throws Exception { return HttpServerHolder.WEBAPP.getContextPath(); }
public static Handler removeContextFromList(List<Handler> hl, String contextPath) { Iterator<Handler> hi = hl.iterator(); while (hi.hasNext()) { Handler h = hi.next(); if ((h instanceof WebAppContext) && ((WebAppContext)h).getContextPath().equals(contextPath)) { hi.remove(); return h; } } return null; }
public void contextInitialized(ServletContextEvent sce) { WebAppContext ctx = (WebAppContext) sce.getServletContext(); System.out.println("context Base Path" + ctx.getContextPath()); System.out.println("Getting the port is a bit trickier"); System.out.println("One valid Port = " + ctx.getServer().getConnectors()[0].getPort()); }
@Override @ManagementOperation(description = "The web app context path") public String getContextPath() { return super.getContextPath(); }
@Override @ManagementOperation(description = "The web app context path") public String getContextPath() { return super.getContextPath(); }
private void dumpUrl() { Connector[] connectors = getServer().getConnectors(); for (int i=0;i<connectors.length;i++) { String displayName = getDisplayName(); if (displayName == null) displayName = "WebApp@"+connectors.hashCode(); LOG.info(displayName + " at http://" + connectors[i].toString() + getContextPath()); } }
private void dumpUrl() { Connector[] connectors = getServer().getConnectors(); for (int i=0;i<connectors.length;i++) { String displayName = getDisplayName(); if (displayName == null) displayName = "WebApp@"+connectors.hashCode(); LOG.info(displayName + " at http://" + connectors[i].toString() + getContextPath()); } }
private void dumpUrl() { Connector[] connectors = getServer().getConnectors(); for (int i=0;i<connectors.length;i++) { String displayName = getDisplayName(); if (displayName == null) displayName = "WebApp@"+Arrays.hashCode(connectors); LOG.info(displayName + " at http://" + connectors[i].toString() + getContextPath()); } }
private void dumpUrl() { Connector[] connectors = getServer().getConnectors(); for (int i=0;i<connectors.length;i++) { String connectorName = connectors[i].getName(); String displayName = getDisplayName(); if (displayName == null) displayName = "WebApp@"+connectors.hashCode(); LOG.info(displayName + " at http://" + connectorName + getContextPath()); } }
private void dumpUrl() { Connector[] connectors = getServer().getConnectors(); for (int i=0;i<connectors.length;i++) { String connectorName = connectors[i].getName(); String displayName = getDisplayName(); if (displayName == null) displayName = "WebApp@"+connectors.hashCode(); LOG.info(displayName + " at http://" + connectorName + getContextPath()); } }
private void dumpUrl() { Connector[] connectors = getServer().getConnectors(); for (int i=0;i<connectors.length;i++) { String connectorName = connectors[i].getName(); String displayName = getDisplayName(); if (displayName == null) displayName = "WebApp@"+connectors.hashCode(); LOG.info(displayName + " at http://" + connectorName + getContextPath()); } }
@Override public void setClassLoader(ClassLoader classLoader) { super.setClassLoader(classLoader); String name = getDisplayName(); if (name==null) name=getContextPath(); if (classLoader!=null && classLoader instanceof WebAppClassLoader && getDisplayName()!=null) ((WebAppClassLoader)classLoader).setName(name); }
// To be passed to all scanned webapps. Ensures SSO between contexts SessionManager sessManager = new HashSessionManager(); SessionCookieConfig config = sessManager.getSessionCookieConfig(); config.setPath("/webapps/"); // Ensures all webapps share the same cookie // Create the Handler (a.k.a the WebAppContext). App app = new App(deployer, provider, module.getFile().getAbsolutePath()); WebAppContext handler = (WebAppContext)app.getContextHandler(); // getContextHandler does the extraction // Consolidating all scanned webapps under a single context path allows SSO handler.setContextPath("/webapps" + handler.getContextPath()); // Cookies need to be shared between webapps for SSO SessionHandler sessHandler = handler.getSessionHandler(); sessHandler.setSessionManager(sessManager);