/** * Set servlet context attributes that can be used in jsp. */ void setContextAttributes(Context ctx, Map<String, Object> contextAttrs) { for (Map.Entry<String, Object> e: contextAttrs.entrySet()) { ctx.setAttribute(e.getKey(), e.getValue()); } }
protected Handler createAdminServlet(Server server, MutableServletContextHandler handler, MetricRegistry metrics, HealthCheckRegistry healthChecks) { configureSessionsAndSecurity(handler, server); handler.setServer(server); handler.getServletContext().setAttribute(MetricsServlet.METRICS_REGISTRY, metrics); handler.getServletContext().setAttribute(HealthCheckServlet.HEALTH_CHECK_REGISTRY, healthChecks); handler.addServlet(new NonblockingServletHolder(new AdminServlet()), "/*"); final String allowedMethodsParam = allowedMethods.stream() .collect(Collectors.joining(",")); handler.addFilter(AllowedMethodsFilter.class, "/*", EnumSet.of(DispatcherType.REQUEST)) .setInitParameter(AllowedMethodsFilter.ALLOWED_METHODS_PARAM, allowedMethodsParam); return handler; }
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; }
HttpServiceContext( final HandlerContainer parent, final Map<String, String> initParams, final Map<String, Object> attributes, final String contextName, final WebContainerContext httpContext, final AccessControlContext accessControllerContext, final Map<ServletContainerInitializer, Set<Class<?>>> containerInitializers, URL jettyWebXmlUrl, List<String> virtualHosts) { super(parent, "/" + contextName, SESSIONS | SECURITY); LOG.info("registering context {}, with context-name: {}", httpContext, contextName); getInitParams().putAll(initParams); this.attributes = attributes; this.httpContext = httpContext; this.accessControllerContext = accessControllerContext; setDisplayName(httpContext.getContextId()); this.servletContainerInitializers = containerInitializers != null ? containerInitializers : new HashMap<>(); this.virtualHosts = new ArrayList<>(virtualHosts); jettyWebXmlURL = jettyWebXmlUrl; _scontext = new SContext(); // TCCL of sessionManager timer threads will be set to thread of pax-web-jetty bundle, not to current TCCL ScheduledExecutorScheduler executorScheduler = new ScheduledExecutorScheduler(getSessionHandler().toString() + "Timer", true, getClass().getClassLoader()); getSessionHandler().addBean(executorScheduler, true); _scontext.setAttribute("org.eclipse.jetty.server.session.timer", executorScheduler); setServletHandler(new HttpServiceServletHandler(httpContext)); setErrorHandler(new ErrorPageErrorHandler()); }
ServletContextHandler context = new ServletContextHandler(server, "/", ServletContextHandler.SESSIONS); context.getServletContext().setAttribute("queryExecutionFactory", qef); context.addServlet(sh, "/*");
@Override protected void doExecute() { final Bundle webAppBundle = deployment.getBundle(); final Bundle extenderBundle = JettyService.this.context.getBundle(); try { context.getServletContext().setAttribute(OSGI_BUNDLE_CONTEXT, webAppBundle.getBundleContext()); JettyService.this.parent.addHandler(context); context.start(); Dictionary<String, Object> props = new Hashtable<>(); props.put(WEB_SYMBOLIC_NAME, webAppBundle.getSymbolicName()); props.put(WEB_VERSION, webAppBundle.getVersion()); props.put(WEB_CONTEXT_PATH, deployment.getContextPath()); deployment.setRegistration(webAppBundle.getBundleContext().registerService(ServletContext.class, context.getServletContext(), props)); postEvent(WebEvent.TOPIC_DEPLOYED, webAppBundle, extenderBundle, null, null, null); } catch (Exception e) { SystemLogger.error(String.format("Deploying web application bundle %s failed.", webAppBundle.getSymbolicName()), e); postEvent(WebEvent.TOPIC_FAILED, webAppBundle, extenderBundle, e, null, null); deployment.setContext(null); } } });
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; }
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; }
@Override protected void doStart() throws Exception { getServletContext().setAttribute(DecoratedObjectFactory.ATTR, _objFactory); super.doStart(); }
public Jetty(String path, int port, ClassLoader classLoader, Injector injector) { WebAppContext webAppContext = new WebAppContext(path, APP_NAME); webAppContext.setClassLoader(classLoader); webAppContext.getServletContext().setAttribute(INJECTOR_KEY, injector); setUp(webAppContext, port); }
/** * Set servlet context attributes that can be used in jsp. */ void setContextAttributes(Context ctx, Map<String, Object> contextAttrs) { for (Map.Entry<String, Object> e: contextAttrs.entrySet()) { ctx.setAttribute(e.getKey(), e.getValue()); } }
private void setContextAttributes(ServletContextHandler context, Configuration conf) { context.getServletContext().setAttribute(CONF_CONTEXT_ATTRIBUTE, conf); context.getServletContext().setAttribute(ADMINS_ACL, adminsAcl); }
private void setContextAttributes(ServletContextHandler context, Configuration conf) { context.getServletContext().setAttribute(CONF_CONTEXT_ATTRIBUTE, conf); context.getServletContext().setAttribute(ADMINS_ACL, adminsAcl); }
@Override protected void doStart() throws Exception { getServletContext().setAttribute(DecoratedObjectFactory.ATTR, _objFactory); super.doStart(); }
context.addServlet(servletHolder, "/*"); context.getServletContext().setAttribute("bimserver", bimServer); if (context.getResourceBase() == null) { if (resourceBase == null) {
protected Handler createAdminServlet(Server server, MutableServletContextHandler handler, MetricRegistry metrics, HealthCheckRegistry healthChecks) { configureSessionsAndSecurity(handler, server); handler.setServer(server); handler.getServletContext().setAttribute(MetricsServlet.METRICS_REGISTRY, metrics); handler.getServletContext().setAttribute(HealthCheckServlet.HEALTH_CHECK_REGISTRY, healthChecks); handler.addServlet(new NonblockingServletHolder(new AdminServlet()), "/*"); handler.addFilter(AllowedMethodsFilter.class, "/*", EnumSet.of(DispatcherType.REQUEST)) .setInitParameter(AllowedMethodsFilter.ALLOWED_METHODS_PARAM, Joiner.on(',').join(allowedMethods)); return handler; }
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); }
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; }
private void setContextAttributes(ServletContextHandler context, Configuration conf) { context.getServletContext().setAttribute(CONF_CONTEXT_ATTRIBUTE, conf); context.getServletContext().setAttribute(ADMINS_ACL, adminsAcl); }
private void setContextAttributes(ServletContextHandler context, Configuration conf) { context.getServletContext().setAttribute(CONF_CONTEXT_ATTRIBUTE, conf); context.getServletContext().setAttribute(ADMINS_ACL, adminsAcl); }