KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > test > compliance > core > notification > Listener


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

7 package test.compliance.core.notification;
8
9 import javax.management.Notification JavaDoc;
10 import javax.management.NotificationListener JavaDoc;
11
12 /**
13  * @author <a HREF="mailto:tom.elrod@jboss.com">Tom Elrod</a>
14  */

15 public class Listener implements NotificationListener JavaDoc
16 {
17    private int expectedCount;
18    private int count;
19
20    public Listener(int expectedCount)
21    {
22       this.expectedCount = expectedCount;
23    }
24
25    public int getCount()
26    {
27       return count;
28    }
29
30    public void handleNotification(Notification JavaDoc event, Object JavaDoc handback)
31    {
32       System.out.println("handleNotification, event: " + event + ", count=" + count);
33       count++;
34       synchronized(this)
35       {
36          if(count == expectedCount)
37          {
38             notifyAll();
39          }
40       }
41    }
42 }
Popular Tags