Search in sources :

Example 36 with SessionHandler

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;
}
Also used : SessionHandler(org.eclipse.jetty.server.session.SessionHandler) ServletHolder(org.eclipse.jetty.servlet.ServletHolder) DefaultServlet(org.eclipse.jetty.servlet.DefaultServlet)

Example 37 with SessionHandler

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);
    }
}
Also used : SessionHandler(org.eclipse.jetty.server.session.SessionHandler) DefaultSessionCache(org.eclipse.jetty.server.session.DefaultSessionCache) FileSessionDataStore(org.eclipse.jetty.server.session.FileSessionDataStore)

Example 38 with SessionHandler

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);
    }
}
Also used : SessionHandler(org.eclipse.jetty.server.session.SessionHandler) ShiroExceptionMapper(org.secnod.shiro.jaxrs.ShiroExceptionMapper) UserFactory(org.secnod.example.webapp.UserFactory)

Example 39 with SessionHandler

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;
}
Also used : SessionHandler(org.eclipse.jetty.server.session.SessionHandler) HashSessionManager(org.eclipse.jetty.server.session.HashSessionManager) WebConfigurer(org.activiti.rest.WebConfigurer) ServletContextHandler(org.eclipse.jetty.servlet.ServletContextHandler)

Example 40 with SessionHandler

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;
}
Also used : SessionHandler(org.eclipse.jetty.server.session.SessionHandler) JPAWebConfigurer(org.activiti.rest.JPAWebConfigurer) HashSessionManager(org.eclipse.jetty.server.session.HashSessionManager) ServletContextHandler(org.eclipse.jetty.servlet.ServletContextHandler)

Aggregations

SessionHandler (org.eclipse.jetty.server.session.SessionHandler)44 Server (org.eclipse.jetty.server.Server)13 ContextHandler (org.eclipse.jetty.server.handler.ContextHandler)11 ServletContextHandler (org.eclipse.jetty.servlet.ServletContextHandler)10 Test (org.junit.Test)10 IOException (java.io.IOException)9 ServletException (javax.servlet.ServletException)7 HttpServletResponse (javax.servlet.http.HttpServletResponse)5 HashSessionManager (org.eclipse.jetty.server.session.HashSessionManager)5 File (java.io.File)4 HttpServletRequest (javax.servlet.http.HttpServletRequest)4 HttpSession (javax.servlet.http.HttpSession)4 HttpConfiguration (org.eclipse.jetty.server.HttpConfiguration)4 AbstractHandler (org.eclipse.jetty.server.handler.AbstractHandler)4 ServletHolder (org.eclipse.jetty.servlet.ServletHolder)4 BeforeClass (org.junit.BeforeClass)4 ConstraintSecurityHandler (org.eclipse.jetty.security.ConstraintSecurityHandler)3 SecurityHandler (org.eclipse.jetty.security.SecurityHandler)3 Handler (org.eclipse.jetty.server.Handler)3 LocalConnector (org.eclipse.jetty.server.LocalConnector)3