The examplesDir/ModelMBean directory contains the TestBean.java 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 javax.management.modelmbean package provided in the runtime JAR file (jdmkrt.jar) of the Java Dynamic Management Kit (DMK).
Compile all files in this directory with the javac command.
For example, on the Solaris platform, type:
$ cd examplesDir/ModelMBean/ $ javac -classpath classpath *.java
To run the example, start the agent class with the following command:
$ java -classpath classpath ModelAgent
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.