org.apache.activemq.web
Class MessageServletSupport

java.lang.Object
  extended by javax.servlet.GenericServlet
      extended by javax.servlet.http.HttpServlet
          extended by org.apache.activemq.web.MessageServletSupport
All Implemented Interfaces:
Serializable, Servlet, ServletConfig
Direct Known Subclasses:
MessageListenerServlet, 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. This servlet can be configured with the following init parameters

topic
Set to 'true' if the servlet should default to using topics rather than channels
destination
The default destination to use if one is not specifiied

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  Destination asDestination(Object value)
           
protected  int asInt(String name)
           
protected  Integer asInteger(Object value)
           
protected  Long asLong(Object value)
           
protected  long asLong(String name)
           
protected  String asString(Object value)
           
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  String getSelector(HttpServletRequest request)
           
protected  int getSendPriority(HttpServletRequest request)
           
protected  long getSendTimeToLive(HttpServletRequest request)
           
 void init(ServletConfig servletConfig)
           
protected  boolean isSendPersistent(HttpServletRequest request)
           
protected  boolean isSync(HttpServletRequest request)
           
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
Specified by:
init in interface Servlet
Overrides:
init in class GenericServlet
Throws:
ServletException

asBoolean

public static boolean asBoolean(String param)

asBoolean

public static boolean asBoolean(String param,
                                boolean defaultValue)

appendParametersToMessage

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

getSendTimeToLive

protected long getSendTimeToLive(HttpServletRequest request)

getSendPriority

protected int getSendPriority(HttpServletRequest request)

isSendPersistent

protected boolean isSendPersistent(HttpServletRequest request)

isSync

protected boolean isSync(HttpServletRequest request)

asDestination

protected Destination asDestination(Object value)

asInteger

protected Integer asInteger(Object value)

asLong

protected Long asLong(Object value)

asLong

protected long asLong(String name)

asInt

protected int asInt(String name)

asString

protected String asString(Object value)

getDestination

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

getDestinationFromURI

protected Destination getDestinationFromURI(WebClient client,
                                            HttpServletRequest request)
                                     throws 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:
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

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

getSelector

protected String getSelector(HttpServletRequest request)
                      throws IOException
Throws:
IOException


Copyright © 2005–2013 The Apache Software Foundation. All rights reserved.