private void setExtendedListenerTypes(boolean extended) { try { this.context.getServletContext().setExtendedListenerTypes(extended); } catch (NoSuchMethodError ex) { // Not available on Jetty 8 } }
private void setExtendedListenerTypes(WebAppContext context, boolean extended) { try { context.getServletContext().setExtendedListenerTypes(extended); } catch (NoSuchMethodError ex) { // Not available on Jetty 8 } }
private static WebAppContext createWebAppContext(String name, Configuration conf, AccessControlList adminsAcl, final String appDir) { WebAppContext ctx = new WebAppContext(); ctx.setDisplayName(name); ctx.setContextPath("/"); ctx.setWar(appDir + "/" + name); ctx.getServletContext().setAttribute(CONF_CONTEXT_ATTRIBUTE, conf); // for org.apache.hadoop.metrics.MetricsServlet ctx.getServletContext().setAttribute( org.apache.hadoop.http.HttpServer2.CONF_CONTEXT_ATTRIBUTE, conf); ctx.getServletContext().setAttribute(ADMINS_ACL, adminsAcl); addNoCacheFilter(ctx); return ctx; }
/** * Create the web context for the application of specified name */ WebAppContext createWebAppContext(Builder b) { WebAppContext ctx = new WebAppContext(); setContextAttributes(ctx.getServletContext(), b.contextAttrs); ctx.setDisplayName(b.name); ctx.setContextPath("/"); ctx.setWar(appDir + "/" + b.name); return ctx; }
private void callInitializers(WebAppContext context) throws ServletException { try { setExtendedListenerTypes(context, true); for (ServletContextInitializer initializer : this.initializers) { initializer.onStartup(context.getServletContext()); } } finally { setExtendedListenerTypes(context, false); } }
private HttpServer2(final Builder b) throws IOException { final String appDir = getWebAppsPath(b.name); this.webServer = new Server(); this.adminsAcl = b.adminsAcl; this.handlers = new HandlerCollection(); this.webAppContext = createWebAppContext(b, adminsAcl, appDir); this.xFrameOptionIsEnabled = b.xFrameEnabled; this.xFrameOption = b.xFrameOption; try { this.secretProvider = constructSecretProvider(b, webAppContext.getServletContext()); this.webAppContext.getServletContext().setAttribute (AuthenticationFilter.SIGNER_SECRET_PROVIDER_ATTRIBUTE, secretProvider); } catch(IOException e) { throw e; } catch (Exception e) { throw new IOException(e); } this.findPort = b.findPort; this.portRanges = b.portRanges; initializeWebServer(b.name, b.hostName, b.conf, b.pathSpecs); }
try { setExtendedListenerTypes(true); this.initializer.onStartup(null, this.context.getServletContext());
private static WebAppContext createWebAppContext(Builder b, AccessControlList adminsAcl, final String appDir) { WebAppContext ctx = new WebAppContext(); ctx.setDefaultsDescriptor(null); ServletHolder holder = new ServletHolder(new DefaultServlet()); Map<String, String> params = ImmutableMap. <String, String> builder() .put("acceptRanges", "true") .put("dirAllowed", "false") .put("gzip", "true") .put("useFileMappedBuffer", "true") .build(); holder.setInitParameters(params); ctx.setWelcomeFiles(new String[] {"index.html"}); ctx.addServlet(holder, "/"); ctx.setDisplayName(b.name); ctx.setContextPath("/"); ctx.setWar(appDir + "/" + b.name); String tempDirectory = b.conf.get(HTTP_TEMP_DIR_KEY); if (tempDirectory != null && !tempDirectory.isEmpty()) { ctx.setTempDirectory(new File(tempDirectory)); ctx.setAttribute("javax.servlet.context.tempdir", tempDirectory); } ctx.getServletContext().setAttribute(CONF_CONTEXT_ATTRIBUTE, b.conf); ctx.getServletContext().setAttribute(ADMINS_ACL, adminsAcl); addNoCacheFilter(ctx); return ctx; }
public void visitTagLib(WebAppContext context, Descriptor descriptor, XmlParser.Node node) { //Additive across web.xml and web-fragment.xml String uri = node.getString("taglib-uri", false, true); String location = node.getString("taglib-location", false, true); context.setResourceAlias(uri, location); JspConfig config = (JspConfig)context.getServletContext().getJspConfigDescriptor(); if (config == null) { config = new JspConfig(); context.getServletContext().setJspConfigDescriptor(config); } TagLib tl = new TagLib(); tl.setTaglibLocation(location); tl.setTaglibURI(uri); config.addTaglibDescriptor(tl); }
@Override public void dump(Appendable out, String indent) throws IOException { List<String> system_classes=null; if (_systemClasses!=null) { system_classes=new ArrayList<>(_systemClasses); Collections.sort(system_classes); } List<String> server_classes=null; if (_serverClasses!=null) { server_classes=new ArrayList<>(_serverClasses); Collections.sort(server_classes); } dumpObjects(out,indent, new ClassLoaderDump(getClassLoader()), new DumpableCollection("Systemclasses "+this,system_classes), new DumpableCollection("Serverclasses "+this,server_classes), new DumpableCollection("Configurations "+this,_configurations), new DumpableCollection("Handler attributes "+this,((AttributesMap)getAttributes()).getAttributeEntrySet()), new DumpableCollection("Context attributes "+this,((Context)getServletContext()).getAttributeEntrySet()), new DumpableCollection("Initparams "+this,getInitParams().entrySet()) ); }
@Override public void preConfigure(final WebAppContext context) throws Exception { boolean useContainerCache = DEFAULT_USE_CONTAINER_METAINF_CACHE; if (context.getServer() != null) { Boolean attr = (Boolean)context.getServer().getAttribute(USE_CONTAINER_METAINF_CACHE); if (attr != null) useContainerCache = attr.booleanValue(); } if (LOG.isDebugEnabled()) LOG.debug("{} = {}", USE_CONTAINER_METAINF_CACHE, useContainerCache); //pre-emptively create empty lists for tlds, fragments and resources as context attributes //this signals that this class has been called. This differentiates the case where this class //has been called but finds no META-INF data from the case where this class was never called if (context.getAttribute(METAINF_TLDS) == null) context.setAttribute(METAINF_TLDS, new HashSet<URL>()); if (context.getAttribute(METAINF_RESOURCES) == null) context.setAttribute(METAINF_RESOURCES, new HashSet<Resource>()); if (context.getAttribute(METAINF_FRAGMENTS) == null) context.setAttribute(METAINF_FRAGMENTS, new HashMap<Resource, Resource>()); //always scan everything from the container's classpath scanJars(context, context.getMetaData().getContainerResources(), useContainerCache, __allScanTypes); //only look for fragments if web.xml is not metadata complete, or it version 3.0 or greater List<String> scanTypes = new ArrayList<>(__allScanTypes); if (context.getMetaData().isMetaDataComplete() || (context.getServletContext().getEffectiveMajorVersion() < 3) && !context.isConfigurationDiscovered()) scanTypes.remove(METAINF_FRAGMENTS); scanJars(context, context.getMetaData().getWebInfJars(), false, scanTypes); }
context.getServletContext().setEffectiveMajorVersion(_webXmlRoot.getMajorVersion()); context.getServletContext().setEffectiveMinorVersion(_webXmlRoot.getMinorVersion());
public void visitJspConfig(WebAppContext context, Descriptor descriptor, XmlParser.Node node) JspConfig config = (JspConfig)context.getServletContext().getJspConfigDescriptor(); if (config == null) context.getServletContext().setJspConfigDescriptor(config);
context.getServletContext().setEffectiveMajorVersion(context.getMetaData().getWebXml().getMajorVersion()); context.getServletContext().setEffectiveMinorVersion(context.getMetaData().getWebXml().getMinorVersion());
ApplicationContext ctx = WebApplicationContextUtils.getWebApplicationContext(webApiContext.getServletContext()); flowService = ctx.getBean("flowService", FlowService.class);
Jsr356Impl.setServletContext(configureContext, context.getServletContext()); Jsr356Impl.setAdditionalWebSocketConfigurator(new AdditionalWebSocketConfigurator() { @Override context.addServlet(servletHolder, "/*"); context.getServletContext().setAttribute("bimserver", bimServer); if (context.getResourceBase() == null) { if (resourceBase == null) {
@Override public void lifeCycleStarting(LifeCycle arg0) { // WebAppInitializer initializer = new WebAppInitializer(); try { Context servletContext = webAppContext.getServletContext(); // servletContext.setExtendedListenerTypes(true); initializer.onStartup(servletContext); } catch (ServletException e) { throw new RuntimeException(e); } } });
@Override public void lifeCycleStarting(LifeCycle event) { ctx.getServletContext().setInitParameter("restx.baseServerUri", baseUrl()); ctx.getServletContext().setInitParameter("restx.serverId", getServerId()); } });
@Override public void lifeCycleStarting(LifeCycle event) { ctx.getServletContext().setInitParameter("restx.baseServerUri", baseUrl()); ctx.getServletContext().setInitParameter("restx.serverId", getServerId()); } });
/** * Create the web context for the application of specified name */ WebAppContext createWebAppContext(Builder b) { WebAppContext ctx = new WebAppContext(); setContextAttributes(ctx.getServletContext(), b.contextAttrs); ctx.setDisplayName(b.name); ctx.setContextPath("/"); ctx.setWar(appDir + "/" + b.name); return ctx; }