1 23 24 27 28 package com.sun.enterprise.admin.mbeans; 29 30 import java.util.Properties ; 32 import java.util.Enumeration ; 33 import java.util.Set ; 34 import java.util.List ; 35 import java.util.ArrayList ; 36 37 import javax.management.ObjectName ; 39 import javax.management.MBeanServer ; 40 import javax.management.MBeanInfo ; 41 import javax.management.MBeanAttributeInfo ; 42 import javax.management.MBeanNotificationInfo ; 43 import javax.management.MalformedObjectNameException ; 44 import javax.management.InstanceNotFoundException ; 45 import javax.management.IntrospectionException ; 46 import javax.management.ReflectionException ; 47 48 49 import com.sun.enterprise.admin.config.BaseConfigMBean; 51 import com.sun.enterprise.admin.config.ConfigMBeanHelper; 52 53 import com.sun.enterprise.config.serverbeans.ElementProperty; 55 import com.sun.enterprise.config.serverbeans.ManagementRules; 56 import com.sun.enterprise.config.serverbeans.ManagementRule; 57 import com.sun.enterprise.config.serverbeans.Event; 58 import com.sun.enterprise.config.serverbeans.Action; 59 import com.sun.enterprise.config.ConfigException; 60 import com.sun.enterprise.config.ConfigContext; 61 import com.sun.enterprise.admin.selfmanagement.event.ManagementRulesMBeanHelper; 62 63 64 public class ManagementRulesMBean extends BaseConfigMBean 65 { 66 67 82 public ObjectName createManagementRule( 83 String ruleName, Boolean bRuleEnabled, 85 String ruleDescription, 86 String eventType, String eventLevel, 88 Boolean eventRecordEvent, 89 String eventDescription, 90 Properties eventProperties, 91 String actionMbeanName 92 ) throws Exception 93 { 94 ManagementRule newRule = new ManagementRule(); 95 newRule.setName(ruleName); 97 if(ruleDescription!=null) 98 newRule.setDescription(ruleDescription); 99 if(bRuleEnabled!=null) 100 newRule.setEnabled(bRuleEnabled.booleanValue()); 101 Event event = new Event(); 103 event.setType(eventType); 104 if(eventRecordEvent!=null) 105 event.setRecordEvent(eventRecordEvent.booleanValue()); 106 if(eventLevel!=null) 107 event.setLevel(eventLevel); 108 if(eventDescription!=null) 109 event.setDescription(eventDescription); 110 if (null != eventProperties) 112 { 113 Enumeration keys = eventProperties.keys(); 114 while (keys.hasMoreElements()) 115 { 116 final String key = (String )keys.nextElement(); 117 ElementProperty prop = new ElementProperty(); 118 prop.setName(key); 119 prop.setValue((String )eventProperties.get(key)); 120 event.addElementProperty(prop); 121 } 122 } 123 newRule.setEvent(event); 124 125 if(actionMbeanName!=null) 127 { 128 Action action = new Action(); 129 action.setActionMbeanName(actionMbeanName); 130 newRule.setAction(action); 131 132 } 133 ManagementRules rules = (ManagementRules)getBaseConfigBean(); 135 rules.addManagementRule(newRule); 136 return ConfigMBeanHelper.getChildObjectName(super.m_registry, super.info, newRule); 137 } 138 139 146 public void addActionToManagementRule( 147 String ruleName, String actionMbeanName) throws ConfigException 149 { 150 ManagementRules rules = (ManagementRules)getBaseConfigBean(); 151 ManagementRule rule = rules.getManagementRuleByName(ruleName); 152 Action action = new Action(); 153 action.setActionMbeanName(actionMbeanName); 154 rule.setAction(action); 155 } 156 157 158 165 public List <String > getAllActionMBeans(boolean enabled) throws ConfigException { 166 return ManagementRulesMBeanHelper.getAllActionMBeans(enabled); 167 } 168 169 175 public List <String > getEventTypes(boolean isEE) { 176 return ManagementRulesMBeanHelper.getEventTypes(isEE); 177 } 178 179 185 public List <String > getEventProperties(String eventType) { 186 return ManagementRulesMBeanHelper.getEventProperties(eventType); 187 } 188 189 190 197 public List <String > getEventPropertyValues(String eventType, String propertyName) 198 throws ConfigException { 199 return ManagementRulesMBeanHelper.getEventPropertyValues(eventType, propertyName); 200 } 201 202 209 List <String > getAllNotificationEmitterMbeans(boolean enabled) throws ConfigException { 210 return ManagementRulesMBeanHelper.getAllNotificationEmitterMbeans(enabled); 211 } 212 213 214 221 public Set <ObjectName > getRegisteredMBeans(String filter) throws 222 MalformedObjectNameException { 223 return ManagementRulesMBeanHelper.getRegisteredMBeans(filter); 224 } 225 226 233 public List <String > getAttributes(ObjectName objName) throws 234 InstanceNotFoundException , 235 IntrospectionException , 236 ReflectionException { 237 return ManagementRulesMBeanHelper.getAttributes(objName); 238 } 239 240 248 public List <String > getMBeanAttributes(String objectNameStr) 249 throws MalformedObjectNameException , 250 InstanceNotFoundException , IntrospectionException , 251 ReflectionException { 252 return ManagementRulesMBeanHelper.getMBeanAttributes(objectNameStr); 253 } 254 255 262 public List <String > getNotificationTypes(ObjectName objName) throws 263 InstanceNotFoundException , 264 IntrospectionException , 265 ReflectionException { 266 return ManagementRulesMBeanHelper.getNotificationTypes(objName); 267 } 268 269 277 public List <String > getNotificationTypes(String objectNameStr) throws 278 MalformedObjectNameException , 279 InstanceNotFoundException , IntrospectionException , 280 ReflectionException { 281 return ManagementRulesMBeanHelper.getNotificationTypes(objectNameStr); 282 } 283 284 285 public List <String > getAttributes(String dottedName) { return null; } 286 287 public List <String > getDottedNames(String dottedName) { return null; } 288 289 290 } 291 292 | Popular Tags |