1 23 24 28 29 package com.sun.enterprise.admin.selfmanagement.event; 30 31 32 import javax.management.NotificationEmitter ; 33 import javax.management.MBeanServer ; 34 35 import com.sun.enterprise.config.serverbeans.ElementProperty; 36 import com.sun.enterprise.admin.selfmanagement.configuration.JavaBeanConfigurator; 37 import java.util.logging.Level ; 38 import static com.sun.enterprise.admin.selfmanagement.event.ManagementRuleConstants.*; 39 40 44 45 public class LifeCycleEventFactory extends EventAbstractFactory { 46 47 private LifeCycleEventFactory( ) { 48 super(); 49 EventBuilder.getInstance().addEventFactory(EVENT_LIFECYCLE, this); 50 try { 51 LifeCycleImpl impl = (LifeCycleImpl) getMBeanServer().instantiate( 52 "com.sun.enterprise.admin.selfmanagement.event.LifeCycleImpl"); 53 getMBeanServer().registerMBean(impl,LifeCycleEvent.getLifeCycleImplObjectName()); 54 } catch (javax.management.ReflectionException rex) { 55 _logger.log(Level.WARNING,"smgt.internal_error", rex); 56 } catch (javax.management.InstanceAlreadyExistsException iex) { 57 _logger.log(Level.WARNING,"smgt.internal_error", iex); 58 } catch (Exception ex) { 59 _logger.log(Level.WARNING,"smgt.internal_error", ex); 60 61 } 62 } 63 64 public Event instrumentEvent( 65 ElementProperty[] properties, String description ) { 66 String eventName = null; 67 for( int i = 0; i < properties.length; i++ ){ 68 ElementProperty property = properties[i]; 69 String propertyName = property.getName( ).toLowerCase( ); 70 if( propertyName.equals(PROPERTY_LIFECYCLE_NAME)) { 71 eventName = "lifecycle." + property.getValue( ).toLowerCase( ); 72 if (!LifeCycleEvent.isValidType(eventName)) 73 throw new IllegalArgumentException ( 74 sm.getString("name","selfmgmt_event.invalid_event_property","lifecycle")); 75 } 76 } 77 return new LifeCycleEvent(eventName, new LifeCycleNotificationFilter(eventName), description); 78 } 79 80 static LifeCycleEventFactory getInstance() { 81 return instance; 82 } 83 private static LifeCycleEventFactory instance = new LifeCycleEventFactory(); 84 } 85 | Popular Tags |