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
SessionDAO implementation that relies on an enterprise caching product as the EIS system of record for all sessions.
It is expected that an injected
Cache or
CacheManager is 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 cause OutOfMemoryExceptions. Just
don't forget to configure* an instance of this class with a production-grade CacheManager that can
handle disk paging for large numbers of sessions and you'll be fine.
*If you configure Shiro's SecurityManager instance with such a CacheManager, 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 a Cache or
CacheManager to perform caching, and the cache is considered the system of record, nothing further needs to
be done for the doReadSession(java.io.Serializable), doUpdate(org.apache.shiro.session.Session) and doDelete(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 -
Method Summary
Modifier and TypeMethodDescriptionprotected SerializableSubclass hook to actually persist the given Session instance to the underlying EIS.protected voidSubclass 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 voidSubclass 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, updateMethods inherited from class org.apache.shiro.session.mgt.eis.AbstractSessionDAO
assignSessionId, generateSessionId, getSessionIdGenerator, setSessionIdGenerator
-
Constructor Details
-
EnterpriseCacheSessionDAO
public EnterpriseCacheSessionDAO()
-
-
Method Details
-
doCreate
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
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
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
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.
-