Java Reference
In-Depth Information
objects. In addition, it will ensure that the MBeans referenced in the roles are the
expected ones, and that they exist in the MBean server. The relation service will
also ensure that the same role name is not used for two different roles. If any of
these criteria are not met, the service will throw an exception when you attempt
to add the relation to the service.
11.3.7
The RelationMain main() method
The last listing from the RelationMain class is its main() method. The Relation-
Main class now contains methods to create the relation type, role information,
and roles, and also to create the relation service within a running JMXBookAgent .
The main() method coordinates the steps in the correct order. Listing 11.11 shows
the main() method.
Listing 11.11
Class definition and main() method from RelationMain
package jmxbook.ch11;
import jmxbook.ch3.RMIClientFactory;
import java.util.*;
import java.io.*;
import java.net.*;
import com.sun.jdmk.comm.*;
import javax.management.*;
import javax.management.relation.*;
public class RelationMain
{
ObjectName relationServiceName = null;
Role voiceProcessorRole = null;
Role faxProcessorRole = null;
RoleList roleList = new RoleList();
RmiConnectorClient client = null;
public RelationMain()
{
client = RMIClientFactory.getClient();
try
{
relationServiceName=new
ObjectName("JMXBookAgent:name=relationService");
}
catch(Exception e)
{
e.printStackTrace();
System.exit(0);
}
}
Search WWH ::




Custom Search