Allow `Attribute` to query an MBean operation
authorPierre-Yves Ritschard <pyr@spootnik.org>
Wed, 18 Jan 2012 12:57:11 +0000 (13:57 +0100)
committerPierre-Yves Ritschard <pyr@spootnik.org>
Wed, 18 Jan 2012 12:57:11 +0000 (13:57 +0100)
MBeans provide two entities to the outside world:

* Attributes
* Operations

The former is a simple key/value lookup, while the latter
triggers a method call and yields the result.

Operations have signatures, they can be fed an array of
parameters. For now, calls are triggered assuming
there are no parameters. Later a separate keyword
`Operation` can be introduced, taking a list of
`Parameter` directives specifying type and values
to feed to the MBean operation.

bindings/java/org/collectd/java/GenericJMXConfValue.java

index 0eb0d5f..0ed1990 100644 (file)
@@ -312,7 +312,14 @@ class GenericJMXConfValue
 
     try
     {
-      value = conn.getAttribute (objName, key);
+      try
+      {
+        value = conn.getAttribute (objName, key);
+      }
+      catch (javax.management.AttributeNotFoundException e)
+      {
+        value = conn.invoke (objName, key, null, null);
+      }
     }
     catch (Exception e)
     {