1 23 24 28 29 package com.sun.enterprise.admin.selfmanagement.event; 30 31 import javax.management.NotificationFilter ; 32 import javax.management.ObjectName ; 33 import javax.management.MalformedObjectNameException ; 34 import com.sun.enterprise.util.SystemPropertyConstants; 35 import com.sun.enterprise.util.i18n.StringManager; 36 import java.util.logging.Logger ; 37 import java.util.logging.Level ; 38 import com.sun.logging.LogDomains; 39 import com.sun.enterprise.admin.common.MBeanServerFactory; 40 import javax.management.MBeanServer ; 41 42 43 47 public class LogEvent implements Event { 48 private static StringManager sm = StringManager.getManager(LogEvent.class); 49 private static Logger _logger=LogDomains.getLogger(LogDomains.SELF_MANAGEMENT_LOGGER); 50 51 52 public LogEvent( LogEventFilter filter , String description) { 53 notificationFilter = filter; 54 if (description != null) 55 this.description = description; 56 else 57 description = defaultDescription; 58 } 59 60 public ObjectName getObjectName() { 61 return getLogObjectName(); 62 } 63 64 65 public String getType() { 66 return "log"; 67 } 68 69 public NotificationFilter getNotificationFilter( ){ 70 return notificationFilter; 71 } 72 73 public String getDescription() { 74 return description; 75 } 76 77 public void destroy() { 78 } 80 81 static ObjectName getLogObjectName() { 82 if (objName != null) 83 return objName; 84 try { 85 objName = new ObjectName ( "amx:j2eeType=X-Logging,name="+ 86 System.getProperty(SystemPropertyConstants.SERVER_NAME )+ 87 ",X-ServerRootMonitor=" + 88 System.getProperty(SystemPropertyConstants.SERVER_NAME )); 89 MBeanServer mbeanServer = MBeanServerFactory.getMBeanServer(); 90 if (mbeanServer.isRegistered(objName)) { 91 return objName; 92 } else 93 _logger.log(Level.WARNING,"smgt.internal_error", 94 new Object [] {sm.getString("selfmgmt_event.log_mbean_is_not_available")}); 95 }catch (MalformedObjectNameException mex) { 96 _logger.log(Level.WARNING,"smgt.internal_error", mex); 97 } 98 return objName; 99 100 } 101 102 private static ObjectName objName = null; 103 private static String defaultDescription = sm.getString("selfmgmt_event.log_event_description"); 104 private static String description = null; 105 private LogEventFilter notificationFilter = null; 106 } 107 | Popular Tags |