@ManagedObject public class FileSessionDataStore extends AbstractSessionDataStore
AbstractLifeCycle.AbstractLifeCycleListenerLifeCycle.ListenerContainer.InheritedListener, Container.Listener| Modifier and Type | Field and Description |
|---|---|
protected java.lang.String |
_contextString |
protected boolean |
_deleteUnrestorableFiles |
protected long |
_lastSweepTime |
protected java.util.Map<java.lang.String,java.lang.String> |
_sessionFileMap |
protected java.io.File |
_storeDir |
_context, _gracePeriodSec, _lastExpiryCheckTime, _savePeriodSec| Constructor and Description |
|---|
FileSessionDataStore() |
| Modifier and Type | Method and Description |
|---|---|
boolean |
delete(java.lang.String id)
Delete a session
|
boolean |
deleteFile(java.lang.String filename)
Delete the file associated with a session
|
java.util.Set<java.lang.String> |
doGetExpired(java.util.Set<java.lang.String> candidates)
Check to see which sessions have expired.
|
SessionData |
doLoad(java.lang.String id)
Load the session from persistent store.
|
protected void |
doStart()
Starts the managed lifecycle beans in the order they were added.
|
protected void |
doStop()
Stops the managed lifecycle beans in the reverse order they were added.
|
void |
doStore(java.lang.String id,
SessionData data,
long lastSaveTime)
Store the session data persistently.
|
boolean |
exists(java.lang.String id)
Test if data exists for a given session id.
|
protected java.lang.String |
getContextFromFilename(java.lang.String filename) |
protected long |
getExpiryFromFilename(java.lang.String filename) |
protected java.lang.String |
getIdFromFilename(java.lang.String filename) |
protected java.lang.String |
getIdWithContext(java.lang.String id)
Get the session id with its context.
|
protected java.lang.String |
getIdWithContextAndExpiry(SessionData data)
Get the session id with its context and its expiry time
|
protected java.lang.String |
getIdWithContextFromFilename(java.lang.String filename)
Extract the session id and context from the filename
|
java.io.File |
getStoreDir() |
void |
initialize(SessionContext context)
Initialize this data map for the
given context.
|
void |
initializeStore()
Read the names of the existing session files and build a map of
fully qualified session ids (ie with context) to filename.
|
boolean |
isDeleteUnrestorableFiles() |
protected boolean |
isOurContextSessionFilename(java.lang.String filename)
Check if the filename matches our session pattern
and is a session for our context.
|
boolean |
isPassivating()
True if this type of datastore will passivate session objects
|
protected boolean |
isSessionFilename(java.lang.String filename)
Check if the filename is a session filename.
|
protected SessionData |
load(java.io.InputStream is,
java.lang.String expectedId)
Load the session data from a file.
|
protected void |
save(java.io.OutputStream os,
java.lang.String id,
SessionData data)
Save the session data.
|
void |
setDeleteUnrestorableFiles(boolean deleteUnrestorableFiles) |
void |
setStoreDir(java.io.File storeDir) |
void |
sweepDisk()
Check all session files that do not belong to this context and
remove any that expired long ago (ie at least 5 gracePeriods ago).
|
void |
sweepFile(long now,
java.nio.file.Path p)
Check to see if the expiry on the file is very old, and
delete the file if so.
|
java.lang.String |
toString() |
checkStarted, getExpired, getGracePeriodSec, getSavePeriodSec, load, newSessionData, setGracePeriodSec, setSavePeriodSec, storeaddBean, addBean, addBean, addEventListener, addManaged, contains, destroy, dump, dump, dump, dump, dump, dumpBeans, dumpObject, dumpObjects, dumpStdErr, dumpThis, getBean, getBeans, getBeans, getContainedBeans, getContainedBeans, isAuto, isManaged, isUnmanaged, manage, removeBean, removeBeans, removeEventListener, setBeans, setStopTimeout, start, stop, unmanage, updateBean, updateBean, updateBeansaddLifeCycleListener, getState, getState, getStopTimeout, isFailed, isRunning, isStarted, isStarting, isStopped, isStopping, removeLifeCycleListener, start, stopclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitaddLifeCycleListener, isFailed, isRunning, isStarted, isStarting, isStopped, isStopping, removeLifeCycleListener, start, start, stop, stopdumpObjects, dumpSelfprotected java.io.File _storeDir
protected boolean _deleteUnrestorableFiles
protected java.util.Map<java.lang.String,java.lang.String> _sessionFileMap
protected java.lang.String _contextString
protected long _lastSweepTime
public void initialize(SessionContext context) throws java.lang.Exception
SessionDataMapinitialize in interface SessionDataMapinitialize in class AbstractSessionDataStorecontext - context associatedjava.lang.Exception - if unable to initialize theprotected void doStart()
throws java.lang.Exception
ContainerLifeCycledoStart in class AbstractSessionDataStorejava.lang.Exceptionprotected void doStop()
throws java.lang.Exception
ContainerLifeCycledoStop in class ContainerLifeCyclejava.lang.Exception@ManagedAttribute(value="dir where sessions are stored", readonly=true) public java.io.File getStoreDir()
public void setStoreDir(java.io.File storeDir)
public boolean isDeleteUnrestorableFiles()
public void setDeleteUnrestorableFiles(boolean deleteUnrestorableFiles)
public boolean delete(java.lang.String id)
throws java.lang.Exception
id - session idjava.lang.Exception - if unable to delete session datapublic boolean deleteFile(java.lang.String filename)
throws java.lang.Exception
filename - name of the file containing the session's informationjava.lang.Exception - indicating delete failurepublic java.util.Set<java.lang.String> doGetExpired(java.util.Set<java.lang.String> candidates)
doGetExpired in class AbstractSessionDataStorecandidates - the set of session ids that the SessionCache believes
have expiredpublic void sweepDisk()
public void sweepFile(long now,
java.nio.file.Path p)
throws java.lang.Exception
now - the time now in msecp - the file to checkjava.lang.Exception - indicating error in sweeppublic SessionData doLoad(java.lang.String id) throws java.lang.Exception
AbstractSessionDataStoredoLoad in class AbstractSessionDataStoreid - the id of the session to loadjava.lang.Exception - if unable to load the sessionpublic void doStore(java.lang.String id,
SessionData data,
long lastSaveTime)
throws java.lang.Exception
AbstractSessionDataStoredoStore in class AbstractSessionDataStoreid - identity of session to storedata - info of the sessionlastSaveTime - time of previous save or 0 if never savedjava.lang.Exception - if unable to store datapublic void initializeStore()
throws java.lang.Exception
java.lang.Exception - if storeDir doesn't exist, isn't readable/writeable
or contains 2 files with the same lastmodify time for the same session. Throws IOException
if the lastmodifytimes can't be read.@ManagedAttribute(value="are sessions serialized by this store", readonly=true) public boolean isPassivating()
SessionDataStorepublic boolean exists(java.lang.String id)
throws java.lang.Exception
SessionDataStoreid - Identity of session whose existence should be checkedjava.lang.Exception - if problem checking existence with persistence layerprotected void save(java.io.OutputStream os,
java.lang.String id,
SessionData data)
throws java.io.IOException
os - the output stream to save toid - identity of the sessiondata - the info of the sessionjava.io.IOExceptionprotected java.lang.String getIdWithContext(java.lang.String id)
id - identity of sessionprotected java.lang.String getIdWithContextAndExpiry(SessionData data)
data - protected java.lang.String getIdFromFilename(java.lang.String filename)
protected long getExpiryFromFilename(java.lang.String filename)
protected java.lang.String getContextFromFilename(java.lang.String filename)
protected java.lang.String getIdWithContextFromFilename(java.lang.String filename)
filename - the name of the file to useprotected boolean isSessionFilename(java.lang.String filename)
filename - the filename to checkprotected boolean isOurContextSessionFilename(java.lang.String filename)
filename - the filename to checkprotected SessionData load(java.io.InputStream is, java.lang.String expectedId) throws java.lang.Exception
is - file input stream containing session dataexpectedId - the id we've been told to loadjava.lang.Exceptionpublic java.lang.String toString()
toString in class AbstractSessionDataStoreCopyright © 1995–2021 Webtide. All rights reserved.