private void processEvent ( final Object event ) { System . out . println ( "Processing event: " + event . toString ( ) ) ; for ( final EventHandler handler : getConsumersFor ( event . getClass ( ) ) ) { EVENT_EXECUTOR . execute ( new Runnable ( ) { @ Override public void run ( ) { try { handler . handle ( event ) ; } catch ( Exception e ) { e . printStackTrace ( ) ; if ( shouldReRaiseOnError ) { System . out . println ( "Event handler failed. Re-publishing event: " + event . toString ( ) ) ; eventQueue . publish ( event ) ; } } } } ) ; } }
Runs each appropriate EventHandler in an Executor .