public Result next ( ActivityContext ac , EventContext sleeEvent , Set < SbbEntityID > sbbEntitiesThatHandledCurrentEvent , SleeContainer sleeContainer ) { SbbEntityID sbbEntityId = null ; SbbEntity sbbEntity = null ; EventEntryDescriptor mEventEntry = null ; // get the highest priority sbb from sbb entities attached to AC for ( Iterator < SbbEntityID > iter = ac . getSortedSbbAttachmentSet ( sbbEntitiesThatHandledCurrentEvent ) . iterator ( ) ; iter . hasNext ( ) ; ) { sbbEntityId = iter . next ( ) ; sbbEntity = sleeContainer . getSbbEntityFactory ( ) . getSbbEntity ( sbbEntityId , true ) ; if ( sbbEntity == null ) { // ignore, sbb entity has been removed continue ; } if ( eventRouterConfiguration . isConfirmSbbEntityAttachement ( ) && ! sbbEntity . isAttached ( ac . getActivityContextHandle ( ) ) ) { // detached by a concurrent tx, see Issue 2313 continue ; } if ( sleeEvent . getService ( ) != null && ! sleeEvent . getService ( ) . equals ( sbbEntityId . getServiceID ( ) ) ) { if ( ! sleeEvent . isActivityEndEvent ( ) ) { continue ; } else { return new Result ( sbbEntity , false ) ; } } // check event is allowed to be handled by the sbb mEventEntry = sbbEntity . getSbbComponent ( ) . getDescriptor ( ) . getEventEntries ( ) . get ( sleeEvent . getEventTypeId ( ) ) ; if ( mEventEntry != null && mEventEntry . isReceived ( ) ) { return new Result ( sbbEntity , true ) ; } else { if ( ! sleeEvent . isActivityEndEvent ( ) ) { if ( logger . isDebugEnabled ( ) ) { logger . debug ( "Event is not received by sbb descriptor of entity " + sbbEntityId + ", will not deliver event to sbb entity ..." ) ; } continue ; } else { return new Result ( sbbEntity , false ) ; } } } return null ; }
Retrieves the next sbb entity to handle the event .