KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > test > compliance > server > support > Listener


1 /*
2  * JBoss, the OpenSource J2EE webOS
3  *
4  * Distributable under LGPL license.
5  * See terms of license at gnu.org.
6  */

7
8 package test.compliance.server.support;
9
10 import javax.management.Notification;
11 import javax.management.NotificationListener;
12 import javax.management.ObjectName;
13
14 /**
15  * @author <a HREF="mailto:Adrian.Brock@HappeningTimes.com">Adrian Brock</a>.
16  * @version $Revision: 1.1 $
17  *
18  */

19 public class Listener
20    implements ListenerMBean, NotificationListener
21 {
22    public int notificationCount = 0;
23
24    public boolean error = false;
25
26    public void doSomething()
27    {
28    }
29
30    public void handleNotification(Notification notification, Object handback)
31    {
32        if (!(handback instanceof String))
33           error = true;
34        if (!(handback.equals("MyHandback")))
35           error = true;
36        if (!(notification.getSource() instanceof ObjectName))
37           error = true;
38        if (!(notification.getSource().toString().equals("JMImplementation:type=MBeanServerDelegate")))
39           error = true;
40
41        notificationCount++;
42    }
43 }
44
Popular Tags