The examplesDir/BaseAgent/ directory contains the source file of the BaseAgent application. Compile the BaseAgent.java file in this directory with the javac command. For example, on the Solaris platform, you would type:
$ cd examplesDir/BaseAgent/ $ javac -classpath classpath *.java |
Again, we don't need the MBean classes at compile time, but they will be needed at run-time, since we don't use a dynamic class loader. You will need to have compiled the standard and dynamic MBean classes as described in "Running the Standard MBean Example" and "Running the Dynamic MBean Example". If you wish to load any other class in the base agent, you must include its directory or jar file in the classpath. To run the example, update your classpath to find the MBeans and launch the agent class:
$ java -classpath classpath:../StandardMBean:../DynamicMBean BaseAgent |
Since the base agent enables internal tracing (see Example 5-1), you can also set the trace level and trace output on the command line. The tracing mechanism is covered in the Java Dynamic Management Kit 4.1 Tools Reference guide and in the Javadoc API of the Trace class. The simplest way to get the default tracing is to specify the filename for a trace log on the java command line:
$ java -classpath classpath -DTRACE_OUTPUT=filename BaseAgent |
Besides any trace information, this agent displays output for the three types of MBean creation.
When the connection MBeans have been created, it is possible to connect to the agent through one of the protocols. The HTTP and RMI connector servers communicate with connector clients in manager applications, as will be done in some of the agent service example. If you connect to the base agent through the HTML adaptor, you could go through the same procedures as with the minimal agent.
When you are finished, type <Enter> to remove all MBeans from the agent and exit the agent application.