@ManagedObject public class MongoSessionDataStore extends NoSqlSessionDataStore
One of the name:value attribute pairs will always be the special attribute "__metadata__". The value is an object representing a version counter which is incremented every time the attributes change.
For example:
{ "_id" : ObjectId("52845534a40b66410f228f23"),
"accessed" : NumberLong("1384818548903"),
"maxIdle" : 1,
"context" : { "0_0_0_0:_testA" : { "A" : "A",
"__metadata__" : { "version" : NumberLong(2) }
},
"0_0_0_0:_testB" : { "B" : "B",
"__metadata__" : { "version" : NumberLong(1) }
}
},
"created" : NumberLong("1384818548903"),
"expiry" : NumberLong("1384818549903"),
"id" : "w01ijx2vnalgv1sqrpjwuirprp7",
"valid" : true
}
In MongoDB, the nesting level is indicated by "." separators for the key name. Thus to
interact with session fields, the key is composed of:
"context".unique_context_name.field_name
Eg "context"."0_0_0_0:_testA"."lastSaved"
NoSqlSessionDataStore.NoSqlSessionDataAbstractLifeCycle.AbstractLifeCycleListenerLifeCycle.ListenerContainer.InheritedListener, Container.Listener| Modifier and Type | Field and Description |
|---|---|
static java.lang.String |
__ACCESSED
Last access time of session
|
static java.lang.String |
__ATTRIBUTES |
static java.lang.String |
__CONTEXT
Name of nested document field containing 1 sub document per context for which the session id is in use
|
static java.lang.String |
__CREATED
Time of session creation
|
static java.lang.String |
__EXPIRY
Time this session will expire, based on last access time and maxIdle
|
static java.lang.String |
__ID
Session id
|
static java.lang.String |
__LAST_ACCESSED |
static java.lang.String |
__LASTNODE |
static java.lang.String |
__LASTSAVED |
static java.lang.String |
__MAX_IDLE
The max idle time of a session (smallest value across all contexts which has a session with the same id)
|
static java.lang.String |
__METADATA
Special attribute for a session that is context-specific
|
static java.lang.String |
__VALID
Whether or not session is valid
|
static java.lang.String |
__VERSION
Special attribute per session per context, incremented each time attributes are modified
|
_context, _gracePeriodSec, _lastExpiryCheckTime, _savePeriodSec| Constructor and Description |
|---|
MongoSessionDataStore() |
| Modifier and Type | Method and Description |
|---|---|
boolean |
delete(java.lang.String id)
Delete session data
|
java.util.Set<java.lang.String> |
doGetExpired(java.util.Set<java.lang.String> candidates)
Implemented by subclasses to resolve which sessions this node
should attempt to expire.
|
SessionData |
doLoad(java.lang.String id)
Load the session from persistent store.
|
void |
doStore(java.lang.String id,
SessionData data,
long lastSaveTime)
Store the session data persistently.
|
protected void |
ensureIndexes() |
boolean |
exists(java.lang.String id)
Test if data exists for a given session id.
|
com.mongodb.DBCollection |
getDBCollection() |
void |
initialize(SessionContext context)
Initialize this data map for the
given context.
|
boolean |
isPassivating()
True if this type of datastore will passivate session objects
|
void |
setDBCollection(com.mongodb.DBCollection collection) |
java.lang.String |
toString() |
newSessionDatacheckStarted, doStart, getExpired, getGracePeriodSec, getSavePeriodSec, load, setGracePeriodSec, setSavePeriodSec, storeaddBean, addBean, addBean, addEventListener, addManaged, contains, destroy, doStop, 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, dumpSelfpublic static final java.lang.String __METADATA
public static final java.lang.String __CONTEXT
public static final java.lang.String __VERSION
public static final java.lang.String __LASTSAVED
public static final java.lang.String __LASTNODE
public static final java.lang.String __ACCESSED
public static final java.lang.String __LAST_ACCESSED
public static final java.lang.String __ATTRIBUTES
public static final java.lang.String __EXPIRY
public static final java.lang.String __MAX_IDLE
public static final java.lang.String __CREATED
public static final java.lang.String __VALID
public static final java.lang.String __ID
public void setDBCollection(com.mongodb.DBCollection collection)
@ManagedAttribute(value="DBCollection", readonly=true) public com.mongodb.DBCollection getDBCollection()
public 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 boolean delete(java.lang.String id)
throws java.lang.Exception
SessionDataMapid - identity of session to deletejava.lang.Exception - if unable to delete session datapublic 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 layerpublic java.util.Set<java.lang.String> doGetExpired(java.util.Set<java.lang.String> candidates)
AbstractSessionDataStoredoGetExpired in class AbstractSessionDataStorecandidates - the ids of sessions the SessionDataStore thinks has expiredpublic void initialize(SessionContext context) throws java.lang.Exception
SessionDataMapinitialize in interface SessionDataMapinitialize in class AbstractSessionDataStorecontext - context associatedjava.lang.Exception - if unable to initialize thepublic 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 dataprotected void ensureIndexes()
throws com.mongodb.MongoException
com.mongodb.MongoException@ManagedAttribute(value="does store serialize sessions", readonly=true) public boolean isPassivating()
SessionDataStorepublic java.lang.String toString()
toString in class AbstractSessionDataStoreCopyright © 1995–2023 Webtide. All rights reserved.