private void processEvent ( EventModel < ? > event ) { if ( ! event . getSource ( ) . isCreatedFromInstance ( ) ) { error ( "event: " + event + "has invalid source" ) ; return ; } debug ( "EventFired: " + event . toString ( ) + " from " + event . getSource ( ) . getID ( ) ) ; submit ( ( ) -> event . lifecycleCallback ( EventLifeCycle . START ) ) ; if ( checkEventsControllers ( event ) ) { submit ( ( ) -> event . lifecycleCallback ( EventLifeCycle . APPROVED ) ) ; submit ( ( ) -> event . lifecycleCallback ( EventLifeCycle . RESOURCE ) ) ; List < ResourceModel > resourceList = getMain ( ) . getResourceManager ( ) . generateResources ( event ) ; event . addResources ( resourceList ) ; submit ( ( ) -> event . lifecycleCallback ( EventLifeCycle . LISTENERS ) ) ; List < EventListenerModel > listenersTemp = event . getAllInformations ( ) . parallelStream ( ) . map ( listeners :: get ) . filter ( Objects :: nonNull ) . flatMap ( Collection :: stream ) . distinct ( ) . collect ( Collectors . toList ( ) ) ; List < CompletableFuture > futures = listenersTemp . stream ( ) . map ( eventListener -> submit ( ( ) -> eventListener . eventFired ( event ) ) ) . collect ( Collectors . toList ( ) ) ; try { timeOut ( futures , 1000 ) ; } catch ( InterruptedException e ) { error ( "interrupted" , e ) ; } submit ( ( ) -> event . lifecycleCallback ( EventLifeCycle . OUTPUT ) ) ; getMain ( ) . getOutputManager ( ) . passDataToOutputPlugins ( event ) ; submit ( ( ) -> event . lifecycleCallback ( EventLifeCycle . ENDED ) ) ; List < EventListenerModel > finishListenersTemp = event . getAllInformations ( ) . parallelStream ( ) . map ( finishListeners :: get ) . filter ( Objects :: nonNull ) . flatMap ( Collection :: stream ) . distinct ( ) . collect ( Collectors . toList ( ) ) ; futures = finishListenersTemp . stream ( ) . map ( eventListener -> submit ( ( ) -> eventListener . eventFired ( event ) ) ) . collect ( Collectors . toList ( ) ) ; try { timeOut ( futures , 1000 ) ; } catch ( InterruptedException e ) { error ( "interrupted" , e ) ; } } else { debug ( "canceling: " + event . toString ( ) + " from " + event . getSource ( ) . getID ( ) ) ; submit ( ( ) -> event . lifecycleCallback ( EventLifeCycle . CANCELED ) ) ; } }
process the Event