Getting Started with the Java Dynamic Management Kit 4.0

Optional: Generating Proxy MBeans

As discussed earlier in this guide, a proxy MBean is an object that represents a remote MBean to a Java Dynamic Management manager. The manager accesses an MBean by performing operations on the proxy MBean. The operations are then propagated to the MBean.

A proxy MBean is generated from its MBean by using the proxygen compiler supplied with the Java Dynamic Management Kit. A generic proxy MBean can be created by simply creating an instance and, hence, there it is not generated using the proxygen compiler. The MBean's input to proxygen must be in the form of compiled Java classes, not source files. The numerous options of this tool allow you to customize your MBeans depending on how you wish to use them in your management application.

A proxy MBean consists of two components:

For example, if you have an MBean MyClass, the proxygen compiler gives you a proxy MBean that consists of the following files:

The proxygen compiler generates Java source code, not compiled Java classes. For your proxy MBeans to be accessible to a Java manager, you have to compile the files that proxygen generates, and make sure that the compiled Java classes are stored at the location specified by the CLASSPATH environment variable of the manager, or are accessible by the class loader of the manager.

Proxy MBean Interface

A proxy MBean consists of:

The interface of a proxy MBean exposes the attributes and operations of the corresponding MBean. All operations have the same signature as in the original MBean, apart from the exceptions which are unique to the proxy MBean interface.

The generated class provides an implementation for the proxy MBean's interface. Therefore, the Java class contains the code to implement the getters, setters and operations of the proxy MBean. To do this, the Java class relies on the com.sun.jdmk.comm.RemoteMBeanServer interface. This interface specifies the API for the connector client object which the management application uses to communicate with its agents. For example, the Java class implementation of a getter operation calls the appropriate operations of the interface. Through this interface, the corresponding getter operation of the MBean is called remotely, and its result is sent back to the proxy MBean.

The generated class implements the com.sun.jdmk.Proxy interface in order to provide additional management capabilities.

As the interface is used by all connector client objects in the Java Dynamic Management Kit, all proxy MBeans can be connected to their corresponding MBean through any of the communication protocols. It also guarantees that the behavior of the proxies is not affected by how the connector client is implemented.

Using The proxygen Compiler

The proxygen compiler takes the compiled Java class of an MBean and generates the Java interface and Java proxies of a proxy MBean. The Java proxies consist of Java source code that implements the interface. To develop a Java manager with code generated by proxygen, you call the operations of the proxy MBean's interface. This allows you to remotely manipulate the corresponding MBean on an agent.

Options of the proxygen compiler enable you to modify the characteristics of the proxies you generate from an MBean. For example, options are available that enable you to generate read-only or read-write proxies. By generating a set of stubs with different characteristics from the same MBean, you can develop a Java manager whose behavior is modified at runtime, depending on which stubs are loaded. For example, when the read-only stubs are loaded, the Java manager will not be able to modify properties in the MBean.

To start proxygen, type the command for your operating environment: