Class Session
- java.lang.Object
-
- com.aspectran.core.component.session.Session
-
- Direct Known Subclasses:
AbstractSessionCache.PlaceHolderSession
public class Session extends java.lang.Object
The basic Session object.Created: 2017. 6. 13.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
Session.State
state of the session: valid, invalid or being invalidated
-
Constructor Summary
Constructors Modifier Constructor Description protected
Session(SessionHandler sessionHandler, SessionData sessionData)
protected
Session(SessionHandler sessionHandler, SessionData sessionData, boolean newSession)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected boolean
access(long time)
protected boolean
beginInvalidate()
protected void
checkLocked()
protected void
checkValidForRead()
Check that the session data can be read.protected void
checkValidForWrite()
Check that the session can be modified.protected void
complete()
protected void
finishInvalidate()
<T> T
getAttribute(java.lang.String name)
java.util.Collection<java.lang.String>
getAttributeNames()
long
getCreationTime()
java.lang.String
getId()
long
getLastAccessedTime()
int
getMaxInactiveInterval()
long
getRequests()
Returns the current number of requests that are active in the Session.SessionData
getSessionData()
protected SessionScope
getSessionScope()
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()
Locker.Lock
lock()
Grab the lock on the session.Locker.Lock
lockIfNotHeld()
Grab the lock on the session if it isn't locked already.void
removeAttribute(java.lang.String name)
void
setAttribute(java.lang.String name, java.lang.Object value)
void
setMaxInactiveInterval(int secs)
protected void
setResident(boolean resident)
protected void
stopInactivityTimer()
Stop the session inactivity timer.java.lang.String
toString()
void
updateInactivityTimer()
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.IllegalStateException
Check that the session can be modified.- Throws:
java.lang.IllegalStateException
- if the session is invalid
-
checkValidForRead
protected void checkValidForRead() throws java.lang.IllegalStateException
Check 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:
toString
in classjava.lang.Object
-
-