Class MessageServletSupport

java.lang.Object
jakarta.servlet.GenericServlet
jakarta.servlet.http.HttpServlet
org.apache.activemq.web.MessageServletSupport
All Implemented Interfaces:
jakarta.servlet.Servlet, jakarta.servlet.ServletConfig, Serializable
Direct Known Subclasses:
MessageListenerServlet, MessageServlet, PortfolioPublishServlet

public abstract class MessageServletSupport extends jakarta.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 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:
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    protected void
    appendParametersToMessage(jakarta.servlet.http.HttpServletRequest request, jakarta.jms.TextMessage message)
     
    static boolean
     
    static boolean
    asBoolean(String param, boolean defaultValue)
     
    protected jakarta.jms.Destination
     
    protected int
    asInt(String name)
     
    protected Integer
     
    protected Long
    asLong(Object value)
     
    protected long
    asLong(String name)
     
    protected String
     
    protected jakarta.jms.Destination
    getDestination(WebClient client, jakarta.servlet.http.HttpServletRequest request)
     
    protected jakarta.jms.Destination
    getDestination(WebClient client, jakarta.servlet.http.HttpServletRequest request, String destinationName)
     
    protected jakarta.jms.Destination
    getDestinationFromURI(WebClient client, jakarta.servlet.http.HttpServletRequest request)
     
    protected String
    getPostedMessageBody(jakarta.servlet.http.HttpServletRequest request)
     
    protected String
    getSelector(jakarta.servlet.http.HttpServletRequest request)
     
    protected int
    getSendPriority(jakarta.servlet.http.HttpServletRequest request)
     
    protected long
    getSendTimeToLive(jakarta.servlet.http.HttpServletRequest request)
     
    void
    init(jakarta.servlet.ServletConfig servletConfig)
     
    protected boolean
    isSendPersistent(jakarta.servlet.http.HttpServletRequest request)
     
    protected boolean
    isSync(jakarta.servlet.http.HttpServletRequest request)
     
    protected boolean
    isTopic(jakarta.servlet.http.HttpServletRequest request)
     

    Methods inherited from class jakarta.servlet.http.HttpServlet

    doDelete, doGet, doHead, doOptions, doPost, doPut, doTrace, getLastModified, service, service

    Methods inherited from class jakarta.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 Details

    • MessageServletSupport

      public MessageServletSupport()
  • Method Details

    • init

      public void init(jakarta.servlet.ServletConfig servletConfig) throws jakarta.servlet.ServletException
      Specified by:
      init in interface jakarta.servlet.Servlet
      Overrides:
      init in class jakarta.servlet.GenericServlet
      Throws:
      jakarta.servlet.ServletException
    • asBoolean

      public static boolean asBoolean(String param)
    • asBoolean

      public static boolean asBoolean(String param, boolean defaultValue)
    • appendParametersToMessage

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

      protected long getSendTimeToLive(jakarta.servlet.http.HttpServletRequest request)
    • getSendPriority

      protected int getSendPriority(jakarta.servlet.http.HttpServletRequest request)
    • isSendPersistent

      protected boolean isSendPersistent(jakarta.servlet.http.HttpServletRequest request)
    • isSync

      protected boolean isSync(jakarta.servlet.http.HttpServletRequest request)
    • asDestination

      protected jakarta.jms.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 jakarta.jms.Destination getDestination(WebClient client, jakarta.servlet.http.HttpServletRequest request) throws jakarta.jms.JMSException
      Returns:
      the destination to use for the current request
      Throws:
      jakarta.jms.JMSException
    • getDestinationFromURI

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

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

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

      protected String getPostedMessageBody(jakarta.servlet.http.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(jakarta.servlet.http.HttpServletRequest request) throws IOException
      Throws:
      IOException