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:
java.io.Serializable, javax.servlet.Servlet, javax.servlet.ServletConfig
Direct Known Subclasses:
MessageListenerServlet, MessageServlet, PortfolioPublishServlet

public abstract class MessageServletSupport
extends javax.servlet.http.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 paramters

topic
Set to 'true' if the servle 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(javax.servlet.http.HttpServletRequest request, javax.jms.TextMessage message)
           
static boolean asBoolean(java.lang.String param)
           
static boolean asBoolean(java.lang.String param, boolean defaultValue)
           
protected  javax.jms.Destination asDestination(java.lang.Object value)
           
protected  int asInt(java.lang.String name)
           
protected  java.lang.Integer asInteger(java.lang.Object value)
           
protected  java.lang.Long asLong(java.lang.Object value)
           
protected  long asLong(java.lang.String name)
           
protected  java.lang.String asString(java.lang.Object value)
           
protected  javax.jms.Destination getDestination(WebClient client, javax.servlet.http.HttpServletRequest request)
           
protected  javax.jms.Destination getDestination(WebClient client, javax.servlet.http.HttpServletRequest request, java.lang.String destinationName)
           
protected  javax.jms.Destination getDestinationFromURI(WebClient client, javax.servlet.http.HttpServletRequest request)
           
protected  java.lang.String getPostedMessageBody(javax.servlet.http.HttpServletRequest request)
           
protected  java.lang.String getSelector(javax.servlet.http.HttpServletRequest request)
           
protected  int getSendPriority(javax.servlet.http.HttpServletRequest request)
           
protected  long getSendTimeToLive(javax.servlet.http.HttpServletRequest request)
           
 void init(javax.servlet.ServletConfig servletConfig)
           
protected  boolean isSendPersistent(javax.servlet.http.HttpServletRequest request)
           
protected  boolean isSync(javax.servlet.http.HttpServletRequest request)
           
protected  boolean isTopic(javax.servlet.http.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(javax.servlet.ServletConfig servletConfig)
          throws javax.servlet.ServletException
Specified by:
init in interface javax.servlet.Servlet
Overrides:
init in class javax.servlet.GenericServlet
Throws:
javax.servlet.ServletException

asBoolean

public static boolean asBoolean(java.lang.String param)

asBoolean

public static boolean asBoolean(java.lang.String param,
                                boolean defaultValue)

appendParametersToMessage

protected void appendParametersToMessage(javax.servlet.http.HttpServletRequest request,
                                         javax.jms.TextMessage message)
                                  throws javax.jms.JMSException
Throws:
javax.jms.JMSException

getSendTimeToLive

protected long getSendTimeToLive(javax.servlet.http.HttpServletRequest request)

getSendPriority

protected int getSendPriority(javax.servlet.http.HttpServletRequest request)

isSendPersistent

protected boolean isSendPersistent(javax.servlet.http.HttpServletRequest request)

isSync

protected boolean isSync(javax.servlet.http.HttpServletRequest request)

asDestination

protected javax.jms.Destination asDestination(java.lang.Object value)

asInteger

protected java.lang.Integer asInteger(java.lang.Object value)

asLong

protected java.lang.Long asLong(java.lang.Object value)

asLong

protected long asLong(java.lang.String name)

asInt

protected int asInt(java.lang.String name)

asString

protected java.lang.String asString(java.lang.Object value)

getDestination

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

getDestinationFromURI

protected javax.jms.Destination getDestinationFromURI(WebClient client,
                                                      javax.servlet.http.HttpServletRequest request)
                                               throws javax.jms.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:
javax.jms.JMSException

getDestination

protected javax.jms.Destination getDestination(WebClient client,
                                               javax.servlet.http.HttpServletRequest request,
                                               java.lang.String destinationName)
                                        throws javax.jms.JMSException
Returns:
the Destination object for the given destination name
Throws:
javax.jms.JMSException

isTopic

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

getPostedMessageBody

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

getSelector

protected java.lang.String getSelector(javax.servlet.http.HttpServletRequest request)
                                throws java.io.IOException
Throws:
java.io.IOException


Copyright © 2005-2011 FuseSource, Corp.. All Rights Reserved.