1 7 package test.compliance.core.notification; 8 9 import javax.management.Notification ; 10 import javax.management.NotificationListener ; 11 12 15 public class Listener implements NotificationListener 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 event, Object 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 |