Java Reference
In-Depth Information
try
{
connectorName = new ObjectName(
"JMXBookAgent:name=RMIConnector");
server.registerMBean( connector, connectorName );
connector.start();
}
catch(Exception e)
{
e.printStackTrace();
}
}
The JMXBookAgent class imports the com.sun.jdmk.comm package in order to
obtain the RmiConnectorServer class. It contains the classes contributed by Sun
Microsystems in Sun's JMX RI .
The class uses the default constructor of the RmiConnectorServer class. The
constructor tells the server to use the default port and service name. However, as
mentioned previously, this is not the RmiConnectorServer class's only constructor.
Table 9.1 lists the constructors and their arguments.
Table 9.1
The constructors of the RmiConnectorServer class
Constructor
Description
The default constructor
RmiConnectorServer()
Specifies a new port for binding to an RMI registry
RmiConnectorServer( int port )
Specifies a name for the object registered on the
RMI registry
RmiConnectorServer( String name)
Specifies both a new registry port and new remote
object name
RmiConnectorServer( int port,
String name)
By using one of the other constructors, you can control the RMI registry the
server will bind to, and you can change the name of the remote object that will
be registered on the registry.
9.2.3
Connecting to the RMI server
Now that we have examined a basic agent that uses an RMI connector, let's look
at the RMI connector client contained in the class RmiConnectorClient . As men-
tioned earlier, this class declares methods that correspond to every method
Search WWH ::




Custom Search