Java Reference
In-Depth Information
ObjectName relationMBeanName = new ObjectName(
"JMXBookAgent:type=RelationMBean");
Object[] params = new Object[4];
params[0] = "RelationId1";
params[1] = relationServiceName;
params[2] = "myRelationType";
params[3] = roleList;
String[] sig = new String[4];
sig[0] = "java.lang.String";
sig[1] = relationServiceName.getClass().getName();
sig[2] = "java.lang.String";
sig[3] = roleList.getClass().getName();
B
Create relation
MBean
client.createMBean( "jmxbook.ch11.CtlRelation",
relationMBeanName, params, sig );
//add the new relation
params = new Object[1];
sig = new String[1];
params[0] = relationMBeanName ;
sig[0] = "javax.management.ObjectName";
C
Invoke
addRelation()
method of
MBeanServer
client.invoke( relationServiceName, "addRelation",
params, sig );
}
catch(Exception e)
{
System.out.println("Could not create the relation");
e.printStackTrace();
}
}
B
The first thing you do in this method is instantiate the CtlRelation MBean and
add it to the JMXBookAgent . You pass the arguments to use in its constructor to
the createMBean() method of the client object. Remember that you must pass it
a relation unique id, the relation service ObjectName value, and the list of Role
objects participating in the relation.
The addRelation() method in the relation service can throw exceptions for sev-
eral reasons. If the relation service is not registered or a role does not exist in the
relation type, an exception will be thrown. If the id chosen is already used by
another relation, or if the relation type does not exist in the relation service, an
exception will occur.
The relation service will do validity checks when the relation is added to
ensure that the multiplicity for the roles matches that defined in the RoleInfo
C
Search WWH ::




Custom Search