jdk/src/share/classes/javax/management/remote/TargetedNotification.java
author ohair
Tue, 25 May 2010 15:58:33 -0700
changeset 5506 202f599c92aa
parent 2 90ce3da70b43
child 20809 b5e0612d60b9
permissions -rw-r--r--
6943119: Rebrand source copyright notices Reviewed-by: darcy, weijun
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     2
 * Copyright (c) 2003, 2007, Oracle and/or its affiliates. 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
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
2
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
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    23
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
package javax.management.remote;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
import java.io.Serializable;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
import javax.management.Notification;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
 * <p>A (Notification, Listener ID) pair.</p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
 * <p>This class is used to associate an emitted notification
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
 *    with the listener ID to which it is targeted.</p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
 * @since 1.5
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
public class TargetedNotification implements Serializable {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
    private static final long serialVersionUID = 7676132089779300926L;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
// If we replace Integer with int...
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
//     /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
//      * <p>Constructs a <code>TargetedNotification</code> object.  The
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
//      * object contains a pair (Notification, Listener ID).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
//      * The Listener ID identifies the client listener to which that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
//      * notification is targeted. The client listener ID is one
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
//      * previously returned by the connector server in response to an
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
//      * <code>addNotificationListener</code> request.</p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
//      * @param notification Notification emitted from the MBean server.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
//      * @param listenerID   The ID of the listener to which this
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
//      *        notification is targeted.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
//      */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
//     public TargetedNotification(Notification notification,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
//                              int listenerID) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
//      this.notif = notification;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
//      this.id = listenerID;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
//     }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
     * <p>Constructs a <code>TargetedNotification</code> object.  The
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
     * object contains a pair (Notification, Listener ID).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
     * The Listener ID identifies the client listener to which that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
     * notification is targeted. The client listener ID is one
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
     * previously returned by the connector server in response to an
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
     * <code>addNotificationListener</code> request.</p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
     * @param notification Notification emitted from the MBean server.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
     * @param listenerID   The ID of the listener to which this
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
     *        notification is targeted.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
     * @exception IllegalArgumentException if the <var>listenerID</var>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
     *        or <var>notification</var> is null.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
    public TargetedNotification(Notification notification,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
                                Integer listenerID) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
        // If we replace integer with int...
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
        // this(notification,intValue(listenerID));
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
        if (notification == null) throw new
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
            IllegalArgumentException("Invalid notification: null");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
        if (listenerID == null) throw new
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
            IllegalArgumentException("Invalid listener ID: null");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
        this.notif = notification;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
        this.id = listenerID;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
     * <p>The emitted notification.</p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
     * @return The notification.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
    public Notification getNotification() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
        return notif;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
     * <p>The ID of the listener to which the notification is
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
     *    targeted.</p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
     * @return The listener ID.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
    public Integer getListenerID() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
        return id;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
     * Returns a textual representation of this Targeted Notification.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
     * @return a String representation of this Targeted Notification.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
     **/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
    public String toString() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
        return "{" + notif + ", " + id + "}";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
     * @serial A notification to transmit to the other side.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
     * @see #getNotification()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
     **/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
    private final Notification notif;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
     * @serial The ID of the listener to which the notification is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
     *         targeted.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
     * @see #getListenerID()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
     **/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
    private final Integer id;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
    //private final int id;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
// Needed if we use int instead of Integer...
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
//     private static int intValue(Integer id) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
//      if (id == null) throw new
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
//          IllegalArgumentException("Invalid listener ID: null");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
//      return id.intValue();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
//     }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
}