![]() |
JMX Agent and Instrumentation Reference Implementation |
The JMX Grinder tool provides a quick way for developers of JMX manageable resources to test their objects against the JMX specification. Target objects are checked for the design patterns set forth in the instrumentation level of JMX. The tool detects standard MBeans and dynamic MBeans; other objects are either non-compliant or unresolved (class not found).The JMX Grinder allows you to develop and test standard MBeans without necessarily having the agent reference implementation available. Testing dynamic MBeans, however, requires that the JMX RI classes be found in the classpath. The tool also reports on the management interface exposed by a compliant MBean.
When an object is non-compliant, the tool indicates the design pattern which have not been followed. When the object is a standard MBean, all constructors, operations, and attributes are listed. For dynamic MBeans, only the constructors are given since objects are introspected statically, not instantiated. Constructors and operations are identified by their full method signature, and attributes by their type and read/write access.
The JMX Grinder only runs on the Java 2 virtual machine.
Set Up
To set up a directory for testing the JMX Grinder, type these commands from the main directory of the software bundle:
prompt% mkdir test; cd test prompt% cp ../examples/StandardMBean/SimpleStandard.java . prompt% cp ../examples/StandardMBean/SimpleStandardMBean.java . prompt% cp ../examples/DynamicMBean/SimpleDynamic.java . prompt% javac -classpath ../lib/jmxri.jar *.java prompt% cd ..
Command Line Interface
The JMX Grinder tool is fully contained in thelib/jmxgrinder.jar
file whose "Main-Class" isJMXGrinder
. You may therefore launch the tool using the-jar
option of thejava
command (when using version 1.2.x).The tool supports command line arguments, and when any are detected, the tool will be lauched in command line mode. Use the
-help
option to display the usage of the other command line options:
prompt% java -classpath lib/jmxgrinder.jar JMXGrinder -help -OR- prompt% java -jar lib/jmxgrinder.jar -help JMXGrinder 1.0 Copyright 2000 Sun Microsystems, Inc., 901 San Antonio Road, Palo Alto, California, 94303, U.S.A. All Rights Reserved. JMXGrinder -version Prints out version information for this release JMXGrinder [-verbose] MBean1 ... Checks classes for both standard and dynamic MBean compliance -verbose Prints out detailed information about constructors, operations, and attributes for each MBean, and then prints a count of each MBean category; ommitting this option only prints out the summary count MBean1 ... The list of MBeans to be checked; MBeans can either be standard, dynamic, non-compliant or unresolved; unresolved applies to classes which cannot be foundThe following examples demonstrate normal and verbose output. All classes to be checked and their corresponding interfaces must be found in the classpath, otherwise they will appear as unresolved.
Note: The JMX reference implementation classes must also be found in the classpath when testing dynamic MBeans. These commands are launched from the main directory of the software bundle.
prompt% java -cp lib/jmxgrinder.jar:lib/jmxri.jar:test \ JMXGrinder SimpleStandard SimpleDynamic SimpleStandard - JMX Standard MBean compliant SimpleDynamic - JMX Dynamic MBean compliant Summary: JMX Standard MBean compliant : 1 JMX Dynamic MBean compliant : 1 Not JMX MBean compliant : 0 Could not resolve class : 0 ------------------------------------- Total checked : 2 -------------------------------------
prompt% java -cp lib/jmxgrinder.jar:lib/jmxri.jar:test \ JMXGrinder -verbose SimpleStandard SimpleDynamic Class name : SimpleStandard Constructor 1 : SimpleStandard( ) Operation 1 : void reset( ) Attribute 1 : Name=NbChanges Type=java.lang.Integer isReadable=true isWriteable=false Attribute 2 : Name=State Type=java.lang.String isReadable=true isWriteable=true SimpleStandard - JMX Standard MBean compliant Class name : SimpleDynamic Constructor 1 : SimpleDynamic( ) SimpleDynamic - JMX Dynamic MBean compliant Summary: JMX Standard MBean compliant : 1 JMX Dynamic MBean compliant : 1 Not JMX MBean compliant : 0 Could not resolve class : 0 ------------------------------------- Total checked : 2 -------------------------------------
Graphical Interface
Calling the JMX Grinder without any command line options launches the graphical interface for the tool:
prompt% java -cp lib/jmxgrinder.jar:lib/jmxri.jar:test JMXGrinderNote: The classpath must contain the JMX reference implementation classes in order for the JMX Grinder to test dynamic MBeans.
The main window of the tool contains:
- A text field for entering a new classpath
- The frame of visible classes for selecting directories or classes to be checked; multiple selections are possible by holding down the Shift or Control key when clicking on items in this frame
- A frame containing four tabs, one for each results category; selecting items in a tab will display its information in a Properties window (see below)
- A status bar containing the total number of classes in each results category
The "Class Path" field initially contains the classpath effective in the Java virtual machine where the tool is launched. You may enter a new classpath and click the "Load" button: this will replace the current directories in the "Visible classes" frame.
The results of all verifications are cumulated in the "Introspection results" frame, with each tab showing all classes in the corresponding category. The total count for each category is displayed in the status bar at the bottom of the window. When loading a new classpath, you can clear the contents of this frame by selecting the "File - Clear results tree" menu item.
- To check classes individually, double click on their name.
- To check all classes in a directory and recursive subdirectories, select (single-click) a directory folder when it is not expanded. Then click on the "Check selected classes" button in the lower right-hand corner of the window.
- To check multiple classes and directories at a time, expand the view so that they are all visible and hold down the Control key while clicking on each. Then click on the "Check selected classes" button in the lower right-hand corner of the window.
Clicking on a class in the "Introspection results" frame brings up the "JMX Properties" window:
The contents of the "JMX Properties" are updated every time you select another class from a results category. It displays all information that was discovered about a class:
- For standard MBeans, this is the full management interface as determined by static introspection
- For dynamic MBeans, this is just the class constructors because all other information can only be determined dynamically
- For non-compliant and unresolved classes, this window contains the name of the exception that was raised while loading or checking the class; this also includes a message which can give the reason for non-compliance
Copyright © 2000
Sun Microsystems, Inc.,
901 San Antonio Road, Palo Alto, CA 94303, USA.
All rights reserved.