Package org.apache.activemq.web
Class MessageServletSupport
- java.lang.Object
-
- javax.servlet.GenericServlet
-
- javax.servlet.http.HttpServlet
-
- org.apache.activemq.web.MessageServletSupport
-
- All Implemented Interfaces:
Serializable,javax.servlet.Servlet,javax.servlet.ServletConfig
- Direct Known Subclasses:
MessageListenerServlet,MessageServlet,PortfolioPublishServlet
public abstract class MessageServletSupport extends javax.servlet.http.HttpServletA 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
Constructors Constructor Description MessageServletSupport()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidappendParametersToMessage(javax.servlet.http.HttpServletRequest request, javax.jms.TextMessage message)static booleanasBoolean(String param)static booleanasBoolean(String param, boolean defaultValue)protected javax.jms.DestinationasDestination(Object value)protected intasInt(String name)protected IntegerasInteger(Object value)protected LongasLong(Object value)protected longasLong(String name)protected StringasString(Object value)protected javax.jms.DestinationgetDestination(WebClient client, javax.servlet.http.HttpServletRequest request)protected javax.jms.DestinationgetDestination(WebClient client, javax.servlet.http.HttpServletRequest request, String destinationName)protected javax.jms.DestinationgetDestinationFromURI(WebClient client, javax.servlet.http.HttpServletRequest request)protected StringgetPostedMessageBody(javax.servlet.http.HttpServletRequest request)protected StringgetSelector(javax.servlet.http.HttpServletRequest request)protected intgetSendPriority(javax.servlet.http.HttpServletRequest request)protected longgetSendTimeToLive(javax.servlet.http.HttpServletRequest request)voidinit(javax.servlet.ServletConfig servletConfig)protected booleanisSendPersistent(javax.servlet.http.HttpServletRequest request)protected booleanisSync(javax.servlet.http.HttpServletRequest request)protected booleanisTopic(javax.servlet.http.HttpServletRequest request)-
Methods inherited from class javax.servlet.http.HttpServlet
doDelete, doGet, doHead, doOptions, doPost, doPut, doTrace, getLastModified, service, service
-
-
-
-
Method Detail
-
init
public void init(javax.servlet.ServletConfig servletConfig) throws javax.servlet.ServletException- Specified by:
initin interfacejavax.servlet.Servlet- Overrides:
initin classjavax.servlet.GenericServlet- Throws:
javax.servlet.ServletException
-
asBoolean
public static boolean asBoolean(String param)
-
asBoolean
public static boolean asBoolean(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(Object value)
-
asLong
protected long asLong(String name)
-
asInt
protected int asInt(String name)
-
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, 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 String getPostedMessageBody(javax.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(javax.servlet.http.HttpServletRequest request) throws IOException
- Throws:
IOException
-
-