javax.servlet.sip
Class SipServlet

java.lang.Object
  |
  +--javax.servlet.GenericServlet
        |
        +--javax.servlet.sip.SipServlet
All Implemented Interfaces:
java.io.Serializable, javax.servlet.Servlet, javax.servlet.ServletConfig

public abstract class SipServlet
extends javax.servlet.GenericServlet

Provides an abstract class to be subclassed to create a SIP servlet.

This class receives incoming messages through the service method. This method calls doRequest or doResponse for incoming requests and responses, respectively. These two methods in turn dispatch on request method or status code to one of the following methods:

The default implementation of doAck, doCancel and all the response handling methods are empty. All other request handling methods reject the request with a 500 error response.

Subclasses of SipServlet will usually override one or more of these methods.

See Also:
RFC 2976, The SIP INFO Method, RFC 3262, Reliability of Provisional Responses in the Session Initiation Protocol (SIP), RFC 3265, Session Initiation Protocol (SIP)-Specific Event Notification, SIP Extensions for Instant Messaging, Serialized Form

Field Summary
static java.lang.String SIP_FACTORY
          The string "javax.servlet.sip.SipFactory".
static java.lang.String SUPPORTED
          The string "javax.servlet.sip.supported".
static java.lang.String TIMER_SERVICE
          The string "javax.servlet.sip.TimerService".
 
Constructor Summary
SipServlet()
           
 
Method Summary
protected  void doAck(SipServletRequest req)
          Invoked by the server (via the service method) to handle incoming ACK requests.
protected  void doBye(SipServletRequest req)
          Invoked by the server (via the service method) to handle incoming BYE requests.
protected  void doCancel(SipServletRequest req)
          Invoked by the server (via the service method) to handle incoming CANCEL requests.
protected  void doErrorResponse(SipServletResponse resp)
          Invoked by the server (via the doResponse method) to handle incoming 4xx - 6xx class responses.
protected  void doInfo(SipServletRequest req)
          Invoked by the server (via the service method) to handle incoming INFO requests.
protected  void doInvite(SipServletRequest req)
          Invoked by the server (via the service method) to handle incoming INVITE requests.
protected  void doMessage(SipServletRequest req)
          Invoked by the server (via the service method) to handle incoming MESSAGE requests.
protected  void doNotify(SipServletRequest req)
          Invoked by the server (via the service method) to handle incoming NOTIFY requests.
protected  void doOptions(SipServletRequest req)
          Invoked by the server (via the service method) to handle incoming OPTIONS requests.
protected  void doPrack(SipServletRequest req)
          Invoked by the server (via the service method) to handle incoming PRACK requests.
protected  void doProvisionalResponse(SipServletResponse resp)
          Invoked by the server (via the doResponse method) to handle incoming 1xx class responses.
protected  void doRedirectResponse(SipServletResponse resp)
          Invoked by the server to notify the servlet of incoming 3xx class responses.
protected  void doRegister(SipServletRequest req)
          Invoked by the server (via the service method) to handle incoming REGISTER requests.
protected  void doRequest(SipServletRequest req)
          Invoked to handle incoming requests.
protected  void doResponse(SipServletResponse resp)
          Invoked to handle incoming responses.
protected  void doSubscribe(SipServletRequest req)
          Invoked by the server (via the service method) to handle incoming SUBSCRIBE requests.
protected  void doSuccessResponse(SipServletResponse resp)
          Invoked by the server (via the doResponse method) to handle incoming 2xx class responses.
 void log(java.lang.String message)
          Writes the specified message to a servlet log file.
 void log(java.lang.String message, java.lang.Throwable t)
          Writes an explanatory message and a stack trace for a given Throwable exception to the servlet log file.
 void service(javax.servlet.ServletRequest req, javax.servlet.ServletResponse resp)
          Invoked to handle incoming SIP messages: requests or responses.
 
Methods inherited from class javax.servlet.GenericServlet
destroy, getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletInfo, getServletName, init, init
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SIP_FACTORY

public static final java.lang.String SIP_FACTORY
The string "javax.servlet.sip.SipFactory". This is the name of the ServletContext attribute whose value is an instance of the SipFactory interface.
See Also:
SipFactory

TIMER_SERVICE

public static final java.lang.String TIMER_SERVICE
The string "javax.servlet.sip.TimerService". This is the name of the ServletContext attribute whose value is an instance of the TimerService interface.
See Also:
TimerService

SUPPORTED

public static final java.lang.String SUPPORTED
The string "javax.servlet.sip.supported". This is the name of the ServletContext attribute whose value is a List containing the names of SIP extensions supported by the container.
Constructor Detail

SipServlet

public SipServlet()
Method Detail

service

public void service(javax.servlet.ServletRequest req,
                    javax.servlet.ServletResponse resp)
             throws javax.servlet.ServletException,
                    java.io.IOException
Invoked to handle incoming SIP messages: requests or responses. Exactly one of the arguments is null: if the event is a request the response argument is null, and vice versa, if the event is a response the request argument is null.

This method dispatched to doRequest() or doResponse() as appropriate. Servlets will not usually need to override this method.

Overrides:
service in class javax.servlet.GenericServlet
Parameters:
req - the request to handle, or null if the triggering event was an incoming response
resp - incoming response or null if the triggering event was an incoming request
Throws:
javax.servlet.ServletException - if an exception occurs that interferes with the servlet's normal operation
java.io.IOException - if an input or output exception occurs

doRequest

protected void doRequest(SipServletRequest req)
                  throws javax.servlet.ServletException,
                         java.io.IOException
Invoked to handle incoming requests. This method dispatched requests to one of the doXxx methods where Xxx is the SIP method used in the request. Servlets will not usually need to override this method.
Parameters:
req - represents the incoming SIP request
Throws:
javax.servlet.ServletException - if an exception occurs that interferes with the servlet's normal operation
java.io.IOException - if an input or output exception occurs

doInvite

protected void doInvite(SipServletRequest req)
                 throws javax.servlet.ServletException,
                        java.io.IOException
Invoked by the server (via the service method) to handle incoming INVITE requests.

The default implementation is empty and must be overridden by subclasses to do something useful.

Parameters:
req - represents the incoming SIP INVITE request
Throws:
javax.servlet.ServletException - if an exception occurs that interferes with the servlet's normal operation
java.io.IOException - if an input or output exception occurs

doAck

protected void doAck(SipServletRequest req)
              throws javax.servlet.ServletException,
                     java.io.IOException
Invoked by the server (via the service method) to handle incoming ACK requests.

The default implementation is empty and must be overridden by subclasses to do something useful.

Parameters:
req - represents the incoming SIP ACK request
Throws:
javax.servlet.ServletException - if an exception occurs that interferes with the servlet's normal operation
java.io.IOException - if an input or output exception occurs

doOptions

protected void doOptions(SipServletRequest req)
                  throws javax.servlet.ServletException,
                         java.io.IOException
Invoked by the server (via the service method) to handle incoming OPTIONS requests.

The default implementation is empty and must be overridden by subclasses to do something useful.

Parameters:
req - represents the incoming SIP OPTIONS request
Throws:
javax.servlet.ServletException - if an exception occurs that interferes with the servlet's normal operation
java.io.IOException - if an input or output exception occurs

doBye

protected void doBye(SipServletRequest req)
              throws javax.servlet.ServletException,
                     java.io.IOException
Invoked by the server (via the service method) to handle incoming BYE requests.

The default implementation is empty and must be overridden by subclasses to do something useful.

Parameters:
req - represents the incoming SIP BYE request
Throws:
javax.servlet.ServletException - if an exception occurs that interferes with the servlet's normal operation
java.io.IOException - if an input or output exception occurs

doCancel

protected void doCancel(SipServletRequest req)
                 throws javax.servlet.ServletException,
                        java.io.IOException
Invoked by the server (via the service method) to handle incoming CANCEL requests.

The default implementation is empty and must be overridden by subclasses to do something useful.

Parameters:
req - represents the incoming SIP CANCEL request
Throws:
javax.servlet.ServletException - if an exception occurs that interferes with the servlet's normal operation
java.io.IOException - if an input or output exception occurs

doRegister

protected void doRegister(SipServletRequest req)
                   throws javax.servlet.ServletException,
                          java.io.IOException
Invoked by the server (via the service method) to handle incoming REGISTER requests.

The default implementation is empty and must be overridden by subclasses to do something useful.

Parameters:
req - represents the incoming SIP REGISTER request
Throws:
javax.servlet.ServletException - if an exception occurs that interferes with the servlet's normal operation
java.io.IOException - if an input or output exception occurs

doSubscribe

protected void doSubscribe(SipServletRequest req)
                    throws javax.servlet.ServletException,
                           java.io.IOException
Invoked by the server (via the service method) to handle incoming SUBSCRIBE requests.

The default implementation is empty and must be overridden by subclasses to do something useful.

Parameters:
req - represents the incoming SIP SUBSCRIBE request
Throws:
javax.servlet.ServletException - if an exception occurs that interferes with the servlet's normal operation
java.io.IOException - if an input or output exception occurs

doNotify

protected void doNotify(SipServletRequest req)
                 throws javax.servlet.ServletException,
                        java.io.IOException
Invoked by the server (via the service method) to handle incoming NOTIFY requests.

The default implementation is empty and must be overridden by subclasses to do something useful.

Parameters:
req - represents the incoming SIP NOTIFY request
Throws:
javax.servlet.ServletException - if an exception occurs that interferes with the servlet's normal operation
java.io.IOException - if an input or output exception occurs

doMessage

protected void doMessage(SipServletRequest req)
                  throws javax.servlet.ServletException,
                         java.io.IOException
Invoked by the server (via the service method) to handle incoming MESSAGE requests.

The default implementation is empty and must be overridden by subclasses to do something useful.

Parameters:
req - represents the incoming SIP MESSAGE request
Throws:
javax.servlet.ServletException - if an exception occurs that interferes with the servlet's normal operation
java.io.IOException - if an input or output exception occurs

doInfo

protected void doInfo(SipServletRequest req)
               throws javax.servlet.ServletException,
                      java.io.IOException
Invoked by the server (via the service method) to handle incoming INFO requests.

The default implementation is empty and must be overridden by subclasses to do something useful.

Parameters:
req - represents the incoming SIP INFO request
Throws:
javax.servlet.ServletException - if an exception occurs that interferes with the servlet's normal operation
java.io.IOException - if an input or output exception occurs

doPrack

protected void doPrack(SipServletRequest req)
                throws javax.servlet.ServletException,
                       java.io.IOException
Invoked by the server (via the service method) to handle incoming PRACK requests.

The default implementation is empty and must be overridden by subclasses to do something useful.

Parameters:
req - represents the incoming SIP PRACK request
Throws:
javax.servlet.ServletException - if an exception occurs that interferes with the servlet's normal operation
java.io.IOException - if an input or output exception occurs

doResponse

protected void doResponse(SipServletResponse resp)
                   throws javax.servlet.ServletException,
                          java.io.IOException
Invoked to handle incoming responses. This method dispatched responses to one of the doProvisionalResponse(), doErrorResponse(), doSuccessResponse(). Servlets will not usually need to override this method.
Parameters:
resp - the response object
Throws:
javax.servlet.ServletException - if an exception occurs that interferes with the servlet's normal operation
java.io.IOException - if an input or output exception occurs

doProvisionalResponse

protected void doProvisionalResponse(SipServletResponse resp)
                              throws javax.servlet.ServletException,
                                     java.io.IOException
Invoked by the server (via the doResponse method) to handle incoming 1xx class responses.

The default implementation is empty and must be overridden by subclasses to do something useful.

Parameters:
resp - the response object
Throws:
javax.servlet.ServletException - if an exception occurs that interferes with the servlet's normal operation
java.io.IOException - if an input or output exception occurs

doSuccessResponse

protected void doSuccessResponse(SipServletResponse resp)
                          throws javax.servlet.ServletException,
                                 java.io.IOException
Invoked by the server (via the doResponse method) to handle incoming 2xx class responses.

The default implementation is empty and must be overridden by subclasses to do something useful.

Parameters:
resp - the response object
Throws:
javax.servlet.ServletException - if an exception occurs that interferes with the servlet's normal operation
java.io.IOException - if an input or output exception occurs

doRedirectResponse

protected void doRedirectResponse(SipServletResponse resp)
                           throws javax.servlet.ServletException,
                                  java.io.IOException
Invoked by the server to notify the servlet of incoming 3xx class responses.

The default implementation is empty and must be overridden by subclasses to do something useful.

Parameters:
resp - the response object
Throws:
javax.servlet.ServletException - if an exception occurs that interferes with the servlet's normal operation
java.io.IOException - if an input or output exception occurs

doErrorResponse

protected void doErrorResponse(SipServletResponse resp)
                        throws javax.servlet.ServletException,
                               java.io.IOException
Invoked by the server (via the doResponse method) to handle incoming 4xx - 6xx class responses.

The default implementation is empty and must be overridden by subclasses to do something useful.

Parameters:
resp - the response object
Throws:
javax.servlet.ServletException - if an exception occurs that interferes with the servlet's normal operation
java.io.IOException - if an input or output exception occurs

log

public void log(java.lang.String message)
Writes the specified message to a servlet log file. See {link ServletContext#log(String)}.
Overrides:
log in class javax.servlet.GenericServlet
Parameters:
msg - a String specifying the message to be written to the log file

log

public void log(java.lang.String message,
                java.lang.Throwable t)
Writes an explanatory message and a stack trace for a given Throwable exception to the servlet log file. See ServletContext.log(String, Throwable).
Overrides:
log in class javax.servlet.GenericServlet
Parameters:
message - a String that describes the error or exception
t - the java.lang.Throwable error or exception


SIP Servlet API 1.0