KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > jonas > management > j2eemanagement > ManagementMBeanFilter


1 /**
2 * JOnAS: Java(TM) Open Application Server
3 * Copyright (C) 2004 Bull S.A.
4 * Contact: jonas-team@objectweb.org
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
19 * USA
20 *
21 * --------------------------------------------------------------------------
22 * $Id: ManagementMBeanFilter.java,v 1.2 2005/02/03 10:25:23 danesa Exp $
23 * --------------------------------------------------------------------------
24 */

25 package org.objectweb.jonas.management.j2eemanagement;
26
27 import javax.management.MBeanServerNotification JavaDoc;
28 import javax.management.Notification JavaDoc;
29 import javax.management.NotificationFilter JavaDoc;
30 import javax.management.ObjectName JavaDoc;
31
32 /**
33 * @author Adriana Danes
34 *
35 * NotificationFilter that accepts only management notifications
36 */

37 public class ManagementMBeanFilter implements NotificationFilter JavaDoc {
38
39    /**
40     * Returns true if the notification is a REGISTRATION or UNREGISTRETION
41     * JOnAS management MBean notification
42     * @param notif notification to filter
43     * @return true if this is a discovery notification, false otherwise
44     */

45     public boolean isNotificationEnabled(Notification JavaDoc notif) {
46         boolean result = false;
47         if (notif instanceof MBeanServerNotification JavaDoc) {
48             ObjectName JavaDoc name = ((MBeanServerNotification JavaDoc) notif).getMBeanName();
49             String JavaDoc onType = name.getKeyProperty("type");
50             String JavaDoc onServer = name.getKeyProperty("server");
51             if (onType != null && onType.equals("management")
52                     && onServer != null && onServer.equals("JOnAS")) {
53                 return true;
54             }
55         }
56         return result;
57     }
58 }
Popular Tags