com.ibm.twss.common.siputils
Class SipApplicationSessionLock

java.lang.Object
  extended by javax.servlet.GenericServlet
      extended by javax.servlet.sip.SipServlet
          extended by com.ibm.twss.common.siputils.SipApplicationSessionLock
All Implemented Interfaces:
java.io.Serializable, javax.servlet.Servlet, javax.servlet.ServletConfig

public class SipApplicationSessionLock
extends javax.servlet.sip.SipServlet

This servlet serves as a SipServlet superclass that performs SipApplicationSession-based locking. It prevents two messages from the same application session from being processed concurrently, and attempts to intelligently handle cases where incoming messages belong to existing but invalid application session or sip session. This locking mechanism introduces an interesting problem, namely that SipSessions may be invalidated between when the message arrives and when it enters subclass code.

Version:
1.4
See Also:
Serialized Form

Field Summary
 
Fields inherited from class javax.servlet.sip.SipServlet
SIP_FACTORY, SUPPORTED, TIMER_SERVICE
 
Constructor Summary
SipApplicationSessionLock()
           
 
Method Summary
protected  void doRequest(javax.servlet.sip.SipServletRequest req)
          For incoming requests, determine if the session is valid, lock, and then delegate to SipServlet.doRequest.
protected  void doRequestPerJSR116Section3Point3(javax.servlet.sip.SipServletRequest req)
          For incoming requests, behave per JSR 116 section 3.3 on page 17: All other methods check whether the request is an initial request, as described in section 8.2.8.
protected  void doResponse(javax.servlet.sip.SipServletResponse resp)
          For incoming responses, determine if the sesion is valid, lock, and delegate to SipServlet.doResponse.
protected  void doUpdate(javax.servlet.sip.SipServletRequest req)
          Provide a default implementation of UPDATE processing.
static boolean isSessionValid(javax.servlet.sip.SipApplicationSession sas)
          Utility method to determine if a given SipApplicationSession is "valid" according to JSR 116.
static boolean isSessionValid(javax.servlet.sip.SipSession ss)
          Utility method to determine if a given SipSession is "valid" according to JSR 116.
 
Methods inherited from class javax.servlet.sip.SipServlet
doAck, doBye, doCancel, doErrorResponse, doInfo, doInvite, doMessage, doNotify, doOptions, doPrack, doProvisionalResponse, doPublish, doRedirectResponse, doRegister, doSubscribe, doSuccessResponse, getServletConfig, getServletContext, init, log, log, service
 
Methods inherited from class javax.servlet.GenericServlet
destroy, getInitParameter, getInitParameterNames, getServletInfo, getServletName, init
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SipApplicationSessionLock

public SipApplicationSessionLock()
Method Detail

doRequest

protected void doRequest(javax.servlet.sip.SipServletRequest req)
                  throws javax.servlet.ServletException,
                         java.io.IOException
For incoming requests, determine if the session is valid, lock, and then delegate to SipServlet.doRequest. If the session is not valid, return an appropriate 481 to the client.

Overrides:
doRequest in class javax.servlet.sip.SipServlet
Parameters:
req - to process, provided by the container.
Throws:
javax.servlet.ServletException
java.io.IOException
See Also:
SipServlet.doRequest(javax.servlet.sip.SipServletRequest)

doRequestPerJSR116Section3Point3

protected void doRequestPerJSR116Section3Point3(javax.servlet.sip.SipServletRequest req)
                                         throws javax.servlet.ServletException,
                                                java.io.IOException
For incoming requests, behave per JSR 116 section 3.3 on page 17:
All other methods check whether the request is an initial request, as described in section 8.2.8. If the request is initial, it is rejected with status code 500; otherwise the method does nothing...
This method is necessary because some of our subclasses will need to delegate to new SIP request types (like UPDATE). The standard patten is do so with a construct like
 protected void doRequest(SipServletRequest request)
 throws ServletException, IOException {
    if ("STORE".equals(request.getMethod())) {
       doStore(request);
    } else {
       super.doRequest(request);
    }
 }
 
which does not work for SipApplicationSessionLock. This method is to provide a default behavior for methods like doUpdate so that children can subclass them appropriately.

Parameters:
req - to process, provided by the container.
Throws:
javax.servlet.ServletException
java.io.IOException
See Also:
SipServlet.doRequest(javax.servlet.sip.SipServletRequest)

doUpdate

protected void doUpdate(javax.servlet.sip.SipServletRequest req)
                 throws javax.servlet.ServletException,
                        java.io.IOException
Provide a default implementation of UPDATE processing. Delegates to doRequestPerJSR116Section3Point3

Parameters:
req - to process, provided by the container.
Throws:
javax.servlet.ServletException
java.io.IOException
See Also:
SipServlet.doRequest(javax.servlet.sip.SipServletRequest)

doResponse

protected void doResponse(javax.servlet.sip.SipServletResponse resp)
                   throws javax.servlet.ServletException,
                          java.io.IOException
For incoming responses, determine if the sesion is valid, lock, and delegate to SipServlet.doResponse. If the session is not valid, camp on the response hopefully forcing the client's request transaction to timeout.

Overrides:
doResponse in class javax.servlet.sip.SipServlet
Parameters:
resp - to process, provided by the container.
Throws:
javax.servlet.ServletException
java.io.IOException
See Also:
SipServlet.doResponse(javax.servlet.sip.SipServletResponse)

isSessionValid

public static boolean isSessionValid(javax.servlet.sip.SipApplicationSession sas)
Utility method to determine if a given SipApplicationSession is "valid" according to JSR 116. Unfortunately there's no direct call in JSR 116 to accomplish this.

Parameters:
sas - session to check.
Returns:
true if the session is valid. False if invalid or null.

isSessionValid

public static boolean isSessionValid(javax.servlet.sip.SipSession ss)
Utility method to determine if a given SipSession is "valid" according to JSR 116. Unfortunately there's no direct call in JSR 116 to accomplish this.

Parameters:
ss - session to check.
Returns:
true if the session is valid. False if invalid or null.


Copyright © 2003 IBM Corp. All Rights Reserved.