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 spring-boot by spring-projects.
the class JettyServletWebServerFactory method configureSession.
private void configureSession(WebAppContext context) {
SessionHandler handler = context.getSessionHandler();
handler.setMaxInactiveInterval(getSessionTimeout() > 0 ? getSessionTimeout() : -1);
if (isPersistSession()) {
DefaultSessionCache cache = new DefaultSessionCache(handler);
FileSessionDataStore store = new FileSessionDataStore();
store.setStoreDir(getValidSessionStoreDir());
cache.setSessionDataStore(store);
handler.setSessionCache(cache);
}
}
use of org.eclipse.jetty.server.session.SessionHandler in project dropwizard-shiro by silb.
the class ApiApplication method run.
@Override
public void run(ApiConfiguration configuration, Environment environment) throws Exception {
environment.jersey().register(new UserFactory());
environment.jersey().register(new ShiroExceptionMapper());
environment.getApplicationContext().setSessionHandler(new SessionHandler());
for (Object resource : IntegrationTestApplication.createAllIntegrationTestResources()) {
environment.jersey().register(resource);
}
}
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;
}
Aggregations