KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > admin > jmx > remote > notification > ListenerInfo


1 /*
2  * The contents of this file are subject to the terms
3  * of the Common Development and Distribution License
4  * (the License). You may not use this file except in
5  * compliance with the License.
6  *
7  * You can obtain a copy of the license at
8  * https://glassfish.dev.java.net/public/CDDLv1.0.html or
9  * glassfish/bootstrap/legal/CDDLv1.0.txt.
10  * See the License for the specific language governing
11  * permissions and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL
14  * Header Notice in each file and include the License file
15  * at glassfish/bootstrap/legal/CDDLv1.0.txt.
16  * If applicable, add the following below the CDDL Header,
17  * with the fields enclosed by brackets [] replaced by
18  * you own identifying information:
19  * "Portions Copyrighted [year] [name of copyright owner]"
20  *
21  * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
22  */

23
24 package com.sun.enterprise.admin.jmx.remote.notification;
25
26 import javax.management.*;
27
28 /**
29  * This class is a composite of a NotificationListener, NotificationFilter and a handback object.
30  * The listener, filter and handback objects that are being registered by the client
31  * via a call to addNotificationListener are set into a new ListenerInfo object.
32  * This ListenerInfo object is then registered in the NotificationManagers.
33  */

34 public class ListenerInfo {
35     public Object JavaDoc proxy = null;
36     public NotificationListener listener = null;
37     public NotificationFilter filter = null;
38     public Object JavaDoc handback = null;
39     public String JavaDoc id = null;
40
41     public ListenerInfo() {
42     }
43
44     public ListenerInfo(NotificationListener listener, NotificationFilter filter, Object JavaDoc handback) {
45         this.listener = listener;
46         this.filter = filter;
47         this.handback = handback;
48         id = computeId();
49     }
50
51     /**
52      * Compute an id for this object.
53      * The id generated by this method is used to match a listener, filter, handback combination
54      * both on the server-side and client-side
55      */

56     public String JavaDoc computeId() {
57         String JavaDoc listenerCode = "null";
58         if (listener != null)
59             listenerCode = Integer.toString(listener.hashCode());
60         String JavaDoc filterCode = "null";
61         if (filter != null)
62             filterCode = Integer.toString(filter.hashCode());
63         String JavaDoc handbackCode = "null";
64         if (handback != null)
65             handbackCode = Integer.toString(handback.hashCode());
66         return ( listenerCode + ":" + filterCode + ":" + handbackCode );
67     }
68 }
69
70
Popular Tags