@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 a session attribute, the key is composed of:
"context".unique_context_name.attribute_name
Eg "context"."0_0_0_0:_testA"."A"
NoSqlSessionDataStore.NoSqlSessionData
AbstractLifeCycle.AbstractLifeCycleListener
LifeCycle.Listener
Container.InheritedListener, Container.Listener
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
__ACCESSED
Last access time of session
|
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 |
__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 |
__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
FAILED, RUNNING, STARTED, STARTING, STOP_ON_FAILURE, STOPPED, STOPPING
Constructor and Description |
---|
MongoSessionDataStore() |
Modifier and Type | Method and Description |
---|---|
protected java.lang.String |
decodeName(java.lang.String name) |
protected java.lang.Object |
decodeValue(java.lang.Object valueToDecode) |
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.
|
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.
|
protected java.lang.Object |
encodeName(java.lang.Object value) |
protected java.lang.String |
encodeName(java.lang.String name) |
protected void |
ensureIndexes() |
boolean |
exists(java.lang.String id)
Test if data exists for a given session id.
|
com.mongodb.DBCollection |
getDBCollection() |
boolean |
isPassivating()
True if this type of datastore will passivate session objects
|
SessionData |
load(java.lang.String id)
Read in session data.
|
void |
setDBCollection(com.mongodb.DBCollection collection) |
java.lang.String |
toString() |
newSessionData
checkStarted, getExpired, getGracePeriodSec, getSavePeriodSec, initialize, setGracePeriodSec, setSavePeriodSec, store
addBean, addBean, addBean, addEventListener, addManaged, contains, destroy, dump, dump, dump, dump, dump, dumpBeans, dumpObject, dumpStdErr, dumpThis, getBean, getBeans, getBeans, 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 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 __EXPIRY
public static final java.lang.String __MAX_IDLE
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 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(String)
public boolean delete(java.lang.String id) throws java.lang.Exception
SessionDataMap
id
- identity of session to deletejava.lang.Exception
- if unable to delete session dataSessionDataMap.delete(String)
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.util.Set<java.lang.String> doGetExpired(java.util.Set<java.lang.String> candidates)
AbstractSessionDataStore
doGetExpired
in class AbstractSessionDataStore
candidates
- the ids of sessions the SessionDataStore thinks has expiredSessionDataStore.getExpired(Set)
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(String, SessionData, long)
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
protected void ensureIndexes() throws com.mongodb.MongoException
com.mongodb.MongoException
protected java.lang.Object decodeValue(java.lang.Object valueToDecode) throws java.io.IOException, java.lang.ClassNotFoundException
java.io.IOException
java.lang.ClassNotFoundException
protected java.lang.String decodeName(java.lang.String name)
protected java.lang.String encodeName(java.lang.String name)
protected java.lang.Object encodeName(java.lang.Object value) throws java.io.IOException
java.io.IOException
@ManagedAttribute(value="does store serialize sessions", readonly=true) public boolean isPassivating()
SessionDataStore
SessionDataStore.isPassivating()
public java.lang.String toString()
toString
in class AbstractSessionDataStore
AbstractSessionDataStore.toString()
Copyright © 1995–2017 Webtide. All rights reserved.