org.apache.shiro.session.mgt.eis
Class EnterpriseCacheSessionDAO

java.lang.Object
  extended by org.apache.shiro.session.mgt.eis.AbstractSessionDAO
      extended by org.apache.shiro.session.mgt.eis.CachingSessionDAO
          extended by org.apache.shiro.session.mgt.eis.EnterpriseCacheSessionDAO
All Implemented Interfaces:
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 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-based CacheManager, 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 the parent 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
EnterpriseCacheSessionDAO()
           
 
Method Summary
protected  Serializable doCreate(Session session)
          Subclass hook to actually persist the given Session instance to the underlying EIS.
protected  void doDelete(Session session)
          Subclass implementation hook to permanently delete the given Session from 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.
protected  void doUpdate(Session session)
          Subclass implementation hook to actually persist the Session'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
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

EnterpriseCacheSessionDAO

public EnterpriseCacheSessionDAO()
Method Detail

doCreate

protected Serializable doCreate(Session session)
Description copied from class: AbstractSessionDAO
Subclass hook to actually persist the given Session instance to the underlying EIS.

Specified by:
doCreate in class AbstractSessionDAO
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: AbstractSessionDAO
Subclass implementation hook that retrieves the Session object from the underlying EIS or null if a session with that ID could not be found.

Specified by:
doReadSession in class AbstractSessionDAO
Parameters:
sessionId - the id of the Session to retrieve.
Returns:
the Session in the EIS identified by sessionId or null if a session with that ID could not be found.

doUpdate

protected void doUpdate(Session session)
Description copied from class: CachingSessionDAO
Subclass implementation hook to actually persist the Session's state to the underlying EIS.

Specified by:
doUpdate in class CachingSessionDAO
Parameters:
session - the session object whose state will be propagated to the EIS.

doDelete

protected void doDelete(Session session)
Description copied from class: CachingSessionDAO
Subclass implementation hook to permanently delete the given Session from the underlying EIS.

Specified by:
doDelete in class CachingSessionDAO
Parameters:
session - the session instance to permanently delete from the EIS.


Copyright © 2004-2014 The Apache Software Foundation. All Rights Reserved.