diff options
Diffstat (limited to 'src/org')
-rw-r--r-- | src/org/traccar/web/WebServer.java | 19 |
1 files changed, 8 insertions, 11 deletions
diff --git a/src/org/traccar/web/WebServer.java b/src/org/traccar/web/WebServer.java index 8887b6af3..4bb88578f 100644 --- a/src/org/traccar/web/WebServer.java +++ b/src/org/traccar/web/WebServer.java @@ -20,11 +20,9 @@ import org.eclipse.jetty.http.HttpStatus; import org.eclipse.jetty.proxy.AsyncProxyServlet; import org.eclipse.jetty.server.Request; import org.eclipse.jetty.server.Server; -import org.eclipse.jetty.server.SessionManager; import org.eclipse.jetty.server.handler.ErrorHandler; import org.eclipse.jetty.server.handler.HandlerList; import org.eclipse.jetty.server.handler.ResourceHandler; -import org.eclipse.jetty.server.session.HashSessionManager; import org.eclipse.jetty.servlet.DefaultServlet; import org.eclipse.jetty.servlet.ServletContextHandler; import org.eclipse.jetty.servlet.ServletHolder; @@ -63,7 +61,7 @@ public class WebServer { private final Config config; private final DataSource dataSource; private final HandlerList handlers = new HandlerList(); - private final SessionManager sessionManager; + private int sessionTimeout; private void initServer() { @@ -79,12 +77,7 @@ public class WebServer { public WebServer(Config config, DataSource dataSource) { this.config = config; this.dataSource = dataSource; - - sessionManager = new HashSessionManager(); - int sessionTimeout = config.getInteger("web.sessionTimeout"); - if (sessionTimeout != 0) { - sessionManager.setMaxInactiveInterval(sessionTimeout); - } + sessionTimeout = config.getInteger("web.sessionTimeout"); initServer(); initApi(); @@ -158,7 +151,9 @@ public class WebServer { WebAppContext app = new WebAppContext(); app.setContextPath("/"); - app.getSessionHandler().setSessionManager(sessionManager); + if (sessionTimeout > 0) { + app.getSessionHandler().setMaxInactiveInterval(sessionTimeout); + } app.setWar(config.getString("web.application")); handlers.addHandler(app); } @@ -166,7 +161,9 @@ public class WebServer { private void initApi() { ServletContextHandler servletHandler = new ServletContextHandler(ServletContextHandler.SESSIONS); servletHandler.setContextPath("/api"); - servletHandler.getSessionHandler().setSessionManager(sessionManager); + if (sessionTimeout > 0) { + servletHandler.getSessionHandler().setMaxInactiveInterval(sessionTimeout); + } servletHandler.addServlet(new ServletHolder(new AsyncSocketServlet()), "/socket"); |