public ExtendedRegisterableItemsFactory build ( ) { return new NoopExtendedRegisterableItemsFactory ( ) { private RuntimeEngine _runtime ; private List < EventListener > _listeners = new ArrayList < EventListener > ( ) ; private synchronized List < EventListener > listeners ( RuntimeEngine runtime ) { if ( _runtime != runtime ) { _runtime = runtime ; _listeners . clear ( ) ; KieRuntimeEventManager runtimeEventManager = _runtime . getKieSession ( ) ; for ( ListenerBuilder builder : _listenerBuilders ) { EventListener listener = builder . build ( runtimeEventManager ) ; if ( listener != null && ! builder . wasAutomaticRegistration ( ) ) { _listeners . add ( listener ) ; } } } return new ArrayList < EventListener > ( _listeners ) ; } @ Override public List < AgendaEventListener > getAgendaEventListeners ( RuntimeEngine runtime ) { List < AgendaEventListener > list = new ArrayList < AgendaEventListener > ( ) ; for ( EventListener listener : listeners ( runtime ) ) { if ( listener instanceof AgendaEventListener ) { list . add ( ( AgendaEventListener ) listener ) ; } } return list ; } @ Override public List < ProcessEventListener > getProcessEventListeners ( RuntimeEngine runtime ) { List < ProcessEventListener > list = new ArrayList < ProcessEventListener > ( ) ; if ( _bpm ) { // always add our EventPublisherProcessEventListener for bpm component list . add ( new EventPublisherProcessEventListener ( getServiceDomain ( ) . getEventPublisher ( ) ) ) ; } for ( EventListener listener : listeners ( runtime ) ) { if ( listener instanceof ProcessEventListener ) { list . add ( ( ProcessEventListener ) listener ) ; } } return list ; } @ Override public List < RuleRuntimeEventListener > getRuleRuntimeEventListeners ( RuntimeEngine runtime ) { List < RuleRuntimeEventListener > list = new ArrayList < RuleRuntimeEventListener > ( ) ; for ( EventListener listener : listeners ( runtime ) ) { if ( listener instanceof RuleRuntimeEventListener ) { list . add ( ( RuleRuntimeEventListener ) listener ) ; } } return list ; } @ Override public Map < String , WorkItemHandler > getWorkItemHandlers ( RuntimeEngine runtime ) { Map < String , WorkItemHandler > map = new LinkedHashMap < String , WorkItemHandler > ( ) ; // wih builder list will always be empty for rules component for ( WorkItemHandlerBuilder builder : _workItemHandlerBuilders ) { ProcessRuntime processRuntime = runtime . getKieSession ( ) ; RuntimeManager runtimeManager = null ; if ( runtime instanceof RuntimeEngineImpl ) { runtimeManager = ( ( RuntimeEngineImpl ) runtime ) . getManager ( ) ; } String name = builder . getWorkItemHandlerName ( ) ; WorkItemHandler handler = builder . build ( processRuntime , runtimeManager ) ; map . put ( name , handler ) ; } return map ; } @ Override public List < KieBaseEventListener > getKieBaseEventListeners ( RuntimeEngine runtime ) { List < KieBaseEventListener > list = new ArrayList < KieBaseEventListener > ( ) ; for ( EventListener listener : listeners ( runtime ) ) { if ( listener instanceof KieBaseEventListener ) { list . add ( ( KieBaseEventListener ) listener ) ; } } return list ; } } ; }
Builds a ExtendedRegisterableItemsFactory .