Continuing the series about “writing JMX scripts in a dynamic language”, after Ruby (part I & II), let’s do that in JavaScript.
Aside of the use of a different scripting language, this example differs completely from the Ruby one by its context of execution: it will be integrated into Eclipse and called directly from its user interface (using Eclipse Monkey as the glue).
The example will:
- ask graphically the user for a logging level
- update all the JVM’s loggers with this level
- display all the loggers of the JVM
in 50 lines of code.
This example is simple but it implies several interesting steps:
- connect to a JMX Server
- retrieve a MBean
- retrieve value of MBean attributes
- invoke operations on the MBean
There are many use cases where you have to perform theses steps in repetition. It’s tedious to do that in a JMX console (e.g. jconsole or eclipse-jmx) and most of the time, it is not worth writing a Java application.
These use cases beg to be scripted.
