From c2aad2a0748930e340c08c74cf5f6ee55e75d7bf Mon Sep 17 00:00:00 2001 From: "Adrian T. Co" Date: Thu, 20 Apr 2006 22:37:03 +0000 Subject: [PATCH] - Read the first string of the request parameter if the value is a String[] - Appended the message properties in the MessageListenerServlet. git-svn-id: https://svn.apache.org/repos/asf/incubator/activemq/trunk@395717 13f79535-47bb-0310-9956-ffa450edef68 --- .../activemq/web/MessageListenerServlet.java | 5 +++- .../activemq/web/MessageServletSupport.java | 26 +++++++++++++++++-- 2 files changed, 28 insertions(+), 3 deletions(-) diff --git a/activemq-web/src/main/java/org/apache/activemq/web/MessageListenerServlet.java b/activemq-web/src/main/java/org/apache/activemq/web/MessageListenerServlet.java index a193b80de7..2abd848702 100644 --- a/activemq-web/src/main/java/org/apache/activemq/web/MessageListenerServlet.java +++ b/activemq-web/src/main/java/org/apache/activemq/web/MessageListenerServlet.java @@ -162,7 +162,8 @@ public class MessageListenerServlet extends MessageServletSupport { else if ("send".equals(type)) { TextMessage message = client.getSession().createTextMessage(messages[i]); - // TODO sent message parameters + appendParametersToMessage(request, message); + client.send(destination, message); message_ids+=message.getJMSMessageID()+"\n"; if (log.isDebugEnabled()) { @@ -201,6 +202,8 @@ public class MessageListenerServlet extends MessageServletSupport { Destination destination=getDestination(client, request); String body = getPostedMessageBody(request); TextMessage message = client.getSession().createTextMessage(body ); + appendParametersToMessage(request, message); + client.send(destination, message); if (log.isDebugEnabled()) { log.debug("Sent to destination: " + destination + " body: " + body); diff --git a/activemq-web/src/main/java/org/apache/activemq/web/MessageServletSupport.java b/activemq-web/src/main/java/org/apache/activemq/web/MessageServletSupport.java index e06dca2ec1..6fd650e87c 100644 --- a/activemq-web/src/main/java/org/apache/activemq/web/MessageServletSupport.java +++ b/activemq-web/src/main/java/org/apache/activemq/web/MessageServletSupport.java @@ -116,7 +116,7 @@ public abstract class MessageServletSupport extends HttpServlet { protected void appendParametersToMessage(HttpServletRequest request, TextMessage message) throws JMSException { Map parameters = new HashMap(request.getParameterMap()); - String correlationID = (String) parameters.remove("JMSCorrelationID"); + String correlationID = asString(parameters.remove("JMSCorrelationID")); if (correlationID != null) { message.setJMSCorrelationID(correlationID); } @@ -132,7 +132,7 @@ public abstract class MessageServletSupport extends HttpServlet { if (replyTo != null) { message.setJMSReplyTo(replyTo); } - String type = (String) parameters.remove("JMSType"); + String type = (String) asString(parameters.remove("JMSType")); if (correlationID != null) { message.setJMSType(type); } @@ -170,6 +170,10 @@ public abstract class MessageServletSupport extends HttpServlet { String text = (String) value; return ActiveMQDestination.createDestination(text, ActiveMQDestination.QUEUE_TYPE); } + if (value instanceof String[]) { + String text = ((String[]) value)[0]; + return ActiveMQDestination.createDestination(text, ActiveMQDestination.QUEUE_TYPE); + } return null; } @@ -180,6 +184,9 @@ public abstract class MessageServletSupport extends HttpServlet { if (value instanceof String) { return Integer.valueOf((String) value); } + if (value instanceof String[]) { + return Integer.valueOf(((String[]) value)[0]); + } return null; } @@ -190,6 +197,21 @@ public abstract class MessageServletSupport extends HttpServlet { if (value instanceof String) { return Long.valueOf((String) value); } + if (value instanceof String[]) { + return Long.valueOf(((String[]) value)[0]); + } + return null; + } + + protected String asString(Object value) { + if (value instanceof String[]) { + return ((String[])value)[0]; + } + + if (value != null) { + return value.toString(); + } + return null; }