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
Implementation of
SessionCache
.
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
ConstructorsConstructorDescriptionDefaultSessionCache
(AbstractSessionManager sessionManager, SessionStore sessionStore, boolean clusterEnabled) -
Method Summary
Modifier and TypeMethodDescriptionprotected ManagedSession
doComputeIfAbsent
(String id, Function<String, ManagedSession> 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 ManagedSession
Remove the session with this identity from the store.protected void
protected ManagedSession
Get the session matching the key.protected void
protected ManagedSession
doPutIfAbsent
(String id, ManagedSession session) Put the session into the map if it wasn't already there.int
void
setMaxActiveSessions
(int maxActiveSessions) Sets the maximum number of active sessions allowed in this session cache.toString()
Methods inherited from class com.aspectran.core.component.session.AbstractSessionCache
add, checkExpiration, checkInactiveSession, cleanOrphans, contains, delete, exists, get, getComponentName, getEvictionIdleSecs, getEvictionIdleSecsForNew, getSessionManager, getSessionStore, getSessionStoreName, getStatistics, isClusterEnabled, isRemoveUnloadableSessions, isSaveOnCreate, isSaveOnInactiveEviction, refresh, release, renewSessionId, renewSessionId, setEvictionIdleSecs, setEvictionIdleSecsForNew, setRemoveUnloadableSessions, setSaveOnCreate, setSaveOnInactiveEviction
Methods inherited from class com.aspectran.core.component.AbstractComponent
checkAvailable, checkInitializable, checkNotDestroyed, destroy, initialize, isAvailable, isDestroyed, isDestroying, isInitializable, isInitialized, isInitializing
-
Constructor Details
-
DefaultSessionCache
public DefaultSessionCache(AbstractSessionManager sessionManager, SessionStore sessionStore, boolean clusterEnabled)
-
-
Method Details
-
getMaxActiveSessions
public int getMaxActiveSessions() -
setMaxActiveSessions
public void setMaxActiveSessions(int maxActiveSessions) 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:
maxActiveSessions
- the maximum number of active sessions allowed in this session cache
-
doGet
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
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 ManagedSession doComputeIfAbsent(String id, Function<String, ManagedSession> 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
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:
- the Session object if removed; null otherwise
-
getActiveSessions
- Returns:
- the identifiers of those sessions that are active on this node, excluding passivated sessions
-
getAllSessions
- Returns:
- the identifiers of all sessions, including both active and passive
-
doInitialize
- Specified by:
doInitialize
in classAbstractComponent
- Throws:
Exception
-
doDestroy
- Specified by:
doDestroy
in classAbstractComponent
- Throws:
Exception
-
toString
-