org.openspml.v2.transport
Class RPCRouterServlet

java.lang.Object
  extended byjavax.servlet.GenericServlet
      extended byjavax.servlet.http.HttpServlet
          extended byorg.openspml.v2.transport.RPCRouterServlet
All Implemented Interfaces:
RPCRouter, java.io.Serializable, javax.servlet.Servlet, javax.servlet.ServletConfig

public class RPCRouterServlet
extends javax.servlet.http.HttpServlet
implements RPCRouter

Component Name: org.openspml.v2.transport.RPCRouterServlet

Author(s): Kent Spaulding

Description:

A message router; that passes on the work to a chain of RPCDispatcher objects. This is the only thing in this package that knows about Servlets - and perhaps should be moved to a util.servlet package...

To configure:

openspmlRouter RPC Router no description org.openspml.v2.transport.RPCRouterServlet dispatchers com.something.CustomDispatcher SpmlViaSoap.spmlMarshallers csv string of marshaller class names spmlMarshaller.somevarname some value

The normal for a SOAP router is often "rpcrouter". Some products use "rpcrouter2" - here we use "openspmlRouter" to avoid conflicts if a site already has another router installed; and is not meant for SPMLv2 requests.

You can name this anything you want, but the corresponding name then needs to be used when specifying the URL in the clients/requestors.

The named "dispatchers" contains a list of names of classes that implement the RPCDispatcher interface. It is represented in the web.xml file as a single string, multiple class names are delimited with a comma. You only need to set this parameter if you want to register your own custom dispatcher(s). By default, this router will add the following handler internally:

org.openspml.v2.transport.SPMLViaSoapDispatcher - for SOAP requests carrying SPML

SPMLViaSoapDispatcher requires that you specify an init parameter named "SpmlViaSoap.spmlMarshallers" that is the name of classes implementing the SPMLMarshaller interface.

In this example, a test handler is registered, though in practice this is always changed to a vendor-specific handler class.

A typical request formatted by the Apache SOAP client looks like:

someString

Author:
kent.spaulding@sun.com

Date: Jan 20, 2006

See Also:
Serialized Form

Constructor Summary
RPCRouterServlet()
           
 
Method Summary
 void closed(RPCRouterMonitor m)
          RPCRouter interface.
 void doGet(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res)
          Called by the servlet container in response to a GET.
 void doPost(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res)
          Called by the servlet container in response to a POST.
 java.lang.String getPostDataAsString(javax.servlet.http.HttpServletRequest req)
          Get the post data as a String.
 void init(javax.servlet.ServletConfig config)
           
static java.lang.Object instantiate(java.lang.String classname)
          Create an instance of a class given a class name.
 void setCharacterEncoding(javax.servlet.http.HttpServletRequest req)
          If we're in a Servlet 2.3 environment, have to set some things to get UTF-8 support.
 void setMonitor(RPCRouterMonitor sm)
          Allow the monitor to be set dynamically.
 
Methods inherited from class javax.servlet.http.HttpServlet
doDelete, doHead, doOptions, doPut, doTrace, getLastModified, service, service
 
Methods inherited from class javax.servlet.GenericServlet
destroy, getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletInfo, getServletName, init, log, log
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RPCRouterServlet

public RPCRouterServlet()
Method Detail

init

public void init(javax.servlet.ServletConfig config)
          throws javax.servlet.ServletException
Specified by:
init in interface javax.servlet.Servlet
Throws:
javax.servlet.ServletException

instantiate

public static java.lang.Object instantiate(java.lang.String classname)
Create an instance of a class given a class name. Public so it can be used by RPCDispatcher implementations.


setMonitor

public void setMonitor(RPCRouterMonitor sm)
Allow the monitor to be set dynamically.

Specified by:
setMonitor in interface RPCRouter
Parameters:
sm -

closed

public void closed(RPCRouterMonitor m)
RPCRouter interface.

Specified by:
closed in interface RPCRouter

doGet

public void doGet(javax.servlet.http.HttpServletRequest req,
                  javax.servlet.http.HttpServletResponse res)
           throws javax.servlet.ServletException,
                  java.io.IOException
Called by the servlet container in response to a GET. We're not expecting these here.

Throws:
javax.servlet.ServletException
java.io.IOException

getPostDataAsString

public java.lang.String getPostDataAsString(javax.servlet.http.HttpServletRequest req)
                                     throws java.io.IOException
Get the post data as a String.

Throws:
java.io.IOException

doPost

public void doPost(javax.servlet.http.HttpServletRequest req,
                   javax.servlet.http.HttpServletResponse res)
            throws javax.servlet.ServletException,
                   java.io.IOException
Called by the servlet container in response to a POST. We get the post data as a String, and pass it along to a Call object for further processing.

Throws:
javax.servlet.ServletException
java.io.IOException

setCharacterEncoding

public void setCharacterEncoding(javax.servlet.http.HttpServletRequest req)
If we're in a Servlet 2.3 environment, have to set some things to get UTF-8 support. But the methods aren't supported in the older Servlet version that this is compiled with by default.



Copyright © Sun Microsystems, Inc. All Rights Reserved.