KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > tomcat > util > modeler > NotificationInfo


1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one or more
3  * contributor license agreements. See the NOTICE file distributed with
4  * this work for additional information regarding copyright ownership.
5  * The ASF licenses this file to You under the Apache License, Version 2.0
6  * (the "License"); you may not use this file except in compliance with
7  * the License. You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */

17
18
19 package org.apache.tomcat.util.modeler;
20
21
22 import java.io.Serializable JavaDoc;
23
24 import javax.management.MBeanNotificationInfo JavaDoc;
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: 467222 $ $Date: 2006-10-24 05:17:11 +0200 (mar., 24 oct. 2006) $
33  */

34
35 public class NotificationInfo extends FeatureInfo implements Serializable JavaDoc {
36     static final long serialVersionUID = -6319885418912650856L;
37
38     // ----------------------------------------------------- Instance Variables
39

40
41     /**
42      * The <code>ModelMBeanNotificationInfo</code> object that corresponds
43      * to this <code>NotificationInfo</code> instance.
44      */

45     transient MBeanNotificationInfo JavaDoc info = null;
46     protected String JavaDoc notifTypes[] = new String JavaDoc[0];
47
48     // ------------------------------------------------------------- Properties
49

50
51     /**
52      * Override the <code>description</code> property setter.
53      *
54      * @param description The new description
55      */

56     public void setDescription(String JavaDoc 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 JavaDoc 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 JavaDoc[] getNotifTypes() {
77         return (this.notifTypes);
78     }
79
80
81     // --------------------------------------------------------- Public Methods
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 JavaDoc notifType) {
90
91         synchronized (notifTypes) {
92             String JavaDoc results[] = new String JavaDoc[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 MBeanNotificationInfo JavaDoc createNotificationInfo() {
107
108         // Return our cached information (if any)
109
if (info != null)
110             return (info);
111
112         // Create and return a new information object
113
info = new MBeanNotificationInfo JavaDoc
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 JavaDoc toString() {
127
128         StringBuffer JavaDoc sb = new StringBuffer JavaDoc("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 }
142
Popular Tags