类 InMemorySessionRepository
- 所有已实现的接口:
SessionRepository
SessionRepository- 从以下版本开始:
- 2019-09-28 10:31
- 作者:
- Harry Yang
-
嵌套类概要
嵌套类修饰符和类型类说明private final class(专用程序包) final classprivate static enum -
字段概要
字段修饰符和类型字段说明private Clockprivate final SessionEventDispatcherprivate final InMemorySessionRepository.ExpiredSessionCheckerprivate final SessionIdGeneratorprivate static final cn.taketoday.logging.Loggerprivate Durationprivate intprivate booleanprivate booleanWhen an attribute that is already present in the session is added again under the same name and the attribute implementsAttributeBindingListener, shouldAttributeBindingListener.valueUnbound(WebSession, String))} be called followed byAttributeBindingListener.valueBound(WebSession, String)private final ConcurrentHashMap<String,InMemorySessionRepository.InMemoryWebSession> -
构造器概要
构造器构造器说明InMemorySessionRepository(SessionEventDispatcher eventDispatcher, SessionIdGenerator idGenerator) -
方法概要
修饰符和类型方法说明booleanCreate a new WebSession.createSession(String id) Create a new WebSession with given session id.getClock()Return the configured clock for session lastAccessTime calculations.String[]intReturn the maximum number of sessions that can be stored.intReturn the map of sessions with anunmodifiablewrapper.voidCheck for expired sessions and remove them.removeSession(String id) Remove the WebSession for the specified id.Return the WebSession for the given id.voidConfigure theClockto use to set lastAccessTime on every created session and to calculate if it is expired.voidsetMaxSessions(int maxSessions) Set the maximum number of sessions that can be stored.voidsetNotifyAttributeListenerOnUnchangedValue(boolean notifyAttributeListenerOnUnchangedValue) When an attribute that is already present in the session is added again under the same name and aWebSessionAttributeListeneris configured for the session shouldWebSessionAttributeListener.attributeReplaced(WebSession, String, Object, Object)be called?voidsetNotifyBindingListenerOnUnchangedValue(boolean notifyBindingListenerOnUnchangedValue) When an attribute that is already present in the session is added again under the same name and the attribute implementsAttributeBindingListener, shouldAttributeBindingListener.valueUnbound(WebSession, String)be called followed byAttributeBindingListener.valueBound(WebSession, String)voidsetSessionMaxIdleTime(Duration timeout) Set the duration of session idle timeoutvoidupdateLastAccessTime(WebSession session) Update the last accessed timestamp to "now".从类继承的方法 java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait从接口继承的方法 cn.taketoday.session.SessionRepository
removeSession
-
字段详细资料
-
log
private static final cn.taketoday.logging.Logger log -
maxSessions
private int maxSessions -
clock
-
notifyBindingListenerOnUnchangedValue
private boolean notifyBindingListenerOnUnchangedValueWhen an attribute that is already present in the session is added again under the same name and the attribute implementsAttributeBindingListener, shouldAttributeBindingListener.valueUnbound(WebSession, String))} be called followed byAttributeBindingListener.valueBound(WebSession, String)The default value is
false.trueif the listener will be notified,falseif it will not -
notifyAttributeListenerOnUnchangedValue
private boolean notifyAttributeListenerOnUnchangedValue -
maxIdleTime
-
idGenerator
-
eventDispatcher
-
expiredSessionChecker
-
sessions
-
-
构造器详细资料
-
InMemorySessionRepository
public InMemorySessionRepository(SessionEventDispatcher eventDispatcher, SessionIdGenerator idGenerator)
-
-
方法详细资料
-
setMaxSessions
public void setMaxSessions(int maxSessions) Set the maximum number of sessions that can be stored. Once the limit is reached, any attempt to store an additional session will result in anIllegalStateException.By default set to 10000.
- 参数:
maxSessions- the maximum number of sessions- 从以下版本开始:
- 4.0
-
getMaxSessions
public int getMaxSessions()Return the maximum number of sessions that can be stored.- 从以下版本开始:
- 4.0
-
setSessionMaxIdleTime
Set the duration of session idle timeout- 参数:
timeout- the duration of session idle timeout- 从以下版本开始:
- 4.0
-
setNotifyBindingListenerOnUnchangedValue
public void setNotifyBindingListenerOnUnchangedValue(boolean notifyBindingListenerOnUnchangedValue) When an attribute that is already present in the session is added again under the same name and the attribute implementsAttributeBindingListener, shouldAttributeBindingListener.valueUnbound(WebSession, String)be called followed byAttributeBindingListener.valueBound(WebSession, String)The default value is
false.- 参数:
notifyBindingListenerOnUnchangedValue-trueif the listener will be notified,falseif it will not- 从以下版本开始:
- 4.0
-
setNotifyAttributeListenerOnUnchangedValue
public void setNotifyAttributeListenerOnUnchangedValue(boolean notifyAttributeListenerOnUnchangedValue) When an attribute that is already present in the session is added again under the same name and aWebSessionAttributeListeneris configured for the session shouldWebSessionAttributeListener.attributeReplaced(WebSession, String, Object, Object)be called?The default value is
true.- 参数:
notifyAttributeListenerOnUnchangedValue-trueif the listener will be notified,falseif it will not- 从以下版本开始:
- 4.0
-
setClock
Configure theClockto use to set lastAccessTime on every created session and to calculate if it is expired.This may be useful to align to different timezone or to set the clock back in a test, e.g.
Clock.offset(clock, Duration.ofMinutes(-31))in order to simulate session expiration.By default this is
Clock.system(ZoneId.of("GMT")).- 参数:
clock- the clock to use- 从以下版本开始:
- 4.0
-
getClock
Return the configured clock for session lastAccessTime calculations.- 从以下版本开始:
- 4.0
-
getSessionCount
public int getSessionCount()- 指定者:
getSessionCount在接口中SessionRepository- 返回:
- the count of sessions
-
getIdentifiers
- 指定者:
getIdentifiers在接口中SessionRepository- 返回:
- all session ids
-
getSessions
Return the map of sessions with anunmodifiablewrapper. This could be used for management purposes, to list active sessions, invalidate expired ones, etc. -
createSession
从接口复制的说明:SessionRepositoryCreate a new WebSession.Note that this does nothing more than create a new instance. The session can later be started explicitly via
WebSession.start()or implicitly by adding attributes -- and then persisted viaWebSession.save().- 指定者:
createSession在接口中SessionRepository- 返回:
- the created session instance
-
createSession
从接口复制的说明:SessionRepositoryCreate a new WebSession with given session id.Note that this does nothing more than create a new instance. The session can later be started explicitly via
WebSession.start()or implicitly by adding attributes -- and then persisted viaWebSession.save().- 指定者:
createSession在接口中SessionRepository- 返回:
- the created session instance
-
retrieveSession
从接口复制的说明:SessionRepositoryReturn the WebSession for the given id.Note: This method should perform an expiration check, and if it has expired remove the session and return empty. This method should also update the lastAccessTime of retrieved sessions.
- 指定者:
retrieveSession在接口中SessionRepository- 参数:
id- the session to load- 返回:
- the session
-
removeSession
从接口复制的说明:SessionRepositoryRemove the WebSession for the specified id.- 指定者:
removeSession在接口中SessionRepository- 参数:
id- the id of the session to remove- 返回:
- an old session
-
updateLastAccessTime
从接口复制的说明:SessionRepositoryUpdate the last accessed timestamp to "now".- 指定者:
updateLastAccessTime在接口中SessionRepository- 参数:
session- the session to update
-
contains
- 指定者:
contains在接口中SessionRepository
-
removeExpiredSessions
public void removeExpiredSessions()Check for expired sessions and remove them. Typically such checks are kicked off lazily during calls tocreateorretrieve, no less than 60 seconds apart. This method can be called to force a check at a specific time.- 从以下版本开始:
- 4.0
-