Java Reference
In-Depth Information
Creating the RelationType object
Listing 11.6 shows the createRelationTypes() method from the RelationMain
class. Its responsibility is to take the RoleInfo objects you just created and create
a RelationType object to register in the relation service found in the JMXBook-
Agent class.
Listing 11.6
The createRelationTypes() method from the RelationMain class
public void createRelationTypes( RoleInfo[] roleInfoArray )
{
try
{
Object[] params = new Object[2];
params[0] = "myRelationType";
params[1] = roleInfoArray;
String[] signature = new String[2];
signature[0] = "java.lang.String";
try {
signature[1] = (roleInfoArray.getClass()).getName();
}
catch (Exception exc)
{
throw exc;
}
client.invoke(relationServiceName, "createRelationType",
params, signature);
}
catch (Exception e)
{
System.out.println("Error Creating the RelationType");
e.printStackTrace();
}
}
This method creates a relation type with an array of RoleInfo objects provided as
a parameter. After creating an instance of RelationType , the method registers it
in the relation service found in the agent connected by the client object (remem-
ber that the client object is a global instance of the RmiConnectorClient from
the RelationMain class).
The parameters needed to create a relation type in the relation service are
the name of the relation type and the array of RoleInfo objects. This method
uses a global ObjectName to find the relation service on the JMXBookAgent and
invoke its createRelationType() method, passing in the name and RoleInfo
Search WWH ::




Custom Search