Top Description Fields Constructors Methods
org.eclipse.jetty.session

public Class CachingSessionDataStore

extends ContainerLifeCycle
implements SessionDataStore
Class Inheritance
All Implemented Interfaces
org.eclipse.jetty.session.SessionDataStore, org.eclipse.jetty.session.SessionDataMap, org.eclipse.jetty.util.component.LifeCycle
Imports
java.util.Set, org.eclipse.jetty.util.component.ContainerLifeCycle, org.slf4j.Logger, .LoggerFactory

CachingSessionDataStore A SessionDataStore is a mechanism for (persistently) storing data associated with sessions. This implementation delegates to a pluggable SessionDataStore for actually storing the session data. It also uses a pluggable cache implementation in front of the delegate SessionDataStore to improve performance: accessing most persistent store technology can be expensive time-wise, so introducing a fronting cache can increase performance. The cache implementation can either be a local cache, a remote cache, or a clustered cache. The implementation here will try to read first from the cache and fallback to reading from the SessionDataStore if the session key is not found. On writes, the session data is written first to the SessionDataStore, and then to the cache. On deletes, the data is deleted first from the SessionDataStore, and then from the cache. There is no transaction manager ensuring atomic operations, so it is possible that failures can result in cache inconsistency.

Field Summary

Modifier and TypeField and Description
protected SessionDataMap
_cache

The fronting cache

protected SessionDataStore
_store

The actual store for the session data

private static final Logger

Constructor Summary

AccessConstructor and Description
public
CachingSessionDataStore(SessionDataMap
the front cache to use
cache
,
SessionDataStore
the actual store for the the session data
store
)

Method Summary

Modifier and TypeMethod and Description
public boolean
delete(String
identity of session to delete
id
)

Implements org.eclipse.jetty.session.SessionDataMap.delete.

Delete session data

protected void
doStart()

Overrides org.eclipse.jetty.util.component.ContainerLifeCycle.doStart.

Starts the managed lifecycle beans in the order they were added.

protected void
doStop()

Overrides org.eclipse.jetty.util.component.ContainerLifeCycle.doStop.

Stops the managed lifecycle beans in the reverse order they were added.

public boolean
exists(String
Identity of session whose existence should be checked
id
)

Implements org.eclipse.jetty.session.SessionDataStore.exists.

Test if data exists for a given session id.

public Set<String>
getExpired(Set<String>
if provided, these are keys of sessions that the SessionDataStore thinks has expired and should be verified by the SessionDataStore
candidates
)

Implements org.eclipse.jetty.session.SessionDataStore.getExpired.

Called periodically, this method should search the data store for sessions that have been expired for a 'reasonable' amount of time.

public SessionDataMap

Returns:

the fronting cache for session data
getSessionDataMap
()

Get the fronting cache for session data.

public SessionDataStore

Returns:

the delegate session store
getSessionStore
()

Get the delegate session store.

public void
initialize(SessionContext
context associated
context
)

Implements org.eclipse.jetty.session.SessionDataMap.initialize.

Initialize this data map for the given context.

public boolean
isPassivating()

Implements org.eclipse.jetty.session.SessionDataStore.isPassivating.

True if this type of datastore will passivate session objects

public SessionData
load(String
identity of session to load
id
)

Implements org.eclipse.jetty.session.SessionDataMap.load.

Read in session data.

public SessionData
newSessionData(String
the id
id
,
long
the timestamp when created
created
,
long
the timestamp when accessed
accessed
,
long
the timestamp when last accessed
lastAccessed
,
long
the max inactive time in milliseconds
maxInactiveMs
)

Implements org.eclipse.jetty.session.SessionDataStore.newSessionData.

Create a new SessionData

public void
store(String
identity of session to store
id
,
SessionData
info of session to store
data
)

Implements org.eclipse.jetty.session.SessionDataMap.store.

Store the session data.

Inherited from org.eclipse.jetty.util.component.ContainerLifeCycle:
addBeanaddBeanaddEventListeneraddManagedcontainsdestroydumpdumpdumpdumpObjectsdumpStdErrgetBeangetBeansgetBeansgetContainedBeansgetContainedBeansisAutoisManagedisUnmanagedmanageremoveBeanremoveBeansremoveEventListenersetBeansstartstopunmanageupdateBeanupdateBeanupdateBeansupdateBeans

Field Detail

_cacheback to summary
protected SessionDataMap _cache

The fronting cache

_storeback to summary
protected SessionDataStore _store

The actual store for the session data

LOGback to summary
private static final Logger LOG

Hides org.eclipse.jetty.util.component.ContainerLifeCycle.LOG.

Constructor Detail

CachingSessionDataStoreback to summary
public CachingSessionDataStore(SessionDataMap cache, SessionDataStore store)
Parameters
cache:SessionDataMap

the front cache to use

store:SessionDataStore

the actual store for the the session data

Method Detail

deleteback to summary
public boolean delete(String id) throws Exception

Implements org.eclipse.jetty.session.SessionDataMap.delete.

Doc from org.eclipse.jetty.session.SessionDataMap.delete.

Delete session data

Parameters
id:String

identity of session to delete

Returns:boolean

true if the session was deleted

Annotations
@Override
Exceptions
Exception:
if unable to delete session data
doStartback to summary
protected void doStart() throws Exception

Overrides org.eclipse.jetty.util.component.ContainerLifeCycle.doStart.

Doc from org.eclipse.jetty.util.component.ContainerLifeCycle.doStart.

Starts the managed lifecycle beans in the order they were added.

Annotations
@Override
Exceptions
Exception:

Doc from org.eclipse.jetty.util.component.AbstractLifeCycle.doStart.

If there was a problem starting. Will cause a transition to FAILED state

doStopback to summary
protected void doStop() throws Exception

Overrides org.eclipse.jetty.util.component.ContainerLifeCycle.doStop.

Doc from org.eclipse.jetty.util.component.ContainerLifeCycle.doStop.

Stops the managed lifecycle beans in the reverse order they were added.

Annotations
@Override
Exceptions
Exception:

Doc from org.eclipse.jetty.util.component.AbstractLifeCycle.doStop.

If there was a problem stopping. Will cause a transition to FAILED state

existsback to summary
public boolean exists(String id) throws Exception

Implements org.eclipse.jetty.session.SessionDataStore.exists.

Doc from org.eclipse.jetty.session.SessionDataStore.exists.

Test if data exists for a given session id.

Parameters
id:String

Identity of session whose existence should be checked

Returns:boolean

true if valid, non-expired session exists

Annotations
@Override
Exceptions
Exception:
if problem checking existence with persistence layer
getExpiredback to summary
public Set<String> getExpired(Set<String> candidates)

Implements org.eclipse.jetty.session.SessionDataStore.getExpired.

Doc from org.eclipse.jetty.session.SessionDataStore.getExpired.

Called periodically, this method should search the data store for sessions that have been expired for a 'reasonable' amount of time.

Parameters
candidates:Set<String>

if provided, these are keys of sessions that the SessionDataStore thinks has expired and should be verified by the SessionDataStore

Returns:Set<String>

set of session ids

Annotations
@Override
getSessionDataMapback to summary
public SessionDataMap getSessionDataMap()

Get the fronting cache for session data.

Returns:SessionDataMap

the fronting cache for session data

getSessionStoreback to summary
public SessionDataStore getSessionStore()

Get the delegate session store.

Returns:SessionDataStore

the delegate session store

initializeback to summary
public void initialize(SessionContext context) throws Exception

Implements org.eclipse.jetty.session.SessionDataMap.initialize.

Doc from org.eclipse.jetty.session.SessionDataMap.initialize.

Initialize this data map for the given context. A SessionDataMap can only be used by one context(/session manager).

Parameters
context:SessionContext

context associated

Annotations
@Override
Exceptions
Exception:
if unable to initialize the
isPassivatingback to summary
public boolean isPassivating()

Implements org.eclipse.jetty.session.SessionDataStore.isPassivating.

Doc from org.eclipse.jetty.session.SessionDataStore.isPassivating.

True if this type of datastore will passivate session objects

Returns:boolean

true if this store can passivate sessions, false otherwise

Annotations
@Override
loadback to summary
public SessionData load(String id) throws Exception

Implements org.eclipse.jetty.session.SessionDataMap.load.

Doc from org.eclipse.jetty.session.SessionDataMap.load.

Read in session data.

Parameters
id:String

identity of session to load

Returns:SessionData

the SessionData matching the id

Annotations
@Override
Exceptions
Exception:
if unable to load session data
newSessionDataback to summary
public SessionData newSessionData(String id, long created, long accessed, long lastAccessed, long maxInactiveMs)

Implements org.eclipse.jetty.session.SessionDataStore.newSessionData.

Doc from org.eclipse.jetty.session.SessionDataStore.newSessionData.

Create a new SessionData

Parameters
id:String

the id

created:long

the timestamp when created

accessed:long

the timestamp when accessed

lastAccessed:long

the timestamp when last accessed

maxInactiveMs:long

the max inactive time in milliseconds

Returns:SessionData

a new SessionData object

Annotations
@Override
storeback to summary
public void store(String id, SessionData data) throws Exception

Implements org.eclipse.jetty.session.SessionDataMap.store.

Doc from org.eclipse.jetty.session.SessionDataMap.store.

Store the session data.

Parameters
id:String

identity of session to store

data:SessionData

info of session to store

Annotations
@Override
Exceptions
Exception:
if unable to write session data