public synchronized void sendEvent ( java . util . EventObject event ) { if ( ! hasListeners || ! enabled ) return ; Object [ ] args = new Object [ 1 ] ; args [ 0 ] = event ; // send event to all listeners ListIterator iter = listeners . listIterator ( ) ; while ( iter . hasNext ( ) ) { Object client = iter . next ( ) ; try { method . invoke ( client , args ) ; } catch ( IllegalAccessException e ) { logger . error ( "ListenerManager IllegalAccessException" , e ) ; iter . remove ( ) ; } catch ( IllegalArgumentException e ) { logger . error ( "ListenerManager IllegalArgumentException" , e ) ; iter . remove ( ) ; } catch ( InvocationTargetException e ) { // logger.error("ListenerManager InvocationTargetException on " + method+ " threw exception " + e.getTargetException(), e); throw new RuntimeException ( e . getCause ( ) ) ; // pass exception to the caller of sendEvent() } } }
Send an event to all registered listeners . If an exception is thrown remove the Listener from the list