Java Reference
In-Depth Information
Figure 3.2 The
JMXBookAgent
showing the different parts of the RMI connector
with example
createMBean()
method delegation from client to server.
3.2 Writing the JMXBookAgent class
Writing the
JMXBookAgent
class is not that difficult (as illustrated by the
HelloAgent
from chapter 2). The process of completing the class is broken into four parts:
■
Writing the class definition and constructor
■
Adding the
HTML
adapter
■
Adding the
RMI
connector
■
Adding the
main()
method
3.2.1
Class definition and constructor
The first step includes declaring the class and writing its constructor. Listing 3.1
shows the class body and constructor in the source file JMXBookAgent.java.
Notice that the package is
jmxbook.ch3
.
Listing 3.1
The first part of JMXBookAgent.java
package jmxbook.ch3;
import com.sun.jdmk.comm.*;
import javax.management.*;
public class JMXBookAgent
{