@ManagedObject public class FileSessionDataStore extends AbstractSessionDataStore
AbstractLifeCycle.AbstractLifeCycleListener
LifeCycle.Listener
Container.InheritedListener, Container.Listener
Modifier and Type | Field and Description |
---|---|
protected long |
_lastSweepTime |
_context, _gracePeriodSec, _lastExpiryCheckTime, _savePeriodSec
FAILED, RUNNING, STARTED, STARTING, STOP_ON_FAILURE, STOPPED, STOPPING
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.
|
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.
|
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() |
boolean |
isPassivating()
True if this type of datastore will passivate session objects
|
SessionData |
load(java.lang.String id)
Read in 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, newSessionData, setGracePeriodSec, setSavePeriodSec, store
addBean, addBean, addBean, addEventListener, addManaged, contains, destroy, dump, dump, dump, dump, dump, dumpBeans, dumpObject, dumpStdErr, dumpThis, getBean, getBeans, getBeans, getContainedBeans, getContainedBeans, isManaged, manage, removeBean, removeBeans, removeEventListener, setBeans, setStopTimeout, start, stop, unmanage, updateBean, updateBean, updateBeans
addLifeCycleListener, getState, getState, getStopTimeout, isFailed, isRunning, isStarted, isStarting, isStopped, isStopping, removeLifeCycleListener, start, stop
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
addLifeCycleListener, isFailed, isRunning, isStarted, isStarting, isStopped, isStopping, removeLifeCycleListener, start, start, stop, stop
public void initialize(SessionContext context) throws java.lang.Exception
SessionDataMap
initialize
in interface SessionDataMap
initialize
in class AbstractSessionDataStore
context
- context associatedjava.lang.Exception
- if unable to initialize theSessionDataMap.initialize(org.eclipse.jetty.server.session.SessionContext)
protected void doStart() throws java.lang.Exception
ContainerLifeCycle
doStart
in class AbstractSessionDataStore
java.lang.Exception
protected void doStop() throws java.lang.Exception
ContainerLifeCycle
doStop
in class ContainerLifeCycle
java.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 AbstractSessionDataStore
candidates
- 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 load(java.lang.String id) throws java.lang.Exception
SessionDataMap
id
- identity of session to loadjava.lang.Exception
- if unable to load session dataSessionDataMap.load(java.lang.String)
public void doStore(java.lang.String id, SessionData data, long lastSaveTime) throws java.lang.Exception
AbstractSessionDataStore
doStore
in class AbstractSessionDataStore
id
- identity of session to storedata
- info of the sessionlastSaveTime
- time of previous save or 0 if never savedjava.lang.Exception
- if unable to store dataAbstractSessionDataStore.doStore(java.lang.String, org.eclipse.jetty.server.session.SessionData, long)
public 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()
SessionDataStore
SessionDataStore.isPassivating()
public boolean exists(java.lang.String id) throws java.lang.Exception
SessionDataStore
id
- Identity of session whose existance should be checkedjava.lang.Exception
- if problem checking existance with persistence layerSessionDataStore.exists(java.lang.String)
public java.lang.String toString()
toString
in class AbstractSessionDataStore
AbstractSessionDataStore.toString()
Copyright © 1995–2018 Webtide. All rights reserved.