@Override public ServletContext getServletContext() { return this.contextHandler.getServletContext(); }
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); }
public static void main(String[] args) throws Exception { final ServletContextHandler context = new ServletContextHandler(ServletContextHandler.SESSIONS); context.setContextPath("/"); context.setResourceBase(System.getProperty("java.io.tmpdir")); DynamicConfig config = DynamicConfigLoader.load("metaserver.properties"); final ServerWrapper wrapper = new ServerWrapper(config); wrapper.start(context.getServletContext()); context.addServlet(MetaServerAddressSupplierServlet.class, "/meta/address"); context.addServlet(MetaManagementServlet.class, "/management"); context.addServlet(SubjectConsumerServlet.class, "/subject/consumers"); context.addServlet(OnOfflineServlet.class, "/onoffline"); // TODO(keli.wang): allow set port use env int port = config.getInt("meta.server.discover.port", 8080); final Server server = new Server(port); server.setHandler(context); server.start(); server.join(); } }
.getServletContext().getAttribute(NativeWebSocketConfiguration.class.getName()); for (String path : webSocketHandlers.keySet()) { WebSocketCreator webSocketCreator = WebSocketCreatorFactory.create(webSocketHandlers.get(path));
ServletManager.getInstance().addServletContext(url.getParameter(Constants.BIND_PORT_KEY, url.getPort()), context.getServletContext());
ServletManager.getInstance().addServletContext(url.getParameter(Constants.BIND_PORT_KEY, url.getPort()), context.getServletContext());
setContextAttributes(genCtx.getServletContext(), b.contextAttrs); genCtx.addServlet(ProfileOutputServlet.class, "/*"); genCtx.setResourceBase(tmpDir.toAbsolutePath().toString()); ServletContextHandler logCtx = new ServletContextHandler(contexts, "/logs"); setContextAttributes(logCtx.getServletContext(), b.contextAttrs); logCtx.addServlet(AdminAuthorizedServlet.class, "/*"); logCtx.setResourceBase(logDir);
/** Get the {@link ServletContext}. * Adding new servlets is possible with care. */ public ServletContext getServletContext() { return ((ServletContextHandler)server.getHandler()).getServletContext(); }
/** Get the {@link ServletContext}. * Adding new servlets is possible with care. */ public ServletContext getServletContext() { return ((ServletContextHandler)server.getHandler()).getServletContext(); }
/** Get the {@link ServletContext}. * Adding new servlets is possible with care. */ public ServletContext getServletContext() { return ((ServletContextHandler)server.getHandler()).getServletContext(); }
public void resetFactories() { LOG.debug("reset >>"); ResourceBinder binder = (ResourceBinder)context.getServletContext().getAttribute(ResourceBinder.class.getName()); ((ResourceBinderImpl)binder).clear(); ApplicationProviderBinder providerBinder = (ApplicationProviderBinder)context.getServletContext().getAttribute(ApplicationProviderBinder.class.getName()); ApplicationProviderBinderHelper.resetApplicationProviderBinder(providerBinder); }
public void publish(Application application){ ResourceBinder binder = (ResourceBinder)context.getServletContext().getAttribute(ResourceBinder.class.getName()); ApplicationProviderBinder providerBinder = (ApplicationProviderBinder)context.getServletContext().getAttribute(ApplicationProviderBinder.class.getName()); ApplicationPublisher applicationPublisher = new ApplicationPublisher(binder, providerBinder); applicationPublisher.publish(application); }
/** Build a ServletContextHandler : one servlet context */ private ServletContextHandler buildServletContext() { ServletContextHandler handler = buildServletContext(contextPath); ServletContext cxt = handler.getServletContext(); adjustForFuseki(cxt); servletAttr.forEach((n,v)->cxt.setAttribute(n, v)); servletsAndFilters(handler); return handler; }
/** * @param app * The app object that handles the root of the URL. */ public JettyRunner(Object app) { server = new Server(); ServletContextHandler root = new ServletContextHandler(server, "/", ServletContextHandler.SESSIONS); root.addServlet(new ServletHolder(new Stapler()), "/*"); WebApp.get(root.getServletContext()).setApp(app); }
@Override protected void doStart() throws Exception { getServletContext().setAttribute(DecoratedObjectFactory.ATTR, _objFactory); super.doStart(); }
/** Build a ServletContextHandler : one servlet context */ private ServletContextHandler buildServletContext() { ServletContextHandler handler = buildServletContext(contextPath); ServletContext cxt = handler.getServletContext(); adjustForFuseki(cxt); servletAttr.forEach((n,v)->cxt.setAttribute(n, v)); servletsAndFilters(handler); return handler; }
public void publishPerRequestGroovyScript(String resourcePath, String name) { GroovyResourcePublisher groovyPublisher = (GroovyResourcePublisher)context.getServletContext().getAttribute(GroovyResourcePublisher.class.getName()); BaseResourceId publishedResourceId = new BaseResourceId(name); groovyPublisher.publishPerRequest(IoUtil.getResource(resourcePath), publishedResourceId, null, null, null); }
@Override public WebApplicationContext createWebContext(ApplicationContext rootContext, ServletContextHandler handler, Config config) { AnnotationConfigWebApplicationContext context = new AnnotationConfigWebApplicationContext(); context.setParent(rootContext); context.setServletContext(handler.getServletContext()); registerConfigClasses(context, config); context.refresh(); return context; }
protected ServletContextHandler createGraphAwareHandler(SessionManager sessionManager, ApplicationContext rootContext) { ServletContextHandler context = new ServletContextHandler(ServletContextHandler.SESSIONS); context.setContextPath(getContextPath(config)); context.getSessionHandler().setSessionManager(sessionManager); context.addLifeCycleListener(new JettyStartingListener(new WebAppInitializer(rootContext, getPackagesToScan(config)), context.getServletContext())); context.addFilter(new FilterHolder(txFilter), "/*", EnumSet.allOf(DispatcherType.class)); addDefaultFilters(context); return context; }