KickJava   Java API By Example, From Geeks To Geeks.

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


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
13 /**
14  * Simple Listener
15  *
16  * @author <a HREF="mailto:Adrian.Brock@HappeningTimes.com">Adrian Brock</a>.
17  * @version $Revision: 1.1 $
18  *
19  */

20 public class MBeanListener
21    implements NotificationListener, MBeanListenerMBean
22 {
23    public long count = 0;
24    public Object source = null;
25    public Object handback = null;
26    public long count1 = 0;
27    public Object source1 = new Object();
28    public Object handback1 = new Object();
29    public long count2 = 0;
30    public Object source2 = new Object();
31    public Object handback2 = new Object();
32
33    Object hb1 = null;
34    Object hb2 = null;
35
36    public MBeanListener()
37    {
38    }
39
40    public MBeanListener(String hb1, String hb2)
41    {
42       this.hb1 = hb1;
43       this.hb2 = hb2;
44    }
45
46    public void handleNotification(Notification n, Object nhb)
47    {
48       if (nhb != null && nhb.equals(hb1))
49       {
50          count1++;
51          source1 = n.getSource();
52          handback1 = nhb;
53       }
54       else if (nhb != null && nhb.equals(hb2))
55       {
56          count2++;
57          source2 = n.getSource();
58          handback2 = nhb;
59       }
60       else
61       {
62          count++;
63          source = n.getSource();
64          handback = nhb;
65       }
66    }
67 }
68
Popular Tags