|
JSecurity | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.jsecurity.session.mgt.eis.CachingSessionDAO
public abstract class CachingSessionDAO
An CachingSessionDAO is a SessionDAO that provides a transparent caching layer between the components that use it and the underlying EIS (Enterprise Information System) for enhanced performance.
This implementation caches all active sessions in a cache created by a
CacheManager. All SessionDAO methods are implemented by this class to employ
caching behavior and delegates the actual EIS operations to respective do* methods to be implemented by
subclasses (doCreate, doRead, etc).
| Field Summary | |
|---|---|
static String |
ACTIVE_SESSION_CACHE_NAME
|
| Constructor Summary | |
|---|---|
CachingSessionDAO()
JavaBeans compatible constructor. |
|
| Method Summary | |
|---|---|
Serializable |
create(Session session)
Creates the session by delegating EIS creation to subclasses via the doCreate(org.jsecurity.session.Session) method, and then
caches the session. |
protected Cache |
createActiveSessionsCache()
|
void |
delete(Session session)
Removes the specified session from any cache and then permanently deletes the session from the EIS by delegating to doDelete(org.jsecurity.session.Session). |
protected abstract Serializable |
doCreate(Session session)
Subclass hook to actually persist the given Session instance to the underlying EIS. |
protected abstract void |
doDelete(Session session)
Subclass implementation hook to permanently delete the given Session from the underlying EIS. |
protected abstract Session |
doReadSession(Serializable sessionId)
Subclass implmentation hook to actually retrieve the Session object from the underlying EIS. |
protected abstract void |
doUpdate(Session session)
Subclass implementation hook to actually persist the Session's state to the underlying EIS. |
protected void |
ensureUncached(Serializable sessionId)
Ensures that there is no cache entry already in place for a session with id of sessionId. |
Collection<Session> |
getActiveSessions()
Returns all active sessions in the system. |
Cache |
getActiveSessionsCache()
|
protected Cache |
getActiveSessionsCacheLazy()
|
String |
getActiveSessionsCacheName()
|
CacheManager |
getCacheManager()
Returns the CacheManager used by the implementation that creates the activeSessions Cache. |
Session |
readSession(Serializable sessionId)
Retrieves the Session object from the underlying EIS identified by sessionId. |
void |
setActiveSessionsCache(Cache cache)
|
void |
setActiveSessionsCacheName(String activeSessionsCacheName)
|
void |
setCacheManager(CacheManager cacheManager)
Sets the cacheManager to use for constructing the session cache. |
void |
update(Session session)
Updates the state of the given session to the EIS. |
protected void |
verifySessionId(Serializable sessionId)
Ensures the sessionId returned from the subclass implementation of doCreate(org.jsecurity.session.Session) is not null and not
already in use. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final String ACTIVE_SESSION_CACHE_NAME
| Constructor Detail |
|---|
public CachingSessionDAO()
| Method Detail |
|---|
public void setCacheManager(CacheManager cacheManager)
setCacheManager in interface CacheManagerAwarecacheManager - the manager to use for constructing the session cache.public CacheManager getCacheManager()
public String getActiveSessionsCacheName()
public void setActiveSessionsCacheName(String activeSessionsCacheName)
public Cache getActiveSessionsCache()
protected Cache getActiveSessionsCacheLazy()
public void setActiveSessionsCache(Cache cache)
protected Cache createActiveSessionsCache()
public Serializable create(Session session)
doCreate(org.jsecurity.session.Session) method, and then
caches the session.
create in interface SessionDAOsession - Session object to create in the EIS and then cache.
protected void verifySessionId(Serializable sessionId)
doCreate(org.jsecurity.session.Session) is not null and not
already in use.
sessionId - session id returned from the subclass implementation of doCreate(org.jsecurity.session.Session)protected void ensureUncached(Serializable sessionId)
verifySessionId(java.io.Serializable) implementation.
sessionId - the session id to check for non-existence in the cache.protected abstract Serializable doCreate(Session session)
session - the Session instance to persist to the EIS.
Session.getId().
public Session readSession(Serializable sessionId)
throws UnknownSessionException
Upon receiving the Session object from the subclass's doReadSession(java.io.Serializable) implementation, it will be
cached first and then returned to the caller.
readSession in interface SessionDAOsessionId - the id of the session to retrieve from the EIS.
UnknownSessionException - if the id specified does not correspond to any session in the cache or EIS.protected abstract Session doReadSession(Serializable sessionId)
sessionId - the id of the Session to retrieve.
public void update(Session session)
throws UnknownSessionException
If the specified session was previously cached, and the session is now invalid, it will be removed from the cache.
If the specified session is not stopped or expired, and was not yet in the cache, it will be added to the cache.
Finally, this method calls doUpdate(org.jsecurity.session.Session) for the subclass to actually push the object state to the EIS.
update in interface SessionDAOsession - the session object to update in the EIS.
UnknownSessionException - if no existing EIS session record exists with the
identifier of session.getId()protected abstract void doUpdate(Session session)
session - the session object whose state will be propagated to the EIS.public void delete(Session session)
doDelete(org.jsecurity.session.Session).
delete in interface SessionDAOsession - the session to remove from caches and permanently delete from the EIS.protected abstract void doDelete(Session session)
session - the session instance to permanently delete from the EIS.public Collection<Session> getActiveSessions()
This implementation merely returns the sessions found in the activeSessions cache. Subclass implementations may wish to override this method to retrieve them in a different way, perhaps by an RDBMS query or by other means.
getActiveSessions in interface SessionDAO
|
JSecurity | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||