javax.servlet.sip
Interface SipSession

All Superinterfaces:
java.io.Serializable

public interface SipSession
extends java.io.Serializable

Represents point-to-point SIP relationships. It roughly corresponds to a SIP dialog. In particular, for UAs it maintains (or is otherwise associated with) dialog state so as to be able to create subequent requests belonging to that dialog (using createRequest).

For UACs, SipSession extend the notion of SIP dialogs to have well-defined state before a dialog has been established and after a final non-2xx terminates an early dialog. This allows UACs to create "subsequent" requests without having an established dialog. The effect is that the subsequent request will have the same Call-ID, From and To headers (with the same From tag and without a To tag), the will exist in the same CSeq space.

All messages are potentially associated with a SipSession. The SipSession can be retrieved from the message by calling SipServletMessage.getSession().


Method Summary
 SipServletRequest createRequest(java.lang.String method)
          Returns a new request
 SipApplicationSession getApplicationSession()
          Returns the application session with which this SipSession is associated.
 java.lang.Object getAttribute(java.lang.String name)
          Returns the object bound with the specified name in this session, or null if no object is bound under the name.
 java.util.Enumeration getAttributeNames()
          Returns an Enumeration over the String objects containing the names of all the objects bound to this session.
 java.lang.String getCallId()
          Returns the Call-ID for this SipSession.
 long getCreationTime()
          Returns the time when this session was created, measured in milliseconds since midnight January 1, 1970 GMT.
 java.lang.String getId()
          Returns a string containing the unique identifier assigned to this session.
 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.
 Address getLocalParty()
          Returns the Address identifying the local party.
 Address getRemoteParty()
          Returns the Address identifying the remote party.
 void invalidate()
          Invalidates this session and unbinds any objects bound to it.
 void removeAttribute(java.lang.String name)
          Removes the object bound with the specified name from this session.
 void setAttribute(java.lang.String name, java.lang.Object attribute)
          Binds an object to this session, using the name specified.
 void setHandler(java.lang.String name)
          Sets the handler for this SipSession.
 

Method Detail

getCreationTime

public long getCreationTime()
Returns the time when this session was created, measured in milliseconds since midnight January 1, 1970 GMT.
Returns:
a long specifying when this session was created, expressed in milliseconds since 1/1/1970 GMT
Throws:
java.lang.IllegalStateException - if this method is called on an invalidated session

getId

public java.lang.String getId()
Returns a string containing the unique identifier assigned to this session. The identifier is assigned by the servlet container and is implementation dependent.
Returns:
a string specifying the identifier assigned to this session

getLastAccessedTime

public 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.
Returns:
a long representing the last time the client sent a request associated with this session, expressed in milliseconds since 1/1/1970 GMT

invalidate

public void invalidate()
Invalidates this session and unbinds any objects bound to it.
Throws:
java.lang.IllegalStateException - if this method is called on an invalidated session

getApplicationSession

public SipApplicationSession getApplicationSession()
Returns the application session with which this SipSession is associated.
Returns:
the application session for this SipSession

getCallId

public java.lang.String getCallId()
Returns the Call-ID for this SipSession. This is the value of the Call-ID header for all messages belonging to this session.
Returns:
the Call-ID for this SipSession

getLocalParty

public Address getLocalParty()
Returns the Address identifying the local party. This is the value of the From header of locally initiated requests in this leg.
Returns:
address of local party

getRemoteParty

public Address getRemoteParty()
Returns the Address identifying the remote party. This is the value of the To header of locally initiated requests in this leg.

createRequest

public SipServletRequest createRequest(java.lang.String method)
Returns a new request
Parameters:
method - the SIP method of the new request
Returns:
the new request object
Throws:
java.lang.IllegalStateException - if this SipSession has been invalidated

setHandler

public void setHandler(java.lang.String name)
                throws javax.servlet.ServletException
Sets the handler for this SipSession. This method can be used to explicitly specify the name of the servlet which should handle all subsequently received messages for this SipSession. The servlet must belong to the same application (i.e. same ServletContext) as the caller.
Parameters:
name - name of the servlet to be invoked for incoming SIP messages belonging to this SipSession
Throws:
javax.servlet.ServletException - if no servlet with the specified name exists in this application

getAttribute

public java.lang.Object getAttribute(java.lang.String name)
Returns the object bound with the specified name in this session, or null if no object is bound under the name.
Parameters:
name - a string specifying the name of the object
Returns:
the object with the specified name
Throws:
java.lang.IllegalStateException - if this method is called on an invalidated session

getAttributeNames

public java.util.Enumeration getAttributeNames()
Returns an Enumeration over the String objects containing the names of all the objects bound to this session.
Returns:
an Enumeration over the String objects specifying the names of all the objects bound to this session
Throws:
java.lang.IllegalStateException - if this method is called on an invalidated session

setAttribute

public void setAttribute(java.lang.String name,
                         java.lang.Object attribute)
Binds an object to this session, using the name specified. If an object of the same name is already bound to the session, the object is replaced.
Parameters:
name - the name to which the object is bound; cannot be null
attribute - the object to be bound; cannot be null
Throws:
java.lang.IllegalStateException - if this method is called on an invalidated session

removeAttribute

public void removeAttribute(java.lang.String name)
Removes the object bound with the specified name from this session. If the session does not have an object bound with the specified name, this method does nothing.
Parameters:
name - the name of the object to remove from this session
Throws:
java.lang.IllegalStateException - if this method is called on an invalidated session


SIP Servlet API 1.0