Fix javadoc comments
This commit is contained in:
parent
ebfb45dd70
commit
eb5e25ce1e
|
@ -28,19 +28,21 @@ import org.eclipse.jetty.util.component.LifeCycle;
|
|||
*/
|
||||
public interface SessionIdManager extends LifeCycle
|
||||
{
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* @param id The plain session ID (ie no workername extension)
|
||||
* @return True if the session ID is in use by at least one context.
|
||||
*/
|
||||
public boolean isIdInUse(String id);
|
||||
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* Notify the sessionid manager that a particular session id is in use
|
||||
* @param the session whose id is being used
|
||||
* @param session the session whose id is being used
|
||||
*/
|
||||
public void useId (Session session);
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* Remove id
|
||||
* @param id the plain session id (no workername extension) of the session to remove
|
||||
|
@ -48,6 +50,8 @@ public interface SessionIdManager extends LifeCycle
|
|||
*/
|
||||
public boolean removeId (String id);
|
||||
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* Invalidate all sessions on all contexts that share the same id.
|
||||
*
|
||||
|
@ -55,6 +59,7 @@ public interface SessionIdManager extends LifeCycle
|
|||
*/
|
||||
public void expireAll(String id);
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* Create a new Session ID.
|
||||
*
|
||||
|
@ -65,7 +70,10 @@ public interface SessionIdManager extends LifeCycle
|
|||
public String newSessionId(HttpServletRequest request,long created);
|
||||
|
||||
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* @return the unique name of this server instance
|
||||
*/
|
||||
public String getWorkerName();
|
||||
|
||||
|
||||
|
|
|
@ -32,11 +32,22 @@ public abstract class AbstractSessionDataStore extends AbstractLifeCycle impleme
|
|||
protected SessionContext _context; //context associated with this session data store
|
||||
|
||||
|
||||
/**
|
||||
* Store the session data persistently.
|
||||
*
|
||||
* @param id identity of session to store
|
||||
* @param data info of the session
|
||||
* @param isNew has session been written out before or not
|
||||
* @throws Exception
|
||||
*/
|
||||
public abstract void doStore(String id, SessionData data, boolean isNew) throws Exception;
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @see org.eclipse.jetty.server.session.SessionDataStore#initialize(org.eclipse.jetty.server.session.SessionContext)
|
||||
*/
|
||||
public void initialize (SessionContext context)
|
||||
{
|
||||
if (isStarted())
|
||||
|
@ -69,8 +80,9 @@ public abstract class AbstractSessionDataStore extends AbstractLifeCycle impleme
|
|||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @see org.eclipse.jetty.server.session.SessionDataStore#newSessionData(org.eclipse.jetty.server.session.SessionKey, long, long, long, long)
|
||||
* @see org.eclipse.jetty.server.session.SessionDataStore#newSessionData(java.lang.String, long, long, long, long)
|
||||
*/
|
||||
@Override
|
||||
public SessionData newSessionData(String id, long created, long accessed, long lastAccessed, long maxInactiveMs)
|
||||
|
@ -78,6 +90,9 @@ public abstract class AbstractSessionDataStore extends AbstractLifeCycle impleme
|
|||
return new SessionData(id, _context.getCanonicalContextPath(), _context.getVhost(), created, accessed, lastAccessed, maxInactiveMs);
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws IllegalStateException
|
||||
*/
|
||||
protected void checkStarted () throws IllegalStateException
|
||||
{
|
||||
if (isStarted())
|
||||
|
|
|
@ -58,12 +58,19 @@ public abstract class AbstractSessionIdManager extends AbstractLifeCycle impleme
|
|||
protected SessionScavenger _scavenger;
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* @param server the server associated with the id manager
|
||||
*/
|
||||
public AbstractSessionIdManager(Server server)
|
||||
{
|
||||
_server = server;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* @param server the server associated with the id manager
|
||||
* @param random a random number generator to use for ids
|
||||
*/
|
||||
public AbstractSessionIdManager(Server server, Random random)
|
||||
{
|
||||
this(server);
|
||||
|
@ -71,6 +78,9 @@ public abstract class AbstractSessionIdManager extends AbstractLifeCycle impleme
|
|||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* @param server the server associated with this id manager
|
||||
*/
|
||||
public void setServer (Server server)
|
||||
{
|
||||
_server = server;
|
||||
|
@ -78,7 +88,9 @@ public abstract class AbstractSessionIdManager extends AbstractLifeCycle impleme
|
|||
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
|
||||
/**
|
||||
* @return the server associated with this id manager
|
||||
*/
|
||||
public Server getServer ()
|
||||
{
|
||||
return _server;
|
||||
|
@ -88,7 +100,7 @@ public abstract class AbstractSessionIdManager extends AbstractLifeCycle impleme
|
|||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* @param scavenger
|
||||
* @param scavenger a SessionScavenger
|
||||
*/
|
||||
public void setSessionScavenger (SessionScavenger scavenger)
|
||||
{
|
||||
|
@ -103,7 +115,7 @@ public abstract class AbstractSessionIdManager extends AbstractLifeCycle impleme
|
|||
* Get the workname. If set, the workername is dot appended to the session
|
||||
* ID and can be used to assist session affinity in a load balancer.
|
||||
*
|
||||
* @return String or null
|
||||
* @return name or null
|
||||
*/
|
||||
@Override
|
||||
public String getWorkerName()
|
||||
|
@ -133,12 +145,18 @@ public abstract class AbstractSessionIdManager extends AbstractLifeCycle impleme
|
|||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* @return the random number generator
|
||||
*/
|
||||
public Random getRandom()
|
||||
{
|
||||
return _random;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* @param random a random number generator for generating ids
|
||||
*/
|
||||
public synchronized void setRandom(Random random)
|
||||
{
|
||||
_random=random;
|
||||
|
@ -166,7 +184,7 @@ public abstract class AbstractSessionIdManager extends AbstractLifeCycle impleme
|
|||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* Create a new session id if necessary.
|
||||
*
|
||||
*
|
||||
* @see org.eclipse.jetty.server.SessionIdManager#newSessionId(javax.servlet.http.HttpServletRequest, long)
|
||||
*/
|
||||
@Override
|
||||
|
@ -200,6 +218,10 @@ public abstract class AbstractSessionIdManager extends AbstractLifeCycle impleme
|
|||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* @param seedTerm
|
||||
* @return a new unique session id
|
||||
*/
|
||||
public String newSessionId(long seedTerm)
|
||||
{
|
||||
// pick a new unique ID!
|
||||
|
@ -249,6 +271,9 @@ public abstract class AbstractSessionIdManager extends AbstractLifeCycle impleme
|
|||
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* @see org.eclipse.jetty.util.component.AbstractLifeCycle#doStart()
|
||||
*/
|
||||
@Override
|
||||
protected void doStart() throws Exception
|
||||
{
|
||||
|
@ -268,6 +293,9 @@ public abstract class AbstractSessionIdManager extends AbstractLifeCycle impleme
|
|||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* @see org.eclipse.jetty.util.component.AbstractLifeCycle#doStop()
|
||||
*/
|
||||
@Override
|
||||
protected void doStop() throws Exception
|
||||
{
|
||||
|
@ -418,7 +446,7 @@ public abstract class AbstractSessionIdManager extends AbstractLifeCycle impleme
|
|||
/* ------------------------------------------------------------ */
|
||||
/** Get SessionManager for every context.
|
||||
*
|
||||
* @return
|
||||
* @return all session managers
|
||||
*/
|
||||
protected Set<SessionManager> getSessionManagers()
|
||||
{
|
||||
|
|
|
@ -50,7 +50,7 @@ public abstract class AbstractSessionStore extends AbstractLifeCycle implements
|
|||
/**
|
||||
* Create a new Session object from session data
|
||||
* @param data
|
||||
* @return
|
||||
* @return a new Session object
|
||||
*/
|
||||
public abstract Session newSession (SessionData data);
|
||||
|
||||
|
@ -59,7 +59,7 @@ public abstract class AbstractSessionStore extends AbstractLifeCycle implements
|
|||
/**
|
||||
* Get the session matching the key
|
||||
* @param id session id
|
||||
* @return
|
||||
* @return the Session object matching the id
|
||||
*/
|
||||
public abstract Session doGet(String id);
|
||||
|
||||
|
@ -79,7 +79,7 @@ public abstract class AbstractSessionStore extends AbstractLifeCycle implements
|
|||
/**
|
||||
* Check to see if the session exists in the store
|
||||
* @param id
|
||||
* @return
|
||||
* @return true if the Session object exists in the session store
|
||||
*/
|
||||
public abstract boolean doExists (String id);
|
||||
|
||||
|
@ -97,7 +97,7 @@ public abstract class AbstractSessionStore extends AbstractLifeCycle implements
|
|||
|
||||
/**
|
||||
* Get a list of keys for sessions that the store thinks has expired
|
||||
* @return
|
||||
* @return ids of all Session objects that might have expired
|
||||
*/
|
||||
public abstract Set<String> doGetExpiredCandidates();
|
||||
|
||||
|
@ -112,11 +112,17 @@ public abstract class AbstractSessionStore extends AbstractLifeCycle implements
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param manager
|
||||
*/
|
||||
public void setSessionManager (SessionManager manager)
|
||||
{
|
||||
_manager = manager;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the SessionManger
|
||||
*/
|
||||
public SessionManager getSessionManager()
|
||||
{
|
||||
return _manager;
|
||||
|
@ -124,6 +130,9 @@ public abstract class AbstractSessionStore extends AbstractLifeCycle implements
|
|||
|
||||
|
||||
|
||||
/**
|
||||
* @see org.eclipse.jetty.server.session.SessionStore#initialize(org.eclipse.jetty.server.session.SessionContext)
|
||||
*/
|
||||
public void initialize (SessionContext context)
|
||||
{
|
||||
if (isStarted())
|
||||
|
@ -131,6 +140,9 @@ public abstract class AbstractSessionStore extends AbstractLifeCycle implements
|
|||
_context = context;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.eclipse.jetty.util.component.AbstractLifeCycle#doStart()
|
||||
*/
|
||||
@Override
|
||||
protected void doStart() throws Exception
|
||||
{
|
||||
|
@ -149,6 +161,9 @@ public abstract class AbstractSessionStore extends AbstractLifeCycle implements
|
|||
super.doStart();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.eclipse.jetty.util.component.AbstractLifeCycle#doStop()
|
||||
*/
|
||||
@Override
|
||||
protected void doStop() throws Exception
|
||||
{
|
||||
|
@ -156,34 +171,47 @@ public abstract class AbstractSessionStore extends AbstractLifeCycle implements
|
|||
super.doStop();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the SessionDataStore or null if there isn't one
|
||||
*/
|
||||
public SessionDataStore getSessionDataStore()
|
||||
{
|
||||
return _sessionDataStore;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param sessionDataStore
|
||||
*/
|
||||
public void setSessionDataStore(SessionDataStore sessionDataStore)
|
||||
{
|
||||
_sessionDataStore = sessionDataStore;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the strategy for detecting stale sessions or null if there isn't one
|
||||
*/
|
||||
public StalenessStrategy getStaleStrategy()
|
||||
{
|
||||
return _staleStrategy;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param staleStrategy
|
||||
*/
|
||||
public void setStaleStrategy(StalenessStrategy staleStrategy)
|
||||
{
|
||||
_staleStrategy = staleStrategy;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get a session object.
|
||||
* Get a session object.
|
||||
*
|
||||
* If the session object is not in this session store, try getting
|
||||
* the data for it from a SessionDataStore associated with the
|
||||
* session manager.
|
||||
*
|
||||
* @see org.eclipse.jetty.server.session.SessionStore#get(java.lang.String)
|
||||
* @see org.eclipse.jetty.server.session.SessionStore#get(java.lang.String, boolean)
|
||||
*/
|
||||
@Override
|
||||
public Session get(String id, boolean staleCheck) throws Exception
|
||||
|
@ -292,7 +320,7 @@ public abstract class AbstractSessionStore extends AbstractLifeCycle implements
|
|||
|
||||
/**
|
||||
* @param session
|
||||
* @return
|
||||
* @return true or false according to the StaleStrategy
|
||||
*/
|
||||
public boolean isStale (Session session)
|
||||
{
|
||||
|
@ -319,6 +347,9 @@ public abstract class AbstractSessionStore extends AbstractLifeCycle implements
|
|||
|
||||
|
||||
|
||||
/**
|
||||
* @see org.eclipse.jetty.server.session.SessionStore#newSession(javax.servlet.http.HttpServletRequest, java.lang.String, long, long)
|
||||
*/
|
||||
@Override
|
||||
public Session newSession(HttpServletRequest request, String id, long time, long maxInactiveMs)
|
||||
{
|
||||
|
|
|
@ -74,7 +74,7 @@ public class CachingSessionDataStore extends AbstractSessionDataStore
|
|||
|
||||
|
||||
/**
|
||||
* @see org.eclipse.jetty.server.session.SessionDataStore#load(org.eclipse.jetty.server.session.SessionKey)
|
||||
* @see org.eclipse.jetty.server.session.SessionDataStore#load(java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public SessionData load(String id) throws Exception
|
||||
|
@ -101,8 +101,9 @@ public class CachingSessionDataStore extends AbstractSessionDataStore
|
|||
return d;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @see org.eclipse.jetty.server.session.SessionDataStore#delete(org.eclipse.jetty.server.session.SessionKey)
|
||||
* @see org.eclipse.jetty.server.session.SessionDataStore#delete(java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public boolean delete(String id) throws Exception
|
||||
|
@ -124,8 +125,9 @@ public class CachingSessionDataStore extends AbstractSessionDataStore
|
|||
return null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @see org.eclipse.jetty.server.session.AbstractSessionDataStore#doStore(org.eclipse.jetty.server.session.SessionKey, org.eclipse.jetty.server.session.SessionData, boolean)
|
||||
* @see org.eclipse.jetty.server.session.AbstractSessionDataStore#doStore(java.lang.String, org.eclipse.jetty.server.session.SessionData, boolean)
|
||||
*/
|
||||
@Override
|
||||
public void doStore(String id, SessionData data, boolean isNew) throws Exception
|
||||
|
|
|
@ -88,8 +88,9 @@ public class FileSessionDataStore extends AbstractSessionDataStore
|
|||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @see org.eclipse.jetty.server.session.SessionDataStore#delete(org.eclipse.jetty.server.session.SessionKey)
|
||||
* @see org.eclipse.jetty.server.session.SessionDataStore#delete(java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public boolean delete(String id) throws Exception
|
||||
|
@ -108,8 +109,9 @@ public class FileSessionDataStore extends AbstractSessionDataStore
|
|||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @see org.eclipse.jetty.server.session.SessionDataStore#getExpired()
|
||||
* @see org.eclipse.jetty.server.session.SessionDataStore#getExpired(java.util.Set)
|
||||
*/
|
||||
@Override
|
||||
public Set<String> getExpired(Set<String> candidates)
|
||||
|
@ -119,8 +121,9 @@ public class FileSessionDataStore extends AbstractSessionDataStore
|
|||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @see org.eclipse.jetty.server.session.SessionDataStore#load(org.eclipse.jetty.server.session.SessionKey)
|
||||
* @see org.eclipse.jetty.server.session.SessionDataStore#load(java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public SessionData load(String id) throws Exception
|
||||
|
@ -173,9 +176,8 @@ public class FileSessionDataStore extends AbstractSessionDataStore
|
|||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @see org.eclipse.jetty.server.session.AbstractSessionDataStore#doStore(org.eclipse.jetty.server.session.SessionKey, org.eclipse.jetty.server.session.SessionData)
|
||||
* @see org.eclipse.jetty.server.session.AbstractSessionDataStore#doStore(java.lang.String, org.eclipse.jetty.server.session.SessionData, boolean)
|
||||
*/
|
||||
@Override
|
||||
public void doStore(String id, SessionData data, boolean isNew) throws Exception
|
||||
|
@ -200,6 +202,9 @@ public class FileSessionDataStore extends AbstractSessionDataStore
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public void initializeStore ()
|
||||
{
|
||||
if (_storeDir == null)
|
||||
|
@ -219,6 +224,12 @@ public class FileSessionDataStore extends AbstractSessionDataStore
|
|||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* @param os the output stream to save to
|
||||
* @param id identity of the session
|
||||
* @param data the info of the session
|
||||
* @throws IOException
|
||||
*/
|
||||
private void save(OutputStream os, String id, SessionData data) throws IOException
|
||||
{
|
||||
DataOutputStream out = new DataOutputStream(os);
|
||||
|
@ -243,12 +254,21 @@ public class FileSessionDataStore extends AbstractSessionDataStore
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param id identity of session
|
||||
* @return
|
||||
*/
|
||||
private String getFileName (String id)
|
||||
{
|
||||
return _context.getCanonicalContextPath()+"_"+_context.getVhost()+"_"+id;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param is inputstream containing session data
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
private SessionData load (InputStream is)
|
||||
throws Exception
|
||||
{
|
||||
|
@ -289,6 +309,12 @@ public class FileSessionDataStore extends AbstractSessionDataStore
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param is inputstream containing session data
|
||||
* @param size number of attributes
|
||||
* @param data the data to restore to
|
||||
* @throws Exception
|
||||
*/
|
||||
private void restoreAttributes (InputStream is, int size, SessionData data)
|
||||
throws Exception
|
||||
{
|
||||
|
|
|
@ -54,8 +54,7 @@ public class HashSessionIdManager extends AbstractSessionIdManager
|
|||
|
||||
|
||||
/**
|
||||
* @see org.eclipse.jetty.server.SessionIdManager#useId(java.lang.String)
|
||||
* @param session the session whose id to use
|
||||
* @see org.eclipse.jetty.server.SessionIdManager#useId(org.eclipse.jetty.server.session.Session)
|
||||
*/
|
||||
@Override
|
||||
public void useId(Session session)
|
||||
|
|
|
@ -630,7 +630,7 @@ public class JDBCSessionDataStore extends AbstractSessionDataStore
|
|||
|
||||
|
||||
/**
|
||||
* @see org.eclipse.jetty.server.session.SessionDataStore#load(org.eclipse.jetty.server.session.SessionKey)
|
||||
* @see org.eclipse.jetty.server.session.SessionDataStore#load(java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public SessionData load(String id) throws Exception
|
||||
|
@ -748,7 +748,7 @@ public class JDBCSessionDataStore extends AbstractSessionDataStore
|
|||
|
||||
|
||||
/**
|
||||
* @see org.eclipse.jetty.server.session.AbstractSessionDataStore#doStore()
|
||||
* @see org.eclipse.jetty.server.session.AbstractSessionDataStore#doStore(java.lang.String, org.eclipse.jetty.server.session.SessionData, boolean)
|
||||
*/
|
||||
@Override
|
||||
public void doStore(String id, SessionData data, boolean isNew) throws Exception
|
||||
|
@ -849,8 +849,9 @@ public class JDBCSessionDataStore extends AbstractSessionDataStore
|
|||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @see org.eclipse.jetty.server.session.SessionDataStore#getExpired()
|
||||
* @see org.eclipse.jetty.server.session.SessionDataStore#getExpired(java.util.Set)
|
||||
*/
|
||||
@Override
|
||||
public Set<String> getExpired(Set<String> candidates)
|
||||
|
|
|
@ -160,10 +160,9 @@ public class JDBCSessionIdManager extends org.eclipse.jetty.server.session.Abstr
|
|||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Record the session id as being in use
|
||||
*
|
||||
* @see org.eclipse.jetty.server.SessionIdManager#useId(java.lang.String)
|
||||
* @see org.eclipse.jetty.server.SessionIdManager#useId(org.eclipse.jetty.server.session.Session)
|
||||
*/
|
||||
@Override
|
||||
public void useId (Session session)
|
||||
|
@ -225,7 +224,7 @@ public class JDBCSessionIdManager extends org.eclipse.jetty.server.session.Abstr
|
|||
/**
|
||||
* Insert a new used session id into the table.
|
||||
*
|
||||
* @param id
|
||||
* @param id the id to put into the table
|
||||
* @throws SQLException
|
||||
*/
|
||||
private void insert (String id)
|
||||
|
@ -254,7 +253,7 @@ public class JDBCSessionIdManager extends org.eclipse.jetty.server.session.Abstr
|
|||
/**
|
||||
* Remove a session id from the table.
|
||||
*
|
||||
* @param id
|
||||
* @param id the id to remove from the table
|
||||
* @throws SQLException
|
||||
*/
|
||||
private boolean delete (String id)
|
||||
|
@ -273,8 +272,8 @@ public class JDBCSessionIdManager extends org.eclipse.jetty.server.session.Abstr
|
|||
/**
|
||||
* Check if a session id exists.
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
* @param id the id to check
|
||||
* @return true if the id exists in the table, false otherwise
|
||||
* @throws SQLException
|
||||
*/
|
||||
private boolean exists (String id)
|
||||
|
@ -350,7 +349,7 @@ public class JDBCSessionIdManager extends org.eclipse.jetty.server.session.Abstr
|
|||
|
||||
/**
|
||||
* Get the database adaptor in order to configure it
|
||||
* @return
|
||||
* @return the database adpator
|
||||
*/
|
||||
public DatabaseAdaptor getDatabaseAdaptor ()
|
||||
{
|
||||
|
|
|
@ -51,11 +51,9 @@ public class MemorySessionStore extends AbstractSessionStore
|
|||
*/
|
||||
public class MemorySession extends Session
|
||||
{
|
||||
|
||||
/**
|
||||
* @param manager
|
||||
* @param request
|
||||
* @param data
|
||||
* @param request the request associated with the new session
|
||||
* @param data the info for the session
|
||||
*/
|
||||
public MemorySession(HttpServletRequest request, SessionData data)
|
||||
{
|
||||
|
@ -63,11 +61,8 @@ public class MemorySessionStore extends AbstractSessionStore
|
|||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @param manager
|
||||
* @param data
|
||||
* @param data the info for the restored session object
|
||||
*/
|
||||
public MemorySession(SessionData data)
|
||||
{
|
||||
|
@ -222,8 +217,9 @@ public class MemorySessionStore extends AbstractSessionStore
|
|||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @see org.eclipse.jetty.server.session.SessionStore#newSession(java.lang.String)
|
||||
* @see org.eclipse.jetty.server.session.AbstractSessionStore#newSession(javax.servlet.http.HttpServletRequest, java.lang.String, long, long)
|
||||
*/
|
||||
@Override
|
||||
public Session newSession(HttpServletRequest request, String id, long time, long maxInactiveMs)
|
||||
|
|
|
@ -38,9 +38,9 @@ public class NullSessionDataStore extends AbstractSessionDataStore
|
|||
return null;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @see org.eclipse.jetty.server.session.SessionDataStore#newSessionData(org.eclipse.jetty.server.session.SessionKey, long, long, long, long)
|
||||
* @see org.eclipse.jetty.server.session.AbstractSessionDataStore#newSessionData(java.lang.String, long, long, long, long)
|
||||
*/
|
||||
@Override
|
||||
public SessionData newSessionData(String id, long created, long accessed, long lastAccessed, long maxInactiveMs)
|
||||
|
@ -57,8 +57,9 @@ public class NullSessionDataStore extends AbstractSessionDataStore
|
|||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @see org.eclipse.jetty.server.session.AbstractSessionDataStore#doStore()
|
||||
* @see org.eclipse.jetty.server.session.AbstractSessionDataStore#doStore(java.lang.String, org.eclipse.jetty.server.session.SessionData, boolean)
|
||||
*/
|
||||
@Override
|
||||
public void doStore(String id, SessionData data, boolean isNew) throws Exception
|
||||
|
@ -66,8 +67,9 @@ public class NullSessionDataStore extends AbstractSessionDataStore
|
|||
//noop
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @see org.eclipse.jetty.server.session.SessionDataStore#getExpired()
|
||||
* @see org.eclipse.jetty.server.session.SessionDataStore#getExpired(java.util.Set)
|
||||
*/
|
||||
@Override
|
||||
public Set<String> getExpired(Set<String> candidates)
|
||||
|
|
|
@ -755,7 +755,7 @@ public class Session implements SessionManager.SessionIf
|
|||
|
||||
/* ------------------------------------------------------------- */
|
||||
/**
|
||||
* @see org.eclipse.jetty.server.session.AbstractSessionManager.SessionIf#getSession()
|
||||
* @see org.eclipse.jetty.server.session.SessionManager.SessionIf#getSession()
|
||||
*/
|
||||
@Override
|
||||
public Session getSession()
|
||||
|
|
|
@ -84,6 +84,9 @@ public class SessionData implements Serializable
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return time at which session was last written out
|
||||
*/
|
||||
public long getLastSaved()
|
||||
{
|
||||
return _lastSaved;
|
||||
|
@ -91,32 +94,53 @@ public class SessionData implements Serializable
|
|||
|
||||
|
||||
|
||||
/**
|
||||
* @param lastSaved
|
||||
*/
|
||||
public void setLastSaved(long lastSaved)
|
||||
{
|
||||
_lastSaved = lastSaved;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return true if a session needs to be written out
|
||||
*/
|
||||
public boolean isDirty()
|
||||
{
|
||||
return _dirty;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param dirty
|
||||
*/
|
||||
public void setDirty(boolean dirty)
|
||||
{
|
||||
_dirty = dirty;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param name
|
||||
* @return the value of the attribute named
|
||||
*/
|
||||
public Object getAttribute (String name)
|
||||
{
|
||||
return _attributes.get(name);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return a Set of attribute names
|
||||
*/
|
||||
public Set<String> getKeys()
|
||||
{
|
||||
return _attributes.keySet();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param name
|
||||
* @param value
|
||||
* @return
|
||||
*/
|
||||
public Object setAttribute (String name, Object value)
|
||||
{
|
||||
Object old = (value==null?_attributes.remove(name):_attributes.put(name,value));
|
||||
|
@ -128,6 +152,9 @@ public class SessionData implements Serializable
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param name
|
||||
*/
|
||||
public void setDirty (String name)
|
||||
{
|
||||
setDirty (true);
|
||||
|
@ -135,101 +162,161 @@ public class SessionData implements Serializable
|
|||
|
||||
|
||||
|
||||
/**
|
||||
* @param attributes
|
||||
*/
|
||||
public void putAllAttributes (Map<String,Object> attributes)
|
||||
{
|
||||
_attributes.putAll(attributes);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return an unmodifiable map of the attributes
|
||||
*/
|
||||
public Map<String,Object> getAllAttributes()
|
||||
{
|
||||
return Collections.unmodifiableMap(_attributes);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the id of the session
|
||||
*/
|
||||
public String getId()
|
||||
{
|
||||
return _id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param id
|
||||
*/
|
||||
public void setId(String id)
|
||||
{
|
||||
_id = id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the context path associated with this session
|
||||
*/
|
||||
public String getContextPath()
|
||||
{
|
||||
return _contextPath;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param contextPath
|
||||
*/
|
||||
public void setContextPath(String contextPath)
|
||||
{
|
||||
_contextPath = contextPath;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return virtual host of context associated with session
|
||||
*/
|
||||
public String getVhost()
|
||||
{
|
||||
return _vhost;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param vhost
|
||||
*/
|
||||
public void setVhost(String vhost)
|
||||
{
|
||||
_vhost = vhost;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return last node to manage the session
|
||||
*/
|
||||
public String getLastNode()
|
||||
{
|
||||
return _lastNode;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param lastNode
|
||||
*/
|
||||
public void setLastNode(String lastNode)
|
||||
{
|
||||
_lastNode = lastNode;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return time at which session expires
|
||||
*/
|
||||
public long getExpiry()
|
||||
{
|
||||
return _expiry;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param expiry
|
||||
*/
|
||||
public void setExpiry(long expiry)
|
||||
{
|
||||
_expiry = expiry;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
public long getCreated()
|
||||
{
|
||||
return _created;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param created
|
||||
*/
|
||||
public void setCreated(long created)
|
||||
{
|
||||
_created = created;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return time cookie was set
|
||||
*/
|
||||
public long getCookieSet()
|
||||
{
|
||||
return _cookieSet;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param cookieSet
|
||||
*/
|
||||
public void setCookieSet(long cookieSet)
|
||||
{
|
||||
_cookieSet = cookieSet;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return time session was accessed
|
||||
*/
|
||||
public long getAccessed()
|
||||
{
|
||||
return _accessed;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param accessed
|
||||
*/
|
||||
public void setAccessed(long accessed)
|
||||
{
|
||||
_accessed = accessed;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return previous time session was accessed
|
||||
*/
|
||||
public long getLastAccessed()
|
||||
{
|
||||
return _lastAccessed;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param lastAccessed
|
||||
*/
|
||||
public void setLastAccessed(long lastAccessed)
|
||||
{
|
||||
_lastAccessed = lastAccessed;
|
||||
|
@ -242,16 +329,26 @@ public class SessionData implements Serializable
|
|||
*/
|
||||
|
||||
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
public long getMaxInactiveMs()
|
||||
{
|
||||
return _maxInactiveMs;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param maxInactive
|
||||
*/
|
||||
public void setMaxInactiveMs(long maxInactive)
|
||||
{
|
||||
_maxInactiveMs = maxInactive;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param out
|
||||
* @throws IOException
|
||||
*/
|
||||
private void writeObject(java.io.ObjectOutputStream out) throws IOException
|
||||
{
|
||||
out.writeUTF(_id); //session id
|
||||
|
@ -269,6 +366,11 @@ public class SessionData implements Serializable
|
|||
out.writeObject(_attributes);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param in
|
||||
* @throws IOException
|
||||
* @throws ClassNotFoundException
|
||||
*/
|
||||
private void readObject(java.io.ObjectInputStream in) throws IOException, ClassNotFoundException
|
||||
{
|
||||
_id = in.readUTF();
|
||||
|
@ -286,6 +388,10 @@ public class SessionData implements Serializable
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param time
|
||||
* @return
|
||||
*/
|
||||
public boolean isExpiredAt (long time)
|
||||
{
|
||||
if (LOG.isDebugEnabled())
|
||||
|
|
|
@ -36,7 +36,7 @@ public interface SessionDataStore extends LifeCycle
|
|||
* given context. A SessionDataStore can only
|
||||
* be used by one context(/session manager).
|
||||
*
|
||||
* @param context
|
||||
* @param context context associated
|
||||
*/
|
||||
void initialize(SessionContext context);
|
||||
|
||||
|
@ -44,8 +44,8 @@ public interface SessionDataStore extends LifeCycle
|
|||
|
||||
/**
|
||||
* Read in session data from storage
|
||||
* @param id
|
||||
* @return
|
||||
* @param id identity of session to load
|
||||
* @return the SessionData matching the id
|
||||
* @throws Exception
|
||||
*/
|
||||
public SessionData load (String id) throws Exception;
|
||||
|
@ -53,7 +53,12 @@ public interface SessionDataStore extends LifeCycle
|
|||
|
||||
/**
|
||||
* Create a new SessionData
|
||||
* @return
|
||||
* @param id
|
||||
* @param created
|
||||
* @param accessed
|
||||
* @param lastAccessed
|
||||
* @param maxInactiveMs
|
||||
* @return a new SessionData object
|
||||
*/
|
||||
public SessionData newSessionData (String id, long created, long accessed, long lastAccessed, long maxInactiveMs);
|
||||
|
||||
|
@ -62,8 +67,8 @@ public interface SessionDataStore extends LifeCycle
|
|||
|
||||
/**
|
||||
* Write out session data to storage
|
||||
* @param id
|
||||
* @param data
|
||||
* @param id identity of session to store
|
||||
* @param data info of session to store
|
||||
* @throws Exception
|
||||
*/
|
||||
public void store (String id, SessionData data) throws Exception;
|
||||
|
@ -72,8 +77,8 @@ public interface SessionDataStore extends LifeCycle
|
|||
|
||||
/**
|
||||
* Delete session data from storage
|
||||
* @param id
|
||||
* @return
|
||||
* @param id identity of session to delete
|
||||
* @return true if the session was deleted from the permanent store
|
||||
* @throws Exception
|
||||
*/
|
||||
public boolean delete (String id) throws Exception;
|
||||
|
@ -88,7 +93,7 @@ public interface SessionDataStore extends LifeCycle
|
|||
* @param candidates if provided, these are keys of sessions that
|
||||
* the SessionStore thinks has expired and should be verified by the
|
||||
* SessionDataStore
|
||||
* @return
|
||||
* @return set of session ids
|
||||
*/
|
||||
public Set<String> getExpired (Set<String> candidates);
|
||||
|
||||
|
@ -96,7 +101,7 @@ public interface SessionDataStore extends LifeCycle
|
|||
|
||||
/**
|
||||
* True if this type of datastore will passivate session objects
|
||||
* @return
|
||||
* @return true if this store can passivate sessions, false otherwise
|
||||
*/
|
||||
public boolean isPassivating ();
|
||||
|
||||
|
|
Loading…
Reference in New Issue