use of org.eclipse.jetty.server.session.SessionHandler in project camel by apache.
the class WebsocketComponent method createStaticResourcesServer.
protected Server createStaticResourcesServer(Server server, ServletContextHandler context, String home) throws Exception {
context.setContextPath("/");
SessionHandler sh = new SessionHandler();
context.setSessionHandler(sh);
if (home != null) {
String[] resources = home.split(":");
if (LOG.isDebugEnabled()) {
LOG.debug(">>> Protocol found: " + resources[0] + ", and resource: " + resources[1]);
}
if (resources[0].equals("classpath")) {
context.setBaseResource(new JettyClassPathResource(getCamelContext().getClassResolver(), resources[1]));
} else if (resources[0].equals("file")) {
context.setBaseResource(Resource.newResource(resources[1]));
}
DefaultServlet defaultServlet = new DefaultServlet();
ServletHolder holder = new ServletHolder(defaultServlet);
// avoid file locking on windows
// http://stackoverflow.com/questions/184312/how-to-make-jetty-dynamically-load-static-pages
holder.setInitParameter("useFileMappedBuffer", "false");
context.addServlet(holder, "/");
}
server.setHandler(context);
return server;
}
use of org.eclipse.jetty.server.session.SessionHandler in project Activiti by Activiti.
the class TestServerUtil method getServletContextHandler.
private static ServletContextHandler getServletContextHandler(AnnotationConfigWebApplicationContext context) throws IOException {
ServletContextHandler contextHandler = new ServletContextHandler();
WebConfigurer configurer = new WebConfigurer();
configurer.setContext(context);
contextHandler.addEventListener(configurer);
// Create the SessionHandler (wrapper) to handle the sessions
HashSessionManager manager = new HashSessionManager();
SessionHandler sessions = new SessionHandler(manager);
contextHandler.setHandler(sessions);
return contextHandler;
}
use of org.eclipse.jetty.server.session.SessionHandler in project Activiti by Activiti.
the class BaseJPARestTestCase method getServletContextHandler.
private static ServletContextHandler getServletContextHandler(AnnotationConfigWebApplicationContext context) throws IOException {
ServletContextHandler contextHandler = new ServletContextHandler();
JPAWebConfigurer configurer = new JPAWebConfigurer();
configurer.setContext(context);
contextHandler.addEventListener(configurer);
// Create the SessionHandler (wrapper) to handle the sessions
HashSessionManager manager = new HashSessionManager();
SessionHandler sessions = new SessionHandler(manager);
contextHandler.setHandler(sessions);
return contextHandler;
}
use of org.eclipse.jetty.server.session.SessionHandler in project camel by apache.
the class HttpProducerSessionTest method initServer.
@BeforeClass
public static void initServer() throws Exception {
port = AvailablePortFinder.getNextAvailable(24000);
localServer = new Server(new InetSocketAddress("127.0.0.1", port));
ContextHandler contextHandler = new ContextHandler();
contextHandler.setContextPath("/session");
SessionHandler sessionHandler = new SessionHandler();
sessionHandler.setHandler(new SessionReflectionHandler());
contextHandler.setHandler(sessionHandler);
localServer.setHandler(contextHandler);
localServer.start();
}
use of org.eclipse.jetty.server.session.SessionHandler in project felix by apache.
the class JettyService method configureSessionManager.
private void configureSessionManager(final ServletContextHandler context) throws Exception {
final SessionHandler sessionHandler = context.getSessionHandler();
sessionHandler.setMaxInactiveInterval(this.config.getSessionTimeout() * 60);
sessionHandler.setSessionIdPathParameterName(this.config.getProperty(JettyConfig.FELIX_JETTY_SERVLET_SESSION_ID_PATH_PARAMETER_NAME, SessionHandler.__DefaultSessionIdPathParameterName));
sessionHandler.setCheckingRemoteSessionIdEncoding(this.config.getBooleanProperty(JettyConfig.FELIX_JETTY_SERVLET_CHECK_REMOTE_SESSION_ENCODING, true));
sessionHandler.setSessionTrackingModes(Collections.singleton(SessionTrackingMode.COOKIE));
final SessionCookieConfig cookieConfig = sessionHandler.getSessionCookieConfig();
cookieConfig.setName(this.config.getProperty(JettyConfig.FELIX_JETTY_SERVLET_SESSION_COOKIE_NAME, SessionHandler.__DefaultSessionCookie));
cookieConfig.setDomain(this.config.getProperty(JettyConfig.FELIX_JETTY_SERVLET_SESSION_DOMAIN, SessionHandler.__DefaultSessionDomain));
cookieConfig.setPath(this.config.getProperty(JettyConfig.FELIX_JETTY_SERVLET_SESSION_PATH, context.getContextPath()));
cookieConfig.setMaxAge(this.config.getIntProperty(JettyConfig.FELIX_JETTY_SERVLET_SESSION_MAX_AGE, -1));
cookieConfig.setHttpOnly(this.config.getBooleanProperty(JettyConfig.FELIX_JETTY_SESSION_COOKIE_HTTP_ONLY, true));
cookieConfig.setSecure(this.config.getBooleanProperty(JettyConfig.FELIX_JETTY_SESSION_COOKIE_SECURE, false));
}
Aggregations