1 package example; 2 3 import java.util.logging.Logger ; 4 5 import javax.management.NotificationListener ; 6 import javax.management.Notification ; 7 8 11 public class Listener implements NotificationListener , ListenerMBean { 12 private static final Logger log = 13 Logger.getLogger(Listener.class.getName()); 14 17 private int _notificationCount; 18 19 22 public int getNotificationCount() 23 { 24 return _notificationCount; 25 } 26 27 34 public void handleNotification(Notification notif, Object handback) 35 { 36 _notificationCount++; 37 38 if (handback != null) 39 log.info("notification(type=" + notif.getType() + ",handback=" + handback + ")"); 40 else 41 log.info("notification(type=" + notif.getType() + ")"); 42 } 43 44 45 48 public String toString() 49 { 50 return "Listener[" + _notificationCount + "]"; 51 } 52 } 53 | Popular Tags |