Java Reference
In-Depth Information
available on an MBean server. The following example shows you how to connect
to the RMI connector server running on the JMXBookAgent .
Reexamining the RMIClientFactory class
In chapter 3, you created the RMIClientFactory class. Recall that you use this
class to acquire an RMI client in which to contact your JMXBookAgent class.
Listing 9.2 lists the class again.
Listing 9.2
RMIClientFactory.java
package jmxbook.ch3;
import javax.management.*;
import com.sun.jdmk.comm.*;
public class RMIClientFactory
{
public static RmiConnectorClient getClient()
{
RmiConnectorClient client = new RmiConnectorClient();
RmiConnectorAddress address = new RmiConnectorAddress();
System.out.println("\t\tTYPE\t= " +
address.getConnectorType ());
System.out.println("\t\tPORT\t= " + address.getPort());
System.out.println("\t\tHOST\t= " + address.getHost());
System.out.println("\t\tSERVER\t= " + address.getName());
try
{
client.connect( address );
}
catch( Exception e )
{
e.printStackTrace();
}
return client;
}
}
To tell the RmiConnectorClient object where to find the RmiConnectorServer , you
need to use the RmiConnectorAddress class. This class encapsulates host, port,
and lookup name values that tell the client object where to find the RMI registry
and look up the remote object of the RMI connector. If you created the RmiCon-
nectorServer using the default constructor, then you can create the address
Search WWH ::




Custom Search