Java Reference
In-Depth Information
Figure 9.2 The components of the RMI connector included in the JMX RI from Sun
Microsystems. The RMI connector uses both a server object and a client object.
rmiClient.getMBeanCount()
to acquire the number of MBeans running on the
remote MBean server. You will find every method on the
RMI
client that you
would find in the
MBeanServer
interface.
9.2.2
Creating the RMI server MBean
The server portion of the
RMI
connector is contained in the
RmiConnectorServer
class. To create the server, you need to perform the following three steps:
Create an instance of
RmiConnectorServer
using one of its four construc-
tors. The different constructors let you specify different values for the
server registration port and service name.
1
Register the connector and the MBean server.
2
Invoke the connector's
start()
method. The
start()
method tells the
server to bind to an
RMI
registry and prepare itself to receive client calls.
3
Reexamining the JMXBookAgent class
When you created the
JMXBookAgent
class in chapter 3, you gave it a
startRMI-
Connector()
method that added the
RMI
connector MBean to the agent. How-
ever, in that chapter, we did not discuss what took place in code. Listing 9.1
shows the method again; let's examine it.
Listing 9.1
The startRMIConnector() method of the JMXBookAgent class
protected void startRMIConnector()
{
RmiConnectorServer connector = new RmiConnectorServer();
ObjectName connectorName = null;