Before we can create relation instances, we need a relation type, and before we can define a relation type, we need to represent the information about its roles. This information includes:
A name string (required)
The name of the MBean class that fulfills this role (required)
Read-write permissions (the default is both readable and writable)
The multiplicity, expressed as a single range (the default is 1..1)
A description string (the default is a null string)
The name can be any string that is manipulated by the Java String class. It will be used to retrieve the corresponding MBeans when accessing a relation instance. The multiplicity is limited to the range between the minimum and maximum number of MBeans required for this role to fulfilled. The read-write permissions apply to all of the MBeans in the role, since the value of a role is read or written as a complete list.
The role information is represented by the RoleInfo class. In our example, we define two different roles:
// Define two roles in an array // - container: SimpleStandard class/read-write access/multiplicity: 1..1 // - contained: SimpleStandard class/read-write access/multiplicity: 0..n RoleInfo[] roleInfoArray = new RoleInfo[2]; String role1Name = "container"; roleInfoArray[0] = new RoleInfo( role1Name, "SimpleStandard", true, true, 1, 1, null); String role2Name = "contained"; roleInfoArray[1] = new RoleInfo( role2Name, "SimpleStandard", true, true, 0, -1, null); |
We build an array of RoleInfo objects that is intended to define a relation type, so it needs to define a valid set of roles. All role names must be unique within the array, and none of the array's elements can be null. Also, the minimum and maximum cardinalities must define a range of at least one integer.