KickJava   Java API By Example, From Geeks To Geeks.

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


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.NotificationBroadcaster;
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 BroadcasterInvocationHandlerTest
23    extends InvocationHandlerTest
24    implements NotificationBroadcaster
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 sendNotification()
51    {
52       Notification notification = new Notification("test", this, 1l);
53       emitter.sendNotification(notification);
54    }
55 }
Popular Tags