Java Reference
In-Depth Information
}
catch (Exception e)
{
System.out.println("Error Creating Roles");
e.printStackTrace();
}
}
The Role class's constructor takes a role name and a role value that is a list of
ObjectName instances that reference the MBeans belonging to this role. The array
list of ObjectName instances must match the names allowed by the RoleInfo
objects you created earlier with the same name. Note that the VoiceProcessor role
has two PhoneCard MBeans (the role could contain up to 10) and that the other
two roles contain a single ObjectName . This arrangement matches the RoleInfo
classes created earlier. Once the roles are created, you add each of the roles to a
list to be used when you create your Relation object.
11.3.4
Creating the Relation MBean
Up to this point, you have modeled all the scenario devices with MBeans and
created a RelationType and Role instances. Now it is time to create the Relation
object. As mentioned earlier in the chapter, relations can be either internal or
external. You're creating an external relation, so you must create a relation
MBean. A relation MBean implements the RelationSupportMBean interface and
represents the actual relationship between existing MBeans participating as roles.
External relations are useful because they can perform operations on their role
values (the participating MBeans). The relation MBean will associate the roles
and expose methods that work on those associations.
The RelationSupport class provides methods that the relation service will use
to validate the relation against its relation type. You will see this process shortly.
The CtlRelationMBean interface is as follows:
package jmxbook.ch11;
import javax.management.*;
import javax.management.relation.*;
public interface CtlRelationMBean extends RelationSupportMBean
{
public void disablePhoneCard(int cardNum)throws MBeanException;
public void disableFaxCard()throws MBeanException;
}
Search WWH ::




Custom Search