2
|
1 |
/*
|
5506
|
2 |
* Copyright (c) 2003, 2007, Oracle and/or its affiliates. All rights reserved.
|
2
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
4 |
*
|
|
5 |
* This code is free software; you can redistribute it and/or modify it
|
|
6 |
* under the terms of the GNU General Public License version 2 only, as
|
5506
|
7 |
* published by the Free Software Foundation. Oracle designates this
|
2
|
8 |
* particular file as subject to the "Classpath" exception as provided
|
5506
|
9 |
* by Oracle in the LICENSE file that accompanied this code.
|
2
|
10 |
*
|
|
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT
|
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that
|
|
15 |
* accompanied this code).
|
|
16 |
*
|
|
17 |
* You should have received a copy of the GNU General Public License version
|
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation,
|
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
20 |
*
|
5506
|
21 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
|
22 |
* or visit www.oracle.com if you need additional information or have any
|
|
23 |
* questions.
|
2
|
24 |
*/
|
|
25 |
|
|
26 |
|
|
27 |
package javax.management.remote;
|
|
28 |
|
|
29 |
import java.io.Serializable;
|
|
30 |
import javax.management.Notification;
|
|
31 |
|
|
32 |
/**
|
|
33 |
* <p>A (Notification, Listener ID) pair.</p>
|
|
34 |
* <p>This class is used to associate an emitted notification
|
|
35 |
* with the listener ID to which it is targeted.</p>
|
|
36 |
*
|
|
37 |
* @since 1.5
|
|
38 |
*/
|
|
39 |
public class TargetedNotification implements Serializable {
|
|
40 |
|
|
41 |
private static final long serialVersionUID = 7676132089779300926L;
|
|
42 |
|
|
43 |
// If we replace Integer with int...
|
|
44 |
// /**
|
|
45 |
// * <p>Constructs a <code>TargetedNotification</code> object. The
|
|
46 |
// * object contains a pair (Notification, Listener ID).
|
|
47 |
// * The Listener ID identifies the client listener to which that
|
|
48 |
// * notification is targeted. The client listener ID is one
|
|
49 |
// * previously returned by the connector server in response to an
|
|
50 |
// * <code>addNotificationListener</code> request.</p>
|
|
51 |
// * @param notification Notification emitted from the MBean server.
|
|
52 |
// * @param listenerID The ID of the listener to which this
|
|
53 |
// * notification is targeted.
|
|
54 |
// */
|
|
55 |
// public TargetedNotification(Notification notification,
|
|
56 |
// int listenerID) {
|
|
57 |
// this.notif = notification;
|
|
58 |
// this.id = listenerID;
|
|
59 |
// }
|
|
60 |
|
|
61 |
/**
|
|
62 |
* <p>Constructs a <code>TargetedNotification</code> object. The
|
|
63 |
* object contains a pair (Notification, Listener ID).
|
|
64 |
* The Listener ID identifies the client listener to which that
|
|
65 |
* notification is targeted. The client listener ID is one
|
|
66 |
* previously returned by the connector server in response to an
|
|
67 |
* <code>addNotificationListener</code> request.</p>
|
|
68 |
* @param notification Notification emitted from the MBean server.
|
|
69 |
* @param listenerID The ID of the listener to which this
|
|
70 |
* notification is targeted.
|
|
71 |
* @exception IllegalArgumentException if the <var>listenerID</var>
|
|
72 |
* or <var>notification</var> is null.
|
|
73 |
*/
|
|
74 |
public TargetedNotification(Notification notification,
|
|
75 |
Integer listenerID) {
|
|
76 |
// If we replace integer with int...
|
|
77 |
// this(notification,intValue(listenerID));
|
|
78 |
if (notification == null) throw new
|
|
79 |
IllegalArgumentException("Invalid notification: null");
|
|
80 |
if (listenerID == null) throw new
|
|
81 |
IllegalArgumentException("Invalid listener ID: null");
|
|
82 |
this.notif = notification;
|
|
83 |
this.id = listenerID;
|
|
84 |
}
|
|
85 |
|
|
86 |
/**
|
|
87 |
* <p>The emitted notification.</p>
|
|
88 |
*
|
|
89 |
* @return The notification.
|
|
90 |
*/
|
|
91 |
public Notification getNotification() {
|
|
92 |
return notif;
|
|
93 |
}
|
|
94 |
|
|
95 |
/**
|
|
96 |
* <p>The ID of the listener to which the notification is
|
|
97 |
* targeted.</p>
|
|
98 |
*
|
|
99 |
* @return The listener ID.
|
|
100 |
*/
|
|
101 |
public Integer getListenerID() {
|
|
102 |
return id;
|
|
103 |
}
|
|
104 |
|
|
105 |
/**
|
|
106 |
* Returns a textual representation of this Targeted Notification.
|
|
107 |
*
|
|
108 |
* @return a String representation of this Targeted Notification.
|
|
109 |
**/
|
|
110 |
public String toString() {
|
|
111 |
return "{" + notif + ", " + id + "}";
|
|
112 |
}
|
|
113 |
|
|
114 |
/**
|
|
115 |
* @serial A notification to transmit to the other side.
|
|
116 |
* @see #getNotification()
|
|
117 |
**/
|
|
118 |
private final Notification notif;
|
|
119 |
/**
|
|
120 |
* @serial The ID of the listener to which the notification is
|
|
121 |
* targeted.
|
|
122 |
* @see #getListenerID()
|
|
123 |
**/
|
|
124 |
private final Integer id;
|
|
125 |
//private final int id;
|
|
126 |
|
|
127 |
// Needed if we use int instead of Integer...
|
|
128 |
// private static int intValue(Integer id) {
|
|
129 |
// if (id == null) throw new
|
|
130 |
// IllegalArgumentException("Invalid listener ID: null");
|
|
131 |
// return id.intValue();
|
|
132 |
// }
|
|
133 |
}
|