Java Dynamic Management Kit 5.1 Tutorial

4.4.2 Open MBean Example 2

In the second open MBean example, we implement an open MBean and manage it through a simple JMX manager application. Although it is helpful to run the first open MBean example before this example, it is not obligatory.

We develop a sample open MBean that uses some of the open data types and correctly exposes its management interface at runtime through the OpenMBean*Info classes. See the CarOpenMBean.html file in the examplesDir/current/OpenMBean2/docs directory for more detailed information on the data structure of this example.

We then develop a simple manager for exercising the open MBean, which involves:

The examplesDir/current/OpenMBean2 directory contains the following source files:

To Run Open MBean Example 2
  1. Compile all files in the examplesDir/current/OpenMBean2 directory with the javac command.

    For example, on the Solaris platform, type:


    $ cd examplesDir/current/OpenMBean2/
    $ javac -classpath classpath *.java
    
  2. Run the agent class that interacts with the open MBean:


    $ java -classpath classpath Agent
    
  3. Open a second terminal window and change to the OpenMBean2 example directory:

    For example, on the Solaris platform, type:


    $ cd examplesDir/current/OpenMBean2/
    
  4. Run the manager class:


    $ java -classpath classpath Manager
    

    Interact with the manager through the standard input and output in the window where it was started. The Manager class displays information about each management step and waits for your input before continuing.