SessionCacheDefaultSessionCachepublic abstract class AbstractSessionCache extends java.lang.Object implements SessionCache
Created: 2017. 6. 24.
| Modifier and Type | Class | Description |
|---|---|---|
protected class |
AbstractSessionCache.PlaceHolderSession |
PlaceHolder
|
| Modifier and Type | Field | Description |
|---|---|---|
protected int |
evictionPolicy |
When, if ever, to evict sessions: never; only when the last request for
them finishes; after inactivity time (expressed as secs)
|
protected boolean |
removeUnloadableSessions |
If true, a Session whose data cannot be read will be
deleted from the SessionDataStore.
|
protected boolean |
saveOnCreate |
If true, as soon as a new session is created, it will be persisted to
the SessionDataStore
|
protected boolean |
saveOnInactiveEviction |
If true, a session that will be evicted from the cache because it has been
inactive too long will be saved before being evicted.
|
protected SessionDataStore |
sessionDataStore |
|
protected SessionHandler |
sessionHandler |
EVICT_ON_INACTIVITY, EVICT_ON_SESSION_EXIT, NEVER_EVICT| Constructor | Description |
|---|---|
AbstractSessionCache(SessionHandler sessionHandler) |
| Modifier and Type | Method | Description |
|---|---|---|
java.util.Set<java.lang.String> |
checkExpiration(java.util.Set<java.lang.String> candidates) |
Check a list of session ids that belong to potentially expired
sessions.
|
void |
checkInactiveSession(Session session) |
Check a session for being inactive and
thus being able to be evicted, if eviction
is enabled.
|
boolean |
contains(java.lang.String id) |
Check to see if this cache contains an entry for the session
corresponding to the session id.
|
Session |
delete(java.lang.String id) |
Remove a session object from this store and from any backing store.
|
abstract Session |
doDelete(java.lang.String id) |
Remove the session with this identity from the store.
|
abstract Session |
doGet(java.lang.String id) |
Get the session matching the key.
|
abstract Session |
doPutIfAbsent(java.lang.String id,
Session session) |
Put the session into the map if it wasn't already there.
|
abstract boolean |
doReplace(java.lang.String id,
Session oldValue,
Session newValue) |
Replace the mapping from id to oldValue with newValue.
|
boolean |
exists(java.lang.String id) |
Check to see if a session corresponding to the id exists.
|
Session |
get(java.lang.String id) |
Get a session object.
|
int |
getEvictionPolicy() |
|
SessionDataStore |
getSessionDataStore() |
|
protected SessionHandler |
getSessionHandler() |
|
boolean |
isRemoveUnloadableSessions() |
|
boolean |
isSaveOnCreate() |
|
boolean |
isSaveOnInactiveEviction() |
Whether we should save a session that has been inactive before
we boot it from the cache.
|
abstract Session |
newSession(SessionData data) |
Create a new Session object from pre-existing session data.
|
Session |
newSession(java.lang.String id,
long time,
long maxInactiveIntervalMS) |
|
void |
put(java.lang.String id,
Session session) |
Put the Session object back into the session store.
|
void |
setEvictionPolicy(int evictionTimeout) |
-1 means we never evict inactive sessions.
|
void |
setRemoveUnloadableSessions(boolean removeUnloadableSessions) |
If a session's data cannot be loaded from the store without error, remove
it from the persistent store.
|
void |
setSaveOnCreate(boolean saveOnCreate) |
Whether or not a session that is newly created should be
immediately saved.
|
void |
setSaveOnInactiveEviction(boolean saveOnEvict) |
Whether or not a a session that is about to be evicted should
be saved before being evicted.
|
void |
setSessionDataStore(SessionDataStore sessionDataStore) |
A SessionDataStore that is the authoritative source
of session information.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitclear, getSessionsCurrent, getSessionsMax, getSessionsTotal, resetStatsprotected final SessionHandler sessionHandler
protected SessionDataStore sessionDataStore
protected int evictionPolicy
protected boolean saveOnCreate
protected boolean saveOnInactiveEviction
protected boolean removeUnloadableSessions
public AbstractSessionCache(SessionHandler sessionHandler)
protected SessionHandler getSessionHandler()
public SessionDataStore getSessionDataStore()
getSessionDataStore in interface SessionCachepublic void setSessionDataStore(SessionDataStore sessionDataStore)
SessionCachesetSessionDataStore in interface SessionCachesessionDataStore - the session data storepublic int getEvictionPolicy()
getEvictionPolicy in interface SessionCachepublic void setEvictionPolicy(int evictionTimeout)
setEvictionPolicy in interface SessionCacheevictionTimeout - -1 is never evict; 0 is evict-on-exit; and any other positive
value is the time in seconds that a session can be idle before it can
be evicted.public boolean isSaveOnCreate()
isSaveOnCreate in interface SessionCachepublic void setSaveOnCreate(boolean saveOnCreate)
SessionCachesetSaveOnCreate in interface SessionCachesaveOnCreate - if true, immediately save the newly created sessionpublic boolean isRemoveUnloadableSessions()
isRemoveUnloadableSessions in interface SessionCachepublic void setRemoveUnloadableSessions(boolean removeUnloadableSessions)
setRemoveUnloadableSessions in interface SessionCacheremoveUnloadableSessions - whether to delete sessions that can not be loadedpublic boolean isSaveOnInactiveEviction()
isSaveOnInactiveEviction in interface SessionCachepublic void setSaveOnInactiveEviction(boolean saveOnEvict)
SessionCachesetSaveOnInactiveEviction in interface SessionCachesaveOnEvict - if true, save the session before evictionpublic Session get(java.lang.String id) throws java.lang.Exception
get in interface SessionCacheid - the session idjava.lang.Exception - if an error occurspublic void put(java.lang.String id,
Session session)
throws java.lang.Exception
This should be called when a request exists the session. Only when the last simultaneous request exists the session will any action be taken.
If there is a SessionDataStore write the session data through to it.
If the SessionDataStore supports passivation, call the passivate/active listeners.
If the evictionPolicy == SessionCache.EVICT_ON_SESSION_EXIT then after we have saved the session, we evict it from the cache.
put in interface SessionCacheid - the session idsession - the session objectjava.lang.Exception - if an error occurspublic boolean exists(java.lang.String id)
throws java.lang.Exception
exists in interface SessionCacheid - the session idjava.lang.Exception - the Exceptionpublic boolean contains(java.lang.String id)
throws java.lang.Exception
contains in interface SessionCacheid - the session idjava.lang.Exception - if an error occurspublic Session delete(java.lang.String id) throws java.lang.Exception
delete in interface SessionCacheid - the session idjava.lang.Exception - if an error occurs when deleting a sessionpublic java.util.Set<java.lang.String> checkExpiration(java.util.Set<java.lang.String> candidates)
SessionCachecheckExpiration in interface SessionCachecandidates - the session ids to checkpublic void checkInactiveSession(Session session)
checkInactiveSession in interface SessionCachesession - session to checkpublic Session newSession(java.lang.String id, long time, long maxInactiveIntervalMS)
newSession in interface SessionCachepublic abstract Session newSession(SessionData data)
newSession in interface SessionCachedata - the session datapublic abstract Session doGet(java.lang.String id)
id - the session idpublic abstract Session doPutIfAbsent(java.lang.String id, Session session)
id - the identity of the sessionsession - the session objectpublic abstract boolean doReplace(java.lang.String id,
Session oldValue,
Session newValue)
id - the session idoldValue - the old valuenewValue - the new valuepublic abstract Session doDelete(java.lang.String id)
id - the session idCopyright © 2008–2018 The Aspectran Project. All rights reserved.