Search in sources :

Example 1 with HouseKeeper

use of org.eclipse.jetty.server.session.HouseKeeper in project ddf by codice.

the class JettySessionManagementTest method setupClass.

@BeforeClass
public static void setupClass() throws Exception {
    // To get the AccessRequestLog to log in the target folder
    System.setProperty("ddf.data", "target");
    server = new Server();
    HandlerList handlers = new HandlerList();
    server.setHandler(handlers);
    // Configure server according to the jetty.xml file
    XmlConfiguration configuration = new XmlConfiguration(JettySessionManagementTest.class.getResourceAsStream("/jetty-session.xml"));
    configuration.configure(server);
    // Have server bind to first available port
    ServerConnector connector = new ServerConnector(server);
    connector.setPort(0);
    server.addConnector(connector);
    ServletContextHandler context = new ServletContextHandler(null, "/context1", ServletContextHandler.SESSIONS);
    context.addServlet(new ServletHolder(new TestServlet()), "/");
    context.getSessionHandler().setMaxInactiveInterval(MAX_INACTIVE_INTERVAL_SECONDS);
    handlers.addHandler(context);
    ServletContextHandler context2 = new ServletContextHandler(null, "/context2", ServletContextHandler.SESSIONS);
    context2.addServlet(new ServletHolder(new TestServlet()), "/");
    context2.getSessionHandler().setMaxInactiveInterval(MAX_INACTIVE_INTERVAL_SECONDS);
    handlers.addHandler(context2);
    HouseKeeper houseKeeper = new HouseKeeper();
    houseKeeper.setIntervalSec(SCAVENGE_INTERVAL_SECONDS);
    server.getSessionIdManager().setSessionHouseKeeper(houseKeeper);
    server.start();
    port = connector.getLocalPort();
}
Also used : HandlerList(org.eclipse.jetty.server.handler.HandlerList) ServerConnector(org.eclipse.jetty.server.ServerConnector) Server(org.eclipse.jetty.server.Server) HouseKeeper(org.eclipse.jetty.server.session.HouseKeeper) ServletHolder(org.eclipse.jetty.servlet.ServletHolder) XmlConfiguration(org.eclipse.jetty.xml.XmlConfiguration) ServletContextHandler(org.eclipse.jetty.servlet.ServletContextHandler) BeforeClass(org.junit.BeforeClass)

Aggregations

Server (org.eclipse.jetty.server.Server)1 ServerConnector (org.eclipse.jetty.server.ServerConnector)1 HandlerList (org.eclipse.jetty.server.handler.HandlerList)1 HouseKeeper (org.eclipse.jetty.server.session.HouseKeeper)1 ServletContextHandler (org.eclipse.jetty.servlet.ServletContextHandler)1 ServletHolder (org.eclipse.jetty.servlet.ServletHolder)1 XmlConfiguration (org.eclipse.jetty.xml.XmlConfiguration)1 BeforeClass (org.junit.BeforeClass)1