Package org.mobicents.javax.servlet.sip

JSR 289 Extensions not defined in the specification that can prove useful and will be proposed for inclusion in a next release of the specification.

See:
          Description


Interface Summary
ProxyBranchExt Interface Extension that adds extra features to the JSR 289 ProxyBranch interface.
ProxyBranchListener Interface Extension that adds extra features to the JSR 289 ProxyBranch capabilities.
ProxyExt Interface Extension that adds extra features to the JSR 289 Proxy interface.
 

Enum Summary
ResponseType  
 

Package org.mobicents.javax.servlet.sip Description

JSR 289 Extensions not defined in the specification that can prove useful and will be proposed for inclusion in a next release of the specification. It adds the following feature to Proxy capabilities :

  1. Allows for applications to set a timeout either on the Proxy or ProxyBranch Object on 1xx responses as JSR 289 defines a timeout only for final responses.
  2. Notification of the application when a proxy timer has expired
Here is some sample code to show how it can be used :
        import java.io.IOException;
        import java.util.ArrayList;
        
        import javax.servlet.ServletException;
        import javax.servlet.sip.Proxy;
        import javax.servlet.sip.ProxyBranch;
        import javax.servlet.sip.SipFactory;
        import javax.servlet.sip.SipServlet;
        import javax.servlet.sip.SipServletRequest;
        import javax.servlet.sip.URI;
        
        import org.mobicents.javax.servlet.sip.ProxyBranchListener;
        import org.mobicents.javax.servlet.sip.ProxyExt;
        import org.mobicents.javax.servlet.sip.ResponseType;

        public class ProxySipServlet extends SipServlet implements ProxyBranchListener {
                        
        protected void doInvite(SipServletRequest request) throws ServletException,
                        IOException {

                if(!request.isInitial()){
                        return;
                }
                        
                SipFactory sipFactory = (SipFactory) getServletContext().getAttribute(SIP_FACTORY);
                Proxy proxy = request.getProxy();
                proxy.setParallel(false);
                // set the timeout for receiving a final response
                proxy.setProxyTimeout(5);
                // set the timeout for receiving a 1xx response
                ((ProxyExt)proxy).setProxy1xxTimeout(1);                                
                proxy.setRecordRoute(true);
                ArrayList uris = new ArrayList();
                URI uri1 = sipFactory.createAddress("sip:receiver@127.0.0.1:5057").getURI();            
                URI uri2 = sipFactory.createAddress("sip:second-receiver@127.0.0.1:5056").getURI();
                uris.add(uri2);
                uris.add(uri1);
        
                proxy.proxyTo(uris);            
        }
        
        /**
         * Called if no 1xx and no final response has been received with a response type of INFORMATIONAL
         * Called if no 2xx response has been received with a response type of FINAL
         */
        public void onProxyBranchResponseTimeout(ResponseType responseType,
                        ProxyBranch proxyBranch) {
                logger.info("onProxyBranchResponseTimeout callback was called. responseType = " + responseType + " , branch = " + proxyBranch + ", request " + proxyBranch.getRequest() + ", response " + proxyBranch.getResponse());
        }



Copyright © 2010. All Rights Reserved.