Class Session
- java.lang.Object
-
- com.aspectran.core.component.session.Session
-
- Direct Known Subclasses:
AbstractSessionCache.PlaceHolderSession
public class Session extends java.lang.ObjectThe basic Session object.Created: 2017. 6. 13.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classSession.Statestate of the session: valid, invalid or being invalidated
-
Constructor Summary
Constructors Modifier Constructor Description protectedSession(SessionHandler sessionHandler, SessionData sessionData)protectedSession(SessionHandler sessionHandler, SessionData sessionData, boolean newSession)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected booleanaccess(long time)protected booleanbeginInvalidate()protected voidcheckLocked()protected voidcheckValidForRead()Check that the session data can be read.protected voidcheckValidForWrite()Check that the session can be modified.protected voidcomplete()protected voidfinishInvalidate()<T> TgetAttribute(java.lang.String name)java.util.Collection<java.lang.String>getAttributeNames()longgetCreationTime()java.lang.StringgetId()longgetLastAccessedTime()intgetMaxInactiveInterval()longgetRequests()Returns the current number of requests that are active in the Session.SessionDatagetSessionData()protected SessionScopegetSessionScope()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()Locker.Locklock()Grab the lock on the session.Locker.LocklockIfNotHeld()Grab the lock on the session if it isn't locked already.voidremoveAttribute(java.lang.String name)voidsetAttribute(java.lang.String name, java.lang.Object value)voidsetMaxInactiveInterval(int secs)protected voidsetResident(boolean resident)protected voidstopInactivityTimer()Stop the session inactivity timer.java.lang.StringtoString()voidupdateInactivityTimer()Set the inactivity timer to the smaller of the session maxInactivity (ie session-timeout from web.xml), or the inactive eviction time.
-
-
-
Constructor Detail
-
Session
protected Session(SessionHandler sessionHandler, SessionData sessionData)
-
Session
protected Session(SessionHandler sessionHandler, SessionData sessionData, boolean newSession)
-
-
Method Detail
-
getId
public java.lang.String getId()
-
getSessionData
public SessionData getSessionData()
-
getSessionScope
protected SessionScope getSessionScope()
-
getAttribute
public <T> T getAttribute(java.lang.String name)
-
setAttribute
public void setAttribute(java.lang.String name, java.lang.Object value)
-
getAttributeNames
public java.util.Collection<java.lang.String> getAttributeNames()
-
removeAttribute
public void removeAttribute(java.lang.String name)
-
getCreationTime
public long getCreationTime()
-
getLastAccessedTime
public long getLastAccessedTime()
-
getMaxInactiveInterval
public int getMaxInactiveInterval()
-
setMaxInactiveInterval
public void setMaxInactiveInterval(int secs)
-
updateInactivityTimer
public void updateInactivityTimer()
Set the inactivity timer to the smaller of the session maxInactivity (ie session-timeout from web.xml), or the inactive eviction time.
-
stopInactivityTimer
protected void stopInactivityTimer()
Stop the session inactivity timer.
-
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.
-
beginInvalidate
protected boolean beginInvalidate()
-
finishInvalidate
protected void finishInvalidate()
-
isNew
public boolean isNew() throws java.lang.IllegalStateException- Throws:
java.lang.IllegalStateException
-
isValid
public boolean isValid()
-
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
-
checkValidForWrite
protected void checkValidForWrite() throws java.lang.IllegalStateExceptionCheck that the session can be modified.- Throws:
java.lang.IllegalStateException- if the session is invalid
-
checkValidForRead
protected void checkValidForRead() throws java.lang.IllegalStateExceptionCheck that the session data can be read.- Throws:
java.lang.IllegalStateException- if the session is invalid
-
checkLocked
protected void checkLocked() throws java.lang.IllegalStateException- Throws:
java.lang.IllegalStateException
-
lock
public Locker.Lock lock()
Grab the lock on the session.- Returns:
- the lock
-
lockIfNotHeld
public Locker.Lock lockIfNotHeld()
Grab the lock on the session if it isn't locked already.- Returns:
- the lock
-
access
protected boolean access(long time)
-
complete
protected void complete()
-
getRequests
public long getRequests()
Returns the current number of requests that are active in the Session.- Returns:
- the number of active requests for this session
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-