public interface Session
HttpSession
that is used to maintain state information
between requests for a particular user of a web application.Modifier and Type | Field and Description |
---|---|
static String |
SESSION_ACTIVATED_EVENT
The SessionEvent event type when a session is activated.
|
static String |
SESSION_CREATED_EVENT
The SessionEvent event type when a session is created.
|
static String |
SESSION_DESTROYED_EVENT
The SessionEvent event type when a session is destroyed.
|
static String |
SESSION_PASSIVATED_EVENT
The SessionEvent event type when a session is passivated.
|
Modifier and Type | Method and Description |
---|---|
void |
access()
Update the accessed time information for this session.
|
void |
addSessionListener(SessionListener listener)
Add a session event listener to this component.
|
void |
endAccess()
End access to the session.
|
void |
expire()
Perform the internal processing required to invalidate this session,
without triggering an exception if the session has already expired.
|
String |
getAuthType() |
long |
getCreationTime() |
long |
getCreationTimeInternal() |
String |
getId() |
String |
getIdInternal() |
long |
getIdleTime() |
long |
getIdleTimeInternal() |
long |
getLastAccessedTime() |
long |
getLastAccessedTimeInternal() |
Manager |
getManager() |
int |
getMaxInactiveInterval() |
Object |
getNote(String name) |
Iterator<String> |
getNoteNames() |
Principal |
getPrincipal() |
HttpSession |
getSession() |
long |
getThisAccessedTime() |
long |
getThisAccessedTimeInternal() |
boolean |
isAttributeDistributable(String name,
Object value)
Does the session implementation support the distributing of the given
attribute?
|
boolean |
isValid() |
void |
recycle()
Release all object references, and initialize instance variables, in
preparation for reuse of this object.
|
void |
removeNote(String name)
Remove any object bound to the specified name in the internal notes
for this session.
|
void |
removeSessionListener(SessionListener listener)
Remove a session event listener from this component.
|
void |
setAuthType(String authType)
Set the authentication type used to authenticate our cached
Principal, if any.
|
void |
setCreationTime(long time)
Set the creation time for this session.
|
void |
setId(String id)
Set the session identifier for this session and notifies any associated
listeners that a new session has been created.
|
void |
setId(String id,
boolean notify)
Set the session identifier for this session and optionally notifies any
associated listeners that a new session has been created.
|
void |
setManager(Manager manager)
Set the Manager within which this Session is valid.
|
void |
setMaxInactiveInterval(int interval)
Set the maximum time interval, in seconds, between client requests
before the servlet container will invalidate the session.
|
void |
setNew(boolean isNew)
Set the
isNew flag for this session. |
void |
setNote(String name,
Object value)
Bind an object to a specified name in the internal notes associated
with this session, replacing any existing binding for this name.
|
void |
setPrincipal(Principal principal)
Set the authenticated Principal that is associated with this Session.
|
void |
setValid(boolean isValid)
Set the
isValid flag for this session. |
void |
tellChangedSessionId(String newId,
String oldId,
boolean notifySessionListeners,
boolean notifyContainerListeners)
Inform the listeners about the change session ID.
|
static final String SESSION_CREATED_EVENT
static final String SESSION_DESTROYED_EVENT
static final String SESSION_ACTIVATED_EVENT
static final String SESSION_PASSIVATED_EVENT
String getAuthType()
void setAuthType(String authType)
authType
- The new cached authentication typelong getCreationTime()
long getCreationTimeInternal()
void setCreationTime(long time)
time
- The new creation timeString getId()
String getIdInternal()
void setId(String id)
id
- The new session identifiervoid setId(String id, boolean notify)
id
- The new session identifiernotify
- Should any associated listeners be notified that a new
session has been created?long getThisAccessedTime()
long getThisAccessedTimeInternal()
getThisAccessedTime()
long getLastAccessedTime()
long getLastAccessedTimeInternal()
getLastAccessedTime()
long getIdleTime()
long getIdleTimeInternal()
getIdleTime()
Manager getManager()
void setManager(Manager manager)
manager
- The new Managerint getMaxInactiveInterval()
void setMaxInactiveInterval(int interval)
interval
- The new maximum intervalvoid setNew(boolean isNew)
isNew
flag for this session.isNew
- The new value for the isNew
flagPrincipal getPrincipal()
Authenticator
with a means to cache a
previously authenticated Principal, and avoid potentially expensive
Realm.authenticate()
calls on every request. If there
is no current associated Principal, return null
.void setPrincipal(Principal principal)
Authenticator
with a means to cache a
previously authenticated Principal, and avoid potentially expensive
Realm.authenticate()
calls on every request.principal
- The new Principal, or null
if noneHttpSession getSession()
HttpSession
for which this object
is the facade.void setValid(boolean isValid)
isValid
flag for this session.isValid
- The new value for the isValid
flagboolean isValid()
true
if the session is still validvoid access()
void addSessionListener(SessionListener listener)
listener
- the SessionListener instance that should be notified
for session eventsvoid endAccess()
void expire()
Object getNote(String name)
name
- Name of the note to be returnednull
if no such binding exists.Iterator<String> getNoteNames()
void recycle()
void removeNote(String name)
name
- Name of the note to be removedvoid removeSessionListener(SessionListener listener)
listener
- remove the sesion listener, which will no longer be
notifiedvoid setNote(String name, Object value)
name
- Name to which the object should be boundvalue
- Object to be bound to the specified namevoid tellChangedSessionId(String newId, String oldId, boolean notifySessionListeners, boolean notifyContainerListeners)
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?boolean isAttributeDistributable(String name, Object value)
IllegalArgumentException
thrown if the proposed attribute is
not distributable.
Note that the Manager
implementation may further restrict which
attributes are distributed but a Manager
level restriction should
not trigger an IllegalArgumentException
in
HttpSession.setAttribute(String, Object)
name
- The attribute namevalue
- The attribute valuetrue
if distribution is supported, otherwise false
Copyright © 2000-2016 Apache Software Foundation. All Rights Reserved.