Java Reference
In-Depth Information
The constructor of this MBean requires the parameters needed to call the
constructor of its super class. The constructor requires an id for the relation, the
relation service's ObjectName value, the name of the relation type, and a Role list.
The id for the relation must be a unique value that identifies the relation within
the relation service. The relation type name corresponds to the name of the rela-
tion type, which describes the constraints for this relation. The Role s that partic-
ipate in this relation are contained within the Role list passed to the constructor.
The Role objects will be validated against the RoleInfo objects once this relation
is added to the relation service.
Notice that this MBean implements the MBeanRegistration interface in order to
get a handle on the MBean server that contains it. This implementation allows
the MBean to interact with the MBeans participating as roles in the relation. This
MBean needs to contact a particular PhoneCard or FaxCard MBean and the Rout-
ingTable MBean.
The first method exposed for the user is disablePhoneCard() . In this method
and the disableFaxCard() method, the CtlRelation MBean contacts the correct
participating MBean in order to disable a particular device and update the rout-
ing table. The disablePhoneCard() method takes an Integer as a parameter in
order to look up the appropriate PhoneCard MBean.
C
11.3.5
Adding the relation service to the JMXBookAgent class
Now that all the code is written to instantiate the Relation , you need to add the
relation service to your JMXBookAgent before you can execute your test. Listing 11.9
is a method added to the JMXBookAgent class definition that will be invoked by
the JMXBookAgent constructor. You will need to modify the constructor to invoke
the new method.
Listing 11.9
createRelationService() method added to JMXBookAgent
public void createRelationService()
{
ObjectName relationServiceName = null;
try
{
relationServiceName = new ObjectName(
"JMXBookAgent:name=relationService" );
Object[] params = new Object[1];
params[0] = new Boolean(true);
String[] signature = new String[1];
signature[0] = "boolean";
Search WWH ::




Custom Search