KickJava   Java API By Example, From Geeks To Geeks.

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


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.server.notification;
25
26 import java.util.logging.Logger JavaDoc;
27 import javax.management.*;
28
29 import com.sun.enterprise.admin.jmx.remote.notification.NotificationWrapper;
30 import com.sun.enterprise.admin.jmx.remote.DefaultConfiguration;
31
32 /**
33  * A Proxy for NotificationListener.
34  * An object of NotificationListenerProxy is registered to the NotificationBroadcaster
35  * for every notification listener that is registered by the client.
36  * Whenever the NotificationBroadcaster calls this proxy's handleNotification method,
37  * this proxy object will invoke ServerNotificationManager.fireNotification(...)
38  */

39 public class NotificationListenerProxy implements NotificationListener {
40     private String JavaDoc id = null;
41     private ServerNotificationManager mgr = null;
42     private ObjectName objname = null;
43     private Notification notification = null;
44
45     private static final Logger JavaDoc logger = Logger.getLogger(
46         DefaultConfiguration.JMXCONNECTOR_LOGGER);/*,
47         DefaultConfiguration.LOGGER_RESOURCE_BUNDLE_NAME );*/

48
49     public NotificationListenerProxy(ObjectName objname,
50                                      ServerNotificationManager mgr,
51                                      String JavaDoc id) {
52         this.objname = objname;
53         this.mgr = mgr;
54         this.id = id;
55     }
56
57     /**
58      * Returns the client id, which has registered the notification listener
59      * represented by this proxy object.
60      */

61     public String JavaDoc getId() {
62         return id;
63     }
64
65
66     public NotificationWrapper getNotificationWrapper() {
67         return ( new NotificationWrapper(objname, notification) );
68     }
69
70     public Notification getNotification() {
71         return notification;
72     }
73
74     public void handleNotification( Notification notification,
75                                     Object JavaDoc handback) {
76         this.notification = notification;
77         mgr.fireNotification(this);
78     }
79 }
80
Popular Tags