Java Reference
In-Depth Information
constructor defined in the object itself. The reflection capabilities used in the
agent will reconcile the object to the primitive type where required.
In addition, the client object being used is an RmiConnectorClient instance
acquired from the RMIClientFactory class that you have been using throughout
the topic. It is a global reference in the RelationMain class.
Now that the code for MBeans representing the system components is fin-
ished, you will proceed to define the objects required for the relation. We won't
dissect particular classes and interfaces in the javax.management.relation pack-
age; rather, we will introduce them as we need them in code. In addition, the rela-
tion package contains more classes than we will discuss; you can examine the API
in the javadoc later.
11.3.2
Defining the relation
Now it is time to create the objects that will help you create the relationship we
have described for this scenario. Before you can create a Relation object, you
need to create a RelationType object. And before you can create the Relation-
Type , you must be able to populate it with an array of RoleInfo objects that
represent the role information of the relation type. In the next section, you
will create an array of role information needed to build your controller appli-
cation relationship.
Creating the RoleInfo objects
For this example, you need to describe three roles: VoiceProcessor , FaxProces-
sor , and CallRouter . The VoiceProcessor role can include from 1 to 10 PhoneCard
MBeans. The FaxProcessor role is restricted to one FaxBoard MBean, and the
CallRouter is limited to one RoutingTable MBean. This follows the architectural
model as described in the example description.
The relation service will use this role information to ensure that the roles used
in a relation follow their constraints. Listing 11.5 is the createRoleInfoArray()
method from the RelationMain class. It creates the three named RoleInfo objects
and places them into an array. An array is used because that is the form needed
to later create the RelationType object for this example.
Listing 11.5
The createRoleInfoArray() method from RelationMain.java
public RoleInfo[] createRoleInfoArray()
{
RoleInfo[] roleInfoArray = new RoleInfo[3];
try
Search WWH ::




Custom Search