KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > javax > management > remote > TargetedNotification


1 /*
2  * @(#)TargetedNotification.java 1.10 03/12/19
3  *
4  * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
5  * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
6  */

7
8
9 package javax.management.remote;
10
11 import java.io.Serializable JavaDoc;
12 import javax.management.Notification JavaDoc;
13
14 /**
15  * <p>A (Notification, Listener ID) pair.</p>
16  * <p>This class is used to associate an emitted notification
17  * with the listener ID to which it is targeted.</p>
18  *
19  * @since 1.5
20  * @since.unbundled 1.0
21  */

22 public class TargetedNotification implements Serializable JavaDoc {
23
24     private static final long serialVersionUID = 7676132089779300926L;
25
26 // If we replace Integer with int...
27
// /**
28
// * <p>Constructs a <code>TargetedNotification</code> object. The
29
// * object contains a pair (Notification, Listener ID).
30
// * The Listener ID identifies the client listener to which that
31
// * notification is targeted. The client listener ID is one
32
// * previously returned by the connector server in response to an
33
// * <code>addNotificationListener</code> request.</p>
34
// * @param notification Notification emitted from the MBean server.
35
// * @param listenerID The ID of the listener to which this
36
// * notification is targeted.
37
// */
38
// public TargetedNotification(Notification notification,
39
// int listenerID) {
40
// this.notif = notification;
41
// this.id = listenerID;
42
// }
43

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      * @exception IllegalArgumentException if the <var>listenerID</var>
55      * or <var>notification</var> is null.
56      */

57     public TargetedNotification(Notification JavaDoc notification,
58                 Integer JavaDoc listenerID) {
59     // If we replace integer with int...
60
// this(notification,intValue(listenerID));
61
if (notification == null) throw new
62         IllegalArgumentException JavaDoc("Invalid notification: null");
63     if (listenerID == null) throw new
64         IllegalArgumentException JavaDoc("Invalid listener ID: null");
65     this.notif = notification;
66     this.id = listenerID;
67     }
68
69     /**
70      * <p>The emitted notification.</p>
71      *
72      * @return The notification.
73      */

74     public Notification JavaDoc getNotification() {
75     return notif;
76     }
77
78     /**
79      * <p>The ID of the listener to which the notification is
80      * targeted.</p>
81      *
82      * @return The listener ID.
83      */

84     public Integer JavaDoc getListenerID() {
85     return id;
86     }
87
88     /**
89      * Returns a textual representation of this Targeted Notification.
90      *
91      * @return a String representation of this Targeted Notification.
92      **/

93     public String JavaDoc toString() {
94     return "{" + notif + ", " + id + "}";
95     }
96
97     /**
98      * @serial A notification to transmit to the other side.
99      * @see #getNotification()
100      **/

101     private final Notification JavaDoc notif;
102     /**
103      * @serial The ID of the listener to which the notification is
104      * targeted.
105      * @see #getListenerID()
106      **/

107     private final Integer JavaDoc id;
108     //private final int id;
109

110 // Needed if we use int instead of Integer...
111
// private static int intValue(Integer id) {
112
// if (id == null) throw new
113
// IllegalArgumentException("Invalid listener ID: null");
114
// return id.intValue();
115
// }
116
}
117
Popular Tags