Refine search
if(auth) LoklakServer.server.addBean(loginService); MultipartConfigElement multipartConfigDefault = new MultipartConfigElement(tmp.getAbsolutePath()); MultipartConfigElement multipartConfig = new MultipartConfigElement(tmp.getAbsolutePath(), multipartConfigDefault.getMaxFileSize(), multipartConfigDefault.getMaxRequestSize(), 1024 * 1024); // reduce IO using a non-zero fileSizeThreshold ServletContextHandler servletHandler = new ServletContextHandler(); for (Class<? extends Servlet> service: services) try { servletHandler.addServlet(service, ((APIHandler) (service.newInstance())).getAPIPath()); } catch (InstantiationException | IllegalAccessException e) { DAO.severe(service.getName() + " instantiation error", e); servletHandler.addServlet(DumpDownloadServlet.class, "/dump/*"); servletHandler.addServlet(ShortlinkFromTweetServlet.class, "/x"); servletHandler.addServlet(AccessServlet.class, "/api/access.json"); LoklakServer.server.setSessionIdManager(idmanager); SessionHandler sessions = new SessionHandler(new HashSessionManager()); sessions.setHandler(gzipHandler); securityHandler.setHandler(sessions); ipaccess.setHandler(securityHandler); LoklakServer.server.setHandler(ipaccess);
server = (Server) new XmlConfiguration(jettyInputStream).configure(); } else { server = new Server(port); server = new Server(port); webAppContext = new WebAppContext(); webAppContext.setInitParameter("org.eclipse.jetty.servlet.Default.useFileMappedBuffer", "false"); SessionManager sessionManager = webAppContext.getSessionHandler().getSessionManager(); sessionManager.setSessionIdPathParameterName(null); server.setHandler(webAppContext);
public WebServer(Config config) { initServer(config); ServletContextHandler servletHandler = new ServletContextHandler(ServletContextHandler.SESSIONS); int sessionTimeout = config.getInteger("web.sessionTimeout"); if (sessionTimeout > 0) { servletHandler.getSessionHandler().setMaxInactiveInterval(sessionTimeout); } initApi(config, servletHandler); if (config.getBoolean("web.console")) { servletHandler.addServlet(new ServletHolder(new ConsoleServlet()), "/console/*"); } initWebApp(config, servletHandler); servletHandler.setErrorHandler(new ErrorHandler() { @Override protected void handleErrorPage( HttpServletRequest request, Writer writer, int code, String message) throws IOException { writer.write("<!DOCTYPE<html><head><title>Error</title></head><html><body>" + code + " - " + HttpStatus.getMessage(code) + "</body></html>"); } }); HandlerList handlers = new HandlerList(); initClientProxy(config, handlers); handlers.addHandler(servletHandler); server.setHandler(handlers); }
private void initSessionManager() { idmanager = new DefaultSessionIdManager(server); server.setSessionIdManager(idmanager); SessionHandler sessions = new SessionHandler(); sessions.setSessionIdManager(idmanager); filters.addHandler(sessions); }
private void loadJAXRSResource( String mountPoint, JaxRsServletHolderFactory jaxRsServletHolderFactory ) { SessionHandler sessionHandler = new SessionHandler(); sessionHandler.setServer( getJetty() ); log.debug( "Mounting servlet at [%s]", mountPoint ); ServletContextHandler jerseyContext = new ServletContextHandler(); jerseyContext.setServer( getJetty() ); jerseyContext.setErrorHandler( new NeoJettyErrorHandler() ); jerseyContext.setContextPath( mountPoint ); jerseyContext.setSessionHandler( sessionHandler ); jerseyContext.addServlet( jaxRsServletHolderFactory.create( defaultInjectables, wadlEnabled ), "/*" ); addFiltersTo( jerseyContext ); handlers.addHandler( jerseyContext ); }
@Override public void setSessionConfig() { SessionHandler sessionHandler = webAppContext.getSessionHandler(); SessionCookieConfig sessionCookieConfig = sessionHandler.getSessionCookieConfig(); sessionCookieConfig.setHttpOnly(true); sessionCookieConfig.setSecure(systemEnvironment.isSessionCookieSecure()); sessionCookieConfig.setMaxAge(systemEnvironment.sessionCookieMaxAgeInSeconds()); sessionHandler.setMaxInactiveInterval(systemEnvironment.sessionTimeoutInSeconds()); }
/** * Starts the JETTY server */ public void run() { Server server = new Server(port); Handler handler = new Handler(); SessionHandler sh = new SessionHandler(); // org.eclipse.jetty.server.session.SessionHandler sh.setHandler(handler); server.setHandler(sh); // set session handle try { server.start(); server.join(); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } } }
public static void main(String[] args) { log.info("Server starting..."); Server embeddedServer = new Server(8080); ServletContextHandler contextHandler = new ServletContextHandler(null, "/", true, false); embeddedServer.setHandler(contextHandler); SessionHandler sessions = new SessionHandler(); contextHandler.setSessionHandler(sessions); ServletHolder servletHolder = new ServletHolder(AppServlet.class); contextHandler.addServlet(servletHolder, "/*"); try { embeddedServer.start(); embeddedServer.join(); } catch (Exception e) { log.error("Server error:\n", e); } log.info("Server stopped"); } }
Server server = new Server(8000); SimpleServlet h1 = new SimpleServlet("Servlet 1"); SimpleServlet h2 = new SimpleServlet("Servlet 2"); ServletContextHandler c = new ServletContextHandler(); c.setContextPath("/"); c.addServlet(new ServletHolder(h1), "/context1"); c.addServlet(new ServletHolder(h2), "/context2"); SessionHandler sh = new SessionHandler(); sh.setHandler(c); server.setHandler(sh);
Server server = new Server(8080); server.setSessionIdManager(idmanager); server.setHandler(context); sessions.setHandler(dump);
public void start() throws Exception { server = new Server(port); WebAppContext webAppContext = new WebAppContext(); webAppContext.setContextPath("/"); webAppContext.setWar("zenvisage.war"); webAppContext.setParentLoaderPriority(true); webAppContext.setServer(server); webAppContext.setClassLoader(ClassLoader.getSystemClassLoader()); webAppContext.getSessionHandler().getSessionManager() .setMaxInactiveInterval(10); server.setHandler(webAppContext); server.start(); // ZvMain zvMain = (ZvMain) SpringApplicationContext.getBean("zvMain"); // zvMain.loadData(); DatabaseAutoLoader databaseAutoLoader = new DatabaseAutoLoader(this); databaseAutoLoader.run(); }
private static ServletContextHandler setWebHttpApiHandler () { ConfigureAdaptor conf = ConfigureManager.getConfigure(); String providerPackages = "scouterx.webapp"; if (conf.isNetHttpApiSwaggerEnabled()) { providerPackages += ",io.swagger.jaxrs.listing"; } final ServletHolder jerseyHolder = new ServletHolder(ServletContainer.class); jerseyHolder.setInitParameter("javax.ws.rs.Application", "scouterx.webapp.main.WebAppMain"); jerseyHolder.setInitParameter("jersey.config.server.provider.packages", providerPackages); jerseyHolder.setInitOrder(1); final ServletContextHandler servletContextHandler = new ServletContextHandler(); servletContextHandler.setSessionHandler(new SessionHandler()); servletContextHandler.getSessionHandler().setMaxInactiveInterval(conf.getNetHttpApiSessionTimeout()); servletContextHandler.setContextPath("/"); servletContextHandler.addServlet(jerseyHolder, "/scouter/*"); servletContextHandler.addServlet(setStaticContentHandler(), "/*"); servletContextHandler.addServlet(setExtWebStaticContentHandler(), "/extweb/*"); servletContextHandler.addServlet(setSwaggerBootstrapHandler(), "/swagger"); addFilter(servletContextHandler); return servletContextHandler; }
if (configuration.getParent() != null) context = new ServletContextHandler(configuration.getParent(), configuration.getContextPath()); context = new ServletContextHandler(ServletContextHandler.SESSIONS); context.setContextPath(configuration.getContextPath()); context.setResourceBase(configuration.getWebapp().getAbsolutePath()); context.addServlet(DefaultServlet.class, configuration.getFilterPath()); context.getSessionHandler().setMaxInactiveInterval(configuration.getMaxInactiveInterval()); return context;
if (logDir != null && logsEnabled) { ServletContextHandler logContext = new ServletContextHandler(parent, "/logs"); logContext.setResourceBase(logDir); logContext.addServlet(AdminAuthorizedServlet.class, "/*"); if (conf.getBoolean( CommonConfigurationKeys.HADOOP_JETTY_LOGS_SERVE_ALIASES, logContext.setDisplayName("logs"); SessionHandler handler = new SessionHandler(); SessionManager sm = handler.getSessionManager(); if (sm instanceof AbstractSessionManager) { AbstractSessionManager asm = (AbstractSessionManager) sm; params.put("org.eclipse.jetty.servlet.Default.dirAllowed", "false"); params.put("org.eclipse.jetty.servlet.Default.gzip", "true"); SessionHandler handler = new SessionHandler(); SessionManager sm = handler.getSessionManager(); if (sm instanceof AbstractSessionManager) { AbstractSessionManager asm = (AbstractSessionManager) sm;
@Override public void configure(ServletContextHandler context) { context.setContextPath("/"); context.getSessionHandler().getSessionManager().setMaxInactiveInterval(serverConfig.getSessionTimeout()); context.setInitParameter(EnvironmentLoader.ENVIRONMENT_CLASS_PARAM, OneWebEnvironment.class.getName()); context.addEventListener(new EnvironmentLoaderListener()); FilterHolder shiroFilterHolder = new FilterHolder(shiroFilter); context.addServlet(imgServletHolder, "/img/*"); context.getSessionHandler().addEventListener(new HttpSessionListener() {
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; }
private ServletContextHandler createHttpContext(@SuppressWarnings("rawtypes") Dictionary dictionary) { ServletContextHandler httpContext = new ServletContextHandler(); // hack in the mime type for xsd until jetty fixes it (bug 393218) httpContext.getMimeTypes().addMimeMapping("xsd", "application/xml"); //$NON-NLS-1$ //$NON-NLS-2$ httpContext.setAttribute(INTERNAL_CONTEXT_CLASSLOADER, Thread.currentThread().getContextClassLoader()); httpContext.setClassLoader(this.getClass().getClassLoader()); httpContext.setContextPath(Details.getString(dictionary, JettyConstants.CONTEXT_PATH, "/")); //$NON-NLS-1$ File contextWorkDir = new File(workDir, DIR_PREFIX + dictionary.get(Constants.SERVICE_PID).hashCode()); contextWorkDir.mkdir(); httpContext.setAttribute(CONTEXT_TEMPDIR, contextWorkDir); SessionHandler handler = new SessionHandler(); handler.setMaxInactiveInterval(Details.getInt(dictionary, JettyConstants.CONTEXT_SESSIONINACTIVEINTERVAL, -1)); httpContext.setSessionHandler(handler); return httpContext; }
QueuedThreadPool threadPool = (QueuedThreadPool) webServer.getThreadPool(); threadPool.setDaemon(true); if (maxThreads != -1) { SessionManager sm = webAppContext.getSessionHandler().getSessionManager(); if (sm instanceof AbstractSessionManager) { AbstractSessionManager asm = (AbstractSessionManager)sm; final String appDir = getWebAppsPath(name); addDefaultApps(contexts, appDir, conf); webServer.setHandler(handlers);
/** * Gets the new servlet context handler. * * @param configuration * the configuration * @return the new servlet context handler */ public static ServletContextHandler getNewServletContextHandler( final ServletContextHandlerConfiguration configuration) { final ServletContextHandler context = new ServletContextHandler( ServletContextHandler.SESSIONS); context.setContextPath(configuration.getContextPath()); context.setResourceBase(configuration.getWebapp().getAbsolutePath()); context.getSessionHandler().setMaxInactiveInterval(configuration.getMaxInactiveInterval()); initializeFilterHolder(configuration, context); initializeServletHolder(configuration, context); for (final Entry<String, String> initParameter : configuration.getInitParameters() .entrySet()) { context.setInitParameter(initParameter.getKey(), initParameter.getValue()); } return context; }
checkRequestedSessionId(baseRequest,request); HttpCookie cookie = _sessionManager.access(session,request.isSecure()); if (cookie != null) // Handle changed ID or max-age refresh baseRequest.getResponse().addCookie(cookie); if (LOG.isDebugEnabled()) LOG.debug("sessionManager=" + _sessionManager); LOG.debug("session=" + session); _outerScope.doHandle(target,baseRequest,request,response); else doHandle(target,baseRequest,request,response); _sessionManager.complete(access); _sessionManager.complete(session);