activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gno...@apache.org
Subject svn commit: r379429 - in /incubator/activemq/trunk/activemq-web/src/main/java/org/apache/activemq/web: MessageListenerServlet.java MessageServlet.java WebClient.java
Date Tue, 21 Feb 2006 11:35:05 GMT
Author: gnodet
Date: Tue Feb 21 03:34:58 2006
New Revision: 379429

URL: http://svn.apache.org/viewcvs?rev=379429&view=rev
Log:
Fix ClassCastException, add debug log statements and allow standalone xml to be used

Modified:
    incubator/activemq/trunk/activemq-web/src/main/java/org/apache/activemq/web/MessageListenerServlet.java
    incubator/activemq/trunk/activemq-web/src/main/java/org/apache/activemq/web/MessageServlet.java
    incubator/activemq/trunk/activemq-web/src/main/java/org/apache/activemq/web/WebClient.java

Modified: incubator/activemq/trunk/activemq-web/src/main/java/org/apache/activemq/web/MessageListenerServlet.java
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/activemq-web/src/main/java/org/apache/activemq/web/MessageListenerServlet.java?rev=379429&r1=379428&r2=379429&view=diff
==============================================================================
--- incubator/activemq/trunk/activemq-web/src/main/java/org/apache/activemq/web/MessageListenerServlet.java
(original)
+++ incubator/activemq/trunk/activemq-web/src/main/java/org/apache/activemq/web/MessageListenerServlet.java
Tue Feb 21 03:34:58 2006
@@ -100,15 +100,19 @@
         
         synchronized (client) {
             
-            // System.err.println("POST client="+client+" session="+request.getSession().getId()+"
info="+request.getPathInfo()+" contentType="+request.getContentType());
+            if (log.isDebugEnabled()) {
+                log.debug("POST client="+client+" session="+request.getSession().getId()+"
info="+request.getPathInfo()+" contentType="+request.getContentType());
             // dump(request.getParameterMap());
+            }
             String[] destinations = request.getParameterValues("destination");
             String[] messages = request.getParameterValues("message");
             String[] types = request.getParameterValues("type");
             
             if (destinations.length!=messages.length || messages.length!=types.length)
             {
-                // System.err.println("ERROR destination="+destinations.length+" message="+messages.length+"
type="+types.length);
+                if (log.isDebugEnabled()) {
+                    log.debug("ERROR destination="+destinations.length+" message="+messages.length+"
type="+types.length);
+                }
                 response.sendError(HttpServletResponse.SC_BAD_REQUEST,"missmatched destination,
message or type");
                 return;
             }
@@ -116,11 +120,14 @@
             for (int i=0;i<types.length;i++)
             {
                 try {
-                    // System.err.println(i+" destination="+destinations[i]+" message="+messages[i]+"
type="+types[i]);
-                    
                     String type=types[i];
                     Destination destination=getDestination(client,request,destinations[i]);
                     
+                    if (log.isDebugEnabled()) {
+                        log.debug(i+" destination="+destinations[i]+" message="+messages[i]+"
type="+types[i]);
+                        log.debug(destination+" is a "+destination.getClass().getName());
+                    }
+                    
                     if ("listen".equals(type))
                     {
                         Listener listener = getListener(request);
@@ -129,7 +136,9 @@
                         
                         consumer.setAvailableListener(listener);
                         consumerIdMap.put(consumer, messages[i]);
-                        // System.err.println("Subscribed: "+consumer+" to "+destination+"
id="+messages[i]);
+                        if (log.isDebugEnabled()) {
+                            log.debug("Subscribed: "+consumer+" to "+destination+" id="+messages[i]);
+                        }
                     }
                     else if ("unlisten".equals(type))
                     {
@@ -139,15 +148,18 @@
                         // TODO should we destroy consumer on unsubscribe?
                         consumer.setAvailableListener(null);
                         consumerIdMap.remove(consumer);
-                        // System.err.println("Unsubscribed: "+consumer);
-                        
+                        if (log.isDebugEnabled()) {
+                            log.debug("Unsubscribed: "+consumer);
+                        }
                     }
                     else if ("send".equals(type))
                     {
                         TextMessage message = client.getSession().createTextMessage(messages[i]);
                         // TODO sent message parameters
                         client.send(destination, message);
-                        // System.err.println("Sent "+messages[i]+" to "+destination);
+                        if (log.isDebugEnabled()) {
+                            log.debug("Sent "+messages[i]+" to "+destination);
+                        }
                         // TODO return message ID.
                     }
                     else
@@ -187,7 +199,9 @@
 
         try {
             WebClient client = getWebClient(request);
-            // System.err.println("GET client="+client+" session="+request.getSession().getId()+"
uri="+request.getRequestURI()+" query="+request.getQueryString());
+            if (log.isDebugEnabled()) {
+                log.debug("GET client="+client+" session="+request.getSession().getId()+"
uri="+request.getRequestURI()+" query="+request.getQueryString());
+            }
 
             doMessages(client, request, response);
         }
@@ -213,7 +227,9 @@
         // This is a poll for any messages
 
         long timeout = getReadTimeout(request);
-        // System.err.println("doMessage timeout="+timeout);
+        if (log.isDebugEnabled()) {
+            log.debug("doMessage timeout="+timeout);
+        }
         
         Continuation continuation = null;
         Message message = null;
@@ -233,7 +249,9 @@
 
                 // Look for any available messages
                 message = consumer.receiveNoWait();
-                // System.err.println("received "+message+" from "+consumer);
+                if (log.isDebugEnabled()) {
+                    log.debug("received "+message+" from "+consumer);
+                }
             }
 
             // Get an existing Continuation or create a new one if there are no
@@ -307,7 +325,11 @@
     protected void writeMessageResponse(PrintWriter writer, Message message) throws JMSException,
IOException {
         if (message instanceof TextMessage) {
             TextMessage textMsg = (TextMessage) message;
-            writer.print(textMsg.getText());
+            String txt = textMsg.getText();
+            if (txt.startsWith("<?")) {
+                txt = txt.substring(txt.indexOf("?>") + 2);
+            }
+            writer.print(txt);
         } else if (message instanceof ObjectMessage) {
             ObjectMessage objectMsg = (ObjectMessage) message;
             Object object = objectMsg.getObject();
@@ -379,8 +401,9 @@
 
         public void onMessageAvailable(MessageConsumer consumer) {
             synchronized (client) {
-                // System.err.println("message for "+consumer+"
-                // continuation="+continuation);
+                if (log.isDebugEnabled()) {
+                    log.debug("message for "+consumer+"continuation="+continuation);
+                }
                 if (continuation != null)
                     continuation.resume();
                 continuation = null;

Modified: incubator/activemq/trunk/activemq-web/src/main/java/org/apache/activemq/web/MessageServlet.java
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/activemq-web/src/main/java/org/apache/activemq/web/MessageServlet.java?rev=379429&r1=379428&r2=379429&view=diff
==============================================================================
--- incubator/activemq/trunk/activemq-web/src/main/java/org/apache/activemq/web/MessageServlet.java
(original)
+++ incubator/activemq/trunk/activemq-web/src/main/java/org/apache/activemq/web/MessageServlet.java
Tue Feb 21 03:34:58 2006
@@ -341,7 +341,11 @@
     protected void writeMessageResponse(PrintWriter writer, Message message) throws JMSException,
IOException {
         if (message instanceof TextMessage) {
             TextMessage textMsg = (TextMessage) message;
-            writer.print(textMsg.getText());
+            String txt = textMsg.getText();
+            if (txt.startsWith("<?")) {
+                txt = txt.substring(txt.indexOf("?>") + 2);
+            }
+            writer.print(txt);
         }
         else if (message instanceof ObjectMessage) {
             ObjectMessage objectMsg = (ObjectMessage) message;

Modified: incubator/activemq/trunk/activemq-web/src/main/java/org/apache/activemq/web/WebClient.java
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/activemq-web/src/main/java/org/apache/activemq/web/WebClient.java?rev=379429&r1=379428&r2=379429&view=diff
==============================================================================
--- incubator/activemq/trunk/activemq-web/src/main/java/org/apache/activemq/web/WebClient.java
(original)
+++ incubator/activemq/trunk/activemq-web/src/main/java/org/apache/activemq/web/WebClient.java
Tue Feb 21 03:34:58 2006
@@ -238,7 +238,10 @@
         
         // TODO check this double synchronization on queue but not on topics
         synchronized (queueConsumers) {
-            list.addAll(queueConsumers.values());
+            for (Iterator it = queueConsumers.values().iterator(); it.hasNext();) {
+                SessionConsumerPair pair = (SessionConsumerPair) it.next();
+                list.add(pair.consumer);
+            }
         }
         list.addAll(topicConsumers.values());
         return list;



Mime
View raw message