Class ManagedSession
java.lang.Object
com.aspectran.core.component.session.ManagedSession
- All Implemented Interfaces:
Session
A default
Session
implementation.
Created: 2017. 6. 13.
-
Nested Class Summary
Nested classes/interfaces inherited from interface com.aspectran.core.component.session.Session
Session.DestroyedReason
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
ManagedSession
(AbstractSessionManager sessionManager, SessionData sessionData, boolean newSession) -
Method Summary
Modifier and TypeMethodDescriptionboolean
access()
Called when a session is first accessed by a request.protected boolean
protected void
Bind value if value implementsSessionBindingListener
(callsSessionBindingListener.valueBound(Session, String, Object)
)protected long
calculateInactivityTimeout
(long now) Calculate what the session timer setting should be based on: the time remaining before the session expires and any idle eviction time configured.protected void
Check that the session data can be read.protected void
Check that the session can be modified.void
complete()
Called when a session is last accessed by a request.protected void
<T> T
getAttribute
(String name) long
Returns the reason why the session was destroyed.protected int
getId()
long
int
protected long
Returns the current number of requests that are active in the Session.protected SessionData
void
Called by users to invalidate a session, or called by the access method as a request enters the session if the session has expired, or called by manager as a result of scavenger expiring session.protected boolean
isExpiredAt
(long time) Check to see if session has expired as at the time given.protected boolean
isIdleLongerThan
(int sec) Check if the Session has been idle longer than a number of seconds.boolean
isNew()
Returns true if a new session was created for the request.protected boolean
boolean
boolean
isValid()
Returns whether it is a valid session or not.protected AutoLock
lock()
Grab the lock on the session.protected void
onSessionAttributeUpdate
(String name, Object oldValue, Object newValue) Call binding and attribute listeners based on the new and old values of the attribute.removeAttribute
(String name) setAttribute
(String name, Object value) protected void
setDestroyedReason
(Session.DestroyedReason destroyedReason) void
setMaxInactiveInterval
(int inactiveIntervalSecs) protected void
setResident
(boolean resident) protected void
setSessionData
(SessionData sessionData) toString()
protected void
unbindValue
(String name, Object value) Unbind value if value implementsSessionBindingListener
(callsSessionBindingListener.valueUnbound(Session, String, Object)
)
-
Constructor Details
-
ManagedSession
protected ManagedSession(AbstractSessionManager sessionManager, @NonNull SessionData sessionData, boolean newSession)
-
-
Method Details
-
getSessionManager
-
getSessionData
-
setSessionData
-
getId
-
getAttribute
- Specified by:
getAttribute
in interfaceSession
-
getAttributeNames
- Specified by:
getAttributeNames
in interfaceSession
-
setAttribute
- Specified by:
setAttribute
in interfaceSession
-
removeAttribute
- Specified by:
removeAttribute
in interfaceSession
-
getCreationTime
public long getCreationTime()- Specified by:
getCreationTime
in interfaceSession
-
getLastAccessedTime
public long getLastAccessedTime()- Specified by:
getLastAccessedTime
in interfaceSession
-
getMaxInactiveInterval
public int getMaxInactiveInterval()- Specified by:
getMaxInactiveInterval
in interfaceSession
-
setMaxInactiveInterval
public void setMaxInactiveInterval(int inactiveIntervalSecs) - Specified by:
setMaxInactiveInterval
in interfaceSession
-
getEvictionIdleSecs
protected int getEvictionIdleSecs() -
isNew
public boolean isNew()Description copied from interface:Session
Returns true if a new session was created for the request. -
isResident
protected boolean isResident() -
setResident
protected void setResident(boolean resident) -
isTempResident
public boolean isTempResident()- Specified by:
isTempResident
in interfaceSession
-
getRequests
protected long getRequests()Returns the current number of requests that are active in the Session.- Returns:
- the number of active requests for this session
-
isValid
public boolean isValid()Description copied from interface:Session
Returns whether it is a valid session or not. -
access
public boolean access()Description copied from interface:Session
Called when a session is first accessed by a request. -
complete
public void complete()Description copied from interface:Session
Called when a session is last accessed by a request. -
calculateInactivityTimeout
protected long calculateInactivityTimeout(long now) Calculate what the session timer setting should be based on: the time remaining before the session expires and any idle eviction time configured. The timer value will be the lesser of the above.- Parameters:
now
- the time at which to calculate remaining expiry- Returns:
- the time remaining before expiry or inactivity timeout
-
invalidate
public void invalidate()Called by users to invalidate a session, or called by the access method as a request enters the session if the session has expired, or called by manager as a result of scavenger expiring session.- Specified by:
invalidate
in interfaceSession
-
beginInvalidate
protected boolean beginInvalidate() -
finishInvalidate
protected void finishInvalidate() -
getDestroyedReason
Description copied from interface:Session
Returns the reason why the session was destroyed.- Specified by:
getDestroyedReason
in interfaceSession
- Returns:
- the destroyed reason
-
setDestroyedReason
-
isExpiredAt
protected boolean isExpiredAt(long time) Check to see if session has expired as at the time given.- Parameters:
time
- the time since the epoch in ms- Returns:
- true if expired
-
isIdleLongerThan
protected boolean isIdleLongerThan(int sec) Check if the Session has been idle longer than a number of seconds.- Parameters:
sec
- the number of seconds- Returns:
- true if the session has been idle longer than the interval
-
onSessionAttributeUpdate
Call binding and attribute listeners based on the new and old values of the attribute.- Parameters:
name
- name of the attributeoldValue
- previous value of the attributenewValue
- new value of the attribute
-
unbindValue
Unbind value if value implementsSessionBindingListener
(callsSessionBindingListener.valueUnbound(Session, String, Object)
)- Parameters:
name
- the name with which the object is bound or unboundvalue
- the bound value
-
bindValue
Bind value if value implementsSessionBindingListener
(callsSessionBindingListener.valueBound(Session, String, Object)
)- Parameters:
name
- the name with which the object is bound or unboundvalue
- the bound value
-
checkValidForWrite
protected void checkValidForWrite()Check that the session can be modified.- Throws:
IllegalStateException
- if the session is invalid
-
checkValidForRead
protected void checkValidForRead()Check that the session data can be read.- Throws:
IllegalStateException
- if the session is invalid
-
lock
Grab the lock on the session.- Returns:
- the lock
-
toString
-