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 DefaultSession
doComputeIfAbsent(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 DefaultSession
doDelete(java.lang.String id)
Remove the session with this identity from the store.protected void
doDestroy()
protected DefaultSession
doGet(java.lang.String id)
Get the session matching the key.protected void
doInitialize()
protected DefaultSession
doPutIfAbsent(java.lang.String id, DefaultSession session)
Put the session into the map if it wasn't already there.protected boolean
doReplace(java.lang.String id, DefaultSession oldValue, DefaultSession newValue)
Replace the mapping from id to oldValue with newValue.long
getActiveSessionCount()
java.util.Set<java.lang.String>
getAllSessions()
long
getCreatedSessionCount()
long
getExpiredSessionCount()
long
getHighestSessionCount()
int
getMaxSessions()
long
getRejectedSessionCount()
void
resetStatistics()
Resets the running total session count in the cache.void
setMaxSessions(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:SessionCache
Sets 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:AbstractSessionCache
Get the session matching the key.- Specified by:
doGet
in 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:AbstractSessionCache
Put the session into the map if it wasn't already there.- Specified by:
doPutIfAbsent
in 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:AbstractSessionCache
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. This method is expected to have precisely the same behaviour asConcurrentHashMap.computeIfAbsent(K, java.util.function.Function<? super K, ? extends V>)
- Specified by:
doComputeIfAbsent
in 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:AbstractSessionCache
Remove the session with this identity from the store.- Specified by:
doDelete
in 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:AbstractSessionCache
Replace the mapping from id to oldValue with newValue.- Specified by:
doReplace
in 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:SessionCache
Resets the running total session count in the cache.
-
doInitialize
protected void doInitialize() throws java.lang.Exception
- Specified by:
doInitialize
in classAbstractComponent
- Throws:
java.lang.Exception
-
doDestroy
protected void doDestroy() throws java.lang.Exception
- Specified by:
doDestroy
in classAbstractComponent
- Throws:
java.lang.Exception
-
-