List of usage examples for javax.management.openmbean CompositeData get
public Object get(String key);
From source file:Main.java
public static void appendTabularMap(Map map, CompositeData cdata, String fieldName) { Object tabularObject = cdata.get(fieldName); if (tabularObject instanceof TabularData) { TabularData tabularData = (TabularData) tabularObject; Collection<CompositeData> values = (Collection<CompositeData>) tabularData.values(); for (CompositeData compositeData : values) { Object key = compositeData.get("key"); Object value = compositeData.get("value"); map.put(key, value);// w ww . j a v a 2 s.c o m } } }
From source file:org.ngrinder.monitor.share.domain.MonitorInfo.java
protected static Object getObject(CompositeData cd, String itemName) { return cd.get(itemName); }
From source file:com.googlecode.psiprobe.tools.JmxTools.java
public static String getStringAttr(CompositeData cds, String name) { Object o = cds.get(name); return o != null ? o.toString() : null; }
From source file:com.googlecode.psiprobe.tools.JmxTools.java
public static boolean getBooleanAttr(CompositeData cds, String name) { Object o = cds.get(name); return o != null && o instanceof Boolean && ((Boolean) o).booleanValue(); }
From source file:com.googlecode.psiprobe.tools.JmxTools.java
public static long getLongAttr(CompositeData cds, String name) { Object o = cds.get(name); if (o != null && o instanceof Long) { return ((Long) o).longValue(); } else {/*from w ww . ja v a2 s. c om*/ return 0; } }
From source file:com.googlecode.psiprobe.tools.JmxTools.java
public static int getIntAttr(CompositeData cds, String name, int defaultValue) { Object o = cds.get(name); if (o != null && o instanceof Integer) { return ((Integer) o).intValue(); } else {//from w w w .j a v a 2s . co m return defaultValue; } }
From source file:org.lsc.beans.SimpleBean.java
@SuppressWarnings("unchecked") public static SimpleBean from(CompositeData cd) { SimpleBean lb = new SimpleBean(); lb.setMainIdentifier((String) cd.get("mainIdentifier")); for (Entry<String, Set<Object>> entry : ((Map<String, Set<Object>>) SerializationUtils .deserialize((byte[]) cd.get("datasetsBytes"))).entrySet()) { lb.setDataset(entry.getKey(), entry.getValue()); }//from ww w. j a v a 2 s. co m return lb; }
From source file:org.apache.hadoop.hbase.util.JSONMetricUtil.java
public static long getLastGcDuration(ObjectName gcCollector) { long lastGcDuration = 0; Object lastGcInfo = getValueFromMBean(gcCollector, "LastGcInfo"); if (lastGcInfo != null && lastGcInfo instanceof CompositeData) { CompositeData cds = (CompositeData) lastGcInfo; lastGcDuration = (long) cds.get("duration"); }//from w ww . j a v a 2 s .co m return lastGcDuration; }
From source file:org.rhq.core.pluginapi.util.ObjectUtil.java
/** * Returns the value of the property with the specified name for the given Object, or null if the Object has no such * property./*w w w . ja v a 2 s. co m*/ * * @param obj an Object * @param propertyName the name of the property whose value should be returned * * @return the value of the property with the specified name for the given Object, or null if the Object has no such * property */ @Nullable public static Object lookupAttributeProperty(Object obj, String propertyName) { Object value = null; if (obj instanceof CompositeData) { CompositeData compositeData = ((CompositeData) obj); if (compositeData.containsKey(propertyName)) { value = compositeData.get(propertyName); } else { LOG.debug("Unable to read attribute/property [" + propertyName + "] from object [" + obj + "] using OpenMBean API - no such property."); } } else { // Try to use reflection. try { PropertyDescriptor[] pds = Introspector.getBeanInfo(obj.getClass()).getPropertyDescriptors(); boolean propertyFound = false; for (PropertyDescriptor pd : pds) { if (pd.getName().equals(propertyName)) { propertyFound = true; Method readMethod = pd.getReadMethod(); if (readMethod == null) { LOG.debug("Unable to read attribute/property [" + propertyName + "] from object [" + obj + "] using Reflection - property is not readable (i.e. it has no getter)."); } else { value = readMethod.invoke(obj); } } } if (!propertyFound) { LOG.debug("Unable to read attribute/property [" + propertyName + "] from object [" + obj + "] using Reflection - no such property."); } } catch (Exception e) { LOG.debug("Unable to read attribute/property [" + propertyName + "] from object [" + obj + "] using Reflection - cause: " + ThrowableUtil.getAllMessages(e)); } } return value; }
From source file:org.rhq.core.pluginapi.util.ObjectUtil.java
/** * Looks up deep object graph attributes using a dot delimited java bean spec style path. So if I have an object A * with a Member object B with a String value C I can refer to it as "b.c" and pass in the object A and I'll get * back the value of a.getB().getC()// w w w . j a v a2 s . c o m * * @param value The object to look into * @param propertyPath the property path to search * * @return the value read from the object's property path */ public static Object lookupDeepAttributeProperty(Object value, String propertyPath) { if (value == null) return null; String[] ps = propertyPath.split("\\.", 2); String searchProperty = ps[0]; if (value instanceof CompositeData) { CompositeData compositeData = ((CompositeData) value); if (compositeData.containsKey(searchProperty)) { value = compositeData.get(searchProperty); } else { LOG.debug("Unable to read attribute property [" + propertyPath + "] from composite data value"); } } else { // Try to use reflection try { PropertyDescriptor[] pds = Introspector.getBeanInfo(value.getClass()).getPropertyDescriptors(); for (PropertyDescriptor pd : pds) { if (pd.getName().equals(searchProperty)) { value = pd.getReadMethod().invoke(value); } } } catch (Exception e) { LOG.debug("Unable to read property from measurement attribute [" + searchProperty + "] not found on [" + ((value != null) ? value.getClass().getSimpleName() : "null") + "]"); } } if (ps.length > 1) { value = lookupDeepAttributeProperty(value, ps[1]); } return value; }