001: /*
002: * JBoss, Home of Professional Open Source.
003: * Copyright 2006, Red Hat Middleware LLC, and individual contributors
004: * as indicated by the @author tags. See the copyright.txt file in the
005: * distribution for a full listing of individual contributors.
006: *
007: * This is free software; you can redistribute it and/or modify it
008: * under the terms of the GNU Lesser General Public License as
009: * published by the Free Software Foundation; either version 2.1 of
010: * the License, or (at your option) any later version.
011: *
012: * This software is distributed in the hope that it will be useful,
013: * but WITHOUT ANY WARRANTY; without even the implied warranty of
014: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
015: * Lesser General Public License for more details.
016: *
017: * You should have received a copy of the GNU Lesser General Public
018: * License along with this software; if not, write to the Free
019: * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
020: * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
021: */
022: package javax.management;
023:
024: /**
025: * A notification sent by the MBeanServer delegate when an MBean is
026: * registered or unregisterd.<p>
027: *
028: * NOTE: The values from the spec are wrong, the real values are<b>
029: * REGISTRATION_NOTIFICATION = "JMX.mbean.registered"<b>
030: * UNREGISTRATION_NOTIFICATION = "JMX.mbean.registered"
031: *
032: * <p><b>Revisions:</b>
033: * <p><b>20020315 Adrian Brock:</b>
034: * <ul>
035: * <li>Spec has wrong values for notification values
036: * </ul>
037: * <p><b>20020711 Adrian Brock:</b>
038: * <ul>
039: * <li> Serialization </li>
040: * </ul>
041: *
042: * @author <a href="mailto:Adrian.Brock@HappeningTimes.com">Adrian Brock</a>.
043: * @version $Revision: 57200 $
044: */
045: public class MBeanServerNotification extends Notification {
046: // Constants ---------------------------------------------------
047:
048: private static final long serialVersionUID = 2876477500475969677L;
049:
050: /**
051: * Notification type sent at MBean registration
052: */
053: public static final java.lang.String REGISTRATION_NOTIFICATION = "JMX.mbean.registered";
054:
055: /**
056: * Notification type sent at MBean registration
057: */
058: public static final java.lang.String UNREGISTRATION_NOTIFICATION = "JMX.mbean.unregistered";
059:
060: // Attributes --------------------------------------------------
061:
062: /**
063: * The object name of the mbean being (un)registered
064: */
065: private ObjectName objectName = null;
066:
067: // Static ------------------------------------------------------
068:
069: // Constructors ------------------------------------------------
070:
071: /**
072: * Construct a new MBeanServer notification
073: *
074: * @param type the type of notification to construct
075: * @param source the source of the notification
076: * @param sequence the sequence number of the notification
077: * @param objectName the object name of the mbean being (un)registered
078: */
079: public MBeanServerNotification(String type, Object source,
080: long sequence, ObjectName objectName) {
081: super (type, source, sequence);
082: this .objectName = objectName;
083: }
084:
085: // Public ------------------------------------------------------
086:
087: /**
088: * Get the object name of the mbean being (un)registered
089: *
090: * @return the object name
091: */
092: public ObjectName getMBeanName() {
093: return objectName;
094: }
095:
096: /**
097: * @return human readable string.
098: */
099: public String toString() {
100: StringBuffer buffer = new StringBuffer(50);
101: buffer.append(getClass().getName()).append(":");
102: buffer.append(" notificationType=").append(getType());
103: buffer.append(" source=").append(getSource());
104: buffer.append(" seq-no=").append(getSequenceNumber());
105: buffer.append(" time=").append(getTimeStamp());
106: buffer.append(" message=").append(getMessage());
107: buffer.append(" objectName=").append(getMBeanName());
108: buffer.append(" userData=").append(getUserData());
109: return buffer.toString();
110: }
111:
112: // X Implementation --------------------------------------------
113:
114: // Y Overrides -------------------------------------------------
115:
116: // Protected ---------------------------------------------------
117:
118: // Private -----------------------------------------------------
119:
120: // Inner classes -----------------------------------------------
121: }
|