cleaned up sessionIdManager setters
This commit is contained in:
parent
fc5e92c43f
commit
17ce8ec161
|
@ -1286,7 +1286,7 @@ public class Request implements HttpServletRequest
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
HttpSession session=getSession(false);
|
HttpSession session=getSession(false);
|
||||||
return (session != null && _sessionManager.getIdManager().getClusterId(_requestedSessionId).equals(_sessionManager.getClusterId(session)));
|
return (session != null && _sessionManager.getSessionIdManager().getClusterId(_requestedSessionId).equals(_sessionManager.getClusterId(session)));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
/* ------------------------------------------------------------ */
|
||||||
|
|
|
@ -187,14 +187,14 @@ public interface SessionManager extends LifeCycle
|
||||||
/* ------------------------------------------------------------ */
|
/* ------------------------------------------------------------ */
|
||||||
/**
|
/**
|
||||||
* @return the cross context session id manager.
|
* @return the cross context session id manager.
|
||||||
* @see #setIdManager(SessionIdManager)
|
* @see #setSessionIdManager(SessionIdManager)
|
||||||
*/
|
*/
|
||||||
public SessionIdManager getIdManager();
|
public SessionIdManager getSessionIdManager();
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
/* ------------------------------------------------------------ */
|
||||||
/**
|
/**
|
||||||
* @return the cross context session id manager.
|
* @return the cross context session id manager.
|
||||||
* @deprecated use {@link #getIdManager()}
|
* @deprecated use {@link #getSessionIdManager()}
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public SessionIdManager getMetaManager();
|
public SessionIdManager getMetaManager();
|
||||||
|
@ -204,9 +204,9 @@ public interface SessionManager extends LifeCycle
|
||||||
* Sets the cross context session id manager
|
* Sets the cross context session id manager
|
||||||
*
|
*
|
||||||
* @param idManager the cross context session id manager.
|
* @param idManager the cross context session id manager.
|
||||||
* @see #getIdManager()
|
* @see #getSessionIdManager()
|
||||||
*/
|
*/
|
||||||
public void setIdManager(SessionIdManager idManager);
|
public void setSessionIdManager(SessionIdManager idManager);
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
/* ------------------------------------------------------------ */
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -108,6 +108,18 @@ public abstract class AbstractSessionManager extends AbstractLifeCycle implement
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* ------------------------------------------------------------ */
|
||||||
|
public ContextHandler.Context getContext()
|
||||||
|
{
|
||||||
|
return _context;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ------------------------------------------------------------ */
|
||||||
|
public ContextHandler getContextHandler()
|
||||||
|
{
|
||||||
|
return _context.getContextHandler();
|
||||||
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
/* ------------------------------------------------------------ */
|
||||||
public HttpCookie access(HttpSession session,boolean secure)
|
public HttpCookie access(HttpSession session,boolean secure)
|
||||||
{
|
{
|
||||||
|
@ -237,7 +249,7 @@ public abstract class AbstractSessionManager extends AbstractLifeCycle implement
|
||||||
/* ------------------------------------------------------------ */
|
/* ------------------------------------------------------------ */
|
||||||
public HttpSession getHttpSession(String nodeId)
|
public HttpSession getHttpSession(String nodeId)
|
||||||
{
|
{
|
||||||
String cluster_id = getIdManager().getClusterId(nodeId);
|
String cluster_id = getSessionIdManager().getClusterId(nodeId);
|
||||||
|
|
||||||
AbstractSession session = getSession(cluster_id);
|
AbstractSession session = getSession(cluster_id);
|
||||||
if (session!=null && !session.getNodeId().equals(nodeId))
|
if (session!=null && !session.getNodeId().equals(nodeId))
|
||||||
|
@ -245,12 +257,21 @@ public abstract class AbstractSessionManager extends AbstractLifeCycle implement
|
||||||
return session;
|
return session;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
|
||||||
/* ------------------------------------------------------------ */
|
/* ------------------------------------------------------------ */
|
||||||
/**
|
/**
|
||||||
* @return Returns the metaManager used for cross context session management
|
* @return Returns the metaManager used for cross context session management
|
||||||
|
* @deprecated Use {@link #getSessionIdManager()}
|
||||||
*/
|
*/
|
||||||
public SessionIdManager getIdManager()
|
public SessionIdManager getIdManager()
|
||||||
|
{
|
||||||
|
return getSessionIdManager();
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ------------------------------------------------------------ */
|
||||||
|
/**
|
||||||
|
* @return Returns the SessionIdManager used for cross context session management
|
||||||
|
*/
|
||||||
|
public SessionIdManager getSessionIdManager()
|
||||||
{
|
{
|
||||||
return _sessionIdManager;
|
return _sessionIdManager;
|
||||||
}
|
}
|
||||||
|
@ -300,12 +321,12 @@ public abstract class AbstractSessionManager extends AbstractLifeCycle implement
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
/* ------------------------------------------------------------ */
|
||||||
/**
|
/**
|
||||||
* @deprecated use {@link #getIdManager()}
|
* @deprecated use {@link #getSessionIdManager()}
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public SessionIdManager getMetaManager()
|
public SessionIdManager getMetaManager()
|
||||||
{
|
{
|
||||||
return getIdManager();
|
return getSessionIdManager();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
/* ------------------------------------------------------------ */
|
||||||
|
@ -491,12 +512,21 @@ public abstract class AbstractSessionManager extends AbstractLifeCycle implement
|
||||||
_httpOnly=httpOnly;
|
_httpOnly=httpOnly;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* ------------------------------------------------------------ */
|
||||||
|
/**
|
||||||
|
* @param metaManager The metaManager used for cross context session management.
|
||||||
|
* @deprecated use {@link #setSessionIdManager(SessionIdManager)}
|
||||||
|
*/
|
||||||
|
public void setIdManager(SessionIdManager metaManager)
|
||||||
|
{
|
||||||
|
setSessionIdManager(metaManager);
|
||||||
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
/* ------------------------------------------------------------ */
|
||||||
/**
|
/**
|
||||||
* @param metaManager The metaManager used for cross context session management.
|
* @param metaManager The metaManager used for cross context session management.
|
||||||
*/
|
*/
|
||||||
public void setIdManager(SessionIdManager metaManager)
|
public void setSessionIdManager(SessionIdManager metaManager)
|
||||||
{
|
{
|
||||||
_sessionIdManager=metaManager;
|
_sessionIdManager=metaManager;
|
||||||
}
|
}
|
||||||
|
@ -522,12 +552,12 @@ public abstract class AbstractSessionManager extends AbstractLifeCycle implement
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
/* ------------------------------------------------------------ */
|
||||||
/**
|
/**
|
||||||
* @deprecated use {@link #setIdManager(SessionIdManager)}
|
* @deprecated use {@link #setSessionIdManager(SessionIdManager)}
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public void setMetaManager(SessionIdManager metaManager)
|
public void setMetaManager(SessionIdManager metaManager)
|
||||||
{
|
{
|
||||||
setIdManager(metaManager);
|
setSessionIdManager(metaManager);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
/* ------------------------------------------------------------ */
|
||||||
|
|
|
@ -105,7 +105,7 @@ public class JDBCSessionManager extends AbstractSessionManager
|
||||||
_created=System.currentTimeMillis();
|
_created=System.currentTimeMillis();
|
||||||
_accessed = _created;
|
_accessed = _created;
|
||||||
_attributes = new HashMap<String,Object>();
|
_attributes = new HashMap<String,Object>();
|
||||||
_lastNode = getIdManager().getWorkerName();
|
_lastNode = getSessionIdManager().getWorkerName();
|
||||||
}
|
}
|
||||||
|
|
||||||
public SessionData (String sessionId,Map<String,Object> attributes)
|
public SessionData (String sessionId,Map<String,Object> attributes)
|
||||||
|
@ -114,7 +114,7 @@ public class JDBCSessionManager extends AbstractSessionManager
|
||||||
_created=System.currentTimeMillis();
|
_created=System.currentTimeMillis();
|
||||||
_accessed = _created;
|
_accessed = _created;
|
||||||
_attributes = attributes;
|
_attributes = attributes;
|
||||||
_lastNode = getIdManager().getWorkerName();
|
_lastNode = getSessionIdManager().getWorkerName();
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized String getId ()
|
public synchronized String getId ()
|
||||||
|
@ -511,7 +511,7 @@ public class JDBCSessionManager extends AbstractSessionManager
|
||||||
" lastSaved="+(session==null?0:session._data._lastSaved)+
|
" lastSaved="+(session==null?0:session._data._lastSaved)+
|
||||||
" interval="+(_saveIntervalSec * 1000)+
|
" interval="+(_saveIntervalSec * 1000)+
|
||||||
" lastNode="+session._data.getLastNode()+
|
" lastNode="+session._data.getLastNode()+
|
||||||
" thisNode="+getIdManager().getWorkerName()+
|
" thisNode="+getSessionIdManager().getWorkerName()+
|
||||||
" difference="+(now - session._data._lastSaved));
|
" difference="+(now - session._data._lastSaved));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -533,13 +533,13 @@ public class JDBCSessionManager extends AbstractSessionManager
|
||||||
|
|
||||||
if (data != null)
|
if (data != null)
|
||||||
{
|
{
|
||||||
if (!data.getLastNode().equals(getIdManager().getWorkerName()) || session==null)
|
if (!data.getLastNode().equals(getSessionIdManager().getWorkerName()) || session==null)
|
||||||
{
|
{
|
||||||
//if the session has no expiry, or it is not already expired
|
//if the session has no expiry, or it is not already expired
|
||||||
if (data._expiryTime <= 0 || data._expiryTime > now)
|
if (data._expiryTime <= 0 || data._expiryTime > now)
|
||||||
{
|
{
|
||||||
Log.debug("getSession("+idInCluster+"): lastNode="+data.getLastNode()+" thisNode="+getIdManager().getWorkerName());
|
Log.debug("getSession("+idInCluster+"): lastNode="+data.getLastNode()+" thisNode="+getSessionIdManager().getWorkerName());
|
||||||
data.setLastNode(getIdManager().getWorkerName());
|
data.setLastNode(getSessionIdManager().getWorkerName());
|
||||||
//session last used on a different node, or we don't have it in memory
|
//session last used on a different node, or we don't have it in memory
|
||||||
session = new Session(now,data);
|
session = new Session(now,data);
|
||||||
_sessions.put(idInCluster, session);
|
_sessions.put(idInCluster, session);
|
||||||
|
@ -879,7 +879,7 @@ public class JDBCSessionManager extends AbstractSessionManager
|
||||||
data.setCanonicalContext(result.getString("contextPath"));
|
data.setCanonicalContext(result.getString("contextPath"));
|
||||||
data.setVirtualHost(result.getString("virtualHost"));
|
data.setVirtualHost(result.getString("virtualHost"));
|
||||||
|
|
||||||
InputStream is = ((JDBCSessionIdManager)getIdManager())._dbAdaptor.getBlobInputStream(result, "map");
|
InputStream is = ((JDBCSessionIdManager)getSessionIdManager())._dbAdaptor.getBlobInputStream(result, "map");
|
||||||
ClassLoadingObjectInputStream ois = new ClassLoadingObjectInputStream (is);
|
ClassLoadingObjectInputStream ois = new ClassLoadingObjectInputStream (is);
|
||||||
Object o = ois.readObject();
|
Object o = ois.readObject();
|
||||||
data.setAttributeMap((Map<String,Object>)o);
|
data.setAttributeMap((Map<String,Object>)o);
|
||||||
|
@ -942,7 +942,7 @@ public class JDBCSessionManager extends AbstractSessionManager
|
||||||
statement.setString(2, data.getId()); //session id
|
statement.setString(2, data.getId()); //session id
|
||||||
statement.setString(3, data.getCanonicalContext()); //context path
|
statement.setString(3, data.getCanonicalContext()); //context path
|
||||||
statement.setString(4, data.getVirtualHost()); //first vhost
|
statement.setString(4, data.getVirtualHost()); //first vhost
|
||||||
statement.setString(5, getIdManager().getWorkerName());//my node id
|
statement.setString(5, getSessionIdManager().getWorkerName());//my node id
|
||||||
statement.setLong(6, data.getAccessed());//accessTime
|
statement.setLong(6, data.getAccessed());//accessTime
|
||||||
statement.setLong(7, data.getLastAccessed()); //lastAccessTime
|
statement.setLong(7, data.getLastAccessed()); //lastAccessTime
|
||||||
statement.setLong(8, data.getCreated()); //time created
|
statement.setLong(8, data.getCreated()); //time created
|
||||||
|
@ -993,7 +993,7 @@ public class JDBCSessionManager extends AbstractSessionManager
|
||||||
long now = System.currentTimeMillis();
|
long now = System.currentTimeMillis();
|
||||||
connection.setAutoCommit(true);
|
connection.setAutoCommit(true);
|
||||||
statement = connection.prepareStatement(__updateSession);
|
statement = connection.prepareStatement(__updateSession);
|
||||||
statement.setString(1, getIdManager().getWorkerName());//my node id
|
statement.setString(1, getSessionIdManager().getWorkerName());//my node id
|
||||||
statement.setLong(2, data.getAccessed());//accessTime
|
statement.setLong(2, data.getAccessed());//accessTime
|
||||||
statement.setLong(3, data.getLastAccessed()); //lastAccessTime
|
statement.setLong(3, data.getLastAccessed()); //lastAccessTime
|
||||||
statement.setLong(4, now); //last saved time
|
statement.setLong(4, now); //last saved time
|
||||||
|
@ -1030,7 +1030,7 @@ public class JDBCSessionManager extends AbstractSessionManager
|
||||||
protected void updateSessionNode (SessionData data)
|
protected void updateSessionNode (SessionData data)
|
||||||
throws Exception
|
throws Exception
|
||||||
{
|
{
|
||||||
String nodeId = getIdManager().getWorkerName();
|
String nodeId = getSessionIdManager().getWorkerName();
|
||||||
Connection connection = getConnection();
|
Connection connection = getConnection();
|
||||||
PreparedStatement statement = null;
|
PreparedStatement statement = null;
|
||||||
try
|
try
|
||||||
|
@ -1067,7 +1067,7 @@ public class JDBCSessionManager extends AbstractSessionManager
|
||||||
long now = System.currentTimeMillis();
|
long now = System.currentTimeMillis();
|
||||||
connection.setAutoCommit(true);
|
connection.setAutoCommit(true);
|
||||||
statement = connection.prepareStatement(__updateSessionAccessTime);
|
statement = connection.prepareStatement(__updateSessionAccessTime);
|
||||||
statement.setString(1, getIdManager().getWorkerName());
|
statement.setString(1, getSessionIdManager().getWorkerName());
|
||||||
statement.setLong(2, data.getAccessed());
|
statement.setLong(2, data.getAccessed());
|
||||||
statement.setLong(3, data.getLastAccessed());
|
statement.setLong(3, data.getLastAccessed());
|
||||||
statement.setLong(4, now);
|
statement.setLong(4, now);
|
||||||
|
@ -1127,7 +1127,7 @@ public class JDBCSessionManager extends AbstractSessionManager
|
||||||
private Connection getConnection ()
|
private Connection getConnection ()
|
||||||
throws SQLException
|
throws SQLException
|
||||||
{
|
{
|
||||||
return ((JDBCSessionIdManager)getIdManager()).getConnection();
|
return ((JDBCSessionIdManager)getSessionIdManager()).getConnection();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -331,7 +331,7 @@ public class ResponseTest
|
||||||
request.setRequestedSessionId("12345");
|
request.setRequestedSessionId("12345");
|
||||||
request.setRequestedSessionIdFromCookie(false);
|
request.setRequestedSessionIdFromCookie(false);
|
||||||
AbstractSessionManager manager=new HashSessionManager();
|
AbstractSessionManager manager=new HashSessionManager();
|
||||||
manager.setIdManager(new HashSessionIdManager());
|
manager.setSessionIdManager(new HashSessionIdManager());
|
||||||
request.setSessionManager(manager);
|
request.setSessionManager(manager);
|
||||||
request.setSession(new TestSession(manager,"12345"));
|
request.setSession(new TestSession(manager,"12345"));
|
||||||
|
|
||||||
|
@ -379,7 +379,7 @@ public class ResponseTest
|
||||||
request.setRequestedSessionId("12345");
|
request.setRequestedSessionId("12345");
|
||||||
request.setRequestedSessionIdFromCookie(false);
|
request.setRequestedSessionIdFromCookie(false);
|
||||||
AbstractSessionManager manager=new HashSessionManager();
|
AbstractSessionManager manager=new HashSessionManager();
|
||||||
manager.setIdManager(new HashSessionIdManager());
|
manager.setSessionIdManager(new HashSessionIdManager());
|
||||||
request.setSessionManager(manager);
|
request.setSessionManager(manager);
|
||||||
request.setSession(new TestSession(manager,"12345"));
|
request.setSession(new TestSession(manager,"12345"));
|
||||||
manager.setCheckingRemoteSessionIdEncoding(false);
|
manager.setCheckingRemoteSessionIdEncoding(false);
|
||||||
|
|
|
@ -417,7 +417,7 @@ public class SessionHandlerTest
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public SessionIdManager getIdManager()
|
public SessionIdManager getSessionIdManager()
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -496,7 +496,7 @@ public class SessionHandlerTest
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setIdManager(SessionIdManager idManager)
|
public void setSessionIdManager(SessionIdManager idManager)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -79,7 +79,7 @@ public class JdbcTestServer extends AbstractTestServer
|
||||||
public SessionManager newSessionManager()
|
public SessionManager newSessionManager()
|
||||||
{
|
{
|
||||||
JDBCSessionManager manager = new JDBCSessionManager();
|
JDBCSessionManager manager = new JDBCSessionManager();
|
||||||
manager.setIdManager((JDBCSessionIdManager)_sessionIdManager);
|
manager.setSessionIdManager((JDBCSessionIdManager)_sessionIdManager);
|
||||||
manager.setSaveInterval(SAVE_INTERVAL); //ensure we save any changes to the session at least once per second
|
manager.setSaveInterval(SAVE_INTERVAL); //ensure we save any changes to the session at least once per second
|
||||||
return manager;
|
return manager;
|
||||||
}
|
}
|
||||||
|
|
|
@ -71,7 +71,7 @@ public abstract class AbstractTestServer
|
||||||
ServletContextHandler context = new ServletContextHandler(_contexts, contextPath);
|
ServletContextHandler context = new ServletContextHandler(_contexts, contextPath);
|
||||||
|
|
||||||
SessionManager sessionManager = newSessionManager();
|
SessionManager sessionManager = newSessionManager();
|
||||||
sessionManager.setIdManager(_sessionIdManager);
|
sessionManager.setSessionIdManager(_sessionIdManager);
|
||||||
sessionManager.setMaxInactiveInterval(_maxInactivePeriod);
|
sessionManager.setMaxInactiveInterval(_maxInactivePeriod);
|
||||||
|
|
||||||
SessionHandler sessionHandler = newSessionHandler(sessionManager);
|
SessionHandler sessionHandler = newSessionHandler(sessionManager);
|
||||||
|
@ -96,7 +96,7 @@ public abstract class AbstractTestServer
|
||||||
WebAppContext context = new WebAppContext(_contexts, warPath, contextPath);
|
WebAppContext context = new WebAppContext(_contexts, warPath, contextPath);
|
||||||
|
|
||||||
SessionManager sessionManager = newSessionManager();
|
SessionManager sessionManager = newSessionManager();
|
||||||
sessionManager.setIdManager(_sessionIdManager);
|
sessionManager.setSessionIdManager(_sessionIdManager);
|
||||||
sessionManager.setMaxInactiveInterval(_maxInactivePeriod);
|
sessionManager.setMaxInactiveInterval(_maxInactivePeriod);
|
||||||
|
|
||||||
SessionHandler sessionHandler = newSessionHandler(sessionManager);
|
SessionHandler sessionHandler = newSessionHandler(sessionManager);
|
||||||
|
|
Loading…
Reference in New Issue