The SIP Servlet Tutorial

SipApplicationSession Methods

SipApplicationSession defines a number of methods for managing application sessions and session data.

SipApplicationSession Data Methods

Storing and retrieving session data is accomplished by using the following methods:

Table 1–7 SipApplicationSession Data Methods

Method 

Description 

getAttributes(String id)

Returns the object bound to the specified ID. Returns null if no such object ID exists. 

getAttributeNames()

Returns an Iterator over the String IDs of the objects bound to this application session.

setAttribute(String name, java.lang.Object attribute)

Binds an object to the session using the specified String as the object's ID for later retrieval. 

removeAttribute(String name)

Removes an object from the session by specifying the bound object's ID. 

SipApplicationSession Protocol Methods

Instances of SipApplicationSession typically have multiple protocol sessions contained within the application session. Such protocol sessions are called child sessions. The following table lists the methods defined in SipApplicationSession for managing child sessions:

Table 1–8 Child Session Methods in SipApplicationSession

Method 

Description 

getSessions()

Retrieves an Iterator over all valid child protocol sessions.

getSessions(String protocol)

Retrieves an Iterator over all valid child sessions for a particular protocol. For example, passing SIP to getSessions will return all SIP protocol sessions.

getSipSession(String id)

Retrieves a particular session by its ID. 

getSession(String id, String protocol)

Retrieves a particular session associated with the specified protocol by its ID. 

SipApplicationSession Lifecycle Methods

The following table lists the methods defined in SipApplicationSession for managing the SIP application session lifecycle:

Table 1–9 SipApplicationSession Lifecycle Methods

Method 

Description 

getCreationTime()

Returns the time that the SipApplicationSession instance was created as a long value representing the number of milliseconds since midnight January 1, 1970 GMT.

getExpirationTime()

Returns the time that the SipApplicationSession will expire as a long value representing the number of milliseconds since midnight January 1, 1970 GMT.

getInvalidateWhenReady()

Returns a boolean value specifying whether the container will notify the application when the SipApplicationSession instance is ready to be invalidated.

getLastAccessedTime()

Returns the time that the SipApplicationSession instance was last accessed as a long value representing the number of milliseconds since midnight January 1, 1970 GMT.

setInvalidateWhenReady(boolean invalidateWhenReady)

Tells the container to notify the application when the SipApplicationSession instance is ready to be invalidated.

invalidate()

Explicitly invalidates the SIP application session and unbinds any objects bound to the session. 

isReadyToInvalidate()

Returns a boolean value specifying whether the SipApplicationSession instance is ready to be invalidated.

isValid()

Returns a boolean value specifying whether the SipApplicationSession instance is valid.

setExpires(int deltaMinutes)

Extends the time of expiry for the SipApplicationSession instance by the number of minutes specified by deltaMinutes. If deltaMinutes is 0 or a negative number, the session will never expire. Returns an int value of the number of minutes by which the session was extended. If it returns 0, the session was not extended.