1 23 24 37 package com.sun.enterprise.server.event; 38 39 import java.util.ArrayList ; 40 41 import java.util.logging.Level ; 42 import java.util.logging.Logger ; 43 44 import com.sun.logging.LogDomains; 45 46 public class ApplicationLoaderEventNotifier { 47 48 private static Logger _logger = 49 LogDomains.getLogger(LogDomains.LOADER_LOGGER); 50 51 private static ApplicationLoaderEventNotifier _notifier = 52 new ApplicationLoaderEventNotifier(); 53 54 private ArrayList listeners = new ArrayList (); 55 56 private ArrayList appclientListeners = new ArrayList (); 57 58 private ApplicationLoaderEventNotifier() { 59 } 60 61 public static ApplicationLoaderEventNotifier getInstance() { 62 return _notifier; 63 } 64 65 public void addListener(ApplicationLoaderEventListener listener) { 66 synchronized (listeners) { 67 listeners.add(listener); 68 } 69 } 70 71 public void removeListener(ApplicationLoaderEventListener listener) { 72 synchronized (listeners) { 73 listeners.remove(listener); 74 } 75 } 76 77 public void addListener(ApplicationClientLoaderEventListener listener) { 78 synchronized (appclientListeners) { 79 appclientListeners.add(listener); 80 } 81 } 82 83 public void removeListener(ApplicationClientLoaderEventListener listener) { 84 synchronized (appclientListeners) { 85 appclientListeners.remove(listener); 86 } 87 } 88 89 public void notifyListeners(ApplicationEvent event) { 90 ArrayList myListeners = null; 91 92 _logger.log(Level.FINE, "LoaderEventNotifier: " + event); 93 94 synchronized (listeners) { 95 myListeners = (ArrayList ) listeners.clone(); 96 } 97 98 int sz = myListeners.size(); 99 for (int i=0; i<sz; i++) { 100 ApplicationLoaderEventListener listener = 101 (ApplicationLoaderEventListener) myListeners.get(i); 102 103 try { 104 listener.handleApplicationEvent(event); 105 } catch (Exception ex) { 106 _logger.log(Level.WARNING, "Exception during " 107 + "handleApplicationEvent", ex); 108 } 109 } 110 } 111 112 public void notifyListeners(EjbContainerEvent event) { 113 ArrayList myListeners = null; 114 115 _logger.log(Level.FINE, "LoaderEventNotifier: " + event); 116 117 synchronized (listeners) { 118 myListeners = (ArrayList ) listeners.clone(); 119 } 120 121 int sz = myListeners.size(); 122 for (int i=0; i<sz; i++) { 123 ApplicationLoaderEventListener listener = 124 (ApplicationLoaderEventListener) myListeners.get(i); 125 126 try { 127 listener.handleEjbContainerEvent(event); 128 } catch (Exception ex) { 129 _logger.log(Level.WARNING, "Exception during " 130 + "handleEjbContainerEvent", ex); 131 } 132 } 133 } 134 135 public void notifyListeners(ApplicationClientEvent event) { 136 ArrayList myListeners = null; 137 138 _logger.log(Level.FINE, "LoaderEventNotifier: " + event); 139 140 synchronized (appclientListeners) { 141 myListeners = (ArrayList ) appclientListeners.clone(); 142 } 143 144 int sz = myListeners.size(); 145 for (int i=0; i<sz; i++) { 146 ApplicationClientLoaderEventListener listener = 147 (ApplicationClientLoaderEventListener) myListeners.get(i); 148 149 try { 150 listener.handleApplicationClientEvent(event); 151 } catch (Exception ex) { 152 _logger.log(Level.WARNING, "Exception during " 153 + "handleApplicationClientEvent", ex); 154 } 155 } 156 } 157 } 158 | Popular Tags |