public class SessionCache
extends java.lang.Object
implements org.springframework.context.ApplicationContextAware
SessionManager
. Maps from
Session
uuid to SessionContext
in memory, with each mapping
also having an additional cache which may spill over to disk,
listeners
.
Uses MapMaker
and various implementations from
java.util.concurrent.atomic to provide a lock-free implementation.Modifier and Type | Class and Description |
---|---|
static interface |
SessionCache.StaleCacheListener
Observer pattern used to refresh sessions in doUpdate.
|
Constructor and Description |
---|
SessionCache() |
Modifier and Type | Method and Description |
---|---|
boolean |
addSessionCallback(java.lang.String session,
SessionCallback cb) |
protected net.sf.ehcache.Ehcache |
createCache(java.lang.String key,
boolean inMemory,
int maxInMemory) |
void |
doUpdate()
Will only ever be accessed by a single thread.
|
java.util.Set<java.lang.String> |
getIds()
Since all methods which use
getIds() will subsequently check for
the existing session, we do not block here. |
long |
getLastUpdated() |
SessionContext |
getSessionContext(java.lang.String uuid)
Retrieve a session possibly raising either
RemovedSessionException or SessionTimeoutException . |
SessionContext |
getSessionContext(java.lang.String uuid,
boolean quietly)
Retrieve a session possibly raising either
RemovedSessionException or SessionTimeoutException . |
java.util.Map<java.lang.String,java.lang.Object> |
getSessionData(java.lang.String uuid,
boolean quietly)
Returns all the data contained in the internal implementation of
this manager.
|
net.sf.ehcache.Ehcache |
inMemoryCache(java.lang.String uuid) |
net.sf.ehcache.Ehcache |
onDiskCache(java.lang.String uuid) |
void |
putSession(java.lang.String uuid,
SessionContext sessionContext)
Puts a session blindly into the context.
|
void |
refresh(java.lang.String uuid,
SessionContext replacement)
Used externally to refresh the
SessionContext instance
associated with the session uuid |
void |
reload(java.lang.String id)
Provides the reloading logic of the
SessionCache for the
SessionManagerImpl to use. |
void |
removeSession(java.lang.String uuid) |
boolean |
removeSessionCallback(java.lang.String session,
SessionCallback cb) |
void |
setApplicationContext(org.springframework.context.ApplicationContext ctx)
Context injector.
|
void |
setCacheManager(net.sf.ehcache.CacheManager manager)
Injection method, also performs the creation of
sessions |
void |
setStaleCacheListener(SessionCache.StaleCacheListener staleCacheListener) |
void |
setUpdateInterval(long milliseconds)
Inject time in milliseconds between updates.
|
void |
updateEvent(UserGroupUpdateEvent ugue)
Adds a new entry to
state . |
public void setCacheManager(net.sf.ehcache.CacheManager manager)
sessions
public void setApplicationContext(org.springframework.context.ApplicationContext ctx) throws org.springframework.beans.BeansException
setApplicationContext
in interface org.springframework.context.ApplicationContextAware
org.springframework.beans.BeansException
public void setUpdateInterval(long milliseconds)
public void setStaleCacheListener(SessionCache.StaleCacheListener staleCacheListener)
public boolean addSessionCallback(java.lang.String session, SessionCallback cb)
public boolean removeSessionCallback(java.lang.String session, SessionCallback cb)
public void putSession(java.lang.String uuid, SessionContext sessionContext)
public void refresh(java.lang.String uuid, SessionContext replacement)
SessionContext
instance
associated with the session uuiduuid
- replacement
- public SessionContext getSessionContext(java.lang.String uuid)
RemovedSessionException
or SessionTimeoutException
.public SessionContext getSessionContext(java.lang.String uuid, boolean quietly)
RemovedSessionException
or SessionTimeoutException
.quietly
- If true, then the access time for the given UUID
will not be updated.public java.util.Map<java.lang.String,java.lang.Object> getSessionData(java.lang.String uuid, boolean quietly)
quietly
- If true, then the access time for the given UUID
will not be updated.public void removeSession(java.lang.String uuid)
public java.util.Set<java.lang.String> getIds()
getIds()
will subsequently check for
the existing session, we do not block here. Blocking is primarily useful
for post-admintype changes which can add or remove a user from a group.
The existence of a session (which is what getIds specifies) is not
significantly effected.public net.sf.ehcache.Ehcache inMemoryCache(java.lang.String uuid)
public net.sf.ehcache.Ehcache onDiskCache(java.lang.String uuid)
protected net.sf.ehcache.Ehcache createCache(java.lang.String key, boolean inMemory, int maxInMemory)
public long getLastUpdated()
public void updateEvent(UserGroupUpdateEvent ugue)
state
. If the
timestamp on the event is invalid, then
System.currentTimeMillis()
will be used.public void doUpdate()
active
gets set to true
value to specify that this
method is currently running.public void reload(java.lang.String id)
SessionCache
for the
SessionManagerImpl
to use.
Version: 5.4.4-ice35-b82
Copyright © 2018 The University of Dundee & Open Microscopy Environment. All Rights Reserved.