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