1 21 package org.objectweb.fractal.jmx.listener; 22 23 import javax.management.Notification ; 24 import javax.management.monitor.MonitorNotification ; 25 import javax.management.NotificationListener ; 26 27 import javax.management.monitor.PeriodicMonitor ; 28 29 import java.util.Date ; 30 31 38 public class BasicListener implements NotificationListener { 39 40 62 public void handleNotification(Notification n, Object handback) { 63 MonitorNotification notif = (MonitorNotification ) n; 64 StringBuffer msg = new StringBuffer (150); 65 msg.append("\n"); 66 if (notif.getType().equals(MonitorNotification.STRING_TO_COMPARE_VALUE_MATCHED) 67 || notif.getType().equals(MonitorNotification.STRING_TO_COMPARE_VALUE_DIFFERED)) { 68 msg.append("***** String Monitor"); 69 } else if (notif.getType().equals(MonitorNotification.THRESHOLD_VALUE_EXCEEDED)) { 70 msg.append("***** Counter Monitor"); 71 } else if (notif.getType().equals(MonitorNotification.THRESHOLD_HIGH_VALUE_EXCEEDED) 72 || notif.getType().equals(MonitorNotification.THRESHOLD_LOW_VALUE_EXCEEDED)) { 73 msg.append("***** Gauge Monitor"); 74 } else if (notif.getType().equals(PeriodicMonitor.PERIODIC_SAMPLING)) { 75 msg.append("***** Periodic Monitor"); 76 } else 77 msg.append("***** Unexpected Monitor notication !!!"); 78 msg.append(" (" + new Date (notif.getTimeStamp()) + ")"); 79 msg.append("\n* NotificationType: " + notif.getType()); 80 msg.append("\n* Src: " + notif.getSource()); 81 msg.append("\n* ObservedObject: " + notif.getObservedObject()); 82 msg.append("\n* ObservedAttribute: " + notif.getObservedAttribute()); 83 msg.append("\n* Trigger: " + notif.getTrigger()); 84 msg.append("\n* DerivedGauge: " + notif.getDerivedGauge()); 85 msg.append("\n*****"); 87 System.out.println(msg); 88 } 89 } 90 91 | Popular Tags |