Class FileSessionDataStore
- java.lang.Object
-
- com.aspectran.core.component.AbstractComponent
-
- com.aspectran.core.component.session.AbstractSessionDataStore
-
- com.aspectran.core.component.session.FileSessionDataStore
-
- All Implemented Interfaces:
Component
,SessionDataStore
public class FileSessionDataStore extends AbstractSessionDataStore
A file-based store of session data.
-
-
Field Summary
-
Fields inherited from class com.aspectran.core.component.session.AbstractSessionDataStore
gracePeriodSec, lastExpiryCheckTime, savePeriodSec
-
-
Constructor Summary
Constructors Constructor Description FileSessionDataStore()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
delete(java.lang.String id)
Delete session data.protected void
doDestroy()
java.util.Set<java.lang.String>
doGetExpired(java.util.Set<java.lang.String> candidates)
Check to see which sessions have expired.protected void
doInitialize()
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()
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()
-
Methods inherited from class com.aspectran.core.component.session.AbstractSessionDataStore
checkInitialized, getExpired, getGracePeriodSec, getSavePeriodSec, newSessionData, setGracePeriodSec, setSavePeriodSec, store
-
Methods inherited from class com.aspectran.core.component.AbstractComponent
destroy, getComponentName, initialize, isAvailable, isDestroyed, isInitialized
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface com.aspectran.core.component.Component
destroy, getComponentName, initialize, isAvailable, isDestroyed, isInitialized
-
-
-
-
Method Detail
-
getStoreDir
public java.io.File getStoreDir()
-
setStoreDir
public void setStoreDir(java.io.File storeDir)
-
isDeleteUnrestorableFiles
public boolean isDeleteUnrestorableFiles()
-
setDeleteUnrestorableFiles
public void setDeleteUnrestorableFiles(boolean deleteUnrestorableFiles)
-
delete
public boolean delete(java.lang.String id) throws java.lang.Exception
Description copied from interface:SessionDataStore
Delete session data.- Parameters:
id
- identity of session to delete- Returns:
- true if the session was deleted
- Throws:
java.lang.Exception
- if unable to delete session data
-
doGetExpired
public java.util.Set<java.lang.String> doGetExpired(java.util.Set<java.lang.String> candidates)
Check to see which sessions have expired.- Specified by:
doGetExpired
in classAbstractSessionDataStore
- Parameters:
candidates
- the set of session ids that the SessionCache believes have expired- Returns:
- the complete set of sessions that have expired, including those that are not currently loaded into the SessionCache
-
load
public SessionData load(java.lang.String id) throws java.lang.Exception
Description copied from interface:SessionDataStore
Read in session data.- Parameters:
id
- identity of session to load- Returns:
- the SessionData matching the id
- Throws:
java.lang.Exception
- if unable to load session data
-
doStore
public void doStore(java.lang.String id, SessionData data, long lastSaveTime) throws java.lang.Exception
Description copied from class:AbstractSessionDataStore
Store the session data persistently.- Specified by:
doStore
in classAbstractSessionDataStore
- Parameters:
id
- identity of session to storedata
- info of the sessionlastSaveTime
- time of previous save or 0 if never saved- Throws:
java.lang.Exception
- if unable to store data
-
isPassivating
public boolean isPassivating()
Description copied from interface:SessionDataStore
True if this type of datastore will passivate session objects.- Returns:
- true if this store can passivate sessions; false otherwise
-
exists
public boolean exists(java.lang.String id) throws java.lang.Exception
Description copied from interface:SessionDataStore
Test if data exists for a given session id.- Parameters:
id
- Identity of session whose existence should be checked- Returns:
- true if valid, non-expired session exists
- Throws:
java.lang.Exception
- if there is a problem checking the existence with persistence layer
-
sweepDisk
public 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).
-
sweepFile
public void sweepFile(long now, java.nio.file.Path p) throws java.lang.Exception
Check to see if the expiry on the file is very old, and delete the file if so. "Old" means that it expired at least 5 gracePeriods ago.- Parameters:
now
- the time now in msecp
- the file to check- Throws:
java.lang.Exception
- indicating error in sweep
-
doInitialize
protected void doInitialize() throws java.lang.Exception
- Overrides:
doInitialize
in classAbstractSessionDataStore
- Throws:
java.lang.Exception
-
doDestroy
protected void doDestroy()
- Overrides:
doDestroy
in classAbstractSessionDataStore
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-