From f6c1ade82f2f84b16996207cf95dee0cd2b83ab3 Mon Sep 17 00:00:00 2001 From: Jan Bartel Date: Thu, 18 Oct 2012 14:40:22 +1100 Subject: [PATCH] Refactor AbstractSession to remove _jdbcAttributes --- .../jetty/server/session/AbstractSession.java | 15 ++++++++-- .../server/session/JDBCSessionManager.java | 29 ++++++++++--------- 2 files changed, 28 insertions(+), 16 deletions(-) diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/session/AbstractSession.java b/jetty-server/src/main/java/org/eclipse/jetty/server/session/AbstractSession.java index d3dab5fd14a..a23f399feba 100644 --- a/jetty-server/src/main/java/org/eclipse/jetty/server/session/AbstractSession.java +++ b/jetty-server/src/main/java/org/eclipse/jetty/server/session/AbstractSession.java @@ -65,8 +65,7 @@ public abstract class AbstractSession implements AbstractSessionManager.SessionI private boolean _newSession; private int _requests; - // TODO remove this. - protected final Map _jdbcAttributes=_attributes; + /* ------------------------------------------------------------- */ protected AbstractSession(AbstractSessionManager abstractSessionManager, HttpServletRequest request) @@ -255,6 +254,18 @@ public abstract class AbstractSession implements AbstractSessionManager.SessionI return (String[])_attributes.keySet().toArray(a); } } + + /* ------------------------------------------------------------ */ + protected Map getAttributeMap () + { + return _attributes; + } + + /* ------------------------------------------------------------ */ + protected void addAttributes(Map map) + { + _attributes.putAll(map); + } /* ------------------------------------------------------------ */ protected boolean access(long time) diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/session/JDBCSessionManager.java b/jetty-server/src/main/java/org/eclipse/jetty/server/session/JDBCSessionManager.java index 16a39b4af63..74cb9b849d5 100644 --- a/jetty-server/src/main/java/org/eclipse/jetty/server/session/JDBCSessionManager.java +++ b/jetty-server/src/main/java/org/eclipse/jetty/server/session/JDBCSessionManager.java @@ -265,7 +265,8 @@ public class JDBCSessionManager extends AbstractSessionManager private static final long serialVersionUID = 5208464051134226143L; private final SessionData _data; private boolean _dirty=false; - + + /** * Session from a request. * @@ -274,7 +275,7 @@ public class JDBCSessionManager extends AbstractSessionManager protected Session (HttpServletRequest request) { super(JDBCSessionManager.this,request); - _data = new SessionData(getClusterId(),_jdbcAttributes); + _data = new SessionData(getClusterId(),getAttributeMap()); if (_dftMaxIdleSecs>0) _data.setMaxIdleMs(_dftMaxIdleSecs*1000L); _data.setCanonicalContext(canonicalize(_context.getContextPath())); @@ -284,18 +285,18 @@ public class JDBCSessionManager extends AbstractSessionManager } /** - * Session restored in database. - * @param data - */ - protected Session (long accessed, SessionData data) - { - super(JDBCSessionManager.this,data.getCreated(), accessed, data.getId()); - _data=data; - if (_dftMaxIdleSecs>0) - _data.setMaxIdleMs(_dftMaxIdleSecs*1000L); - _jdbcAttributes.putAll(_data.getAttributeMap()); - _data.setAttributeMap(_jdbcAttributes); - } + * Session restored in database. + * @param data + */ + protected Session (long accessed, SessionData data) + { + super(JDBCSessionManager.this,data.getCreated(), accessed, data.getId()); + _data=data; + if (_dftMaxIdleSecs>0) + _data.setMaxIdleMs(_dftMaxIdleSecs*1000L); + addAttributes(_data.getAttributeMap()); + _data.setAttributeMap(getAttributeMap()); + } @Override public void setAttribute (String name, Object value)