1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package org.apache.commons.modeler;
19
20
21 import java.io.Serializable;
22
23 import javax.management.Descriptor;
24 import javax.management.modelmbean.ModelMBeanNotificationInfo;
25
26
27 /***
28 * <p>Internal configuration information for a <code>Notification</code>
29 * descriptor.</p>
30 *
31 * @author Craig R. McClanahan
32 * @version $Revision: 155428 $ $Date: 2005-02-26 08:12:25 -0500 (Sat, 26 Feb 2005) $
33 */
34
35 public class NotificationInfo extends FeatureInfo implements Serializable {
36 static final long serialVersionUID = -6319885418912650856L;
37
38
39
40
41 /***
42 * The <code>ModelMBeanNotificationInfo</code> object that corresponds
43 * to this <code>NotificationInfo</code> instance.
44 */
45 transient ModelMBeanNotificationInfo info = null;
46 protected String notifTypes[] = new String[0];
47
48
49
50
51 /***
52 * Override the <code>description</code> property setter.
53 *
54 * @param description The new description
55 */
56 public void setDescription(String description) {
57 super.setDescription(description);
58 this.info = null;
59 }
60
61
62 /***
63 * Override the <code>name</code> property setter.
64 *
65 * @param name The new name
66 */
67 public void setName(String name) {
68 super.setName(name);
69 this.info = null;
70 }
71
72
73 /***
74 * The set of notification types for this MBean.
75 */
76 public String[] getNotifTypes() {
77 return (this.notifTypes);
78 }
79
80
81
82
83
84 /***
85 * Add a new notification type to the set managed by an MBean.
86 *
87 * @param notifType The new notification type
88 */
89 public void addNotifType(String notifType) {
90
91 synchronized (notifTypes) {
92 String results[] = new String[notifTypes.length + 1];
93 System.arraycopy(notifTypes, 0, results, 0, notifTypes.length);
94 results[notifTypes.length] = notifType;
95 notifTypes = results;
96 this.info = null;
97 }
98
99 }
100
101
102 /***
103 * Create and return a <code>ModelMBeanNotificationInfo</code> object that
104 * corresponds to the attribute described by this instance.
105 */
106 public ModelMBeanNotificationInfo createNotificationInfo() {
107
108
109 if (info != null)
110 return (info);
111
112
113 info = new ModelMBeanNotificationInfo
114 (getNotifTypes(), getName(), getDescription());
115 Descriptor descriptor = info.getDescriptor();
116 addFields(descriptor);
117 info.setDescriptor(descriptor);
118 return (info);
119
120 }
121
122
123 /***
124 * Return a string representation of this notification descriptor.
125 */
126 public String toString() {
127
128 StringBuffer sb = new StringBuffer("NotificationInfo[");
129 sb.append("name=");
130 sb.append(name);
131 sb.append(", description=");
132 sb.append(description);
133 sb.append(", notifTypes=");
134 sb.append(notifTypes.length);
135 sb.append("]");
136 return (sb.toString());
137
138 }
139
140
141 }