[jboss-cvs] JBoss Messaging SVN: r4699 - in branches/Branch_JBMESSAGING-1303: src/main/org/jboss/messaging/jms/client and 5 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Mon Jul 21 11:41:43 EDT 2008


Author: jmesnil
Date: 2008-07-21 11:41:43 -0400 (Mon, 21 Jul 2008)
New Revision: 4699

Added:
   branches/Branch_JBMESSAGING-1303/src/main/org/jboss/messaging/core/management/PropertiesInfo.java
   branches/Branch_JBMESSAGING-1303/src/main/org/jboss/messaging/jms/server/management/JMSMessageInfo.java
Modified:
   branches/Branch_JBMESSAGING-1303/src/main/org/jboss/messaging/core/management/MessageInfo.java
   branches/Branch_JBMESSAGING-1303/src/main/org/jboss/messaging/jms/client/JBossMessage.java
   branches/Branch_JBMESSAGING-1303/src/main/org/jboss/messaging/jms/server/JMSServerManager.java
   branches/Branch_JBMESSAGING-1303/src/main/org/jboss/messaging/jms/server/impl/JMSServerManagerImpl.java
   branches/Branch_JBMESSAGING-1303/src/main/org/jboss/messaging/jms/server/management/JMSQueueControlMBean.java
   branches/Branch_JBMESSAGING-1303/src/main/org/jboss/messaging/jms/server/management/impl/JMSQueueControl.java
   branches/Branch_JBMESSAGING-1303/tests/jms-tests/src/org/jboss/test/messaging/tools/container/LocalTestServer.java
   branches/Branch_JBMESSAGING-1303/tests/jms-tests/src/org/jboss/test/messaging/tools/container/RMITestServer.java
Log:
JBMESSAGING-1303: Revisit management interfaces
* added listAllMessages() operation to JMSQueueControlMBean

Modified: branches/Branch_JBMESSAGING-1303/src/main/org/jboss/messaging/core/management/MessageInfo.java
===================================================================
--- branches/Branch_JBMESSAGING-1303/src/main/org/jboss/messaging/core/management/MessageInfo.java	2008-07-21 15:29:14 UTC (rev 4698)
+++ branches/Branch_JBMESSAGING-1303/src/main/org/jboss/messaging/core/management/MessageInfo.java	2008-07-21 15:41:43 UTC (rev 4699)
@@ -28,9 +28,7 @@
 import static javax.management.openmbean.SimpleType.LONG;
 import static javax.management.openmbean.SimpleType.STRING;
 
-import java.util.HashMap;
 import java.util.Map;
-import java.util.Map.Entry;
 
 import javax.management.openmbean.CompositeData;
 import javax.management.openmbean.CompositeDataSupport;
@@ -200,72 +198,4 @@
          return null;
       }
    }
-
-   // Package protected ---------------------------------------------
-
-   // Protected -----------------------------------------------------
-
-   // Private -------------------------------------------------------
-
-   // Inner classes -------------------------------------------------
-
-   private static class PropertiesInfo
-   {
-      public static final TabularType TABULAR_TYPE;
-      private static CompositeType ROW_TYPE;
-
-      private final Map<String, String> properties = new HashMap<String, String>();
-
-      static
-      {
-         try
-         {
-            ROW_TYPE = new CompositeType("Property", "Property", new String[] {
-                  "key", "value" }, new String[] { "Key of the property",
-                  "Value of the property" }, new OpenType[] { STRING, STRING });
-            TABULAR_TYPE = new TabularType("PropertyInfo",
-                  "Properties of the message", ROW_TYPE, new String[] { "key" });
-         } catch (OpenDataException e)
-         {
-            e.printStackTrace();
-            throw new IllegalStateException(e);
-         }
-      }
-
-      PropertiesInfo()
-      {
-      }
-
-      /**
-       * @return
-       */
-      public Map<String, String> entries()
-      {
-         return properties;
-      }
-
-      void put(String key, String value)
-      {
-         properties.put(key, value);
-      }
-
-      TabularData toTabularData()
-      {
-         try
-         {
-            TabularDataSupport data = new TabularDataSupport(TABULAR_TYPE);
-            for (Entry<String, String> entry : properties.entrySet())
-            {
-               data.put(new CompositeDataSupport(ROW_TYPE, new String[] {
-                     "key", "value" }, new Object[] { entry.getKey(),
-                     entry.getValue() }));
-            }
-            return data;
-         } catch (OpenDataException e)
-         {
-            e.printStackTrace();
-            return null;
-         }
-      }
-   }
 }

Added: branches/Branch_JBMESSAGING-1303/src/main/org/jboss/messaging/core/management/PropertiesInfo.java
===================================================================
--- branches/Branch_JBMESSAGING-1303/src/main/org/jboss/messaging/core/management/PropertiesInfo.java	                        (rev 0)
+++ branches/Branch_JBMESSAGING-1303/src/main/org/jboss/messaging/core/management/PropertiesInfo.java	2008-07-21 15:41:43 UTC (rev 4699)
@@ -0,0 +1,97 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */ 
+
+package org.jboss.messaging.core.management;
+
+import static javax.management.openmbean.SimpleType.STRING;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Map.Entry;
+
+import javax.management.openmbean.CompositeDataSupport;
+import javax.management.openmbean.CompositeType;
+import javax.management.openmbean.OpenDataException;
+import javax.management.openmbean.OpenType;
+import javax.management.openmbean.TabularData;
+import javax.management.openmbean.TabularDataSupport;
+import javax.management.openmbean.TabularType;
+
+class PropertiesInfo
+{
+   public static final TabularType TABULAR_TYPE;
+   private static CompositeType ROW_TYPE;
+
+   private final Map<String, String> properties = new HashMap<String, String>();
+
+   static
+   {
+      try
+      {
+         ROW_TYPE = new CompositeType("Property", "Property", new String[] {
+               "key", "value" }, new String[] { "Key of the property",
+               "Value of the property" }, new OpenType[] { STRING, STRING });
+         TABULAR_TYPE = new TabularType("PropertyInfo",
+               "Properties of the message", ROW_TYPE, new String[] { "key" });
+      } catch (OpenDataException e)
+      {
+         e.printStackTrace();
+         throw new IllegalStateException(e);
+      }
+   }
+
+   PropertiesInfo()
+   {
+   }
+
+   /**
+    * @return
+    */
+   public Map<String, String> entries()
+   {
+      return properties;
+   }
+
+   void put(String key, String value)
+   {
+      properties.put(key, value);
+   }
+
+   TabularData toTabularData()
+   {
+      try
+      {
+         TabularDataSupport data = new TabularDataSupport(TABULAR_TYPE);
+         for (Entry<String, String> entry : properties.entrySet())
+         {
+            data.put(new CompositeDataSupport(ROW_TYPE, new String[] {
+                  "key", "value" }, new Object[] { entry.getKey(),
+                  entry.getValue() }));
+         }
+         return data;
+      } catch (OpenDataException e)
+      {
+         e.printStackTrace();
+         return null;
+      }
+   }
+}
\ No newline at end of file

Modified: branches/Branch_JBMESSAGING-1303/src/main/org/jboss/messaging/jms/client/JBossMessage.java
===================================================================
--- branches/Branch_JBMESSAGING-1303/src/main/org/jboss/messaging/jms/client/JBossMessage.java	2008-07-21 15:29:14 UTC (rev 4698)
+++ branches/Branch_JBMESSAGING-1303/src/main/org/jboss/messaging/jms/client/JBossMessage.java	2008-07-21 15:41:43 UTC (rev 4699)
@@ -59,7 +59,7 @@
 {
    // Constants -----------------------------------------------------
 
-   private static final SimpleString REPLYTO_HEADER_NAME = new SimpleString("JMSReplyTo");
+   public static final SimpleString REPLYTO_HEADER_NAME = new SimpleString("JMSReplyTo");
    
    public static final SimpleString CORRELATIONID_HEADER_NAME = new SimpleString("JMSCorrelationID");
 

Modified: branches/Branch_JBMESSAGING-1303/src/main/org/jboss/messaging/jms/server/JMSServerManager.java
===================================================================
--- branches/Branch_JBMESSAGING-1303/src/main/org/jboss/messaging/jms/server/JMSServerManager.java	2008-07-21 15:29:14 UTC (rev 4698)
+++ branches/Branch_JBMESSAGING-1303/src/main/org/jboss/messaging/jms/server/JMSServerManager.java	2008-07-21 15:41:43 UTC (rev 4699)
@@ -35,11 +35,6 @@
  */
 public interface JMSServerManager extends Serializable
 {
-   public enum ListType
-   {
-      ALL, DURABLE, NON_DURABLE
-   }
-
    /**
     * Has the Server been started.
     * @return true if the server us running
@@ -239,21 +234,6 @@
 //    */
 // //  void changeMessagePriority(String queue, String messageId, int priority) throws Exception;
 //
-   /**
-    * returns how many messages a queue is currently holding
-    * @param queue the name of the queue
-    * @return the number of messages
-    * @throws Exception if a problem occurred
-    */
-   int getMessageCountForQueue(String queue) throws Exception;
-
-   /**
-    * lists all the subscriptions for a specific topic
-    * @param topic the name of the topic
-    * @return the subscriptions
-    * @throws Exception if a problem occurred
-    */
-   List<SubscriptionInfo> listSubscriptions(String topic) throws Exception;
 //
 //   /**
 //    * lists all the subscriptions for a specific topic for a specific ListType.

Modified: branches/Branch_JBMESSAGING-1303/src/main/org/jboss/messaging/jms/server/impl/JMSServerManagerImpl.java
===================================================================
--- branches/Branch_JBMESSAGING-1303/src/main/org/jboss/messaging/jms/server/impl/JMSServerManagerImpl.java	2008-07-21 15:29:14 UTC (rev 4698)
+++ branches/Branch_JBMESSAGING-1303/src/main/org/jboss/messaging/jms/server/impl/JMSServerManagerImpl.java	2008-07-21 15:41:43 UTC (rev 4699)
@@ -34,17 +34,14 @@
 
 import org.jboss.messaging.core.logging.Logger;
 import org.jboss.messaging.core.management.MessagingServerManagement;
-import org.jboss.messaging.core.server.Queue;
 import org.jboss.messaging.jms.JBossDestination;
 import org.jboss.messaging.jms.JBossQueue;
 import org.jboss.messaging.jms.JBossTopic;
 import org.jboss.messaging.jms.client.JBossConnectionFactory;
 import org.jboss.messaging.jms.server.JMSServerManager;
-import org.jboss.messaging.jms.server.SubscriptionInfo;
 import org.jboss.messaging.jms.server.management.JMSManagementRegistration;
 import org.jboss.messaging.jms.server.management.impl.JMSManagementRegistrationImpl;
 import org.jboss.messaging.util.JNDIUtil;
-import org.jboss.messaging.util.Pair;
 
 /**
  * A Deployer used to create and add to JNDI queues, topics and connection factories. Typically this would only be used
@@ -390,21 +387,7 @@
 ////              "JMSMessageID='" + messageId + "'", priority);
 ////   }
 //
-   public int getMessageCountForQueue(String queue) throws Exception
-   {
-      return getMessageCount(new JBossQueue(queue));
-   }
-
-   public List<SubscriptionInfo> listSubscriptions(String topicName) throws Exception
-   {
-      return listSubscriptions(new JBossTopic(topicName));
-   }
 //
-//   public List<SubscriptionInfo> listSubscriptions(String topic, ListType type) throws Exception
-//   {
-//      return listSubscriptions(new JBossTopic(topic), type);
-//   }
-//
 //   public int getSubscriptionsCountForTopic(String topicName) throws Exception
 //   {
 //      return getSubscriptionsCount(new JBossTopic(topicName));
@@ -627,40 +610,6 @@
 //      return 0;  //To change body of implemented methods use File | Settings | File Templates.
 //   }
 //
-   private List<SubscriptionInfo> listSubscriptions(JBossTopic topic) throws Exception
-   {
-      return listSubscriptions(topic, ListType.ALL);
-   }
-
-   private List<SubscriptionInfo> listSubscriptions(JBossTopic topic, ListType type) throws Exception
-   {
-      List<SubscriptionInfo> subs = new ArrayList<SubscriptionInfo>();
-
-      List<Queue> queues = messagingServerManagement.getQueuesForAddress(topic.getSimpleAddress());
-
-      for (Queue queue : queues)
-      {
-         if (type == ListType.ALL || (type == ListType.DURABLE && queue.isDurable()) || (type == ListType.NON_DURABLE && !queue.isDurable()))
-         {
-            String subName = null;
-            String clientID = null;
-
-            if (queue.isDurable())
-            {
-               Pair<String, String> pair = JBossTopic.decomposeQueueNameForDurableSubscription(queue.getName().toString());
-               clientID = pair.a;
-               subName = pair.b;
-            }
-
-            SubscriptionInfo info = new SubscriptionInfo(queue.getName().toString(), queue.isDurable(), subName, clientID,
-                    queue.getFilter() == null ? null : queue.getFilter().getFilterString().toString(), queue.getMessageCount(), queue.getMaxSizeBytes());
-
-            subs.add(info);
-         }
-      }
-
-      return subs;
-   }
 //
 //   private int getSubscriptionsCount(JBossTopic topic) throws Exception
 //   {

Added: branches/Branch_JBMESSAGING-1303/src/main/org/jboss/messaging/jms/server/management/JMSMessageInfo.java
===================================================================
--- branches/Branch_JBMESSAGING-1303/src/main/org/jboss/messaging/jms/server/management/JMSMessageInfo.java	                        (rev 0)
+++ branches/Branch_JBMESSAGING-1303/src/main/org/jboss/messaging/jms/server/management/JMSMessageInfo.java	2008-07-21 15:41:43 UTC (rev 4699)
@@ -0,0 +1,234 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.messaging.jms.server.management;
+
+import static javax.management.openmbean.SimpleType.INTEGER;
+import static javax.management.openmbean.SimpleType.LONG;
+import static javax.management.openmbean.SimpleType.STRING;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+
+import javax.management.openmbean.CompositeData;
+import javax.management.openmbean.CompositeDataSupport;
+import javax.management.openmbean.CompositeType;
+import javax.management.openmbean.OpenDataException;
+import javax.management.openmbean.OpenType;
+import javax.management.openmbean.TabularData;
+import javax.management.openmbean.TabularDataSupport;
+import javax.management.openmbean.TabularType;
+
+/**
+ * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>
+ * 
+ * @version <tt>$Revision$</tt>
+ * 
+ */
+public class JMSMessageInfo
+{
+   // Constants -----------------------------------------------------
+
+   public static final CompositeType TYPE;
+   private static final String MESSAGE_TYPE_NAME = "JMSMessageInfo";
+   private static final String MESSAGE_TABULAR_TYPE_NAME = "JMSMessageTabularInfo";
+   private static final String[] ITEM_NAMES = new String[] { "messageID",
+         "correlationID", "deliveryMode", "priority", "replyTo", "timestamp",
+         "expiration", "jmsType", "properties" };
+   private static final String[] ITEM_DESCRIPTIONS = new String[] {
+         "Message ID", "Correlation ID", "Delivery Mode", "Priority",
+         "Reply To", "Timestamp", "Expiration", "JMS Type", "JMS Properties" };
+   private static final OpenType[] TYPES;
+   private static final TabularType TABULAR_TYPE;
+
+   static
+   {
+      try
+      {
+         TYPES = new OpenType[] { STRING, STRING, INTEGER, INTEGER, STRING,
+               LONG, LONG, STRING, PropertiesInfo.TABULAR_TYPE };
+         TYPE = new CompositeType(MESSAGE_TYPE_NAME,
+               "Information for a JMS Message", ITEM_NAMES, ITEM_DESCRIPTIONS,
+               TYPES);
+         TABULAR_TYPE = new TabularType(MESSAGE_TABULAR_TYPE_NAME,
+               "Information for tabular JMSMessageInfo", TYPE,
+               new String[] { "messageID" });
+      } catch (OpenDataException e)
+      {
+         e.printStackTrace();
+         throw new IllegalStateException(e);
+      }
+   }
+
+   // Attributes ----------------------------------------------------
+
+   private final String messageID;
+   private final String correlationID;
+   private final int deliveryMode;
+   private final int priority;
+   private final String replyTo;
+   private final long timestamp;
+   private final long expiration;
+   private final String jmsType;
+   private PropertiesInfo properties;
+
+   // Static --------------------------------------------------------
+
+   public static TabularData toTabularData(JMSMessageInfo[] infos)
+         throws OpenDataException
+   {
+      TabularData data = new TabularDataSupport(TABULAR_TYPE);
+      for (JMSMessageInfo messageInfo : infos)
+      {
+         data.put(messageInfo.toCompositeData());
+      }
+      return data;
+   }
+
+   public static TabularData toTabularData(List<JMSMessageInfo> infos)
+   {
+      TabularData data = new TabularDataSupport(TABULAR_TYPE);
+      for (JMSMessageInfo messageInfo : infos)
+      {
+         data.put(messageInfo.toCompositeData());
+      }
+      return data;
+   }
+
+   // Constructors --------------------------------------------------
+
+   public JMSMessageInfo(String messageID, String correlationID,
+         int deliveryMode, int priority, String replyTo, long timestamp,
+         long expiration, String jmsType)
+   {
+      this.messageID = messageID;
+      this.correlationID = correlationID;
+      this.deliveryMode = deliveryMode;
+      this.priority = priority;
+      this.replyTo = replyTo;
+      this.timestamp = timestamp;
+      this.expiration = expiration;
+      this.jmsType = jmsType;
+      this.properties = new PropertiesInfo();
+   }
+
+   // Public --------------------------------------------------------
+
+   public String getJMSMessageID()
+   {
+      return messageID;
+   }
+
+   public void putProperty(String key, String value)
+   {
+      properties.put(key, value);
+   }
+
+   public Map<String, String> getProperties()
+   {
+      return properties.entries();
+   }
+
+   public CompositeData toCompositeData()
+   {
+      try
+      {
+         return new CompositeDataSupport(TYPE, ITEM_NAMES, new Object[] {
+               messageID, correlationID, deliveryMode, priority, replyTo,
+               timestamp, expiration, jmsType, properties.toTabularData() });
+      } catch (OpenDataException e)
+      {
+         e.printStackTrace();
+         return null;
+      }
+   }
+
+   // Package protected ---------------------------------------------
+
+   // Protected -----------------------------------------------------
+
+   // Private -------------------------------------------------------
+
+   // Inner classes -------------------------------------------------
+
+   private static class PropertiesInfo
+   {
+      public static final TabularType TABULAR_TYPE;
+      private static CompositeType ROW_TYPE;
+
+      private final Map<String, String> properties = new HashMap<String, String>();
+
+      static
+      {
+         try
+         {
+            ROW_TYPE = new CompositeType("Property", "Property", new String[] {
+                  "key", "value" }, new String[] { "Key of the property",
+                  "Value of the property" }, new OpenType[] { STRING, STRING });
+            TABULAR_TYPE = new TabularType("PropertyInfo",
+                  "Properties of the message", ROW_TYPE, new String[] { "key" });
+         } catch (OpenDataException e)
+         {
+            e.printStackTrace();
+            throw new IllegalStateException(e);
+         }
+      }
+
+      PropertiesInfo()
+      {
+      }
+
+      /**
+       * @return
+       */
+      public Map<String, String> entries()
+      {
+         return properties;
+      }
+
+      void put(String key, String value)
+      {
+         properties.put(key, value);
+      }
+
+      TabularData toTabularData()
+      {
+         try
+         {
+            TabularDataSupport data = new TabularDataSupport(TABULAR_TYPE);
+            for (Entry<String, String> entry : properties.entrySet())
+            {
+               data.put(new CompositeDataSupport(ROW_TYPE, new String[] {
+                     "key", "value" }, new Object[] { entry.getKey(),
+                     entry.getValue() }));
+            }
+            return data;
+         } catch (OpenDataException e)
+         {
+            e.printStackTrace();
+            return null;
+         }
+      }
+   }
+}

Modified: branches/Branch_JBMESSAGING-1303/src/main/org/jboss/messaging/jms/server/management/JMSQueueControlMBean.java
===================================================================
--- branches/Branch_JBMESSAGING-1303/src/main/org/jboss/messaging/jms/server/management/JMSQueueControlMBean.java	2008-07-21 15:29:14 UTC (rev 4698)
+++ branches/Branch_JBMESSAGING-1303/src/main/org/jboss/messaging/jms/server/management/JMSQueueControlMBean.java	2008-07-21 15:41:43 UTC (rev 4699)
@@ -22,6 +22,8 @@
 
 package org.jboss.messaging.jms.server.management;
 
+import javax.management.openmbean.TabularData;
+
 /**
  * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>
  * 
@@ -30,4 +32,5 @@
  */
 public interface JMSQueueControlMBean extends DestinationControlMBean
 {
+   TabularData listAllMessages() throws Exception;
 }

Modified: branches/Branch_JBMESSAGING-1303/src/main/org/jboss/messaging/jms/server/management/impl/JMSQueueControl.java
===================================================================
--- branches/Branch_JBMESSAGING-1303/src/main/org/jboss/messaging/jms/server/management/impl/JMSQueueControl.java	2008-07-21 15:29:14 UTC (rev 4698)
+++ branches/Branch_JBMESSAGING-1303/src/main/org/jboss/messaging/jms/server/management/impl/JMSQueueControl.java	2008-07-21 15:41:43 UTC (rev 4699)
@@ -22,13 +22,24 @@
 
 package org.jboss.messaging.jms.server.management.impl;
 
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.jms.DeliveryMode;
 import javax.management.NotCompliantMBeanException;
 import javax.management.StandardMBean;
+import javax.management.openmbean.TabularData;
 
+import org.jboss.messaging.core.server.MessageReference;
 import org.jboss.messaging.core.server.Queue;
+import org.jboss.messaging.core.server.ServerMessage;
+import org.jboss.messaging.jms.JBossDestination;
 import org.jboss.messaging.jms.JBossQueue;
+import org.jboss.messaging.jms.client.JBossMessage;
 import org.jboss.messaging.jms.server.JMSServerManager;
+import org.jboss.messaging.jms.server.management.JMSMessageInfo;
 import org.jboss.messaging.jms.server.management.JMSQueueControlMBean;
+import org.jboss.messaging.util.SimpleString;
 
 /**
  * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>
@@ -52,7 +63,9 @@
 
    // Constructors --------------------------------------------------
 
-   public JMSQueueControl(JBossQueue queue, Queue coreQueue, String jndiBinding, JMSServerManager server) throws NotCompliantMBeanException
+   public JMSQueueControl(JBossQueue queue, Queue coreQueue,
+         String jndiBinding, JMSServerManager server)
+         throws NotCompliantMBeanException
    {
       super(JMSQueueControlMBean.class);
       this.managedQueue = queue;
@@ -69,7 +82,7 @@
    {
       return managedQueue.getName();
    }
-   
+
    public String getAddress()
    {
       return managedQueue.getAddress();
@@ -84,7 +97,7 @@
    {
       return coreQueue.getMessageCount();
    }
-   
+
    public String getJNDIBinding()
    {
       return binding;
@@ -94,7 +107,61 @@
    {
       server.removeAllMessages(managedQueue);
    }
-   
+
+   public TabularData listAllMessages() throws Exception
+   {
+      try
+      {
+         List<MessageReference> messageRefs = coreQueue.list(null);
+         List<JMSMessageInfo> infos = new ArrayList<JMSMessageInfo>(messageRefs
+               .size());
+         for (MessageReference messageRef : messageRefs)
+         {
+            ServerMessage message = messageRef.getMessage();
+
+            String messageID = message.getProperty(JBossMessage.JBM_MESSAGE_ID)
+                  .toString();
+            SimpleString simpleCorrelationID = (SimpleString) message
+                  .getProperty(JBossMessage.CORRELATIONID_HEADER_NAME);
+            String correlationID = (simpleCorrelationID == null) ? null
+                  : simpleCorrelationID.toString();
+            SimpleString simpleJMSType = (SimpleString) message
+                  .getProperty(JBossMessage.TYPE_HEADER_NAME);
+            String jmsType = (simpleJMSType == null) ? null : simpleJMSType
+                  .toString();
+            int deliveryMode = message.isDurable() ? DeliveryMode.PERSISTENT
+                  : DeliveryMode.NON_PERSISTENT;
+            int priority = message.getPriority();
+            String replyTo = null;
+            SimpleString replyAddress = (SimpleString) message
+                  .getProperty(JBossMessage.REPLYTO_HEADER_NAME);
+            if (replyAddress != null)
+            {
+               replyTo = JBossDestination.fromAddress(replyAddress.toString())
+                     .toString();
+            }
+            long timestamp = message.getTimestamp();
+            long expiration = message.getExpiration();
+
+            JMSMessageInfo info = new JMSMessageInfo(messageID, correlationID,
+                  deliveryMode, priority, replyTo, timestamp, expiration,
+                  jmsType);
+            for (SimpleString key : message.getPropertyNames())
+            {
+               info.putProperty(key.toString(), message.getProperty(key)
+                     .toString());
+            }
+            infos.add(info);
+
+         }
+         return JMSMessageInfo.toTabularData(infos);
+      } catch (Throwable t)
+      {
+         t.printStackTrace();
+         return null;
+      }
+   }
+
    // Package protected ---------------------------------------------
 
    // Protected -----------------------------------------------------

Modified: branches/Branch_JBMESSAGING-1303/tests/jms-tests/src/org/jboss/test/messaging/tools/container/LocalTestServer.java
===================================================================
--- branches/Branch_JBMESSAGING-1303/tests/jms-tests/src/org/jboss/test/messaging/tools/container/LocalTestServer.java	2008-07-21 15:29:14 UTC (rev 4698)
+++ branches/Branch_JBMESSAGING-1303/tests/jms-tests/src/org/jboss/test/messaging/tools/container/LocalTestServer.java	2008-07-21 15:41:43 UTC (rev 4699)
@@ -22,15 +22,18 @@
 package org.jboss.test.messaging.tools.container;
 
 import java.io.File;
+import java.lang.management.ManagementFactory;
 import java.sql.Connection;
 import java.sql.PreparedStatement;
 import java.sql.SQLException;
+import java.util.Arrays;
 import java.util.Collection;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Properties;
 import java.util.Set;
 
+import javax.management.MBeanServerInvocationHandler;
 import javax.management.NotificationListener;
 import javax.management.ObjectName;
 import javax.naming.InitialContext;
@@ -44,11 +47,11 @@
 import org.jboss.messaging.core.server.MessagingServer;
 import org.jboss.messaging.core.settings.impl.QueueSettings;
 import org.jboss.messaging.jms.JBossDestination;
-import org.jboss.messaging.jms.JBossQueue;
-import org.jboss.messaging.jms.JBossTopic;
 import org.jboss.messaging.jms.server.JMSServerManager;
+import org.jboss.messaging.jms.server.management.JMSQueueControlMBean;
+import org.jboss.messaging.jms.server.management.TopicControlMBean;
+import org.jboss.messaging.jms.server.management.impl.JMSManagementRegistrationImpl;
 import org.jboss.messaging.microcontainer.JBMBootstrapServer;
-import org.jboss.messaging.util.SimpleString;
 import org.jboss.test.messaging.tools.ConfigurationHelper;
 import org.jboss.test.messaging.tools.ServerManagement;
 import org.jboss.test.messaging.tools.jboss.MBeanConfigurationElement;
@@ -633,7 +636,10 @@
 
    public Integer getMessageCountForQueue(String queueName) throws Exception
    {
-      return getJMSServerManager().getMessageCountForQueue(queueName);
+      ObjectName objectName = JMSManagementRegistrationImpl.getJMSQueueObjectName(queueName);
+      JMSQueueControlMBean queue = (JMSQueueControlMBean) MBeanServerInvocationHandler.newProxyInstance(
+            ManagementFactory.getPlatformMBeanServer(), objectName, JMSQueueControlMBean.class, false);
+      return queue.getMessageCount();
    }
 
    public void removeAllMessages(JBossDestination destination) throws Exception
@@ -643,7 +649,10 @@
 
    public List listAllSubscriptionsForTopic(String s) throws Exception
    {
-      return getJMSServerManager().listSubscriptions(s);
+      ObjectName objectName = JMSManagementRegistrationImpl.getJMSTopicObjectName(s);
+      TopicControlMBean topic = (TopicControlMBean) MBeanServerInvocationHandler.newProxyInstance(
+            ManagementFactory.getPlatformMBeanServer(), objectName, TopicControlMBean.class, false);
+      return Arrays.asList(topic.listAllSubscriberInfos());
    }
 
 

Modified: branches/Branch_JBMESSAGING-1303/tests/jms-tests/src/org/jboss/test/messaging/tools/container/RMITestServer.java
===================================================================
--- branches/Branch_JBMESSAGING-1303/tests/jms-tests/src/org/jboss/test/messaging/tools/container/RMITestServer.java	2008-07-21 15:29:14 UTC (rev 4698)
+++ branches/Branch_JBMESSAGING-1303/tests/jms-tests/src/org/jboss/test/messaging/tools/container/RMITestServer.java	2008-07-21 15:41:43 UTC (rev 4699)
@@ -21,9 +21,11 @@
   */
 package org.jboss.test.messaging.tools.container;
 
+import java.lang.management.ManagementFactory;
 import java.rmi.registry.LocateRegistry;
 import java.rmi.registry.Registry;
 import java.rmi.server.UnicastRemoteObject;
+import java.util.Arrays;
 import java.util.Collections;
 import java.util.HashMap;
 import java.util.Hashtable;
@@ -31,6 +33,7 @@
 import java.util.Map;
 import java.util.Set;
 
+import javax.management.MBeanServerInvocationHandler;
 import javax.management.NotificationListener;
 import javax.management.ObjectName;
 import javax.naming.InitialContext;
@@ -42,6 +45,9 @@
 import org.jboss.messaging.core.server.MessagingServer;
 import org.jboss.messaging.jms.JBossDestination;
 import org.jboss.messaging.jms.server.JMSServerManager;
+import org.jboss.messaging.jms.server.management.JMSQueueControlMBean;
+import org.jboss.messaging.jms.server.management.TopicControlMBean;
+import org.jboss.messaging.jms.server.management.impl.JMSManagementRegistrationImpl;
 
 /**
  * An RMI wrapper to access the ServiceContainer from a different address space.
@@ -458,13 +464,19 @@
 
    public Integer getMessageCountForQueue(String queueName) throws Exception
    {
-      return getJMSServerManager().getMessageCountForQueue(queueName);
+      ObjectName objectName = JMSManagementRegistrationImpl.getJMSQueueObjectName(queueName);
+      JMSQueueControlMBean queue = (JMSQueueControlMBean) MBeanServerInvocationHandler.newProxyInstance(
+            ManagementFactory.getPlatformMBeanServer(), objectName, JMSQueueControlMBean.class, false);
+      return queue.getMessageCount();
    }
 
 
    public List listAllSubscriptionsForTopic(String s) throws Exception
    {
-      return server.listAllSubscriptionsForTopic(s);
+      ObjectName objectName = JMSManagementRegistrationImpl.getJMSTopicObjectName(s);
+      TopicControlMBean topic = (TopicControlMBean) MBeanServerInvocationHandler.newProxyInstance(
+            ManagementFactory.getPlatformMBeanServer(), objectName, TopicControlMBean.class, false);
+      return Arrays.asList(topic.listAllSubscriberInfos());
    }
 
 




More information about the jboss-cvs-commits mailing list