Java Reference
In-Depth Information
System.out.println("\n>>> REGISTERING PhoneCard1 MBean");
ObjectName phoneCard1Name = new
ObjectName("JMXBookAgent:name=phoneCard,slot=1");
client.createMBean( "jmxbook.ch11.PhoneCard",
phoneCard1Name,
params,
sig );
//register the second PhoneCard
params[0] = new Integer(2);
System.out.println("\n>>> REGISTERING PhoneCard2 MBean");
ObjectName phoneCard2Name = new
ObjectName( "JMXBookAgent:name=phoneCard,slot=2" );
client.createMBean( "jmxbook.ch11.PhoneCard",
phoneCard2Name,
params,
sig );
//register the FaxCard
System.out.println("\n>>> REGISTERING FaxCard MBean");
ObjectName faxCardName = new
ObjectName( "JMXBookAgent:name=faxCard" );
client.createMBean( "jmxbook.ch11.FaxCard",faxCardName );
//register the RoutingTable
System.out.println("\n>>> REGISTERING RoutingTable MBean");
ObjectName routingTableName = new
ObjectName( "JMXBookAgent:name=routingTable" );
client.createMBean("jmxbook.ch11.RoutingTable",
routingTableName);
}
catch(Exception e)
{
e.printStackTrace();
System.out.println("Error Registering MBeans");
}
}
In this method, you create four MBeans in the agent (two PhoneCard MBeans,
one FaxCard MBean, and one RoutingTable MBean). Notice that the create-
MBean() invocation for the phone cards requires more parameters than the fax or
routing table MBeans. This is the case because the PhoneCard MBean constructor
requires an integer to define the slot number for the card.
Also note that an Integer object, not an int , is used as the parameter for
the constructor to the phone card. This is a different signature than that of the
Search WWH ::




Custom Search