Package org.apache.shiro.session.mgt.eis
Class EnterpriseCacheSessionDAO
- java.lang.Object
-
- org.apache.shiro.session.mgt.eis.AbstractSessionDAO
-
- org.apache.shiro.session.mgt.eis.CachingSessionDAO
-
- org.apache.shiro.session.mgt.eis.EnterpriseCacheSessionDAO
-
- All Implemented Interfaces:
org.apache.shiro.cache.CacheManagerAware,SessionDAO
public class EnterpriseCacheSessionDAO extends CachingSessionDAO
SessionDAO implementation that relies on an enterprise caching product as the EIS system of record for all sessions. It is expected that an injectedCacheorCacheManageris backed by an enterprise caching product that can support all application sessions and/or provide disk paging for resilient data storage.Production Note
This implementation defaults to using an in-memory map-basedCacheManager, which is great for testing but will typically not scale for production environments and could easily causeOutOfMemoryExceptions. Just don't forget to configure* an instance of this class with a production-gradeCacheManagerthat can handle disk paging for large numbers of sessions and you'll be fine. *If you configure Shiro'sSecurityManagerinstance with such aCacheManager, it will be automatically applied to an instance of this class and you won't need to explicitly set it in configuration.Implementation Details
This implementation relies heavily on theparent class's transparent caching behavior for all storage operations with the enterprise caching product. Because the parent class uses aCacheorCacheManagerto perform caching, and the cache is considered the system of record, nothing further needs to be done for thedoReadSession(java.io.Serializable),doUpdate(org.apache.shiro.session.Session)anddoDelete(org.apache.shiro.session.Session)method implementations. This class implements those methods as required by the parent class, but they essentially do nothing.- Since:
- 1.0
-
-
Field Summary
-
Fields inherited from class org.apache.shiro.session.mgt.eis.CachingSessionDAO
ACTIVE_SESSION_CACHE_NAME
-
-
Constructor Summary
Constructors Constructor Description EnterpriseCacheSessionDAO()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected SerializabledoCreate(Session session)Subclass hook to actually persist the given Session instance to the underlying EIS.protected voiddoDelete(Session session)Subclass implementation hook to permanently delete the given Session from the underlying EIS.protected SessiondoReadSession(Serializable sessionId)Subclass implementation hook that retrieves the Session object from the underlying EIS ornullif a session with that ID could not be found.protected voiddoUpdate(Session session)Subclass implementation hook to actually persist theSession's state to the underlying EIS.-
Methods inherited from class org.apache.shiro.session.mgt.eis.CachingSessionDAO
cache, cache, create, createActiveSessionsCache, delete, getActiveSessions, getActiveSessionsCache, getActiveSessionsCacheName, getCachedSession, getCachedSession, getCacheManager, readSession, setActiveSessionsCache, setActiveSessionsCacheName, setCacheManager, uncache, update
-
Methods inherited from class org.apache.shiro.session.mgt.eis.AbstractSessionDAO
assignSessionId, generateSessionId, getSessionIdGenerator, setSessionIdGenerator
-
-
-
-
Method Detail
-
doCreate
protected Serializable doCreate(Session session)
Description copied from class:AbstractSessionDAOSubclass hook to actually persist the given Session instance to the underlying EIS.- Specified by:
doCreatein classAbstractSessionDAO- Parameters:
session- the Session instance to persist to the EIS.- Returns:
- the id of the session created in the EIS (i.e. this is almost always a primary key and should be the
value returned from
Session.getId().
-
doReadSession
protected Session doReadSession(Serializable sessionId)
Description copied from class:AbstractSessionDAOSubclass implementation hook that retrieves the Session object from the underlying EIS ornullif a session with that ID could not be found.- Specified by:
doReadSessionin classAbstractSessionDAO- Parameters:
sessionId- the id of the Session to retrieve.- Returns:
- the Session in the EIS identified by sessionId or
nullif a session with that ID could not be found.
-
doUpdate
protected void doUpdate(Session session)
Description copied from class:CachingSessionDAOSubclass implementation hook to actually persist theSession's state to the underlying EIS.- Specified by:
doUpdatein classCachingSessionDAO- Parameters:
session- the session object whose state will be propagated to the EIS.
-
doDelete
protected void doDelete(Session session)
Description copied from class:CachingSessionDAOSubclass implementation hook to permanently delete the given Session from the underlying EIS.- Specified by:
doDeletein classCachingSessionDAO- Parameters:
session- the session instance to permanently delete from the EIS.
-
-