Package org.apache.catalina
Interface Session
-
- All Known Subinterfaces:
ClusterSession
- All Known Implementing Classes:
DeltaSession,DummyProxySession,StandardSession
public interface SessionA Session is the Catalina-internal facade for anHttpSessionthat is used to maintain state information between requests for a particular user of a web application.
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringSESSION_ACTIVATED_EVENTThe SessionEvent event type when a session is activated.static java.lang.StringSESSION_CHANGED_ID_EVENTThe SessionEvent event type when a session changes its sessionId.static java.lang.StringSESSION_CREATED_EVENTThe SessionEvent event type when a session is created.static java.lang.StringSESSION_DESTROYED_EVENTThe SessionEvent event type when a session is destroyed.static java.lang.StringSESSION_PASSIVATED_EVENTThe SessionEvent event type when a session is passivated.
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description voidaccess()Update the accessed time information for this session.voidaddSessionListener(SessionListener listener)Add a session event listener to this component.voidendAccess()End access to the session.voidexpire()Perform the internal processing required to invalidate this session, without triggering an exception if the session has already expired.java.lang.StringgetAuthType()Returns the authentication type used to authenticate the cached Principal, if any.longgetCreationTime()Returns the creation time for this session.longgetCreationTimeInternal()Returns the creation time for this session, bypassing the session validity checks.java.lang.StringgetId()Returns the session identifier for this session.java.lang.StringgetIdInternal()Returns the session identifier for this session, bypassing validity checks.longgetIdleTime()Returns the idle time from last client access time.longgetIdleTimeInternal()Returns the idle time from last client access time without invalidation check.longgetLastAccessedTime()Returns the last time the client sent a request associated with this session, as the number of milliseconds since midnight, January 1, 1970 GMT.longgetLastAccessedTimeInternal()Returns the last client access time without invalidation check.ManagergetManager()Returns the Manager within which this Session is valid.intgetMaxInactiveInterval()Returns the maximum time interval, in seconds, between client requests before the servlet container will invalidate the session.java.lang.ObjectgetNote(java.lang.String name)Returns the object bound with the specified name to the internal notes for this session, ornullif no such binding exists.java.util.Iterator<java.lang.String>getNoteNames()Returns an Iterator containing the String names of all notes bindings that exist for this session.java.security.PrincipalgetPrincipal()Returns the authenticated Principal that is associated with this Session.HttpSessiongetSession()Returns theHttpSessionfor which this object is the facade.longgetThisAccessedTime()Returns the last time the client sent a request associated with this session, as the number of milliseconds since midnight, January 1, 1970 GMT.longgetThisAccessedTimeInternal()Returns the last client access time without invalidation check.booleanisAttributeDistributable(java.lang.String name, java.lang.Object value)Does the session implementation support the distributing of the given attribute?booleanisValid()Returns whether the session is still valid.voidrecycle()Release all object references, and initialize instance variables, in preparation for reuse of this object.voidremoveNote(java.lang.String name)Remove any object bound to the specified name in the internal notes for this session.voidremoveSessionListener(SessionListener listener)Remove a session event listener from this component.voidsetAuthType(java.lang.String authType)Set the authentication type used to authenticate our cached Principal, if any.voidsetCreationTime(long time)Set the creation time for this session.voidsetId(java.lang.String id)Set the session identifier for this session and notifies any associated listeners that a new session has been created.voidsetId(java.lang.String id, boolean notify)Set the session identifier for this session and optionally notifies any associated listeners that a new session has been created.voidsetManager(Manager manager)Set the Manager within which this Session is valid.voidsetMaxInactiveInterval(int interval)Set the maximum time interval, in seconds, between client requests before the servlet container will invalidate the session.voidsetNew(boolean isNew)Set theisNewflag for this session.voidsetNote(java.lang.String name, java.lang.Object value)Bind an object to a specified name in the internal notes associated with this session, replacing any existing binding for this name.voidsetPrincipal(java.security.Principal principal)Set the authenticated Principal that is associated with this Session.voidsetValid(boolean isValid)Set theisValidflag for this session.voidtellChangedSessionId(java.lang.String newId, java.lang.String oldId, boolean notifySessionListeners, boolean notifyContainerListeners)Inform the listeners about the change session ID.
-
-
-
Field Detail
-
SESSION_CREATED_EVENT
static final java.lang.String SESSION_CREATED_EVENT
The SessionEvent event type when a session is created.- See Also:
- Constant Field Values
-
SESSION_DESTROYED_EVENT
static final java.lang.String SESSION_DESTROYED_EVENT
The SessionEvent event type when a session is destroyed.- See Also:
- Constant Field Values
-
SESSION_ACTIVATED_EVENT
static final java.lang.String SESSION_ACTIVATED_EVENT
The SessionEvent event type when a session is activated.- See Also:
- Constant Field Values
-
SESSION_PASSIVATED_EVENT
static final java.lang.String SESSION_PASSIVATED_EVENT
The SessionEvent event type when a session is passivated.- See Also:
- Constant Field Values
-
SESSION_CHANGED_ID_EVENT
static final java.lang.String SESSION_CHANGED_ID_EVENT
The SessionEvent event type when a session changes its sessionId.- See Also:
- Constant Field Values
-
-
Method Detail
-
getAuthType
java.lang.String getAuthType()
Returns the authentication type used to authenticate the cached Principal, if any.- Returns:
- the authentication type
-
setAuthType
void setAuthType(java.lang.String authType)
Set the authentication type used to authenticate our cached Principal, if any.- Parameters:
authType- The new cached authentication type
-
getCreationTime
long getCreationTime()
Returns the creation time for this session.- Returns:
- the creation time in milliseconds since midnight, January 1, 1970 GMT
-
getCreationTimeInternal
long getCreationTimeInternal()
Returns the creation time for this session, bypassing the session validity checks.- Returns:
- the creation time in milliseconds since midnight, January 1, 1970 GMT
-
setCreationTime
void setCreationTime(long time)
Set the creation time for this session. This method is called by the Manager when an existing Session instance is reused.- Parameters:
time- The new creation time
-
getId
java.lang.String getId()
Returns the session identifier for this session.- Returns:
- the session identifier
-
getIdInternal
java.lang.String getIdInternal()
Returns the session identifier for this session, bypassing validity checks.- Returns:
- the session identifier
-
setId
void setId(java.lang.String id)
Set the session identifier for this session and notifies any associated listeners that a new session has been created.- Parameters:
id- The new session identifier
-
setId
void setId(java.lang.String id, boolean notify)Set the session identifier for this session and optionally notifies any associated listeners that a new session has been created.- Parameters:
id- The new session identifiernotify- Should any associated listeners be notified that a new session has been created?
-
getThisAccessedTime
long getThisAccessedTime()
Returns the last time the client sent a request associated with this session, as the number of milliseconds since midnight, January 1, 1970 GMT. Actions that your application takes, such as getting or setting a value associated with the session, do not affect the access time. This one gets updated whenever a request starts.- Returns:
- the last access time in milliseconds
-
getThisAccessedTimeInternal
long getThisAccessedTimeInternal()
Returns the last client access time without invalidation check.- Returns:
- the last access time in milliseconds
- See Also:
getThisAccessedTime()
-
getLastAccessedTime
long getLastAccessedTime()
Returns the last time the client sent a request associated with this session, as the number of milliseconds since midnight, January 1, 1970 GMT. Actions that your application takes, such as getting or setting a value associated with the session, do not affect the access time. This one gets updated whenever a request finishes.- Returns:
- the last access time in milliseconds
-
getLastAccessedTimeInternal
long getLastAccessedTimeInternal()
Returns the last client access time without invalidation check.- Returns:
- the last access time in milliseconds
- See Also:
getLastAccessedTime()
-
getIdleTime
long getIdleTime()
Returns the idle time from last client access time.- Returns:
- the idle time in milliseconds
-
getIdleTimeInternal
long getIdleTimeInternal()
Returns the idle time from last client access time without invalidation check.- Returns:
- the idle time in milliseconds
- See Also:
getIdleTime()
-
getManager
Manager getManager()
Returns the Manager within which this Session is valid.- Returns:
- the manager
-
setManager
void setManager(Manager manager)
Set the Manager within which this Session is valid.- Parameters:
manager- The new Manager
-
getMaxInactiveInterval
int getMaxInactiveInterval()
Returns the maximum time interval, in seconds, between client requests before the servlet container will invalidate the session. A negative time indicates that the session should never time out.- Returns:
- the maximum inactive interval in seconds
-
setMaxInactiveInterval
void setMaxInactiveInterval(int interval)
Set the maximum time interval, in seconds, between client requests before the servlet container will invalidate the session. A negative time indicates that the session should never time out.- Parameters:
interval- The new maximum interval
-
setNew
void setNew(boolean isNew)
Set theisNewflag for this session.- Parameters:
isNew- The new value for theisNewflag
-
getPrincipal
java.security.Principal getPrincipal()
Returns the authenticated Principal that is associated with this Session. This provides anAuthenticatorwith a means to cache a previously authenticated Principal, and avoid potentially expensiveRealm.authenticate()calls on every request. If there is no current associated Principal, returnnull.- Returns:
- the authenticated principal, or
nullif none
-
setPrincipal
void setPrincipal(java.security.Principal principal)
Set the authenticated Principal that is associated with this Session. This provides anAuthenticatorwith a means to cache a previously authenticated Principal, and avoid potentially expensiveRealm.authenticate()calls on every request.- Parameters:
principal- The new Principal, ornullif none
-
getSession
HttpSession getSession()
Returns theHttpSessionfor which this object is the facade.- Returns:
- the HTTP session
-
setValid
void setValid(boolean isValid)
Set theisValidflag for this session.- Parameters:
isValid- The new value for theisValidflag
-
isValid
boolean isValid()
Returns whether the session is still valid.- Returns:
trueif the session is valid
-
access
void access()
Update the accessed time information for this session. This method should be called by the context when a request comes in for a particular session, even if the application does not reference it.
-
addSessionListener
void addSessionListener(SessionListener listener)
Add a session event listener to this component.- Parameters:
listener- the SessionListener instance that should be notified for session events
-
endAccess
void endAccess()
End access to the session.
-
expire
void expire()
Perform the internal processing required to invalidate this session, without triggering an exception if the session has already expired.
-
getNote
java.lang.Object getNote(java.lang.String name)
Returns the object bound with the specified name to the internal notes for this session, ornullif no such binding exists.- Parameters:
name- Name of the note to be returned- Returns:
- the note object, or
nullif not found
-
getNoteNames
java.util.Iterator<java.lang.String> getNoteNames()
Returns an Iterator containing the String names of all notes bindings that exist for this session.- Returns:
- the iterator of note names
-
recycle
void recycle()
Release all object references, and initialize instance variables, in preparation for reuse of this object.
-
removeNote
void removeNote(java.lang.String name)
Remove any object bound to the specified name in the internal notes for this session.- Parameters:
name- Name of the note to be removed
-
removeSessionListener
void removeSessionListener(SessionListener listener)
Remove a session event listener from this component.- Parameters:
listener- remove the session listener, which will no longer be notified
-
setNote
void setNote(java.lang.String name, java.lang.Object value)Bind an object to a specified name in the internal notes associated with this session, replacing any existing binding for this name.- Parameters:
name- Name to which the object should be boundvalue- Object to be bound to the specified name
-
tellChangedSessionId
void tellChangedSessionId(java.lang.String newId, java.lang.String oldId, boolean notifySessionListeners, boolean notifyContainerListeners)Inform the listeners about the change session ID.- Parameters:
newId- new session IDoldId- old session IDnotifySessionListeners- Should any associated sessionListeners be notified that session ID has been changed?notifyContainerListeners- Should any associated ContainerListeners be notified that session ID has been changed?
-
isAttributeDistributable
boolean isAttributeDistributable(java.lang.String name, java.lang.Object value)Does the session implementation support the distributing of the given attribute? If the Manager is marked as distributable, then this method must be used to check attributes before adding them to a session and anIllegalArgumentExceptionthrown if the proposed attribute is not distributable.Note that the
Managerimplementation may further restrict which attributes are distributed but aManagerlevel restriction should not trigger anIllegalArgumentExceptioninHttpSession.setAttribute(String, Object)- Parameters:
name- The attribute namevalue- The attribute value- Returns:
trueif distribution is supported, otherwisefalse
-
-