org.activemq.web
Class MessageServletSupport

java.lang.Object
  extended byjavax.servlet.GenericServlet
      extended byjavax.servlet.http.HttpServlet
          extended byorg.activemq.web.MessageServletSupport
All Implemented Interfaces:
Serializable, Servlet, ServletConfig
Direct Known Subclasses:
MessageServlet, PortfolioPublishServlet

public abstract class MessageServletSupport
extends HttpServlet

A useful base class for any JMS related servlet; there are various ways to map JMS operations to web requests so we put most of the common behaviour in a reusable base class.

Version:
$Revision: 1.1.1.1 $
See Also:
Serialized Form

Constructor Summary
MessageServletSupport()
           
 
Method Summary
protected  void appendParametersToMessage(HttpServletRequest request, TextMessage message)
           
static boolean asBoolean(String param)
           
static boolean asBoolean(String param, boolean defaultValue)
           
protected  long asLong(String name)
           
protected  WebClient createWebClient(HttpServletRequest request)
           
protected  Destination getDestination(WebClient client, HttpServletRequest request)
           
protected  Destination getDestination(WebClient client, HttpServletRequest request, String destinationName)
           
protected  Destination getDestinationFromURI(WebClient client, HttpServletRequest request)
           
protected  String getPostedMessageBody(HttpServletRequest request)
           
protected  WebClient getWebClient(HttpServletRequest request)
          Helper method to get the client for the current session
 void init(ServletConfig servletConfig)
           
protected  boolean isTopic(HttpServletRequest request)
           
 
Methods inherited from class javax.servlet.http.HttpServlet
doDelete, doGet, doHead, doOptions, doPost, 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

MessageServletSupport

public MessageServletSupport()
Method Detail

init

public void init(ServletConfig servletConfig)
          throws ServletException
Throws:
ServletException

createWebClient

protected WebClient createWebClient(HttpServletRequest request)

asBoolean

public static boolean asBoolean(String param)

asBoolean

public static boolean asBoolean(String param,
                                boolean defaultValue)

getWebClient

protected WebClient getWebClient(HttpServletRequest request)
Helper method to get the client for the current session

Parameters:
request - is the current HTTP request
Returns:
the current client or a newly creates

appendParametersToMessage

protected void appendParametersToMessage(HttpServletRequest request,
                                         TextMessage message)
                                  throws JMSException
Throws:
JMSException

getDestination

protected Destination getDestination(WebClient client,
                                     HttpServletRequest request)
                              throws JMSException,
                                     NoDestinationSuppliedException
Returns:
the destination to use for the current request
Throws:
JMSException
NoDestinationSuppliedException

getDestinationFromURI

protected Destination getDestinationFromURI(WebClient client,
                                            HttpServletRequest request)
                                     throws NoDestinationSuppliedException,
                                            JMSException
Returns:
the destination to use for the current request using the relative URI from where this servlet was invoked as the destination name
Throws:
NoDestinationSuppliedException
JMSException

getDestination

protected Destination getDestination(WebClient client,
                                     HttpServletRequest request,
                                     String destinationName)
                              throws JMSException
Returns:
the Destination object for the given destination name
Throws:
JMSException

isTopic

protected boolean isTopic(HttpServletRequest request)
Returns:
true if the current request is for a topic destination, else false if its for a queue

asLong

protected long asLong(String name)

getPostedMessageBody

protected String getPostedMessageBody(HttpServletRequest request)
                               throws IOException
Returns:
the text that was posted to the servlet which is used as the body of the message to be sent
Throws:
IOException


Copyright © 2004-2007 Protique, Ltd.. All Rights Reserved.