1 64 65 package com.jcorporate.expresso.core.misc; 66 67 import java.util.Enumeration ; 68 import java.util.Hashtable ; 69 import java.util.Vector ; 70 71 72 public class DefaultSysEventHubImpl 73 implements SysEventHubImpl { 74 private Hashtable listeners = new Hashtable (); 75 76 public void addListener(SysEventListener listener, 77 String newTriggeringClass, String newCode) { 78 Vector oneListenerList = (Vector ) listeners.get(newTriggeringClass + 79 "|" + newCode); 80 81 if (oneListenerList == null) { 82 oneListenerList = new Vector (); 83 listeners.put(newTriggeringClass + "|" + newCode, oneListenerList); 84 } 85 86 oneListenerList.addElement(listener); 87 } 88 89 90 public void removeListener(SysEventListener listener, 91 String newTriggeringClass, String newCode) { 92 Vector oneListenerList = (Vector ) listeners.get(newTriggeringClass + 93 "|" + newCode); 94 95 if (oneListenerList == null) { 96 return; 97 } 98 for (Enumeration ee = oneListenerList.elements(); 99 ee.hasMoreElements();) { 100 SysEventListener oneListener = (SysEventListener) ee.nextElement(); 101 102 if (oneListener == listener) { 103 oneListenerList.remove(listener); 104 } 105 } 106 } 107 108 109 public void trigger(SysEvent theEvent) { 110 Vector oneListenerList = (Vector ) listeners.get(theEvent.getTriggeringObjectClass() + 111 "|" + 112 theEvent.getEventCode()); 113 114 if (oneListenerList == null) { 115 116 117 return; 118 } 119 for (Enumeration ee = oneListenerList.elements(); 120 ee.hasMoreElements();) { 121 SysEventListener oneListener = (SysEventListener) ee.nextElement(); 122 oneListener.receiveEvent(theEvent); 123 } 124 } 125 } | Popular Tags |