From 49ce555add153d5ffcfe0516fd7665db05dcc42b Mon Sep 17 00:00:00 2001 From: Jan Bartel Date: Thu, 19 May 2016 13:01:38 +1000 Subject: [PATCH] Ensure SessionCache and SessionDataStore are managed as beans --- .../jetty/server/session/AbstractSessionCache.java | 10 ++++------ .../jetty/server/session/SessionHandler.java | 14 ++++++-------- 2 files changed, 10 insertions(+), 14 deletions(-) diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/session/AbstractSessionCache.java b/jetty-server/src/main/java/org/eclipse/jetty/server/session/AbstractSessionCache.java index bd4b1ab91f4..dc29116ef64 100644 --- a/jetty-server/src/main/java/org/eclipse/jetty/server/session/AbstractSessionCache.java +++ b/jetty-server/src/main/java/org/eclipse/jetty/server/session/AbstractSessionCache.java @@ -25,7 +25,7 @@ import java.util.Set; import javax.servlet.http.HttpServletRequest; import org.eclipse.jetty.util.StringUtil; -import org.eclipse.jetty.util.component.AbstractLifeCycle; +import org.eclipse.jetty.util.component.ContainerLifeCycle; import org.eclipse.jetty.util.log.Log; import org.eclipse.jetty.util.log.Logger; import org.eclipse.jetty.util.thread.Locker.Lock; @@ -51,7 +51,7 @@ import org.eclipse.jetty.util.thread.Locker.Lock; * passivated before eviction from the cache. * */ -public abstract class AbstractSessionCache extends AbstractLifeCycle implements SessionCache +public abstract class AbstractSessionCache extends ContainerLifeCycle implements SessionCache { final static Logger LOG = Log.getLogger("org.eclipse.jetty.server.session"); @@ -204,10 +204,7 @@ public abstract class AbstractSessionCache extends AbstractLifeCycle implements if (_context == null) throw new IllegalStateException ("No ContextId"); - _sessionDataStore.initialize(_context); - _sessionDataStore.start(); - - + _sessionDataStore.initialize(_context); super.doStart(); } @@ -234,6 +231,7 @@ public abstract class AbstractSessionCache extends AbstractLifeCycle implements */ public void setSessionDataStore(SessionDataStore sessionStore) { + updateBean(_sessionDataStore, sessionStore); _sessionDataStore = sessionStore; } diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/session/SessionHandler.java b/jetty-server/src/main/java/org/eclipse/jetty/server/session/SessionHandler.java index c9fb387dbaa..6d6fe4fb2f8 100644 --- a/jetty-server/src/main/java/org/eclipse/jetty/server/session/SessionHandler.java +++ b/jetty-server/src/main/java/org/eclipse/jetty/server/session/SessionHandler.java @@ -412,11 +412,7 @@ public class SessionHandler extends ScopedHandler if (_sessionCache == null) { SessionCacheFactory ssFactory = server.getBean(SessionCacheFactory.class); - if (ssFactory != null) - _sessionCache = ssFactory.getSessionCache(this); - else - _sessionCache = new DefaultSessionCache(this); - + setSessionCache(ssFactory != null?ssFactory.getSessionCache(this):new DefaultSessionCache(this)); SessionDataStore sds = null; SessionDataStoreFactory sdsFactory = server.getBean(SessionDataStoreFactory.class); if (sdsFactory != null) @@ -499,10 +495,8 @@ public class SessionHandler extends ScopedHandler _checkingRemoteSessionIdEncoding=Boolean.parseBoolean(tmp); } - _sessionContext = new SessionContext(_sessionIdManager.getWorkerName(), _context); - + _sessionContext = new SessionContext(_sessionIdManager.getWorkerName(), _context); _sessionCache.initialize(_sessionContext); - _sessionCache.start(); super.doStart(); } @@ -1008,8 +1002,12 @@ public class SessionHandler extends ScopedHandler } + /** + * @param cache + */ public void setSessionCache (SessionCache cache) { + updateBean(_sessionCache, cache); _sessionCache = cache; }