Sun Microsystems, Inc  JMX Agent and Instrumentation
Reference Implementation

JMX Grinder Tool for MBeans

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 the lib/jmxgrinder.jar file whose "Main-Class" is JMXGrinder. You may therefore launch the tool using the -jar option of the java 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 found

The 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 JMXGrinder

Note: 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:

JMX Grinder graphical user interface

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.

Clicking on a class in the "Introspection results" frame brings up the "JMX Properties" window:

JMX Grinder 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:


Java coffee cup logo

Copyright © 2000 Sun Microsystems, Inc., 901 San Antonio Road, Palo Alto, CA  94303, USA.
All rights reserved.