|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.shiro.session.mgt.eis.AbstractSessionDAO org.apache.shiro.session.mgt.eis.MemorySessionDAO
public class MemorySessionDAO
Simple memory-based implementation of the SessionDAO that stores all of its sessions in an in-memory
ConcurrentMap
. This implementation does not page to disk and is therefore unsuitable for applications
that could experience a large amount of sessions and would therefore cause OutOfMemoryException
s. It is
not recommended for production use in most environments.
SessionDAO
implementation which
uses a more expansive or permanent backing data store.
In this case, it is recommended to instead use a custom
CachingSessionDAO
implementation that communicates with a higher-capacity data store of your choice
(file system, database, etc).
CachingSessionDAO
, but this caused problems with many
cache implementations that would expunge entries due to TTL settings, resulting in Sessions that would be randomly
(and permanently) lost. The Shiro 1.0 release refactored this implementation to be 100% memory-based (without
Cache
usage to avoid this problem.
CachingSessionDAO
Constructor Summary | |
---|---|
MemorySessionDAO()
|
Method Summary | |
---|---|
void |
delete(Session session)
Deletes the associated EIS record of the specified session . |
protected Serializable |
doCreate(Session session)
Subclass hook to actually persist the given Session instance to the underlying EIS. |
protected Session |
doReadSession(Serializable sessionId)
Subclass implementation hook that retrieves the Session object from the underlying EIS or null if a
session with that ID could not be found. |
Collection<Session> |
getActiveSessions()
Returns all sessions in the EIS that are considered active, meaning all sessions that haven't been stopped/expired. |
protected Session |
storeSession(Serializable id,
Session session)
|
void |
update(Session session)
Updates (persists) data from a previously created Session instance in the EIS identified by {@link Session#getId() session.getId()} . |
Methods inherited from class org.apache.shiro.session.mgt.eis.AbstractSessionDAO |
---|
assignSessionId, create, generateSessionId, getSessionIdGenerator, readSession, setSessionIdGenerator |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public MemorySessionDAO()
Method Detail |
---|
protected Serializable doCreate(Session session)
AbstractSessionDAO
doCreate
in class AbstractSessionDAO
session
- the Session instance to persist to the EIS.
Session.getId()
.protected Session storeSession(Serializable id, Session session)
protected Session doReadSession(Serializable sessionId)
AbstractSessionDAO
null
if a
session with that ID could not be found.
doReadSession
in class AbstractSessionDAO
sessionId
- the id of the Session to retrieve.
null
if a
session with that ID could not be found.public void update(Session session) throws UnknownSessionException
SessionDAO
{@link Session#getId() session.getId()}
. This effectively propagates
the data in the argument to the EIS record previously saved.
In addition to UnknownSessionException, implementations are free to throw any other
exceptions that might occur due to integrity violation constraints or other EIS related
errors.
session
- the Session to update
UnknownSessionException
- if no existing EIS session record exists with the
identifier of session.getSessionId()
public void delete(Session session)
SessionDAO
session
. If there never
existed a session EIS record with the identifier of
session.getId()
, then this method does nothing.
session
- the session to delete.public Collection<Session> getActiveSessions()
SessionDAO
null
.
lastAccessTime
.
SimpleSession
s were being stored):
select * from sessions s where s.lastAccessTimestamp < ? and s.stopTimestamp is nullwhere the
?
parameter is a date instance equal to 'now' minus the session timeout
(e.g. now - 30 minutes).
Session
s that are considered active, or an
empty collection or null
if there are no active sessions.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |