[jboss-svn-commits] JBL Code SVN: r36570 - labs/jbossrules/soa_branches/BRMS-5.1-GA_SOA-2771/drools-core/src/main/java/org/drools/impl.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Mon Jan 24 11:11:34 EST 2011
Author: tsurdilovic
Date: 2011-01-24 11:11:33 -0500 (Mon, 24 Jan 2011)
New Revision: 36570
Modified:
labs/jbossrules/soa_branches/BRMS-5.1-GA_SOA-2771/drools-core/src/main/java/org/drools/impl/StatelessKnowledgeSessionImpl.java
Log:
SOA-2771 : Ruleflow broken inside BusinessRulesProcessor
Modified: labs/jbossrules/soa_branches/BRMS-5.1-GA_SOA-2771/drools-core/src/main/java/org/drools/impl/StatelessKnowledgeSessionImpl.java
===================================================================
--- labs/jbossrules/soa_branches/BRMS-5.1-GA_SOA-2771/drools-core/src/main/java/org/drools/impl/StatelessKnowledgeSessionImpl.java 2011-01-24 15:18:27 UTC (rev 36569)
+++ labs/jbossrules/soa_branches/BRMS-5.1-GA_SOA-2771/drools-core/src/main/java/org/drools/impl/StatelessKnowledgeSessionImpl.java 2011-01-24 16:11:33 UTC (rev 36570)
@@ -16,6 +16,7 @@
package org.drools.impl;
+import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.IdentityHashMap;
@@ -75,6 +76,7 @@
public WorkingMemoryEventSupport workingMemoryEventSupport = new WorkingMemoryEventSupport();
public AgendaEventSupport agendaEventSupport = new AgendaEventSupport();
public RuleFlowEventSupport ruleFlowEventSupport = new RuleFlowEventSupport();
+ public List<RuleFlowEventListener> copiedRuleFlowEventListeners = new ArrayList<RuleFlowEventListener>();
private KnowledgeSessionConfiguration conf;
private Environment environment;
@@ -135,10 +137,12 @@
(SessionConfiguration) this.conf,
this.environment );
- // copy the wm event listeners
+ // copy the ruleflow event listeners
Iterator<RuleFlowEventListener> wmFlowListenerIter = wm.getRuleFlowEventListeners().iterator();
while ( wmFlowListenerIter.hasNext() ) {
- this.ruleFlowEventSupport.addEventListener(wmFlowListenerIter.next());
+ RuleFlowEventListener rfel = wmFlowListenerIter.next();
+ this.ruleFlowEventSupport.addEventListener(rfel);
+ this.copiedRuleFlowEventListeners.add(rfel);
}
wm.setRuleFlowEventSupport( this.ruleFlowEventSupport );
}
@@ -300,6 +304,7 @@
}
} finally {
((StatefulKnowledgeSessionImpl) ksession).session.endBatchExecution();
+ cleanupRuleFlowEventListeners();
}
}
@@ -308,6 +313,7 @@
ksession.insert( object );
ksession.fireAllRules( );
+ cleanupRuleFlowEventListeners( );
}
public void execute(Iterable objects) {
@@ -317,10 +323,22 @@
ksession.insert( object );
}
ksession.fireAllRules( );
+ cleanupRuleFlowEventListeners( );
}
public Environment getEnvironment() {
return environment;
}
+
+ private void cleanupRuleFlowEventListeners() {
+ if(this.ruleFlowEventSupport.getEventListeners().size() > 0 && (this.copiedRuleFlowEventListeners != null && this.copiedRuleFlowEventListeners.size() > 0)) {
+ for(RuleFlowEventListener nextEventListener : this.copiedRuleFlowEventListeners) {
+ if(this.ruleFlowEventSupport.getEventListeners().contains(nextEventListener)) {
+ this.ruleFlowEventSupport.removeEventListener(nextEventListener);
+ }
+ }
+ }
+ this.copiedRuleFlowEventListeners = new ArrayList<RuleFlowEventListener>();
+ }
}
More information about the jboss-svn-commits
mailing list