The examplesDir/StandardMBean directory contains the SimpleStandard.java and SimpleStandardMBean.java files which make up the MBean. This directory also contains a simple agent application which instantiates this MBean, introspects its management interface and manipulates its attributes and operations.
Compile all files in this directory with the javac command. For example, on the Solaris platform with the Korn shell, you would type:
$ cd examplesDir/StandardMBean/ $ javac -classpath classpath *.java |
To run the example, launch the agent class which will interact with the SimpleStandard MBean:
$ java -classpath classpath StandardAgent |
Type return when the application pauses to step through the example. The agent application handles all input and output in this example and gives us a view of the MBean at runtime.
We will look at how agents work in "The MBean Server in a Minimal Agent", but this example demonstrates how the MBean interface limits the view of what the MBean exposes for management. Roughly, the agent introspects the MBean interface at runtime to determine what attributes and operations are available. You then see the result of calling the getters, setters and operations.
The lesson on agents will also cover the topics of object names and exceptions which you see when running this example.