001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. See the NOTICE file distributed with
004: * this work for additional information regarding copyright ownership.
005: * The ASF licenses this file to You under the Apache License, Version 2.0
006: * (the "License"); you may not use this file except in compliance with
007: * the License. You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: */
017:
018: package org.apache.tomcat.util.modeler;
019:
020: import java.io.Serializable;
021:
022: import javax.management.MBeanNotificationInfo;
023:
024: /**
025: * <p>Internal configuration information for a <code>Notification</code>
026: * descriptor.</p>
027: *
028: * @author Craig R. McClanahan
029: * @version $Revision: 467222 $ $Date: 2006-10-24 05:17:11 +0200 (mar., 24 oct. 2006) $
030: */
031:
032: public class NotificationInfo extends FeatureInfo implements
033: Serializable {
034: static final long serialVersionUID = -6319885418912650856L;
035:
036: // ----------------------------------------------------- Instance Variables
037:
038: /**
039: * The <code>ModelMBeanNotificationInfo</code> object that corresponds
040: * to this <code>NotificationInfo</code> instance.
041: */
042: transient MBeanNotificationInfo info = null;
043: protected String notifTypes[] = new String[0];
044:
045: // ------------------------------------------------------------- Properties
046:
047: /**
048: * Override the <code>description</code> property setter.
049: *
050: * @param description The new description
051: */
052: public void setDescription(String description) {
053: super .setDescription(description);
054: this .info = null;
055: }
056:
057: /**
058: * Override the <code>name</code> property setter.
059: *
060: * @param name The new name
061: */
062: public void setName(String name) {
063: super .setName(name);
064: this .info = null;
065: }
066:
067: /**
068: * The set of notification types for this MBean.
069: */
070: public String[] getNotifTypes() {
071: return (this .notifTypes);
072: }
073:
074: // --------------------------------------------------------- Public Methods
075:
076: /**
077: * Add a new notification type to the set managed by an MBean.
078: *
079: * @param notifType The new notification type
080: */
081: public void addNotifType(String notifType) {
082:
083: synchronized (notifTypes) {
084: String results[] = new String[notifTypes.length + 1];
085: System.arraycopy(notifTypes, 0, results, 0,
086: notifTypes.length);
087: results[notifTypes.length] = notifType;
088: notifTypes = results;
089: this .info = null;
090: }
091:
092: }
093:
094: /**
095: * Create and return a <code>ModelMBeanNotificationInfo</code> object that
096: * corresponds to the attribute described by this instance.
097: */
098: public MBeanNotificationInfo createNotificationInfo() {
099:
100: // Return our cached information (if any)
101: if (info != null)
102: return (info);
103:
104: // Create and return a new information object
105: info = new MBeanNotificationInfo(getNotifTypes(), getName(),
106: getDescription());
107: //Descriptor descriptor = info.getDescriptor();
108: //addFields(descriptor);
109: //info.setDescriptor(descriptor);
110: return (info);
111:
112: }
113:
114: /**
115: * Return a string representation of this notification descriptor.
116: */
117: public String toString() {
118:
119: StringBuffer sb = new StringBuffer("NotificationInfo[");
120: sb.append("name=");
121: sb.append(name);
122: sb.append(", description=");
123: sb.append(description);
124: sb.append(", notifTypes=");
125: sb.append(notifTypes.length);
126: sb.append("]");
127: return (sb.toString());
128:
129: }
130:
131: }
|