public static CompositeType getThrowableCompositeType() throws JMException { if (THROWABLE_COMPOSITE_TYPE == null) { THROWABLE_COMPOSITE_TYPE = new CompositeType("Throwable", "Throwable", THROWABLE_COMPOSITE_INDEX_NAMES, THROWABLE_COMPOSITE_INDEX_DESCRIPTIONS, THROWABLE_COMPOSITE_INDEX_TYPES); } return THROWABLE_COMPOSITE_TYPE; }
@Override public TabularData getConnectionList() throws JMException { CompositeType rowType = JdbcConnectionStat.Entry.getCompositeType(); String[] indexNames = rowType.keySet().toArray(new String[rowType.keySet().size()]); TabularType tabularType = new TabularType("ConnectionListStatistic", "ConnectionListStatistic", rowType, indexNames); TabularData data = new TabularDataSupport(tabularType); for (Map.Entry<Long, JdbcConnectionStat.Entry> entry : getConnections().entrySet()) { data.put(entry.getValue().getCompositeData()); } return data; }
for(String f: td[0].getCompositeType().keySet()) { if (!header.contains(f)) { header.add(f); td.getTabularType().getIndexNames(); List<String> header = new ArrayList<String>(td.getTabularType().getIndexNames()); for(String f: td.getTabularType().getRowType().keySet()) { if (!header.contains(f)) { header.add(f); CompositeData cd = (CompositeData)v; List<String[]> content = new ArrayList<String[]>(); for(String field: cd.getCompositeType().keySet()) { String val = formatLine(cd.get(field), cd.getCompositeType().getType(field).getClassName()); content.add(new String[]{field + ": ", val});
private Map<String, Object> toNeo4jValue( CompositeData composite ) { HashMap<String,Object> properties = new HashMap<>(); for ( String key : composite.getCompositeType().keySet() ) { properties.put( key, toNeo4jValue(composite.get( key )) ); } return map( "description", composite.getCompositeType().getDescription(), "properties", properties ); }
TabularData td = (TabularData)v; StringBuilder sb = new StringBuilder(); for(Object c: td.values()) { sb.append(formatLine(c, td.getTabularType().getRowType().getClassName())); sb.append(","); StringBuilder sb = new StringBuilder(); for(Object c: td) { sb.append(formatLine(c, ((CompositeData)c).getCompositeType().getClassName())); sb.append(","); StringBuilder sb = new StringBuilder(); sb.append("{"); for(String attr: cdata.getCompositeType().keySet()) { sb.append(attr).append("="); sb.append(formatLine(cdata.get(attr), cdata.getCompositeType().getType(attr).getClassName())); sb.append(',');
@Override public TabularData getJobs() throws MBeanException { try { CompositeType jobType = new CompositeType("Job", "Scheduler job", new String[]{ "Job", "Schedule" }, new String[]{ "Job Name", "Job Scheduling" }, new OpenType[]{ SimpleType.STRING, SimpleType.STRING }); TabularType tableType = new TabularType("Jobs", "Tables of all jobs", jobType, new String[]{ "Job" }); TabularData table = new TabularDataSupport(tableType); Map<Object, ScheduleOptions> jobs = scheduler.getJobs(); for (Map.Entry<Object, ScheduleOptions> entry : jobs.entrySet()) { CompositeData data = new CompositeDataSupport(jobType, new String[]{ "Job", "Schedule" }, new Object[]{ entry.getValue().name(), entry.getValue().schedule()}); table.put(data); } return table; } catch (Exception e) { throw new MBeanException(null, e.toString()); } }
} else if(value instanceof CompositeData) { CompositeData cds = (CompositeData)value; CompositeType comp = cds.getCompositeType(); Set<String> keys = comp.keySet(); jg.writeStartObject(); for (String key: keys) { writeAttribute(jg, key, null, cds.get(key)); TabularData tds = (TabularData)value; jg.writeStartArray(); for(Object entry : tds.values()) { writeObject(jg, description, entry);
/** * Recursively extracts simple numeric values from composite data objects. * The map {@code values} will be populated with a path to the value as * the key and the simple object as the value. */ private void extractValues(String path, Map<String, Object> values, CompositeData obj) { for (String key : obj.getCompositeType().keySet()) { String newPath = (path == null) ? key : path + "." + key; Object value = obj.get(key); if (value instanceof CompositeData) { extractValues(newPath, values, (CompositeData) value); } else if (value != null) { values.put(newPath, value); } } }
throws InvalidObjectException { CompositeType ct = cd.getCompositeType(); BitSet present = new BitSet(); for (int i = 0; i < itemNames.length; i++) { if (ct.getType(itemNames[i]) != null) present.set(i); + "items: " + ct.keySet(); throw new InvalidObjectException(msg); if (!max.presentParams.get(i)) continue; Object openItem = cd.get(itemNames[i]); Object javaItem = converters[i].fromOpenValue(openItem); int index = max.paramIndexes[i];
@SneakyThrows @Override public TabularData getCascadingDecisions() { CompositeType type = new CompositeType("Decision", "Cascading decision", new String[]{"Index", "Engine"}, new String[]{"Index", "Index Engine"}, new OpenType[]{SimpleType.STRING, SimpleType.STRING}); TabularDataSupport tab = new TabularDataSupport( new TabularType("Decisions", "Cascading decisions", type, new String[]{"Index"})); for (Map.Entry<String, IndexEngine> entry : decisions.entrySet()) { tab.put(new CompositeDataSupport(type, new String[]{"Index", "Engine"}, new Object[]{entry.getKey(), entry.getValue().getType()})); } return tab; } }
null, null, null ) ); when( jmxServer.getAttribute( beanName, "name" ) ).thenReturn( new CompositeDataSupport( new CompositeType( "myComposite", "Composite description",
for (Object nm : parent.keySet()) { String key = (String) nm; all.add(new Item(key, parent.getDescription(key), parent.getType(key))); return new CompositeType(name, description, names, descriptions, types); } catch (OpenDataException e) { throw new RuntimeException(e);
for(String f: td[0].getCompositeType().keySet()) { if (!header.contains(f)) { header.add(f); CompositeData cd = (CompositeData) v; List<String> header = new ArrayList<String>(); for(String f: cd.getCompositeType().keySet()) { if (!header.contains(f)) { header.add(f); td.getTabularType().getIndexNames(); List<String> header = new ArrayList<String>(td.getTabularType().getIndexNames()); for(String f: td.getTabularType().getRowType().keySet()) { if (!header.contains(f)) { header.add(f);
private String[] formatRow(CompositeData row, List<String> header) { String[] text = new String[header.size()]; for(int i = 0; i != text.length; ++i) { String attr = header.get(i); text[i] = formatLine(row.get(attr), row.getCompositeType().getType(attr).getClassName()); } return text; }
private TabularData convertToTabularTypeFromMap(TabularType pType, JSONObject pValue) { CompositeType rowType = pType.getRowType(); // A TabularData is requested for mapping a map for the call to an MXBean // as described in http://download.oracle.com/javase/6/docs/api/javax/management/MXBean.html // This means, we will convert a JSONObject to the required format TabularDataSupport tabularData = new TabularDataSupport(pType); @SuppressWarnings("unchecked") Map<String, String> jsonObj = (Map<String,String>) pValue; for(Map.Entry<String, String> entry : jsonObj.entrySet()) { Map<String, Object> map = new HashMap<String, Object>(); map.put("key", getDispatcher().convertToObject(rowType.getType("key"), entry.getKey())); map.put("value", getDispatcher().convertToObject(rowType.getType("value"), entry.getValue())); try { CompositeData compositeData = new CompositeDataSupport(rowType, map); tabularData.put(compositeData); } catch (OpenDataException e) { throw new IllegalArgumentException(e.getMessage(),e); } } return tabularData; }
private static MBeanDump.MBeanValue getTabularDataValue(TabularData tabularData) { Set<String> attributeNames = tabularData.getTabularType().getRowType().keySet(); for (Object key : tabularData.keySet()) { String keyString = Joiner.on(", ").join(keyList); @SuppressWarnings("argument.type.incompatible") CompositeData compositeData = tabularData.get(keyList.toArray()); innerEntries.add(MBeanDump.MBeanValueMapEntry.newBuilder() .setKey(attributeName) .setValue(getMBeanAttributeValue(compositeData.get(attributeName))) .build());
CompositeType compositeType = cd.getCompositeType(); String typeName = compositeType.getTypeName(); SpecificRecordBase rec; try { Object obj = cd.get(field.name()); try { rec.put(field.pos(),
Map<String, OpenType<?>> openTypes = Maps.newHashMap(); final String[] names = new String[getOpenType().keySet().size()]; final String[] descriptions = new String[getOpenType().keySet().size()]; OpenType<?>[] itemTypes = new OpenType[names.length]; int i = 0; descriptions[i] = getOpenType().getDescription(names[i]); itemTypes[i] = openTypes.get(innerAttrNameStr); i++; try { LOG.trace("Attribute {} with open type {}. Reconstructing open type.", attrName, getOpenType()); setOpenType(new CompositeType(getOpenType().getTypeName(), getOpenType().getDescription(), names, descriptions, itemTypes)); LOG.debug("Attribute {}. Open type reconstructed to {}", attrName, getOpenType(), getOpenType()); parsedValue = new CompositeDataSupport(getOpenType(), items); } catch (OpenDataException e) { throw new IllegalStateException("An error occurred during restoration of composite type " + this
CompositeType rt = new CompositeType("a", "b", new String[] { "a" }, new String[] { javax.management.openmbean.SimpleType.INTEGER }); TabularType tt = new TabularType("a", "b", rt, new String[] { "a" }); TabularDataSupport t1 = new TabularDataSupport(tt); TabularDataSupport t2 = new TabularDataSupport(tt);
private static List<String> getCompositeTypeAttributeNames(MBeanAttributeInfo attribute, Object compositeData, CompositeType compositeType) { List<String> attributeNames = Lists.newArrayList(); for (String itemName : compositeType.keySet()) { OpenType<?> itemType = compositeType.getType(itemName); if (itemType == null) { continue; attributeNames.add(attribute.getName() + '.' + itemName); } else if (clazz == String.class && compositeData instanceof CompositeData) { Object val = ((CompositeData) compositeData).get(itemName); if (val instanceof String) { try {