org.echarts.servlet.sip
Class EChartsProxyServlet

java.lang.Object
  extended by javax.servlet.GenericServlet
      extended by javax.servlet.sip.SipServlet
          extended by org.echarts.servlet.sip.EChartsProxyServlet
All Implemented Interfaces:
java.io.Serializable, javax.servlet.Servlet, javax.servlet.ServletConfig
Direct Known Subclasses:
CCFServlet, ProxyRequestServlet, RegistrarServlet, UCFServlet

public class EChartsProxyServlet
extends SipServlet

SipServlet that adds monitor capability. Override handleInitialRequest, specifyRequestURI, modifyRequest, and modifyResponse to specialize this SipServlet as desired. Session (in)validation is the responsibility of the subclass. Two boolean init-param values, "isRecordRoute" and "isSupervised", can be defined in the servlet deployment descriptor to specify how requests are to be proxied. Their default values are both true.

See Also:
Serialized Form

Field Summary
protected  boolean isRecordRoute
           
protected  boolean isSupervised
           
protected  Monitor monitor
           
 
Fields inherited from class javax.servlet.sip.SipServlet
OUTBOUND_INTERFACES, PRACK_SUPPORTED, SIP_FACTORY, SIP_SESSIONS_UTIL, SUPPORTED, SUPPORTED_RFCs, TIMER_SERVICE
 
Constructor Summary
EChartsProxyServlet()
           
 
Method Summary
 void destroy()
          Removes logger.
 void doRequest(SipServletRequest req)
          Handles request processing by calling handleInitialRequest, specifyRequestURI and modifyRequest.
 void doResponse(SipServletResponse resp)
          Handles response processing by calling modifyResponse and logging to monitor.
protected  boolean getBooleanInitParameter(java.lang.String paramName, boolean defaultValue)
          Get the value of an init-param (from sip.xml) representing a boolean
 Monitor getMonitor()
          Returns this servlet's ECharts monitor.
 java.util.Properties getServletProperties()
          Gets initialization parameters from sip.xml.
protected  boolean handleInitialRequest(SipServletRequest req)
          Override handleInitialRequest to customize handling of initial requests.
 void init(javax.servlet.ServletConfig sc)
          Initialize the servlet and monitor.
protected  void modifyRequest(SipServletRequest req)
          Override this method to perform arbitrary modifications to a SipServletRequest.
protected  void modifyResponse(SipServletResponse resp)
          Override this method to perform arbitrary modifications to a SipServletResponse
 void sendResponse(SipServletResponse resp)
          Sends a response and logs to monitor
protected  URI specifyRequestURI(SipServletRequest req)
          Override this method to specify the desired Request-URI for initial request
 
Methods inherited from class javax.servlet.sip.SipServlet
doAck, doBranchResponse, doBye, doCancel, doErrorResponse, doInfo, doInvite, doMessage, doNotify, doOptions, doPrack, doProvisionalResponse, doPublish, doRedirectResponse, doRefer, doRegister, doSubscribe, doSuccessResponse, doUpdate, log, log, service
 
Methods inherited from class javax.servlet.GenericServlet
getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletInfo, getServletName, init
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

isRecordRoute

protected boolean isRecordRoute

isSupervised

protected boolean isSupervised

monitor

protected Monitor monitor
Constructor Detail

EChartsProxyServlet

public EChartsProxyServlet()
Method Detail

init

public void init(javax.servlet.ServletConfig sc)
          throws javax.servlet.ServletException
Initialize the servlet and monitor.

Specified by:
init in interface javax.servlet.Servlet
Overrides:
init in class javax.servlet.GenericServlet
Throws:
javax.servlet.ServletException

destroy

public void destroy()
Removes logger.

Specified by:
destroy in interface javax.servlet.Servlet
Overrides:
destroy in class javax.servlet.GenericServlet

doRequest

public void doRequest(SipServletRequest req)
               throws javax.servlet.ServletException,
                      java.io.IOException
Handles request processing by calling handleInitialRequest, specifyRequestURI and modifyRequest. The incoming request and the outgoing proxied request are logged to monitor. For initial requests, if handleInitialRequest returns false, and this method proxies the request to the Request-URI of the request, the outgoing request is logged. Otherwise, if handleInitialRequest sends a final response and returns true, it should use the sendResponse method so that the outgoing response is logged to monitor.

Overrides:
doRequest in class SipServlet
Throws:
javax.servlet.ServletException
java.io.IOException

doResponse

public void doResponse(SipServletResponse resp)
                throws javax.servlet.ServletException,
                       java.io.IOException
Handles response processing by calling modifyResponse and logging to monitor.

Overrides:
doResponse in class SipServlet
Throws:
javax.servlet.ServletException
java.io.IOException

sendResponse

public void sendResponse(SipServletResponse resp)
                  throws java.io.IOException
Sends a response and logs to monitor

Throws:
java.io.IOException

getServletProperties

public java.util.Properties getServletProperties()
Gets initialization parameters from sip.xml.

Returns:
All init-param key/value pairs from sip.xml deployment descriptor.

getMonitor

public Monitor getMonitor()
Returns this servlet's ECharts monitor.

Returns:
This servlet's ECharts monitor.

handleInitialRequest

protected boolean handleInitialRequest(SipServletRequest req)
                                throws javax.servlet.ServletException,
                                       java.io.IOException
Override handleInitialRequest to customize handling of initial requests. If this methods returns true, it signifies that the request handling is complete, and the calling method doRequest returns immediately.

This allows the subclass to perform alternative action in handleInitialRequest, for example to act as UAS and send a final response, or set a timer to handle the request later.

Parameters:
req - initial request
Returns:
Whether request handling is completed
Throws:
javax.servlet.ServletException
java.io.IOException

modifyRequest

protected void modifyRequest(SipServletRequest req)
Override this method to perform arbitrary modifications to a SipServletRequest.

Parameters:
req -

modifyResponse

protected void modifyResponse(SipServletResponse resp)
Override this method to perform arbitrary modifications to a SipServletResponse

Parameters:
resp -

specifyRequestURI

protected URI specifyRequestURI(SipServletRequest req)
Override this method to specify the desired Request-URI for initial request

Parameters:
req - initial request
Returns:
desired Request-URI, or null for no change

getBooleanInitParameter

protected boolean getBooleanInitParameter(java.lang.String paramName,
                                          boolean defaultValue)
Get the value of an init-param (from sip.xml) representing a boolean

Parameters:
paramName - name of init-param
defaultValue - default value if init-param is not specified
Returns:
boolean value of init-param, if present