public class Session extends Object implements SessionHandler.SessionIf
| Modifier and Type | Class and Description |
|---|---|
class |
Session.SessionInactivityTimeout
SessionInactivityTimeout
|
static class |
Session.State
State
Validity states of a session
|
| Modifier and Type | Field and Description |
|---|---|
protected String |
_extendedId |
protected SessionHandler |
_handler |
protected long |
_requests |
protected SessionData |
_sessionData |
static String |
SESSION_CREATED_SECURE |
| Constructor and Description |
|---|
Session(SessionHandler handler,
javax.servlet.http.HttpServletRequest request,
SessionData data)
Create a new session
|
Session(SessionHandler handler,
SessionData data)
Re-create an existing session
|
| Modifier and Type | Method and Description |
|---|---|
protected boolean |
access(long time) |
void |
bindValue(String name,
Object value)
Bind value if value implements
HttpSessionBindingListener (calls HttpSessionBindingListener.valueBound(HttpSessionBindingEvent)) |
protected void |
callSessionAttributeListeners(String name,
Object newValue,
Object oldValue)
Call binding and attribute listeners based on the new and old
values of the attribute.
|
protected void |
checkLocked() |
protected void |
checkValidForRead()
asserts that the session is valid
|
protected void |
checkValidForWrite()
asserts that the session is valid
|
protected void |
complete() |
protected void |
cookieSet() |
void |
didActivate()
Call the activation listeners.
|
protected void |
doInvalidate() |
Object |
getAttribute(String name) |
Enumeration<String> |
getAttributeNames() |
int |
getAttributes() |
String |
getContextPath() |
long |
getCookieSetTime() |
long |
getCreationTime() |
String |
getExtendedId() |
String |
getId() |
long |
getLastAccessedTime() |
int |
getMaxInactiveInterval() |
Set<String> |
getNames() |
long |
getRequests()
Should call this method with a lock held if you want to
make decision on what to do with the session
|
javax.servlet.ServletContext |
getServletContext() |
Session |
getSession() |
javax.servlet.http.HttpSessionContext |
getSessionContext() |
protected SessionData |
getSessionData() |
SessionHandler |
getSessionHandler() |
Object |
getValue(String name) |
String[] |
getValueNames()
Deprecated.
As of Version 2.2, this method is replaced by
getAttributeNames() |
String |
getVHost() |
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.
|
boolean |
isIdChanged() |
protected boolean |
isIdleLongerThan(int sec) |
boolean |
isNew() |
boolean |
isResident() |
boolean |
isValid() |
Locker.Lock |
lock()
Grab the lock on the session
|
void |
putValue(String name,
Object value) |
void |
removeAttribute(String name) |
void |
removeValue(String name) |
void |
renewId(javax.servlet.http.HttpServletRequest request) |
void |
setAttribute(String name,
Object value) |
void |
setExtendedId(String extendedId) |
void |
setIdChanged(boolean changed) |
void |
setMaxInactiveInterval(int secs) |
void |
setResident(boolean resident) |
void |
stopInactivityTimer() |
void |
unbindValue(String name,
Object value)
Unbind value if value implements
HttpSessionBindingListener (calls HttpSessionBindingListener.valueUnbound(HttpSessionBindingEvent)) |
void |
updateInactivityTimer()
Set the inactivity timer to the smaller of the session maxInactivity
(ie session-timeout from web.xml), or the inactive eviction time.
|
void |
willPassivate()
Call the passivation listeners.
|
public static final String SESSION_CREATED_SECURE
protected SessionData _sessionData
protected SessionHandler _handler
protected String _extendedId
protected long _requests
public Session(SessionHandler handler, javax.servlet.http.HttpServletRequest request, SessionData data)
handler - TODOrequest - the request the session should be based ondata - the session datapublic Session(SessionHandler handler, SessionData data)
handler - TODOdata - the session datapublic long getRequests()
public void setExtendedId(String extendedId)
protected void cookieSet()
protected boolean access(long time)
protected void complete()
protected boolean isExpiredAt(long time)
time - the time in millisecondsprotected boolean isIdleLongerThan(int sec)
protected void callSessionAttributeListeners(String name, Object newValue, Object oldValue)
name - name of the attributenewValue - new value of the attributeoldValue - previous value of the attributepublic void unbindValue(String name, Object value)
HttpSessionBindingListener (calls HttpSessionBindingListener.valueUnbound(HttpSessionBindingEvent))name - the name with which the object is bound or unboundvalue - the bound valuepublic void bindValue(String name, Object value)
HttpSessionBindingListener (calls HttpSessionBindingListener.valueBound(HttpSessionBindingEvent))name - the name with which the object is bound or unboundvalue - the bound valuepublic void didActivate()
public void willPassivate()
public boolean isValid()
public long getCookieSetTime()
public long getCreationTime()
throws IllegalStateException
getCreationTime in interface javax.servlet.http.HttpSessionIllegalStateExceptionpublic String getId()
getId in interface javax.servlet.http.HttpSessionHttpSession.getId()public String getExtendedId()
public String getContextPath()
public String getVHost()
public long getLastAccessedTime()
getLastAccessedTime in interface javax.servlet.http.HttpSessionHttpSession.getLastAccessedTime()public javax.servlet.ServletContext getServletContext()
getServletContext in interface javax.servlet.http.HttpSessionHttpSession.getServletContext()public void setMaxInactiveInterval(int secs)
setMaxInactiveInterval in interface javax.servlet.http.HttpSessionHttpSession.setMaxInactiveInterval(int)public void updateInactivityTimer()
public void stopInactivityTimer()
public int getMaxInactiveInterval()
getMaxInactiveInterval in interface javax.servlet.http.HttpSessionHttpSession.getMaxInactiveInterval()public javax.servlet.http.HttpSessionContext getSessionContext()
getSessionContext in interface javax.servlet.http.HttpSessionHttpSession.getSessionContext()public SessionHandler getSessionHandler()
protected void checkValidForWrite()
throws IllegalStateException
IllegalStateException - if the session is invalidprotected void checkValidForRead()
throws IllegalStateException
IllegalStateException - if the session is invalidprotected void checkLocked()
throws IllegalStateException
IllegalStateExceptionpublic Object getAttribute(String name)
getAttribute in interface javax.servlet.http.HttpSessionHttpSession.getAttribute(java.lang.String)public Object getValue(String name)
getValue in interface javax.servlet.http.HttpSessionHttpSession.getValue(java.lang.String)public Enumeration<String> getAttributeNames()
getAttributeNames in interface javax.servlet.http.HttpSessionHttpSession.getAttributeNames()public int getAttributes()
@Deprecated public String[] getValueNames() throws IllegalStateException
getAttributeNames()getValueNames in interface javax.servlet.http.HttpSessionIllegalStateExceptionpublic void setAttribute(String name, Object value)
setAttribute in interface javax.servlet.http.HttpSessionHttpSession.setAttribute(java.lang.String, java.lang.Object)public void putValue(String name, Object value)
putValue in interface javax.servlet.http.HttpSessionHttpSession.putValue(java.lang.String, java.lang.Object)public void removeAttribute(String name)
removeAttribute in interface javax.servlet.http.HttpSessionHttpSession.removeAttribute(java.lang.String)public void removeValue(String name)
removeValue in interface javax.servlet.http.HttpSessionHttpSession.removeValue(java.lang.String)public void renewId(javax.servlet.http.HttpServletRequest request)
public void invalidate()
invalidate in interface javax.servlet.http.HttpSessionHttpSession.invalidate()public Locker.Lock lock()
protected void doInvalidate()
throws IllegalStateException
IllegalStateExceptionpublic boolean isNew()
throws IllegalStateException
isNew in interface javax.servlet.http.HttpSessionIllegalStateExceptionpublic void setIdChanged(boolean changed)
public boolean isIdChanged()
public Session getSession()
getSession in interface SessionHandler.SessionIfprotected SessionData getSessionData()
public void setResident(boolean resident)
public boolean isResident()
Copyright © 1995–2016 Mort Bay Consulting. All rights reserved.