Class DefaultSessionCache
- java.lang.Object
-
- com.aspectran.core.component.AbstractComponent
-
- com.aspectran.core.component.session.AbstractSessionCache
-
- com.aspectran.core.component.session.DefaultSessionCache
-
- All Implemented Interfaces:
Component,SessionCache
public class DefaultSessionCache extends AbstractSessionCache
Implementation ofSessionCache.Created: 2017. 6. 24.
-
-
Field Summary
-
Fields inherited from interface com.aspectran.core.component.session.SessionCache
EVICT_ON_INACTIVITY, EVICT_ON_SESSION_EXIT, NEVER_EVICT
-
-
Constructor Summary
Constructors Constructor Description DefaultSessionCache(SessionHandler sessionHandler, SessionStore sessionStore, boolean clusterEnabled)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected DefaultSessiondoComputeIfAbsent(java.lang.String id, java.util.function.Function<java.lang.String,DefaultSession> mappingFunction)Compute the mappingFunction to create a Session object if the session with the given id isn't already in the map, otherwise return the existing Session.protected DefaultSessiondoDelete(java.lang.String id)Remove the session with this identity from the store.protected voiddoDestroy()protected DefaultSessiondoGet(java.lang.String id)Get the session matching the key.protected voiddoInitialize()protected DefaultSessiondoPutIfAbsent(java.lang.String id, DefaultSession session)Put the session into the map if it wasn't already there.protected booleandoReplace(java.lang.String id, DefaultSession oldValue, DefaultSession newValue)Replace the mapping from id to oldValue with newValue.longgetActiveSessionCount()java.util.Set<java.lang.String>getAllSessions()longgetCreatedSessionCount()longgetExpiredSessionCount()longgetHighestSessionCount()intgetMaxSessions()longgetRejectedSessionCount()voidresetStatistics()Resets the running total session count in the cache.voidsetMaxSessions(int maxSessions)Sets the maximum number of active sessions allowed in this session cache.-
Methods inherited from class com.aspectran.core.component.session.AbstractSessionCache
add, checkExpiration, checkInactiveSession, contains, delete, exists, get, getEvictionIdleSecs, getSessionHandler, getSessionStore, isClusterEnabled, isRemoveUnloadableSessions, isSaveOnCreate, isSaveOnInactiveEviction, release, renewSessionId, renewSessionId, setEvictionIdleSecs, setRemoveUnloadableSessions, setSaveOnCreate, setSaveOnInactiveEviction
-
Methods inherited from class com.aspectran.core.component.AbstractComponent
destroy, getComponentName, initialize, isAvailable, isDestroyed, isDestroying, isInitialized
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.aspectran.core.component.session.SessionCache
destroy
-
-
-
-
Constructor Detail
-
DefaultSessionCache
public DefaultSessionCache(SessionHandler sessionHandler, SessionStore sessionStore, boolean clusterEnabled)
-
-
Method Detail
-
getMaxSessions
public int getMaxSessions()
-
setMaxSessions
public void setMaxSessions(int maxSessions)
Description copied from interface:SessionCacheSets the maximum number of active sessions allowed in this session cache. The number of active sessions exceeds this limit, attempts to create new sessions will be rejected. If set to 0 (the default), there is no limit.- Parameters:
maxSessions- the maximum number of active sessions allowed in this session cache
-
doGet
protected DefaultSession doGet(java.lang.String id)
Description copied from class:AbstractSessionCacheGet the session matching the key.- Specified by:
doGetin classAbstractSessionCache- Parameters:
id- the session id- Returns:
- the Session object matching the id
-
doPutIfAbsent
protected DefaultSession doPutIfAbsent(java.lang.String id, DefaultSession session)
Description copied from class:AbstractSessionCachePut the session into the map if it wasn't already there.- Specified by:
doPutIfAbsentin classAbstractSessionCache- Parameters:
id- the identity of the sessionsession- the session object- Returns:
- null if the session wasn't already in the map, or the existing entry otherwise
-
doComputeIfAbsent
protected DefaultSession doComputeIfAbsent(java.lang.String id, java.util.function.Function<java.lang.String,DefaultSession> mappingFunction)
Description copied from class:AbstractSessionCacheCompute the mappingFunction to create a Session object if the session with the given id isn't already in the map, otherwise return the existing Session. This method is expected to have precisely the same behaviour asConcurrentHashMap.computeIfAbsent(K, java.util.function.Function<? super K, ? extends V>)- Specified by:
doComputeIfAbsentin classAbstractSessionCache- Parameters:
id- the session idmappingFunction- the function to load the data for the session- Returns:
- an existing Session from the cache
-
doDelete
protected DefaultSession doDelete(java.lang.String id)
Description copied from class:AbstractSessionCacheRemove the session with this identity from the store.- Specified by:
doDeletein classAbstractSessionCache- Parameters:
id- the session id- Returns:
- true if removed; false otherwise
-
doReplace
protected boolean doReplace(java.lang.String id, DefaultSession oldValue, DefaultSession newValue)Description copied from class:AbstractSessionCacheReplace the mapping from id to oldValue with newValue.- Specified by:
doReplacein classAbstractSessionCache- Parameters:
id- the session idoldValue- the old valuenewValue- the new value- Returns:
- true if replacement was done
-
getAllSessions
public java.util.Set<java.lang.String> getAllSessions()
-
getActiveSessionCount
public long getActiveSessionCount()
- Returns:
- the number of sessions in the cache
-
getHighestSessionCount
public long getHighestSessionCount()
- Returns:
- the max number of sessions in the cache
-
getCreatedSessionCount
public long getCreatedSessionCount()
- Returns:
- a running total of sessions in the cache
-
getExpiredSessionCount
public long getExpiredSessionCount()
-
getRejectedSessionCount
public long getRejectedSessionCount()
-
resetStatistics
public void resetStatistics()
Description copied from interface:SessionCacheResets the running total session count in the cache.
-
doInitialize
protected void doInitialize() throws java.lang.Exception- Specified by:
doInitializein classAbstractComponent- Throws:
java.lang.Exception
-
doDestroy
protected void doDestroy() throws java.lang.Exception- Specified by:
doDestroyin classAbstractComponent- Throws:
java.lang.Exception
-
-