01: /* JFox, the OpenSource J2EE Application Server
02: *
03: * Copyright (C) 2002 huihoo.org
04: * Distributable under GNU LGPL license
05: * See the GNU Lesser General Public License for more details.
06: */
07:
08: package example.jmx.relation;
09:
10: import javax.management.relation.RoleInfo;
11: import javax.management.relation.RelationTypeSupport;
12:
13: /**
14: *
15: * @author <a href="mailto:young_yy@hotmail.org">Young Yang</a>
16: */
17:
18: /**
19: * The "SimpleRelationType" class shows how to define a relation type, to
20: * avoid to have to describe the role infos each time and to doCreate an
21: * internal RelationTypeSupport object in the Relation Service.
22: * <P>Here an instance of SimpleRelationType will represent the relation type
23: * and be stored in the Relation Service.
24: * <P>As any class expected to represent a relation type, it has to implement
25: * the RelationType interface. It is achieved by extending the
26: * RelationTypeSupport class.
27: * <P>Another relation type extending SimpleRelationType would simply extend
28: * the class SimpleRelationType, thus inheriting the implementation of
29: * RelationType interface.
30: */
31:
32: public class SimpleRelationType extends RelationTypeSupport {
33:
34: /*
35: * -----------------------------------------------------
36: * CONSTRUCTORS
37: * -----------------------------------------------------
38: */
39:
40: public SimpleRelationType(String theRelTypeName) {
41:
42: super (theRelTypeName);
43:
44: // Defines two role infos:
45: // - primary:
46: // - element class: SimpleStandard
47: // - read: y, write: y
48: // - multiplicity: 2,2
49: // - secondary:
50: // - element class: SimpleStandard
51: // - read: y, write: n
52: // - multiplicity: 2,2
53: try {
54: RoleInfo primaryRoleInfo = new RoleInfo("primary",
55: "example.jmx.standard.SimpleStandard", true, true,
56: 2, 2, "Primary");
57: addRoleInfo(primaryRoleInfo);
58: RoleInfo secondaryRoleInfo = new RoleInfo("secondary",
59: "example.jmx.standard.SimpleStandard", true, false,
60: 2, 2, "Secondary");
61: addRoleInfo(secondaryRoleInfo);
62: } catch (Exception exc) {
63: throw new RuntimeException(exc.getMessage());
64: }
65: }
66: }
|