Class DefaultSession
- java.lang.Object
-
- com.aspectran.core.component.session.DefaultSession
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description classDefaultSession.SessionInactivityTimerThe Class SessionInactivityTimer.-
Nested classes/interfaces inherited from interface com.aspectran.core.component.session.Session
Session.DestroyedReason
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedDefaultSession(SessionData sessionData, SessionHandler sessionHandler, boolean newSession)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanaccess()Called when a session is first accessed by a request.protected booleanbeginInvalidate()protected voidbindValue(java.lang.String name, java.lang.Object value)Bind value if value implementsSessionBindingListener(callsSessionBindingListener.valueBound(Session, String, Object))protected voidcheckLocked()protected voidcheckValidForRead()Check that the session data can be read.protected voidcheckValidForWrite()Check that the session can be modified.voidcomplete()Called when a session is last accessed by a request.protected voidfinishInvalidate()protected voidfireSessionAttributeListeners(java.lang.String name, java.lang.Object oldValue, java.lang.Object newValue)Call binding and attribute listeners based on the new and old values of the attribute.<T> TgetAttribute(java.lang.String name)java.util.Set<java.lang.String>getAttributeNames()longgetCreationTime()Session.DestroyedReasongetDestroyedReason()java.lang.StringgetId()longgetLastAccessedTime()intgetMaxInactiveInterval()protected longgetRequests()Returns the current number of requests that are active in the Session.SessionDatagetSessionData()SessionHandlergetSessionHandler()voidinvalidate()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 booleanisExpiredAt(long time)Check to see if session has expired as at the time given.protected booleanisIdleLongerThan(int sec)Check if the Session has been idle longer than a number of seconds.booleanisNew()protected booleanisResident()booleanisValid()protected Locker.Locklock()Grab the lock on the session.java.lang.ObjectremoveAttribute(java.lang.String name)java.lang.ObjectsetAttribute(java.lang.String name, java.lang.Object value)protected voidsetDestroyedReason(Session.DestroyedReason destroyedReason)voidsetMaxInactiveInterval(int secs)protected voidsetResident(boolean resident)java.lang.StringtoString()protected voidunbindValue(java.lang.String name, java.lang.Object value)Unbind value if value implementsSessionBindingListener(callsSessionBindingListener.valueUnbound(Session, String, Object))
-
-
-
Constructor Detail
-
DefaultSession
protected DefaultSession(SessionData sessionData, SessionHandler sessionHandler, boolean newSession)
-
-
Method Detail
-
getSessionData
public SessionData getSessionData()
-
getSessionHandler
public SessionHandler getSessionHandler()
-
getAttribute
public <T> T getAttribute(java.lang.String name)
- Specified by:
getAttributein interfaceSession
-
setAttribute
public java.lang.Object setAttribute(java.lang.String name, java.lang.Object value)- Specified by:
setAttributein interfaceSession
-
getAttributeNames
public java.util.Set<java.lang.String> getAttributeNames()
- Specified by:
getAttributeNamesin interfaceSession
-
removeAttribute
public java.lang.Object removeAttribute(java.lang.String name)
- Specified by:
removeAttributein interfaceSession
-
getCreationTime
public long getCreationTime()
- Specified by:
getCreationTimein interfaceSession
-
getLastAccessedTime
public long getLastAccessedTime()
- Specified by:
getLastAccessedTimein interfaceSession
-
getMaxInactiveInterval
public int getMaxInactiveInterval()
- Specified by:
getMaxInactiveIntervalin interfaceSession
-
setMaxInactiveInterval
public void setMaxInactiveInterval(int secs)
- Specified by:
setMaxInactiveIntervalin interfaceSession
-
access
public boolean access()
Description copied from interface:SessionCalled when a session is first accessed by a request.
-
complete
public void complete()
Description copied from interface:SessionCalled when a session is last accessed by a request.
-
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
-
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:
invalidatein interfaceSession
-
beginInvalidate
protected boolean beginInvalidate()
-
finishInvalidate
protected void finishInvalidate()
-
getDestroyedReason
public Session.DestroyedReason getDestroyedReason()
- Specified by:
getDestroyedReasonin interfaceSession
-
setDestroyedReason
protected void setDestroyedReason(Session.DestroyedReason destroyedReason)
-
isResident
protected boolean isResident()
-
setResident
protected void setResident(boolean resident)
-
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
-
fireSessionAttributeListeners
protected void fireSessionAttributeListeners(java.lang.String name, java.lang.Object oldValue, java.lang.Object newValue)Call binding and attribute listeners based on the new and old values of the attribute.- Parameters:
name- name of the attributenewValue- new value of the attributeoldValue- previous value of the attribute- Throws:
java.lang.IllegalStateException- if no session manager can be find
-
unbindValue
protected void unbindValue(java.lang.String name, java.lang.Object value)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
protected void bindValue(java.lang.String name, java.lang.Object value)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:
java.lang.IllegalStateException- if the session is invalid
-
checkValidForRead
protected void checkValidForRead()
Check that the session data can be read.- Throws:
java.lang.IllegalStateException- if the session is invalid
-
checkLocked
protected void checkLocked()
-
lock
protected Locker.Lock lock()
Grab the lock on the session.- Returns:
- the lock
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-