private Object getAttributeValue(Object o, JmxAttributeMetadata attr) { String name = attr.getName(); String methodName = (attr.isIs() ? "is" : "get") + name.substring(0, 1).toUpperCase() + name.substring(1); try { Method method = o.getClass().getMethod(methodName); return method.invoke(o); } catch (Exception e) { return "N/A"; } }
private Object getAttributeValue(Object o, JmxAttributeMetadata attr) { String name = attr.getName(); String methodName = (attr.isIs() ? "is" : "get") + name.substring(0, 1).toUpperCase() + name.substring(1); try { Method method = o.getClass().getMethod(methodName); return method.invoke(o); } catch (Exception e) { return "N/A"; } }
private void printComponentStats(PrintWriter pw, Cache<?, ?> cache, Object component) { if (component == null) { return; } ComponentMetadataRepo mr = cache.getAdvancedCache().getComponentRegistry().getComponentMetadataRepo(); ComponentMetadata cm = mr.findComponentMetadata(component.getClass().getName()); if (cm == null || !(cm instanceof ManageableComponentMetadata)) { return; } ManageableComponentMetadata mcm = cm.toManageableComponentMetadata(); pw.printf("%s: {\n", mcm.getJmxObjectName()); List<JmxAttributeMetadata> attrs = new ArrayList<>(mcm.getAttributeMetadata()); Collections.sort(attrs, Comparator.comparing(JmxAttributeMetadata::getName)); for (JmxAttributeMetadata s : attrs) { pw.printf(" %s: %s\n", s.getName(), getAttributeValue(component, s)); } pw.println("}"); }
private void printComponentStats(PrintWriter pw, Cache<?, ?> cache, Object component) { if (component == null) { return; } ComponentMetadataRepo mr = cache.getAdvancedCache().getComponentRegistry().getComponentMetadataRepo(); ComponentMetadata cm = mr.findComponentMetadata(component.getClass().getName()); if (cm == null || !(cm instanceof ManageableComponentMetadata)) { return; } ManageableComponentMetadata mcm = cm.toManageableComponentMetadata(); pw.printf("%s: {\n", mcm.getJmxObjectName()); for (JmxAttributeMetadata s : mcm.getAttributeMetadata()) { pw.printf(" %s: %s\n", s.getName(), getAttributeValue(component, s)); } pw.println("}"); }