com.oki.sip.engine
Class SipRequestDispatcher

java.lang.Object
  extended bycom.oki.sip.engine.SipRequestDispatcher
All Implemented Interfaces:
SipConstants

public class SipRequestDispatcher
extends java.lang.Object
implements SipConstants

Dispatcher to call a SIP servlet from an HTTP servlet.

While HTTP servlet typically retrieves a servlet which is the destination of HTTP requests using ServletContext#getNamedDispatcher(String name), this class provides SIP servlet with this process. This means that HTTP servlet can use this class to invoke SIP servlet on the same servlet context. Note that it is different from the HTTP/HTTP forward in the following:

How to call

For HTTP/HTTP forward, the servlet container, as well as the caller, calls doXxx method. For HTTP/SIP forward, a method to invoke must be explicitly specified because HTTP and SIP use different methods.
Only SipRequestParams must be defined as a parameter of method to invoke. In other words, makeCall(ServletRequest req) cannot be invoked due to difference in the argument, while makeCall(SipRequestParams params) method can be legally called. Although the argument that can be specified when invoking the method is restricted to SipRequestParams, multiple arguments including one specific to AP can be specified to be passed to SIP servlet because of the way to register multiple data provided for this class.

Timing to call

When RequestDispatcher#forward(ServletRequest request, ServletResponse response) is used in HTTP servlet, the process does not transit at call time. The forward process is performed when the called doXxx method returns. In contrast, the invoke method provided by this class can invoke a method on SIP servlet side at call time. Processes on the HTTP servlet side will remain blocked until a called method is returned, because the method is called synchronously on the SIP servlet side. Therefore, you need to design so that methods invoked by this class can return as soon as possible to return control to the HTTP side.

Since:
SSE 2.0
Version:
$Revision: 1.3 $ $Date: 2005/01/27 01:06:06 $
Author:
Oki Electric Industry Co.,Ltd.
See Also:
SipConstants, ServletContext#getNamedDispatcher(String name), RequestDispatcher#forward(ServletRequest request, ServletResponse response)

Field Summary
 
Fields inherited from interface com.oki.sip.SipConstants
APPSESSION_TIMEOUT_DURATION, APPSESSION_TIMEOUT_MAX, BRANCH_PREFIX, CATTR_FACTORY, CATTR_SUPPORTED, CATTR_TIMER, CATTR_TMPDIR, DEFAULT_ENCODING, DEFAULT_EXPIRES, DEFAULT_MAX_FORWARDS, DEFAULT_MAX_UDP_SIZE, DEFAULT_MTU_SIZE, DEFAULT_T1, DEFAULT_T2, DEFAULT_T4, DEFAULT_TCP_PORT, DEFAULT_TLS_PORT, DEFAULT_UDP_PORT, HEADER_CLUSTER_INFO, HEADER_PARAMETER_CLUSTER, HEADER_PROXY_POLICY, MINUTE, MTU_HEADER_SIZE, SIP_VERSION, UDP_PACKET_SIZE
 
Constructor Summary
SipRequestDispatcher(java.lang.Object source, javax.servlet.ServletContext context, java.lang.String servletName)
          Constructor.
SipRequestDispatcher(java.lang.Object source, java.lang.String contextName, java.lang.String servletName)
          Constructor.
 
Method Summary
static SipRequestDispatcher getInstance(java.lang.Object source, javax.servlet.ServletContext context, java.lang.String servletName)
          Factory method that creates SipRequestDispatcher object.
static SipRequestDispatcher getInstance(java.lang.Object source, java.lang.String contextName, java.lang.String servletName)
          Factory method that creates SipRequestDispatcher object.
 java.lang.Object invoke(java.lang.String methodName, SipRequestParams params)
          Method that invokes a method on a SIP servlet.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SipRequestDispatcher

public SipRequestDispatcher(java.lang.Object source,
                            java.lang.String contextName,
                            java.lang.String servletName)
                     throws javax.servlet.ServletException
Constructor.

Parameters:
source - Caller information. Recorded on access log.
contextName - Name of Context of HTTP servlet
servletName - SIP servlet name
Throws:
javax.servlet.ServletException - Thrown if a specified context or servlet does not exist.

SipRequestDispatcher

public SipRequestDispatcher(java.lang.Object source,
                            javax.servlet.ServletContext context,
                            java.lang.String servletName)
                     throws javax.servlet.ServletException
Constructor.

Parameters:
source - Caller information. Recorded on access log.
context - Context of HTTP or SIP servlet
servletName - SIP servlet name to be invoked. SIP servlet name indicates a name specified for the <servlet-name> tag in "sip.xml."
Throws:
java.lang.IllegalArgumentException - Exception that occurs if a caller specified for the source is null.
javax.servlet.ServletException - Exception that occurs if no SIP servlet corresponding to a servlet specified for the context exists or a SIP servlet corresponding to the servletName is not registered.
Method Detail

getInstance

public static SipRequestDispatcher getInstance(java.lang.Object source,
                                               java.lang.String contextName,
                                               java.lang.String servletName)
                                        throws javax.servlet.ServletException
Factory method that creates SipRequestDispatcher object.

Parameters:
source - Caller information. Recorded on access log.
contextName - Name of Context of HTTP servlet
servletName - SIP servlet name
Throws:
javax.servlet.ServletException - Thrown if a specified context or servlet does not exist.

getInstance

public static SipRequestDispatcher getInstance(java.lang.Object source,
                                               javax.servlet.ServletContext context,
                                               java.lang.String servletName)
                                        throws javax.servlet.ServletException
Factory method that creates SipRequestDispatcher object.

Parameters:
source - Caller information. Recorded on access log.
context - Context of SIP servlet
servletName - SIP servlet name
Throws:
javax.servlet.ServletException - Thrown if a specified context or servlet does not exist.

invoke

public java.lang.Object invoke(java.lang.String methodName,
                               SipRequestParams params)
                        throws java.lang.Exception
Method that invokes a method on a SIP servlet. An exception that the invoked method threw is normally wrapped in java.lang.reflect.InvocationTargetException, but this method unwraps the exception and throws it.

Parameters:
methodName - Method name to be invoked.
params - Parameter passed as argument upon invoking.
Throws:
java.lang.IllegalArgumentException - Thrown if source or methodName is null.
SipInvocationException - Exception that occurred upon invoking method. Contains the exception such as NoSuchMethodException other than the one that invoked method explicitly threw. Uses this exception class to store and return an exception that occurs when a method is called, even if that exception is not in the Exception class.
java.lang.Exception