KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > admin > jmx > remote > server > callers > AddNotifLsnrObjNameCaller


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 /* CVS information
25  * $Header: /cvs/glassfish/jmx-remote/rjmx-impl/src/java/com/sun/enterprise/admin/jmx/remote/server/callers/AddNotifLsnrObjNameCaller.java,v 1.4 2005/12/25 04:26:37 tcfujii Exp $
26  * $Revision: 1.4 $
27  * $Date: 2005/12/25 04:26:37 $
28 */

29
30 package com.sun.enterprise.admin.jmx.remote.server.callers;
31
32 /* BEGIN -- S1WS_MOD */
33 import java.util.logging.Logger JavaDoc;
34 /* END -- S1WS_MOD */
35 import com.sun.enterprise.admin.jmx.remote.DefaultConfiguration;
36 import javax.management.MBeanServerConnection JavaDoc;
37 /* BEGIN -- S1WS_MOD */
38 import javax.management.NotificationFilter JavaDoc;
39 import javax.management.ObjectName JavaDoc;
40 /* END -- S1WS_MOD */
41 import javax.management.remote.message.MBeanServerRequestMessage;
42 import javax.management.remote.message.MBeanServerResponseMessage;
43
44 /* BEGIN -- S1WS_MOD */
45 import com.sun.enterprise.admin.jmx.remote.notification.ListenerInfo;
46 import com.sun.enterprise.admin.jmx.remote.server.notification.ServerNotificationManager;
47
48 /* END -- S1WS_MOD */
49
50 /** Invokes the method addNotificationListener of the MBeanServerConnection.
51  * @see MBeanServerRequestMessage#ADD_NOTIFICATION_LISTENER_OBJECTNAME
52  * @author Kedar Mhaswade
53  * @since S1AS8.0
54  * @version 1.0
55  */

56
57 public class AddNotifLsnrObjNameCaller extends AbstractMethodCaller {
58 /* BEGIN -- S1WS_MOD */
59     private final Logger JavaDoc logger = Logger.getLogger(
60         DefaultConfiguration.JMXCONNECTOR_LOGGER);/*,
61         DefaultConfiguration.LOGGER_RESOURCE_BUNDLE_NAME );*/

62     
63     private ServerNotificationManager notifMgr = null;
64
65 // public AddNotifLsnrObjNameCaller(MBeanServerConnection mbsc) {
66
public AddNotifLsnrObjNameCaller(MBeanServerConnection JavaDoc mbsc, ServerNotificationManager mgr) {
67 /* END -- S1WS_MOD */
68         super(mbsc);
69         METHOD_ID = MBeanServerRequestMessage.ADD_NOTIFICATION_LISTENER_OBJECTNAME;
70 /* BEGIN -- S1WS_MOD */
71         this.notifMgr = mgr;
72 /* END -- S1WS_MOD */
73     }
74     
75     public MBeanServerResponseMessage call(MBeanServerRequestMessage request) {
76 /* BEGIN -- S1WS_MOD */
77 // final Object result = new UnsupportedOperationException("" + METHOD_ID);
78
// boolean isException = true;
79
Object JavaDoc result = null;
80         boolean isException = false;
81
82         ObjectName JavaDoc objname1 = (ObjectName JavaDoc) request.getParams()[0];
83         ObjectName JavaDoc objname2 = (ObjectName JavaDoc) request.getParams()[1];
84         NotificationFilter JavaDoc filter = (NotificationFilter JavaDoc) request.getParams()[2];
85         Object JavaDoc handback = request.getParams()[3];
86         String JavaDoc lsnrid = (String JavaDoc) request.getParams()[4];
87
88         notifMgr.addObjNameNotificationListener(objname1, filter, handback, lsnrid);
89
90         try {
91             mbsc.addNotificationListener(objname1, objname2, filter, handback);
92         } catch (Exception JavaDoc e) {
93             result = e;
94             isException = true;
95         }
96
97 /* END -- S1WS_MOD */
98         return ( new MBeanServerResponseMessage(METHOD_ID, result, isException) );
99     }
100 }
101
Popular Tags