public class QuercusSessionManager extends java.lang.Object implements AlarmListener
Modifier and Type | Field and Description |
---|---|
protected boolean |
_isClosed |
protected long |
_sessionCreateCount |
protected java.util.Iterator<SessionArrayValue> |
_sessionIter |
protected java.util.ArrayList<SessionArrayValue> |
_sessionList |
protected int |
_sessionMax |
protected LruCache<java.lang.String,SessionArrayValue> |
_sessions |
protected long |
_sessionTimeoutCount |
protected java.lang.Object |
_statisticsLock |
Constructor and Description |
---|
QuercusSessionManager(QuercusContext quercus)
Creates and initializes a new session manager.
|
Modifier and Type | Method and Description |
---|---|
void |
close()
Cleans up the sessions when the Application shuts down gracefully.
|
protected SessionArrayValue |
create(Env env,
java.lang.String key,
long now)
Creates a session.
|
SessionArrayValue |
createSession(Env env,
java.lang.String oldId,
long now)
Create a new session.
|
java.lang.String |
createSessionId(Env env)
Creates a pseudo-random session id.
|
protected SessionArrayValue |
createSessionValue(java.lang.String key,
long now,
long sessionTimeout)
Creates a new SessionArrayValue instance.
|
int |
getActiveSessionCount()
Returns the current number of active sessions.
|
int |
getReuseSessionId()
True if the server should reuse the current session id if the
session doesn't exist.
|
boolean |
getSaveOnlyOnShutdown()
True if sessions should only be saved on shutdown.
|
SessionArrayValue |
getSession(Env env,
java.lang.String key,
long now)
Returns a session from the session store, returning null if there's
no cached session.
|
long |
getSessionCreateCount()
Returns the created sessions.
|
int |
getSessionMax()
Returns the maximum number of sessions.
|
long |
getSessionTimeoutCount()
Returns the timeout sessions.
|
void |
handleAlarm(Alarm alarm)
Timeout for reaping old sessions.
|
boolean |
isClosed()
Returns true if the sessions are closed.
|
boolean |
isEmpty(java.lang.Object obj)
Checks if the session is empty.
|
protected boolean |
load(Env env,
SessionArrayValue session,
long now)
Loads the session from the backing store.
|
void |
load(java.io.ObjectInputStream in,
java.lang.Object obj)
Loads the session.
|
void |
notifyRemove(java.lang.String id)
Notification from the cluster.
|
void |
notifyUpdate(java.lang.String id)
Notification from the cluster.
|
protected void |
remove(java.lang.String sessionId) |
void |
removeSession(java.lang.String sessionId)
Removes a session from the cache and deletes it from the backing store,
if applicable.
|
void |
saveSession(Env env,
SessionArrayValue session) |
void |
setAlwaysLoadSession(boolean load)
True if sessions should always be loadd.
|
void |
setAlwaysSaveSession(boolean save)
True if sessions should always be saved.
|
void |
setCookieAppendServerIndex(boolean isAppend)
Sets module session id generation.
|
void |
setCookieLength(int cookieLength)
Sets the cookie length
|
void |
setReuseSessionId(java.lang.String reuse)
True if the server should reuse the current session id if the
session doesn't exist.
|
void |
setSaveOnlyOnShutdown(boolean save)
True if sessions should only be saved on shutdown.
|
void |
setSaveOnShutdown(boolean save)
True if sessions should only be saved on shutdown.
|
void |
setSessionMax(int max)
Returns the maximum number of sessions.
|
protected void |
setSessionTimeout(long sessionTimeout) |
void |
store(java.io.OutputStream out,
java.lang.Object obj)
Saves the session.
|
protected LruCache<java.lang.String,SessionArrayValue> _sessions
protected java.util.Iterator<SessionArrayValue> _sessionIter
protected java.util.ArrayList<SessionArrayValue> _sessionList
protected int _sessionMax
protected boolean _isClosed
protected java.lang.Object _statisticsLock
protected long _sessionCreateCount
protected long _sessionTimeoutCount
public QuercusSessionManager(QuercusContext quercus)
public void setAlwaysSaveSession(boolean save)
public void setAlwaysLoadSession(boolean load)
public boolean getSaveOnlyOnShutdown()
public void setSaveOnlyOnShutdown(boolean save)
public void setSaveOnShutdown(boolean save)
public void setCookieLength(int cookieLength)
protected void setSessionTimeout(long sessionTimeout)
public int getActiveSessionCount()
public long getSessionCreateCount()
public long getSessionTimeoutCount()
public int getReuseSessionId()
public void setReuseSessionId(java.lang.String reuse) throws ConfigException
ConfigException
public boolean isClosed()
public int getSessionMax()
public void setSessionMax(int max)
public void removeSession(java.lang.String sessionId)
protected void remove(java.lang.String sessionId)
public void load(java.io.ObjectInputStream in, java.lang.Object obj) throws java.io.IOException
in
- the input stream containing the serialized sessionobj
- the session object to be deserializedjava.io.IOException
public boolean isEmpty(java.lang.Object obj)
public void setCookieAppendServerIndex(boolean isAppend)
public SessionArrayValue createSession(Env env, java.lang.String oldId, long now)
oldId
- the id passed to the request. Reuse if possible.now
- the current datepublic java.lang.String createSessionId(Env env)
public SessionArrayValue getSession(Env env, java.lang.String key, long now)
key
- the session idnow
- the time in milliseconds. now == 0 implies
that we're just checking for the existence of such a session in
the cache and do not intend actually to load it if it is not.public void saveSession(Env env, SessionArrayValue session)
protected SessionArrayValue create(Env env, java.lang.String key, long now)
protected SessionArrayValue createSessionValue(java.lang.String key, long now, long sessionTimeout)
protected boolean load(Env env, SessionArrayValue session, long now)
session
- the session to load.now
- current time in milliseconds. now == 0 implies
that we're just checking for the existence of such a session in
the cache and do not intend actually to load it if it is not.public void handleAlarm(Alarm alarm)
handleAlarm
in interface AlarmListener
public void close()
public void notifyRemove(java.lang.String id)
public void notifyUpdate(java.lang.String id)
public void store(java.io.OutputStream out, java.lang.Object obj) throws java.io.IOException
java.io.IOException