listener.java

来自「RESIN 3.2 最新源码」· Java 代码 · 共 53 行

JAVA
53
字号
package example;import java.util.logging.Logger;import javax.management.NotificationListener;import javax.management.Notification;/** * Implements an MBean event listener. */public class Listener implements NotificationListener, ListenerMBean {  private static final Logger log =    Logger.getLogger(Listener.class.getName());  /**   * Count of the notifications received.   */  private int _notificationCount;  /**   * Returns the count of notifications received.   */  public int getNotificationCount()  {    return _notificationCount;  }  /**   * Handles the notification.   *   * @param notif the notification sent by the event's MBean   * @param handback an opaque object configured when the listener   *   was configured.   */  public void handleNotification(Notification notif, Object handback)  {    _notificationCount++;        if (handback != null)      log.info("notification(type=" + notif.getType() + ",handback=" + handback + ")");    else      log.info("notification(type=" + notif.getType() + ")");  }    /**   * Returns a printable version of the resource.   */  public String toString()  {    return "Listener[" + _notificationCount + "]";  }}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?