Refactor AbstractSession to remove _jdbcAttributes

This commit is contained in:
Jan Bartel 2012-10-18 14:40:22 +11:00
parent bf1966ca94
commit f6c1ade82f
2 changed files with 28 additions and 16 deletions

View File

@ -65,8 +65,7 @@ public abstract class AbstractSession implements AbstractSessionManager.SessionI
private boolean _newSession;
private int _requests;
// TODO remove this.
protected final Map<String,Object> _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<String,Object> getAttributeMap ()
{
return _attributes;
}
/* ------------------------------------------------------------ */
protected void addAttributes(Map<String,Object> map)
{
_attributes.putAll(map);
}
/* ------------------------------------------------------------ */
protected boolean access(long time)

View File

@ -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)