KickJava   Java API By Example, From Geeks To Geeks.

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


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.ListenerNotFoundException;
11 import javax.management.MBeanNotificationInfo;
12 import javax.management.Notification;
13 import javax.management.NotificationBroadcasterSupport;
14 import javax.management.NotificationEmitter;
15 import javax.management.NotificationFilter;
16 import javax.management.NotificationListener;
17
18 /**
19  * @author <a HREF="mailto:Adrian.Brock@HappeningTimes.com">Adrian Brock</a>.
20  * @version $Revision: 1.3 $
21  */

22 public class EmitterInvocationHandlerTest
23    extends InvocationHandlerTest
24    implements NotificationEmitter
25 {
26    NotificationBroadcasterSupport emitter = new NotificationBroadcasterSupport();
27
28    public void addNotificationListener(NotificationListener listener,
29                                        NotificationFilter filter,
30                                        Object handback)
31    {
32       emitter.addNotificationListener(listener, filter, handback);
33    }
34
35    public MBeanNotificationInfo[] getNotificationInfo()
36    {
37       String[] types = { "test" };
38       return new MBeanNotificationInfo[]
39       {
40          new MBeanNotificationInfo(types, "name", "description")
41       };
42    }
43
44    public void removeNotificationListener(NotificationListener listener)
45       throws ListenerNotFoundException
46    {
47       emitter.removeNotificationListener(listener);
48    }
49
50    public void removeNotificationListener(NotificationListener listener,
51                                           NotificationFilter filter,
52                                           Object handback)
53       throws ListenerNotFoundException
54    {
55       emitter.removeNotificationListener(listener, filter, handback);
56    }
57
58    public void sendNotification()
59    {
60       Notification notification = new Notification("test", this, 1l);
61       emitter.sendNotification(notification);
62    }
63 }
Popular Tags