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 String |
__ACCESSED
Last access time of session
|
static String |
__EXPIRY
Time this session will expire, based on last access time and maxIdle
|
static String |
__ID
Session id
|
static String |
__LASTNODE |
static String |
__LASTSAVED |
static String |
__MAX_IDLE
The max idle time of a session (smallest value across all contexts which has a session with the same id)
|
static String |
__VALID
Whether or not session is valid
|
static String |
__VERSION
Special attribute per session per context, incremented each time attributes are modified
|
_context, _gracePeriodSec, _lastExpiryCheckTime
FAILED, RUNNING, STARTED, STARTING, STOP_ON_FAILURE, STOPPED, STOPPING
Constructor and Description |
---|
MongoSessionDataStore() |
Modifier and Type | Method and Description |
---|---|
protected String |
decodeName(String name) |
protected Object |
decodeValue(Object valueToDecode) |
boolean |
delete(String id)
Delete session data
|
Set<String> |
doGetExpired(Set<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(String id,
SessionData data,
long lastSaveTime)
Store the session data persistently.
|
protected Object |
encodeName(Object value) |
protected String |
encodeName(String name) |
protected void |
ensureIndexes() |
boolean |
exists(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(String id)
Read in session data.
|
void |
setDBCollection(com.mongodb.DBCollection collection) |
String |
toString() |
newSessionData
checkStarted, getExpired, getGracePeriodSec, initialize, setGracePeriodSec, 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, stop
public static final String __VERSION
public static final String __LASTSAVED
public static final String __LASTNODE
public static final String __ACCESSED
public static final String __EXPIRY
public static final String __MAX_IDLE
public static final String __VALID
public static final String __ID
public void setDBCollection(com.mongodb.DBCollection collection)
public com.mongodb.DBCollection getDBCollection()
public SessionData load(String id) throws Exception
SessionDataMap
id
- identity of session to loadException
- if unable to load session dataSessionDataMap.load(String)
public boolean delete(String id) throws Exception
SessionDataMap
id
- identity of session to deleteException
- if unable to delete session dataSessionDataMap.delete(String)
public boolean exists(String id) throws Exception
SessionDataStore
id
- Identity of session whose existance should be checkedException
- if problem checking existance with persistence layerSessionDataStore.exists(java.lang.String)
public Set<String> doGetExpired(Set<String> candidates)
AbstractSessionDataStore
doGetExpired
in class AbstractSessionDataStore
candidates
- the ids of sessions the SessionDataStore thinks has expiredSessionDataStore.getExpired(Set)
public void doStore(String id, SessionData data, long lastSaveTime) throws Exception
AbstractSessionDataStore
doStore
in class AbstractSessionDataStore
id
- identity of session to storedata
- info of the sessionlastSaveTime
- time of previous save or 0 if never savedException
- if unable to store dataAbstractSessionDataStore.doStore(String, SessionData, long)
protected void doStart() throws Exception
ContainerLifeCycle
doStart
in class AbstractSessionDataStore
Exception
protected void doStop() throws Exception
ContainerLifeCycle
doStop
in class ContainerLifeCycle
Exception
protected void ensureIndexes() throws com.mongodb.MongoException
com.mongodb.MongoException
protected Object decodeValue(Object valueToDecode) throws IOException, ClassNotFoundException
IOException
ClassNotFoundException
protected Object encodeName(Object value) throws IOException
IOException
public boolean isPassivating()
SessionDataStore
SessionDataStore.isPassivating()
public String toString()
toString
in class AbstractSessionDataStore
AbstractSessionDataStore.toString()
Copyright © 1995–2017 Webtide. All rights reserved.