MBeanInfo mbeanInfo;
try {
mbeanInfo = server.getMBeanInfo(mbean);
}
catch (JMException e) {
throw new ScriptException(e);
}
for (MBeanAttributeInfo attributeInfo : mbeanInfo.getAttributes()) {
if (attributeInfo.isReadable()) {
tmp.add(attributeInfo.getName());
}
}
}
names = tmp.toArray(new String[tmp.size()]);
} else {
names = attributes.toArray(new String[attributes.size()]);
}
// Produce the output
for (ObjectName mbean : buffer) {
LinkedHashMap<String, Object> tuple = new LinkedHashMap<String, Object>();
if (name != null) {
tuple.put(name, mbean);
}
for (String name : names) {
Object value;
try {
value = server.getAttribute(mbean, name);
}
catch (RuntimeMBeanException runtime) {
if (Boolean.TRUE.equals(silent)) {
throw new ScriptException(runtime.getCause());
} else {
value = null;
}
}
catch (AttributeNotFoundException e) {
value = null;
}
catch (JMException e) {
throw new ScriptException(e);
}
tuple.put(name, value);
}
context.provide(tuple);
}