Novell exteNd Web Services SDK API

com.sssw.jbroker.web.servlet
Class JMSRouter

java.lang.Object
  extended byjavax.servlet.GenericServlet
      extended byjavax.servlet.http.HttpServlet
          extended bycom.sssw.jbroker.web.servlet.JMSRouter
All Implemented Interfaces:
Serializable, Servlet, ServletConfig

public class JMSRouter
extends HttpServlet

A servlet that routes incoming SOAP messages to a JMS destination wrapped in a TextMessage. The servlet is configured using several properties that describe how the various JMS artifacts such as connection factories and destination should be located. For example:

 <?xml version="1.0" encoding="UTF-8"?>

 <!DOCTYPE web-app
   PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN"
   "http://java.sun.com/j2ee/dtds/web-app_2_2.dtd">
 
 <web-app>
   <context-param>
     <param-name>jms.queue.factory.jndi</param-name>
     <param-value>queue/connectionFactory</param-value>
     <description>
       The JNDI lookup name for the queue connection factory.
     </description>
   </context-param>
   <context-param>
     <param-name>jms.queue.jndi</param-name>
     <param-value>queue/queue0</param-value>
     <description>
       The JNDI lookup name for the queue.
     </description>
   </context-param>

 <servlet>
     <servlet-name>JMSRouter</servlet-name>
     <servlet-class>com.sssw.jbroker.web.servlet.JMSRouter</servlet-class>
   </servlet>

   <servlet-mapping>
     <servlet-name>JMSRouter</servlet-name>
     <url-pattern>/jms/queue0</url-pattern>
   </servlet-mapping>

 </web-app>
 
Note that all properties specified to the servlet will be used when creating the initial context used to lookup JMS object:
  Properties props = new Properties();
  ServletContext context = config.getServletContext();
  Enumeration e = context.getInitParameterNames();
  while (e.hasMoreElements()) {
      String name = (String) e.nextElement();
      props.put(name, context.getInitParameter(name));
  }
  InitialContext ctx = new InitialContext(props);
 
If the JMS_USE_REQUESTOR property is set to TRUE, the servlet will await a response message and return it from the doPost method as a SOAP message.

If a replyTo destination is specified and its type is different from the regular destination, then both a queue and a topic connection factory must be specified. If the JMS_USE_CORRELATION_ID property is specified, the ultimate message consumer must transfer the correlation id from the request message to the response message.

Since:
jBroker Web 2.1
See Also:
Stub.USERNAME, Stub.PASSWORD, Stub.JMS_TOPIC_JNDI, Stub.JMS_QUEUE_JNDI, Stub.JMS_TOPIC_REPLY_JNDI, Stub.JMS_QUEUE_REPLY_JNDI, Stub.JMS_TOPIC_FACTORY_JNDI, Stub.JMS_QUEUE_FACTORY_JNDI, Stub.JMS_REPLY_TIMEOUT, Stub.JMS_REPLY_SELECTOR, Stub.JMS_USE_REQUESTOR, Stub.JMS_USE_CORRELATION_ID, Serialized Form

Constructor Summary
JMSRouter()
           
 
Method Summary
 void doGet(HttpServletRequest request, HttpServletResponse response)
          Process an HTTP GET command.
 void doPost(HttpServletRequest request, HttpServletResponse response)
          Process an HTTP POST command.
 void init(ServletConfig config)
          Initialization of the JMS router servlet.
 
Methods inherited from class javax.servlet.http.HttpServlet
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
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JMSRouter

public JMSRouter()
Method Detail

init

public void init(ServletConfig config)
          throws ServletException
Initialization of the JMS router servlet. A JMS connection will be established according to the servlet configuration parameters.

Parameters:
config - the ServletConfig object
Throws:
ServletException - if configuration is insufficient or erronous

doGet

public void doGet(HttpServletRequest request,
                  HttpServletResponse response)
           throws IOException,
                  ServletException
Process an HTTP GET command. The JMS router servlet will return a web page with information about its current status. The status includes statistics, error log and configuration information.

Parameters:
request - the HttpServletRequest object
response - the HttpServletResponse object
Throws:
IOException - if an I/O exception occurred
ServletException - if a general servlet exception occurred

doPost

public void doPost(HttpServletRequest request,
                   HttpServletResponse response)
            throws IOException,
                   ServletException
Process an HTTP POST command. The JMS router servlet expects the servlet request to contain a SOAP message, which will be forwarded to the destination specified in the servlet configuration. Optionally, the servlet will read a message response from a replyTo destination. If a reply is available, the appropriate SOAP message will be written to the servlet response. If a void reponse is available, a "void" SOAP message will be written to the servlet response. If an error occurs, a SOAP fault will be written to the servlet response.

Parameters:
request - the HttpServletRequest object
response - the HttpServletResponse object
Throws:
IOException - if an I/O exception occurred
ServletException - if a general servlet exception occurred

Novell exteNd Web Services SDK API

exteNd is a registered trademark of Novell, Inc.
Copyright 1998-2003 Novell, Inc. All Rights Reserved.