Class BasicSession
- java.lang.Object
-
- com.aspectran.core.component.session.BasicSession
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description class
BasicSession.SessionInactivityTimer
The Class SessionInactivityTimer.-
Nested classes/interfaces inherited from interface com.aspectran.core.component.session.Session
Session.DestroyedReason
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
BasicSession(SessionData sessionData, SessionHandler sessionHandler, boolean newSession)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
access()
Called when a session is first accessed by a request.protected boolean
beginInvalidate()
protected void
bindValue(java.lang.String name, java.lang.Object value)
Bind value if value implementsSessionBindingListener
(callsSessionBindingListener.valueBound(Session, String, Object)
)protected void
checkLocked()
protected void
checkValidForRead()
Check that the session data can be read.protected void
checkValidForWrite()
Check that the session can be modified.void
complete()
Called when a session is last accessed by a request.protected void
finishInvalidate()
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.<T> T
getAttribute(java.lang.String name)
java.util.Set<java.lang.String>
getAttributeNames()
long
getCreationTime()
Session.DestroyedReason
getDestroyedReason()
java.lang.String
getId()
long
getLastAccessedTime()
int
getMaxInactiveInterval()
protected long
getRequests()
Returns the current number of requests that are active in the Session.SessionData
getSessionData()
SessionHandler
getSessionHandler()
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.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()
protected boolean
isResident()
boolean
isValid()
protected Locker.Lock
lock()
Grab the lock on the session.java.lang.Object
removeAttribute(java.lang.String name)
java.lang.Object
setAttribute(java.lang.String name, java.lang.Object value)
protected void
setDestroyedReason(Session.DestroyedReason destroyedReason)
void
setMaxInactiveInterval(int secs)
protected void
setResident(boolean resident)
java.lang.String
toString()
protected void
unbindValue(java.lang.String name, java.lang.Object value)
Unbind value if value implementsSessionBindingListener
(callsSessionBindingListener.valueUnbound(Session, String, Object)
)
-
-
-
Constructor Detail
-
BasicSession
protected BasicSession(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:
getAttribute
in interfaceSession
-
setAttribute
public java.lang.Object setAttribute(java.lang.String name, java.lang.Object value)
- Specified by:
setAttribute
in interfaceSession
-
getAttributeNames
public java.util.Set<java.lang.String> getAttributeNames()
- Specified by:
getAttributeNames
in interfaceSession
-
removeAttribute
public java.lang.Object removeAttribute(java.lang.String name)
- 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 secs)
- Specified by:
setMaxInactiveInterval
in interfaceSession
-
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.
-
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:
invalidate
in interfaceSession
-
beginInvalidate
protected boolean beginInvalidate()
-
finishInvalidate
protected void finishInvalidate()
-
getDestroyedReason
public Session.DestroyedReason getDestroyedReason()
- Specified by:
getDestroyedReason
in 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:
toString
in classjava.lang.Object
-
-