String objNameStr = Metric.decode(metric.getObjectName());
Object o = MxUtil.getValue(metric.getProperties(), objNameStr, metric.getAttributeName());
if (o instanceof Collection<?>) {
Collection<?> c = (Collection<?>) o;
return new MetricValue(c.size());
} else if (o instanceof Map<?, ?>) {
Map<?, ?> m = (Map<?, ?>) o;
return new MetricValue(m.size());
} else if (o instanceof Number) {
Number n = (Number) o;
return new MetricValue(n);
}
} catch (IOException e) {
throw new MetricUnreachableException("Error during communication with remote MBean Server.", e);
} catch (Exception e) {
throw new PluginException(e);