Java Dynamic Management Kit 5.0 Tutorial

Running the Model MBean Example

The examplesDir/ModelMBean directory contains the file that is the target object of the sample model MBean. This directory also contains a simple notification listener class and the agent application, ModelAgent, which instantiates, configures, and manages a model MBean.

The model MBean itself is given by the RequiredModelMBean class defined in the package provided in the runtime JAR file (jdmkrt.jar) of the Java Dynamic Management Kit (DMK).

To Run the Model MBean Example
  1. Compile all files in this directory with the javac command.

    For example, on the Solaris platform, type:

    $ cd examplesDir/ModelMBean/
    $ javac -classpath classpath *.java
  2. To run the example, start the agent class with the following command:

    $ java -classpath classpath ModelAgent
  3. Press Enter when the application pauses to step through the example.

    The agent application handles all input and output in this example and gives a view of the MBean at runtime.

We can then see the result of managing the resource through its exposed attributes and operations. The agent also instantiates and registers a listener object for attribute change notifications sent by the model MBean. You can see the output of this listener whenever it receives a notification, after the application has called one of the attribute setters.