public interface SipApplicationSession extends AttributeStore
SipApplicationSession
interface acts as a store for application data and provides access to
contained protocol sessions, e.g. SipSession
and
HttpSession
objects representing point-to-point signaling
relationships.Modifier and Type | Interface and Description |
---|---|
static class |
SipApplicationSession.Protocol
Possible protocols to which sessions contained in the
SipApplicationSession belong to. |
Modifier and Type | Method and Description |
---|---|
void |
addIndexKey(String indexKey)
Add specified key to the set of index keys of this
SipApplicationSession . |
void |
encodeURI(URI uri)
Deprecated.
has potential to break application composition
instead of this use the SipApplicationKey mechanism
as described in section 15.11.2 in the SIP Servlet
specification document.
|
URL |
encodeURL(URL url)
Encode specified URL to include the application session ID in a way
such that the parameter used to encode the application session ID
should be unique across implementations.
|
String |
getApplicationName()
Returns the name of the SIP application this
SipApplicationSession is
associated with. |
Iterator<String> |
getAttributeNames()
Deprecated.
As of release 2.0, replaced by
AttributeStore.getAttributeNameSet() |
long |
getCreationTime()
Returns the time when this session was created, measured in
milliseconds since midnight January 1, 1970 GMT.
|
long |
getExpirationTime()
Returns the time in future when this SipApplicationSession will expire.
|
String |
getId()
Returns a string containing the unique identifier assigned to
this session.
|
Set<String> |
getIndexKeys()
Return an immutable
Set of index keys added to this
SipApplicationSession object. |
boolean |
getInvalidateWhenReady()
Returns true if the container will notify the application when this
SipApplicationSession is in the ready-to-invalidate state. |
long |
getLastAccessedTime()
Returns the last time an event occurred on this application session.
|
Object |
getSession(String id,
SipApplicationSession.Protocol protocol)
Returns the session object with the specified id associated with the
specified protocol belonging to this application session, or null if not
found.
|
Iterator<?> |
getSessions()
Returns an
Iterator over all valid "protocol" sessions
associated with this application session. |
Iterator<?> |
getSessions(String protocol)
Returns an
Iterator over all valid "protocol" session objects
associated with the specified protocol associated with this application
session. |
Set<?> |
getSessionSet()
Returns an immutable
Set of all valid "protocol" sessions
associated with this application session. |
Set<?> |
getSessionSet(String protocol)
Returns an immutable
Set of all valid "protocol" session objects
associated with the specified protocol associated with this application
session. |
SipSession |
getSipSession(String id)
Returns the
SipSession with the specified id belonging
to this application session, or null if not found. |
Future |
getTaskFuture(String identityName)
Returns
Future object of the task with the specified identity name. |
Set<Future> |
getTaskFutures()
Returns
Future objects of all submitted or scheduled task belonging
to this application session. |
ServletTimer |
getTimer(String id)
Returns the active timer identified by a specific id that is associated
with this application session.
|
Collection<ServletTimer> |
getTimers()
Returns all active timers associated with this application session.
|
void |
invalidate()
Invalidates this application session and unbinds any objects bound to
it.
|
boolean |
isReadyToInvalidate()
Returns true if this application session is in a ready-to-invalidate state.
|
boolean |
isValid()
Returns if this SipApplicationSession is valid, false otherwise.
|
void |
removeIndexKey(String indexKey)
Remove the specified key from the set of index keys of this
SipApplicationSession . |
int |
setExpires(int deltaMinutes)
Sets the time of expiry for this application session.
|
void |
setInvalidateWhenReady(boolean invalidateWhenReady)
Specifies whether the container should notify the application when the
SipApplicationSession is in the ready-to-invalidate state as defined
above.
|
clearAttributes, getAttribute, getAttributeNameSet, removeAttribute, setAttribute
long getCreationTime()
IllegalStateException
- if this method is called on an invalidated sessionlong getLastAccessedTime()
Actions that applications take, such as getting or setting a value associated with the session, do not affect the access time.
long getExpirationTime()
Long.MIN_VALUE
The time is returned as the number of milliseconds
since midnight January 1, 1970 GMT.IllegalStateException
- if this application session is not validString getId()
String
identifier for this application sessionString getApplicationName()
SipApplicationSession
is
associated with.SipApplicationSession
is
associated withint setExpires(int deltaMinutes)
This allows servlets to programmatically extend the lifetime
of application sessions. This method may be invoked by an
application in the notification that the application session has
expired: SipApplicationSessionListener.sessionExpired
.
If the server is willing to extend the session lifetime it returns
the actual number of minutes the session lifetime has been extended
with, and the listener will be invoked about session expiry again
at a later time.
This helps applications clean up resources in a reasonable amount of time in situations where it depends on external events to complete an application session. Being able to extend session lifetime means the application is not forced to choose a very high session lifetime to begin with.
It is entirely up to server policy whether to grant or deny the
applications request to extend session lifetime.
Note that any attempt to extend the lifetime of an explicitly
invalidated application session, one for which setExpires(int)
has been invoked, will always fail.
In order to make the SipApplicationSession immortal i.e never
expire, setExpires should be called with 0 (or -ve number),
again it is upto the container to accept this or not. If the container
does accept setting the session to never expire then it returns
Integer.MAX_VALUE
.
deltaMinutes
- the number of minutes that the lifetime of this
SipApplicationSession
is extended with, if this param is
0 (or negative) then the session never expiresIllegalStateException
- if this application session is not validvoid invalidate()
IllegalStateException
- if this application session is not validboolean isReadyToInvalidate()
SipApplicationSession
is in the ready-to-invalidate state
if the following conditions are met:
IllegalStateException
- if this application session is not validSipSession.isReadyToInvalidate()
void setInvalidateWhenReady(boolean invalidateWhenReady)
SipApplicationSessionListener.sessionReadyToInvalidate
callback.invalidateWhenReady
- if true, the container will observe this
application session and notify the application when it is in the
ready-to-invalidate state. The application session is not observed if the
flag is false.
The default is true for v1.1 applications and false for v1.0
applications.IllegalStateException
- if this application session is not validisReadyToInvalidate()
,
SipApplicationSessionListener.sessionReadyToInvalidate(SipApplicationSessionEvent ev)
boolean getInvalidateWhenReady()
SipApplicationSession
is in the ready-to-invalidate state.IllegalStateException
- if this application session is not validisReadyToInvalidate()
Iterator<?> getSessions()
Iterator
over all valid "protocol" sessions
associated with this application session. This may include a mix
of different types of protocol sessions, e.g. SipSession
and javax.servlet.http.HttpSession
objects.Iterator
over set of valid protocol sessions belonging
to this application sessionIllegalStateException
- if this application session is not validSet<?> getSessionSet()
Set
of all valid "protocol" sessions
associated with this application session. This may include a mix
of different types of protocol sessions, e.g. SipSession
and javax.servlet.http.HttpSession
objects.Set
of set of valid protocol sessions belonging
to this application sessionIllegalStateException
- if this application session is not validIterator<?> getSessions(String protocol)
Iterator
over all valid "protocol" session objects
associated with the specified protocol associated with this application
session. If the specified protocol is not supported, an empty
Iterator
is returned.
If "SIP" is specified the result will be an Iterator
over the set of valid SipSession
objects belonging to this application
session. For "HTTP" the result will be a list of
javax.servlet.http.HttpSession
objects.
protocol
- a string identifying the protocol name, e.g. "SIP"Iterator
over all valid protocol sessions of the
specified protocolIllegalStateException
- if this application session is not validNullPointerException
- if the protocol
is nullIllegalArgumentException
- if the protocol
is not understood by container.Set<?> getSessionSet(String protocol)
Set
of all valid "protocol" session objects
associated with the specified protocol associated with this application
session. If the specified protocol is not supported, an empty
Set
is returned.
If "SIP" is specified the result will be an Set
over the set of valid SipSession
objects belonging to this application
session. For "HTTP" the result will be a Set
of
javax.servlet.http.HttpSession
objects.
protocol
- a string identifying the protocol name, e.g. "SIP"Set
of all valid protocol sessions of the
specified protocolIllegalStateException
- if this application session is not validNullPointerException
- if the protocol
is nullIllegalArgumentException
- if the protocol
is not understood by container.SipSession getSipSession(String id)
SipSession
with the specified id belonging
to this application session, or null if not found.id
- the SipSession
idSipSession
, or null if none is found.NullPointerException
- on null id
IllegalStateException
- if this application session is not validObject getSession(String id, SipApplicationSession.Protocol protocol)
id
- the session idprotocol
- an Enum identifying the protocolNullPointerException
- on null id
or protocol
IllegalStateException
- if this application session is not validvoid encodeURI(URI uri)
SipApplicationSession
into the
specified URI. The container must then be prepared to associate
this application session with an incoming request which was
triggered by activating the encoded URI.
In the case of SIP and SIPS URIs, the container may also rewrite the host, port, and transport protocol components of the URI based on its knowledge of local listen points. When doing so it should take existing settings as a hint as to which listen point to select when it has more than one.
This method allow applications to correlate events which would otherwise be treated as being independent, that is, as belonging to different application sessions. For example, an application might send an instant message with an HTML body to someone. The IM body may then contain a SIP URI pointing back to the SIP servlet container and the application session in which the IM was generated, thus ensuring that an INVITE triggered by the IM recipient triggering that URI is associated with this application session when received by the container.
Containers are required to support rewriting of SIP and SIPS URIs.
uri
- the uri to be encodedIllegalArgumentException
- if the container doesn't know how
to rewrite the specified URI, for example, because it doesn't
know the specific schemeIllegalStateException
- if this application session is not valid@Deprecated Iterator<String> getAttributeNames()
AttributeStore.getAttributeNameSet()
Collection<ServletTimer> getTimers()
Collection
of ServletTimer
objects belonging to this application sessionIllegalStateException
- if this application session is not validServletTimer getTimer(String id)
ServletTimer
object identified by the id belonging
to this application sessionIllegalStateException
- if this application session is not validSet<Future> getTaskFutures()
Future
objects of all submitted or scheduled task belonging
to this application session. Only the tasks that are yet to be completed or
still to be run are returned.Collection
of Future
objects of tasks belonging to this application sessionIllegalStateException
- if this application session is not validFuture getTaskFuture(String identityName)
Future
object of the task with the specified identity name.
Only a task that is yet to be completed or still to be run is returned. If there
is no task matching the criteria, then null is returned. The given identity name
must be the value of javax.enterprise.concurrent.ManagedTask.IDENTITY_NAME
execution property of the submitted or scheduled task.identityName
- Identity Name of the task.Collection
of Future
object of task with the specified identity name.IllegalStateException
- if this application session is not validIllegalArgumentException
- if there are more than one task with the specified
identity name.boolean isValid()
SipSession.invalidate()
on it or if its invalidateWhenReady flag
is true and it transitions to the ready-to-invalidate state.
Also the SipSession can be invalidated by the container when either the associated
SipApplicationSession
times out or
invalidate()
is invoked.URL encodeURL(URL url)
com.acme.appsession
. This mechanism can be used by the applications
to encode the HTTP URL with the application session Id. This URL can
then be sent out through some of out of band mechanism. When the HTTP
Request comes back to the converged container with this request, the
container must associate the new HttpSession with the encoded
Application Session. In case the HTTP request is not a new request
but a follow on request already associated with a HTTP Session then
the converged containers must use the HTTP session association
mechanism to route the request to the right HTTP Session. If that HTTP
Session was not associated with the encoded SipApplicationSession in the
request then that association MUST occur. This mechanism is
similar to how the (deprecated) encodeURI() operates for SIP.
url
- the URL to be encodedIllegalStateException
- if this application session is not validvoid addIndexKey(String indexKey)
SipApplicationSession
.
Application can use SipSessionsUtil.getApplicationSessionIds(String indexKey)
to find the Id of the SipApplicationSession
. Invoking this method multiple
times with the same index key does not have any effect.indexKey
- A string that act as the index key for retrieving the
Id of the SipApplicationSession
IllegalStateException
- if this method is called
on an invalidated SipApplicationSession
SipSessionsUtil.getSipApplicationSessionIds(String)
void removeIndexKey(String indexKey)
SipApplicationSession
. Nothing happens if the set of
index keys does not contain the specified index key.indexKey
- A string that act as the index key for retrieving the
Id of the SipApplicationSession
IllegalStateException
- if this method is called
on an invalidated SipApplicationSession
addIndexKey(String)
Set<String> getIndexKeys()
Set
of index keys added to this
SipApplicationSession
object.Set
of of Index Keys. If no index key
is added to the SipApplicationSession
an empty
Set
is returned.IllegalStateException
- if this method is called
on an invalidated SipApplicationSession
addIndexKey(String)
Copyright © 1996-2015, Oracle and/or its affiliates. All Rights Reserved. Use is subject to license terms.