/** */ private static void processTabularDataSupport(List<Result> resList, MBeanInfo info, ObjectInstance oi, Result r, String attributeName, TabularDataSupport tds, Query query) { Set<Entry<Object, Object>> entries = tds.entrySet(); for (Entry<Object, Object> entry : entries) { Object entryKeys = entry.getKey(); if (entryKeys instanceof List) { // ie: attributeName=LastGcInfo.Par Survivor Space // i haven't seen this be smaller or larger than List<1>, but // might as well loop it. StringBuilder sb = new StringBuilder(); for (Object entryKey : (List<?>) entryKeys) { sb.append("."); sb.append(entryKey); } String attributeName2 = sb.toString(); Object entryValue = entry.getValue(); if (entryValue instanceof CompositeDataSupport) { getResult(resList, info, oi, attributeName + attributeName2, (CompositeDataSupport) entryValue, query); } else { throw new RuntimeException("!!!!!!!!!! Please file a bug: http://code.google.com/p/jmxtrans/issues/entry entryValue is: " + entryValue.getClass().getCanonicalName()); } } else { throw new RuntimeException("!!!!!!!!!! Please file a bug: http://code.google.com/p/jmxtrans/issues/entry entryKeys is: " + entryKeys.getClass().getCanonicalName()); } } }
if (value != null) { if (value instanceof CompositeDataSupport) { getResult(resList, info, oi, attribute.getName(), (CompositeData) value, query); } else if (value instanceof CompositeData[]) { for (CompositeData cd : (CompositeData[]) value) { getResult(resList, info, oi, attribute.getName(), cd, query);
/** * Populates the Result objects. This is a recursive function. Query * contains the keys that we want to get the values of. */ private static void getResult(List<Result> resList, MBeanInfo info, ObjectInstance oi, String attributeName, CompositeData cds, Query query) { CompositeType t = cds.getCompositeType(); Result r = getNewResultObject(info, oi, attributeName, query); Set<String> keys = t.keySet(); for (String key : keys) { Object value = cds.get(key); if (value instanceof TabularDataSupport) { TabularDataSupport tds = (TabularDataSupport) value; processTabularDataSupport(resList, info, oi, r, attributeName + "." + key, tds, query); r.addValue(key, value); } else if (value instanceof CompositeDataSupport) { // now recursively go through everything. CompositeDataSupport cds2 = (CompositeDataSupport) value; getResult(resList, info, oi, attributeName, cds2, query); return; // because we don't want to add to the list yet. } else { r.addValue(key, value); } } resList.add(r); }
getResult(resList, info, oi, attribute, query);