public synchronized void sendEvent(IApplicationEvent event) { List<IApplicationEventListener> bListeners = listeners.get(event.getBrowser()); if (bListeners != null) { for (Iterator<IApplicationEventListener> l = bListeners.iterator(); l.hasNext(); ) { IApplicationEventListener listener = l.next(); try { listener.onEvent(event); } catch (RuntimeException e) { MozideCorePlugin.log(e); } } } for (Iterator<IApplicationEventListener> l = unboundListeners.iterator(); l.hasNext(); ) { IApplicationEventListener listener = l.next(); try { listener.onEvent(event); } catch (RuntimeException e) { MozideCorePlugin.log(e); } } }
private void notifyListeners() { IApplicationEvent[] events = null; synchronized (eventsQueue) { if (eventsQueue.size() == 0) { return; } events = (IApplicationEvent[]) eventsQueue.toArray(new IApplicationEvent[eventsQueue.size()]); eventsQueue.clear(); } for (int i = 0; i < events.length; i++) { IApplicationEvent event = events[i]; try { sendEvent(event); } catch (RuntimeException e) { MozideCorePlugin.log(e); } } }