Package org.apache.catalina
Interface Session
- All Known Subinterfaces:
- ClusterSession
- All Known Implementing Classes:
- DeltaSession,- DummyProxySession,- StandardSession
public interface Session
A Session is the Catalina-internal facade for an
 
HttpSession that is used to maintain state information
 between requests for a particular user of a web application.- Author:
- Craig R. McClanahan
- 
Field SummaryFieldsModifier and TypeFieldDescriptionstatic final StringThe SessionEvent event type when a session is activated.static final StringThe SessionEvent event type when a session is created.static final StringThe SessionEvent event type when a session is destroyed.static final StringThe SessionEvent event type when a session is passivated.
- 
Method SummaryModifier and TypeMethodDescriptionvoidaccess()Update the accessed time information for this session.voidaddSessionListener(SessionListener listener) Add a session event listener to this component.voidEnd access to the session.voidexpire()Perform the internal processing required to invalidate this session, without triggering an exception if the session has already expired.longlonggetId()longlonglonglongintlonglongbooleanisAttributeDistributable(String name, Object value) Does the session implementation support the distributing of the given attribute?booleanisValid()voidrecycle()Release all object references, and initialize instance variables, in preparation for reuse of this object.voidremoveNote(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(String authType) Set the authentication type used to authenticate our cached Principal, if any.voidsetCreationTime(long time) Set the creation time for this session.voidSet the session identifier for this session and notifies any associated listeners that a new session has been created.voidSet 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.voidBind an object to a specified name in the internal notes associated with this session, replacing any existing binding for this name.voidsetPrincipal(Principal principal) Set the authenticated Principal that is associated with this Session.voidsetValid(boolean isValid) Set theisValidflag for this session.voidtellChangedSessionId(String newId, String oldId, boolean notifySessionListeners, boolean notifyContainerListeners) Inform the listeners about the change session ID.
- 
Field Details- 
SESSION_CREATED_EVENTThe SessionEvent event type when a session is created.- See Also:
 
- 
SESSION_DESTROYED_EVENTThe SessionEvent event type when a session is destroyed.- See Also:
 
- 
SESSION_ACTIVATED_EVENTThe SessionEvent event type when a session is activated.- See Also:
 
- 
SESSION_PASSIVATED_EVENTThe SessionEvent event type when a session is passivated.- See Also:
 
 
- 
- 
Method Details- 
getAuthTypeString getAuthType()- Returns:
- the authentication type used to authenticate our cached Principal, if any.
 
- 
setAuthTypeSet the authentication type used to authenticate our cached Principal, if any.- Parameters:
- authType- The new cached authentication type
 
- 
getCreationTimelong getCreationTime()- Returns:
- the creation time for this session.
 
- 
getCreationTimeInternallong getCreationTimeInternal()- Returns:
- the creation time for this session, bypassing the session validity checks.
 
- 
setCreationTimevoid 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
 
- 
getIdString getId()- Returns:
- the session identifier for this session.
 
- 
getIdInternalString getIdInternal()- Returns:
- the session identifier for this session.
 
- 
setIdSet the session identifier for this session and notifies any associated listeners that a new session has been created.- Parameters:
- id- The new session identifier
 
- 
setIdSet the session identifier for this session and optionally notifies any associated listeners that a new session has been created.- Parameters:
- id- The new session identifier
- notify- Should any associated listeners be notified that a new session has been created?
 
- 
getThisAccessedTimelong 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.
 
- 
getThisAccessedTimeInternallong getThisAccessedTimeInternal()- Returns:
- the last client access time without invalidation check
- See Also:
 
- 
getLastAccessedTimelong 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.
 
- 
getLastAccessedTimeInternallong getLastAccessedTimeInternal()- Returns:
- the last client access time without invalidation check
- See Also:
 
- 
getIdleTimelong getIdleTime()- Returns:
- the idle time (in milliseconds) from last client access time.
 
- 
getIdleTimeInternallong getIdleTimeInternal()- Returns:
- the idle time from last client access time without invalidation check
- See Also:
 
- 
getManagerManager getManager()- Returns:
- the Manager within which this Session is valid.
 
- 
setManagerSet the Manager within which this Session is valid.- Parameters:
- manager- The new Manager
 
- 
getMaxInactiveIntervalint 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.
 
- 
setMaxInactiveIntervalvoid 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
 
- 
setNewvoid setNew(boolean isNew) Set theisNewflag for this session.- Parameters:
- isNew- The new value for the- isNewflag
 
- 
getPrincipalPrincipal getPrincipal()- Returns:
- the authenticated Principal that is associated with this Session.
 This provides an Authenticatorwith 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.
 
- 
setPrincipalSet 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, or- nullif none
 
- 
getSessionHttpSession getSession()- Returns:
- the HttpSessionfor which this object is the facade.
 
- 
setValidvoid setValid(boolean isValid) Set theisValidflag for this session.- Parameters:
- isValid- The new value for the- isValidflag
 
- 
isValidboolean isValid()- Returns:
- trueif the session is still valid
 
- 
accessvoid 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.
- 
addSessionListenerAdd a session event listener to this component.- Parameters:
- listener- the SessionListener instance that should be notified for session events
 
- 
endAccessvoid endAccess()End access to the session.
- 
expirevoid expire()Perform the internal processing required to invalidate this session, without triggering an exception if the session has already expired.
- 
getNote- Parameters:
- name- Name of the note to be returned
- Returns:
- the object bound with the specified name to the internal notes
 for this session, or nullif no such binding exists.
 
- 
getNoteNames- Returns:
- an Iterator containing the String names of all notes bindings that exist for this session.
 
- 
recyclevoid recycle()Release all object references, and initialize instance variables, in preparation for reuse of this object.
- 
removeNoteRemove any object bound to the specified name in the internal notes for this session.- Parameters:
- name- Name of the note to be removed
 
- 
removeSessionListenerRemove a session event listener from this component.- Parameters:
- listener- remove the session listener, which will no longer be notified
 
- 
setNoteBind 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 bound
- value- Object to be bound to the specified name
 
- 
tellChangedSessionIdvoid tellChangedSessionId(String newId, String oldId, boolean notifySessionListeners, boolean notifyContainerListeners) Inform the listeners about the change session ID.- Parameters:
- newId- new session ID
- oldId- old session ID
- notifySessionListeners- 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?
 
- 
isAttributeDistributableDoes 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 name
- value- The attribute value
- Returns:
- trueif distribution is supported, otherwise- false
 
 
-