Strings.toString(strbuf, value);
strbuf.append('\n');
}
public static void dumpAttributes(String name, String path) {
FileWriter writer = null;
try {
Set mBeans = null;
try {
mBeans = MXWrapper.queryNames(name);
} catch (Exception exc) {
logger.log(BasicLevel.ERROR, "DumpAttributes.dumpAttributes, bad name: " + name, exc);
return;
}
if (mBeans != null) {
writer = new FileWriter(path, true);
StringBuffer strbuf = new StringBuffer();
for (Iterator iterator = mBeans.iterator(); iterator.hasNext();) {
String mBean = (String) iterator.next();
// Get all mbean's attributes
try {
List attributes = MXWrapper.getAttributeNames(mBean);
if (attributes != null) {
for (int i = 0; i < attributes.size(); i++) {
String attname = (String) attributes.get(i);
try {
addRecord(strbuf, mBean, attname, MXWrapper.getAttribute(mBean, attname));
} catch (Exception exc) {
logger.log(BasicLevel.ERROR,
"DumpAttributes.dumpAttributes, bad attribute : " + mBean + ":" + attname, exc);
}
}
}
writer.write(strbuf.toString());
strbuf.setLength(0);
} catch (Exception exc) {
logger.log(BasicLevel.ERROR, "DumpAttributes.dumpAttributes", exc);
}
}
writer.close();
}
} catch (IOException exc) {
logger.log(BasicLevel.ERROR,
"FileMonitoringTimerTask.<init>, cannot open file \"" + path + "\"", exc);
}