1 23 24 package com.sun.enterprise.admin.selfmanagement.event; 25 import javax.management.ObjectName ; 26 import javax.management.NotificationFilter ; 27 import javax.management.monitor.Monitor ; 28 import com.sun.enterprise.admin.common.MBeanServerFactory; 29 import java.util.logging.Logger ; 30 import java.util.logging.Level ; 31 import com.sun.logging.LogDomains; 32 import com.sun.enterprise.util.i18n.StringManager; 33 34 35 public class MonitorEvent implements Event { 36 private static Logger _logger=LogDomains.getLogger(LogDomains.SELF_MANAGEMENT_LOGGER); 37 private static StringManager sm = StringManager.getManager(MonitorEvent.class); 38 39 MonitorEvent(StatisticMonitor monitor, ObjectName objName, String description) { 40 monitor.start(); 41 try { 42 MBeanServerFactory.getMBeanServer().registerMBean(monitor,objName); 43 } catch (Exception ex) { 44 _logger.log(Level.WARNING,"smgt.internal_error", ex); 45 } 46 47 this.sMonitor = monitor; 48 this.objName = objName; 49 if (description != null) 50 this.description = description; 51 else 52 this.description = defaultDescription; 53 } 54 55 MonitorEvent(Monitor monitor, ObjectName objName, String description) { 56 monitor.start(); 57 try { 58 MBeanServerFactory.getMBeanServer().registerMBean(monitor,objName); 59 } catch (Exception ex) { 60 _logger.log(Level.WARNING,"smgt.internal_error", ex); 61 } 62 63 this.monitor = monitor; 64 this.objName = objName; 65 if (description != null) 66 this.description = description; 67 else 68 this.description = defaultDescription; 69 } 70 71 72 public ObjectName getObjectName() { 73 return objName; 74 } 75 public String getType() { 76 return "monitor"; 77 } 78 public NotificationFilter getNotificationFilter() { 79 return null; 80 } 81 public String getDescription() { 82 return description; 83 } 84 public void destroy() { 85 try { 86 if (monitor != null) 87 monitor.stop(); 88 if (sMonitor != null) 89 sMonitor.stop(); 90 } catch (Exception ex) { 91 _logger.log(Level.WARNING,"smgt.internal_error", ex); 92 } 93 try { 94 MBeanServerFactory.getMBeanServer().unregisterMBean(objName); 95 } catch (Exception ex) { 96 _logger.log(Level.WARNING,"smgt.internal_error", ex); 97 } 98 } 99 private ObjectName objName = null; 100 private static String description = null; 101 private static String defaultDescription = sm.getString("selfmgmt_event.monitor_event_description"); 102 private StatisticMonitor sMonitor = null; 103 private Monitor monitor = null; 104 } 105 | Popular Tags |