jdk/src/share/classes/javax/management/MBeanServerNotification.java
author xdono
Thu, 02 Oct 2008 19:58:32 -0700
changeset 1247 b4c26443dee5
parent 1003 b2f6b7e00c29
child 1570 4165709c91e3
permissions -rw-r--r--
6754988: Update copyright year Summary: Update for files that have been modified starting July 2008 Reviewed-by: ohair, tbell
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
1247
b4c26443dee5 6754988: Update copyright year
xdono
parents: 1003
diff changeset
     2
 * Copyright 1999-2008 Sun Microsystems, Inc.  All Rights Reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
90ce3da70b43 Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.  Sun designates this
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
90ce3da70b43 Initial load
duke
parents:
diff changeset
     9
 * by Sun in the LICENSE file that accompanied this code.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    21
 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    22
 * CA 95054 USA or visit www.sun.com if you need additional information or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    23
 * have any questions.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
package javax.management;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
 * Represents a notification emitted by the MBean server through the MBeanServerDelegate MBean.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
 * The MBean Server emits the following types of notifications: MBean registration, MBean
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
 * de-registration.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
 * <P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
 * To receive to MBeanServerNotifications, you need to be declared as listener to
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
 * the {@link javax.management.MBeanServerDelegate javax.management.MBeanServerDelegate} MBean
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
 * that represents the MBeanServer. The ObjectName of the MBeanServerDelegate is:
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
 * <CODE>JMImplementation:type=MBeanServerDelegate</CODE>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
 * @since 1.5
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
 */
1003
b2f6b7e00c29 6689505: Improve MBeanServerNotification.toString
dfuchs
parents: 2
diff changeset
    41
public class MBeanServerNotification extends Notification {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
1003
b2f6b7e00c29 6689505: Improve MBeanServerNotification.toString
dfuchs
parents: 2
diff changeset
    44
    /* Serial version */
b2f6b7e00c29 6689505: Improve MBeanServerNotification.toString
dfuchs
parents: 2
diff changeset
    45
    private static final long serialVersionUID = 2876477500475969677L;
b2f6b7e00c29 6689505: Improve MBeanServerNotification.toString
dfuchs
parents: 2
diff changeset
    46
    /**
b2f6b7e00c29 6689505: Improve MBeanServerNotification.toString
dfuchs
parents: 2
diff changeset
    47
     * Notification type denoting that an MBean has been registered.
b2f6b7e00c29 6689505: Improve MBeanServerNotification.toString
dfuchs
parents: 2
diff changeset
    48
     * Value is "JMX.mbean.registered".
b2f6b7e00c29 6689505: Improve MBeanServerNotification.toString
dfuchs
parents: 2
diff changeset
    49
     */
b2f6b7e00c29 6689505: Improve MBeanServerNotification.toString
dfuchs
parents: 2
diff changeset
    50
    public static final String REGISTRATION_NOTIFICATION =
b2f6b7e00c29 6689505: Improve MBeanServerNotification.toString
dfuchs
parents: 2
diff changeset
    51
            "JMX.mbean.registered";
b2f6b7e00c29 6689505: Improve MBeanServerNotification.toString
dfuchs
parents: 2
diff changeset
    52
    /**
b2f6b7e00c29 6689505: Improve MBeanServerNotification.toString
dfuchs
parents: 2
diff changeset
    53
     * Notification type denoting that an MBean has been unregistered.
b2f6b7e00c29 6689505: Improve MBeanServerNotification.toString
dfuchs
parents: 2
diff changeset
    54
     * Value is "JMX.mbean.unregistered".
b2f6b7e00c29 6689505: Improve MBeanServerNotification.toString
dfuchs
parents: 2
diff changeset
    55
     */
b2f6b7e00c29 6689505: Improve MBeanServerNotification.toString
dfuchs
parents: 2
diff changeset
    56
    public static final String UNREGISTRATION_NOTIFICATION =
b2f6b7e00c29 6689505: Improve MBeanServerNotification.toString
dfuchs
parents: 2
diff changeset
    57
            "JMX.mbean.unregistered";
b2f6b7e00c29 6689505: Improve MBeanServerNotification.toString
dfuchs
parents: 2
diff changeset
    58
    /**
b2f6b7e00c29 6689505: Improve MBeanServerNotification.toString
dfuchs
parents: 2
diff changeset
    59
     * @serial The object names of the MBeans concerned by this notification
b2f6b7e00c29 6689505: Improve MBeanServerNotification.toString
dfuchs
parents: 2
diff changeset
    60
     */
b2f6b7e00c29 6689505: Improve MBeanServerNotification.toString
dfuchs
parents: 2
diff changeset
    61
    private final ObjectName objectName;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
1003
b2f6b7e00c29 6689505: Improve MBeanServerNotification.toString
dfuchs
parents: 2
diff changeset
    63
    /**
b2f6b7e00c29 6689505: Improve MBeanServerNotification.toString
dfuchs
parents: 2
diff changeset
    64
     * Creates an MBeanServerNotification object specifying object names of
b2f6b7e00c29 6689505: Improve MBeanServerNotification.toString
dfuchs
parents: 2
diff changeset
    65
     * the MBeans that caused the notification and the specified notification
b2f6b7e00c29 6689505: Improve MBeanServerNotification.toString
dfuchs
parents: 2
diff changeset
    66
     * type.
b2f6b7e00c29 6689505: Improve MBeanServerNotification.toString
dfuchs
parents: 2
diff changeset
    67
     *
b2f6b7e00c29 6689505: Improve MBeanServerNotification.toString
dfuchs
parents: 2
diff changeset
    68
     * @param type A string denoting the type of the
b2f6b7e00c29 6689505: Improve MBeanServerNotification.toString
dfuchs
parents: 2
diff changeset
    69
     * notification. Set it to one these values: {@link
b2f6b7e00c29 6689505: Improve MBeanServerNotification.toString
dfuchs
parents: 2
diff changeset
    70
     * #REGISTRATION_NOTIFICATION}, {@link
b2f6b7e00c29 6689505: Improve MBeanServerNotification.toString
dfuchs
parents: 2
diff changeset
    71
     * #UNREGISTRATION_NOTIFICATION}.
b2f6b7e00c29 6689505: Improve MBeanServerNotification.toString
dfuchs
parents: 2
diff changeset
    72
     * @param source The MBeanServerNotification object responsible
b2f6b7e00c29 6689505: Improve MBeanServerNotification.toString
dfuchs
parents: 2
diff changeset
    73
     * for forwarding MBean server notification.
b2f6b7e00c29 6689505: Improve MBeanServerNotification.toString
dfuchs
parents: 2
diff changeset
    74
     * @param sequenceNumber A sequence number that can be used to order
b2f6b7e00c29 6689505: Improve MBeanServerNotification.toString
dfuchs
parents: 2
diff changeset
    75
     * received notifications.
b2f6b7e00c29 6689505: Improve MBeanServerNotification.toString
dfuchs
parents: 2
diff changeset
    76
     * @param objectName The object name of the MBean that caused the
b2f6b7e00c29 6689505: Improve MBeanServerNotification.toString
dfuchs
parents: 2
diff changeset
    77
     * notification.
b2f6b7e00c29 6689505: Improve MBeanServerNotification.toString
dfuchs
parents: 2
diff changeset
    78
     *
b2f6b7e00c29 6689505: Improve MBeanServerNotification.toString
dfuchs
parents: 2
diff changeset
    79
     */
b2f6b7e00c29 6689505: Improve MBeanServerNotification.toString
dfuchs
parents: 2
diff changeset
    80
    public MBeanServerNotification(String type, Object source,
b2f6b7e00c29 6689505: Improve MBeanServerNotification.toString
dfuchs
parents: 2
diff changeset
    81
            long sequenceNumber, ObjectName objectName) {
b2f6b7e00c29 6689505: Improve MBeanServerNotification.toString
dfuchs
parents: 2
diff changeset
    82
        super(type, source, sequenceNumber);
b2f6b7e00c29 6689505: Improve MBeanServerNotification.toString
dfuchs
parents: 2
diff changeset
    83
        this.objectName = objectName;
b2f6b7e00c29 6689505: Improve MBeanServerNotification.toString
dfuchs
parents: 2
diff changeset
    84
    }
b2f6b7e00c29 6689505: Improve MBeanServerNotification.toString
dfuchs
parents: 2
diff changeset
    85
b2f6b7e00c29 6689505: Improve MBeanServerNotification.toString
dfuchs
parents: 2
diff changeset
    86
    /**
b2f6b7e00c29 6689505: Improve MBeanServerNotification.toString
dfuchs
parents: 2
diff changeset
    87
     * Returns the  object name of the MBean that caused the notification.
b2f6b7e00c29 6689505: Improve MBeanServerNotification.toString
dfuchs
parents: 2
diff changeset
    88
     *
b2f6b7e00c29 6689505: Improve MBeanServerNotification.toString
dfuchs
parents: 2
diff changeset
    89
     * @return the object name of the MBean that caused the notification.
b2f6b7e00c29 6689505: Improve MBeanServerNotification.toString
dfuchs
parents: 2
diff changeset
    90
     */
b2f6b7e00c29 6689505: Improve MBeanServerNotification.toString
dfuchs
parents: 2
diff changeset
    91
    public ObjectName getMBeanName() {
b2f6b7e00c29 6689505: Improve MBeanServerNotification.toString
dfuchs
parents: 2
diff changeset
    92
        return objectName;
b2f6b7e00c29 6689505: Improve MBeanServerNotification.toString
dfuchs
parents: 2
diff changeset
    93
    }
b2f6b7e00c29 6689505: Improve MBeanServerNotification.toString
dfuchs
parents: 2
diff changeset
    94
b2f6b7e00c29 6689505: Improve MBeanServerNotification.toString
dfuchs
parents: 2
diff changeset
    95
    @Override
b2f6b7e00c29 6689505: Improve MBeanServerNotification.toString
dfuchs
parents: 2
diff changeset
    96
    public String toString() {
b2f6b7e00c29 6689505: Improve MBeanServerNotification.toString
dfuchs
parents: 2
diff changeset
    97
        return super.toString() + "[mbeanName=" + objectName + "]";
b2f6b7e00c29 6689505: Improve MBeanServerNotification.toString
dfuchs
parents: 2
diff changeset
    98
b2f6b7e00c29 6689505: Improve MBeanServerNotification.toString
dfuchs
parents: 2
diff changeset
    99
    }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
 }