mirror of https://github.com/apache/activemq.git
further enhancement for AMQ-1904 to add helper method to extract the Map of all user properties
git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@687864 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
3dd6575ac8
commit
a655335471
|
@ -34,6 +34,11 @@ public class CompositeDataHelper {
|
||||||
*/
|
*/
|
||||||
public static Map getTabularMap(CompositeData cdata, String fieldName) {
|
public static Map getTabularMap(CompositeData cdata, String fieldName) {
|
||||||
Map map = new HashMap();
|
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);
|
Object tabularObject = cdata.get(fieldName);
|
||||||
if (tabularObject instanceof TabularData) {
|
if (tabularObject instanceof TabularData) {
|
||||||
TabularData tabularData = (TabularData) tabularObject;
|
TabularData tabularData = (TabularData) tabularObject;
|
||||||
|
@ -44,6 +49,25 @@ public class CompositeDataHelper {
|
||||||
map.put(key, value);
|
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;
|
return map;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -188,6 +188,11 @@ public class MBeanTest extends EmbeddedBrokerTestSupport {
|
||||||
assertEquals("stringProperties size()", 1, stringProperties.size());
|
assertEquals("stringProperties size()", 1, stringProperties.size());
|
||||||
assertEquals("stringProperties.MyHeader", "StringHeader" + i, stringProperties.get("MyStringHeader"));
|
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, "JMSXGroupSeq", 1234);
|
||||||
assertComplexData(cdata, "JMSXGroupID", "MyGroupID");
|
assertComplexData(cdata, "JMSXGroupID", "MyGroupID");
|
||||||
assertComplexData(cdata, "Text", "message:" + i);
|
assertComplexData(cdata, "Text", "message:" + i);
|
||||||
|
|
Loading…
Reference in New Issue