1 23 24 28 29 package com.sun.enterprise.admin.selfmanagement.event; 30 31 import java.util.concurrent.ConcurrentHashMap ; 32 import com.sun.enterprise.config.serverbeans.ElementProperty; 33 import com.sun.enterprise.util.i18n.StringManager; 34 import java.util.Hashtable ; 35 36 40 public class EventBuilder { 41 42 private static final EventBuilder instance = new EventBuilder( ); 43 44 private static ConcurrentHashMap <String ,EventAbstractFactory> 45 eventFactoryMap = new ConcurrentHashMap <String ,EventAbstractFactory>(10, 0.75f, 2); 46 private boolean initialized = false; 47 48 protected static StringManager sm = StringManager.getManager(EventBuilder.class); 49 50 51 private EventBuilder() { 52 } 53 54 public static EventBuilder getInstance( ) { 55 return instance; 56 } 57 58 public synchronized void addEventFactory(String eventType, EventAbstractFactory factory) { 59 if ( eventFactoryMap.get( eventType ) == null) 60 eventFactoryMap.put(eventType, factory); 61 } 62 63 72 public Event getEvent( String eventType, 73 ElementProperty[] properties, String description ) { 74 if (!initialized) { 75 initialized = true; 76 LogEventFactory.getInstance(); 77 NotificationEventFactory.getInstance(); 78 LifeCycleEventFactory.getInstance(); 79 MonitorEventFactory.getInstance(); 80 TimerEventFactory.getInstance(); 81 TraceEventFactory.getInstance(); 82 } 83 EventAbstractFactory factory = 84 eventFactoryMap.get( eventType ); 85 86 if( factory == null ) { 87 throw new IllegalArgumentException ( 88 sm.getString("selfmgmt_event.unknown_event_type",eventType)); 89 } 90 91 return factory.instrumentEvent(properties, description); 92 } 93 94 public Event getEvent( String eventType, String description, 95 Hashtable attributes, ElementProperty[] properties) { 96 return getEvent(eventType,properties, description); 97 } 98 99 100 } 101 | Popular Tags |