Index: src/main/java/org/drools/common/AbstractWorkingMemory.java =================================================================== --- src/main/java/org/drools/common/AbstractWorkingMemory.java (revision 32996) +++ src/main/java/org/drools/common/AbstractWorkingMemory.java (working copy) @@ -81,7 +81,6 @@ import org.drools.reteoo.InitialFactHandleDummyObject; import org.drools.reteoo.LIANodePropagation; import org.drools.reteoo.LeftTuple; -import org.drools.reteoo.ModifyPreviousTuples; import org.drools.reteoo.ObjectTypeConf; import org.drools.reteoo.PartitionManager; import org.drools.reteoo.PartitionTaskManager; @@ -266,10 +265,47 @@ public AbstractWorkingMemory(final int id, final InternalRuleBase ruleBase, final FactHandleFactory handleFactory, + final SessionConfiguration config, + final Environment environment, + final WorkingMemoryEventSupport workingMemoryEventSupport, + final AgendaEventSupport agendaEventSupport, + final RuleFlowEventSupport ruleFlowEventSupport) { + this( id, + ruleBase, + handleFactory, + null, + 0, + config, + environment, + workingMemoryEventSupport, + agendaEventSupport, + ruleFlowEventSupport); +} + + public AbstractWorkingMemory(final int id, + final InternalRuleBase ruleBase, + final FactHandleFactory handleFactory, final InitialFactHandle initialFactHandle, final long propagationContext, final SessionConfiguration config, - final Environment environment) { + final Environment environment) + { + this( id, ruleBase, handleFactory, initialFactHandle, propagationContext, config, environment, + new WorkingMemoryEventSupport(), + new AgendaEventSupport(), + new RuleFlowEventSupport()); + } + + public AbstractWorkingMemory(final int id, + final InternalRuleBase ruleBase, + final FactHandleFactory handleFactory, + final InitialFactHandle initialFactHandle, + final long propagationContext, + final SessionConfiguration config, + final Environment environment, + final WorkingMemoryEventSupport workingMemoryEventSupport, + final AgendaEventSupport agendaEventSupport, + final RuleFlowEventSupport ruleFlowEventSupport) { this.id = id; this.config = config; this.ruleBase = ruleBase; @@ -311,9 +347,9 @@ this.actionQueue = new LinkedList(); this.addRemovePropertyChangeListenerArgs = new Object[]{this}; - this.workingMemoryEventSupport = new WorkingMemoryEventSupport(); - this.agendaEventSupport = new AgendaEventSupport(); - this.workflowEventSupport = new RuleFlowEventSupport(); + this.workingMemoryEventSupport = workingMemoryEventSupport; + this.agendaEventSupport = agendaEventSupport; + this.workflowEventSupport = ruleFlowEventSupport; this.__ruleBaseEventListeners = new LinkedList(); this.lock = new ReentrantLock(); this.liaPropagations = Collections.EMPTY_LIST; Index: src/main/java/org/drools/reteoo/ReteooStatelessSession.java =================================================================== --- src/main/java/org/drools/reteoo/ReteooStatelessSession.java (revision 32996) +++ src/main/java/org/drools/reteoo/ReteooStatelessSession.java (working copy) @@ -5,6 +5,7 @@ import java.io.ObjectInput; import java.io.ObjectOutput; import java.util.Collection; +import java.util.EventListener; import java.util.Iterator; import java.util.List; @@ -20,6 +21,7 @@ import org.drools.concurrent.CommandExecutor; import org.drools.concurrent.ExecutorService; import org.drools.concurrent.FireAllRules; +import org.drools.event.AbstractEventSupport; import org.drools.event.AgendaEventListener; import org.drools.event.AgendaEventSupport; import org.drools.event.RuleBaseEventListener; @@ -90,12 +92,12 @@ InternalWorkingMemory wm = new ReteooWorkingMemory( this.ruleBase.nextWorkingMemoryCounter(), this.ruleBase, this.sessionConf, - EnvironmentFactory.newEnvironment() ); + EnvironmentFactory.newEnvironment(), + this.workingMemoryEventSupport, + this.agendaEventSupport, + this.ruleFlowEventSupport); wm.setGlobalResolver( this.globalResolver ); - wm.setWorkingMemoryEventSupport( this.workingMemoryEventSupport ); - wm.setAgendaEventSupport( this.agendaEventSupport ); - wm.setRuleFlowEventSupport( ruleFlowEventSupport ); final InitialFactHandleDummyObject initialFact = new InitialFactHandleDummyObject(); final InitialFactHandle handle = new InitialFactHandle( wm.getFactHandleFactory().newFactHandle( initialFact, @@ -112,7 +114,16 @@ } } - public void addEventListener(final WorkingMemoryEventListener listener) { + private void addAllEventListeners(List eventListeners, + AbstractEventSupport eventSupport) + { + for(E listener : eventListeners) + { + eventSupport.addEventListener(listener); + } + } + + public void addEventListener(final WorkingMemoryEventListener listener) { this.workingMemoryEventSupport.addEventListener( listener ); } Index: src/main/java/org/drools/reteoo/ReteooWorkingMemory.java =================================================================== --- src/main/java/org/drools/reteoo/ReteooWorkingMemory.java (revision 32996) +++ src/main/java/org/drools/reteoo/ReteooWorkingMemory.java (working copy) @@ -20,15 +20,11 @@ import java.io.ObjectInput; import java.io.ObjectOutput; import java.util.Collection; -import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import org.drools.FactHandle; import org.drools.QueryResults; import org.drools.SessionConfiguration; +import org.drools.base.DroolsQuery; import org.drools.base.StandardQueryViewChangedEventListener; -import org.drools.base.DroolsQuery; import org.drools.common.AbstractWorkingMemory; import org.drools.common.DefaultAgenda; import org.drools.common.EventFactHandle; @@ -38,21 +34,22 @@ import org.drools.common.InternalWorkingMemory; import org.drools.common.PropagationContextImpl; import org.drools.common.WorkingMemoryAction; +import org.drools.event.AgendaEventSupport; +import org.drools.event.RuleFlowEventSupport; +import org.drools.event.WorkingMemoryEventSupport; import org.drools.impl.EnvironmentFactory; import org.drools.marshalling.impl.MarshallerReaderContext; import org.drools.marshalling.impl.MarshallerWriteContext; import org.drools.rule.Declaration; import org.drools.rule.EntryPoint; import org.drools.rule.Package; -import org.drools.rule.Query; import org.drools.rule.Rule; import org.drools.runtime.Environment; import org.drools.runtime.ObjectFilter; import org.drools.runtime.rule.LiveQuery; import org.drools.runtime.rule.ViewChangedEventListener; +import org.drools.runtime.rule.impl.LiveQueryImpl; import org.drools.runtime.rule.impl.OpenQueryViewChangedEventListenerAdapter; -import org.drools.runtime.rule.impl.LiveQueryImpl; -import org.drools.runtime.rule.impl.RowAdapter; import org.drools.spi.FactHandleFactory; import org.drools.spi.PropagationContext; @@ -100,7 +97,27 @@ this.agenda = new DefaultAgenda( ruleBase ); this.agenda.setWorkingMemory( this ); } + public ReteooWorkingMemory(final int id, + final InternalRuleBase ruleBase, + final SessionConfiguration config, + final Environment environment, + final WorkingMemoryEventSupport workingMemoryEventSupport, + final AgendaEventSupport agendaEventSupport, + final RuleFlowEventSupport ruleFlowEventSupport) { + super( id, + ruleBase, + ruleBase.newFactHandleFactory(), + config, + environment, + workingMemoryEventSupport, + agendaEventSupport, + ruleFlowEventSupport); + this.agenda = new DefaultAgenda( ruleBase ); + this.agenda.setWorkingMemory( this ); +} + + public ReteooWorkingMemory(final int id, final InternalRuleBase ruleBase, final FactHandleFactory handleFactory,