activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jstrac...@apache.org
Subject svn commit: r687864 - in /activemq/trunk/activemq-core/src: main/java/org/apache/activemq/broker/jmx/CompositeDataHelper.java test/java/org/apache/activemq/broker/jmx/MBeanTest.java
Date Thu, 21 Aug 2008 21:13:39 GMT
Author: jstrachan
Date: Thu Aug 21 14:13:39 2008
New Revision: 687864

URL: http://svn.apache.org/viewvc?rev=687864&view=rev
Log:
further enhancement for AMQ-1904 to add helper method to extract the Map of all user properties

Modified:
    activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/jmx/CompositeDataHelper.java
    activemq/trunk/activemq-core/src/test/java/org/apache/activemq/broker/jmx/MBeanTest.java

Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/jmx/CompositeDataHelper.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/jmx/CompositeDataHelper.java?rev=687864&r1=687863&r2=687864&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/jmx/CompositeDataHelper.java
(original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/jmx/CompositeDataHelper.java
Thu Aug 21 14:13:39 2008
@@ -34,6 +34,11 @@
      */
     public static Map getTabularMap(CompositeData cdata, String fieldName) {
         Map map = new HashMap();
+        appendTabularMap(map, cdata, fieldName);
+        return map;
+    }
+
+    public static void appendTabularMap(Map map, CompositeData cdata, String fieldName) {
         Object tabularObject = cdata.get(fieldName);
         if (tabularObject instanceof TabularData) {
             TabularData tabularData = (TabularData) tabularObject;
@@ -44,6 +49,25 @@
                 map.put(key, value);
             }
         }
+    }
+
+    /**
+     * Returns a map of all the user properties in the given message {@link javax.management.openmbean.CompositeData}
+     * object
+     *
+     * @param cdata
+     * @return
+     */
+    public static Map getMessageUserProperties(CompositeData cdata) {
+        Map map = new HashMap();
+        appendTabularMap(map, cdata, CompositeDataConstants.STRING_PROPERTIES);
+        appendTabularMap(map, cdata, CompositeDataConstants.BOOLEAN_PROPERTIES);
+        appendTabularMap(map, cdata, CompositeDataConstants.BYTE_PROPERTIES);
+        appendTabularMap(map, cdata, CompositeDataConstants.SHORT_PROPERTIES);
+        appendTabularMap(map, cdata, CompositeDataConstants.INT_PROPERTIES);
+        appendTabularMap(map, cdata, CompositeDataConstants.LONG_PROPERTIES);
+        appendTabularMap(map, cdata, CompositeDataConstants.FLOAT_PROPERTIES);
+        appendTabularMap(map, cdata, CompositeDataConstants.DOUBLE_PROPERTIES);
         return map;
     }
 }

Modified: activemq/trunk/activemq-core/src/test/java/org/apache/activemq/broker/jmx/MBeanTest.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/broker/jmx/MBeanTest.java?rev=687864&r1=687863&r2=687864&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/test/java/org/apache/activemq/broker/jmx/MBeanTest.java
(original)
+++ activemq/trunk/activemq-core/src/test/java/org/apache/activemq/broker/jmx/MBeanTest.java
Thu Aug 21 14:13:39 2008
@@ -188,6 +188,11 @@
             assertEquals("stringProperties size()", 1, stringProperties.size());
             assertEquals("stringProperties.MyHeader", "StringHeader" + i, stringProperties.get("MyStringHeader"));
 
+            Map properties = CompositeDataHelper.getMessageUserProperties(cdata);
+            assertEquals("properties size()", 2, properties.size());
+            assertEquals("properties.MyHeader", i, properties.get("MyHeader"));
+            assertEquals("properties.MyHeader", "StringHeader" + i, properties.get("MyStringHeader"));
+
             assertComplexData(cdata, "JMSXGroupSeq", 1234);
             assertComplexData(cdata, "JMSXGroupID", "MyGroupID");
             assertComplexData(cdata, "Text", "message:" + i);



Mime
View raw message