diff --git a/bindings/java/org/collectd/java/GenericJMXConfMBean.java b/bindings/java/org/collectd/java/GenericJMXConfMBean.java
index eea2d8ab81901b2e375859d9bb55f2f2fd557663..1b4d9ccf99086f825726fa8478d78338ae1fab55 100644 (file)
package org.collectd.java;
-import java.util.List;
import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
import java.util.ArrayList;
import javax.management.MBeanServerConnection;
import javax.management.ObjectName;
import javax.management.MalformedObjectNameException;
-
import org.collectd.api.Collectd;
import org.collectd.api.PluginData;
import org.collectd.api.OConfigValue;
} /* }}} GenericJMXConfMBean (OConfigItem ci) */
- public String getName ()
+ public String getName () /* {{{ */
{
return (this._name);
- }
+ } /* }}} */
public void query (MBeanServerConnection conn, PluginData pd) /* {{{ */
{
- pd.setPluginInstance ((this._instance != null) ? this._instance : "");
+ Set<ObjectName> names;
+ Iterator<ObjectName> iter;
+
+ try
+ {
+ names = conn.queryNames (this._obj_name, /* query = */ null);
+ }
+ catch (Exception e)
+ {
+ Collectd.logError ("GenericJMXConfMBean: queryNames failed: " + e);
+ return;
+ }
+
+ if (names.size () == 0)
+ {
+ Collectd.logWarning ("GenericJMXConfMBean: No MBean matched "
+ + "the ObjectName " + this._obj_name);
+ }
+
+ iter = names.iterator ();
+ while (iter.hasNext ())
+ {
+ ObjectName objName;
+ PluginData pd_tmp;
- for (int i = 0; i < this._values.size (); i++)
- this._values.get (i).query (conn, this._obj_name, pd);
+ objName = iter.next ();
+ pd_tmp = new PluginData (pd);
+
+ Collectd.logDebug ("GenericJMXConfMBean: objName = "
+ + objName.toString ());
+
+ pd_tmp.setPluginInstance ((this._instance != null) ? this._instance : "");
+
+ for (int i = 0; i < this._values.size (); i++)
+ this._values.get (i).query (conn, objName, pd_tmp);
+ }
} /* }}} void query */
}