Skip to content

Commit

Permalink
[DROOLS-751] fix jbpm compilation issues
Browse files Browse the repository at this point in the history
  • Loading branch information
mariofusco committed May 5, 2015
1 parent f79eadd commit a8d64d1
Show file tree
Hide file tree
Showing 9 changed files with 48 additions and 36 deletions.
Expand Up @@ -104,7 +104,10 @@ public void clearNodeMemory(MemoryFactory node) {

public void executeQueuedActions() {
// TODO Auto-generated method stub

}

public void executeQueuedActionsForRete() {
// TODO Auto-generated method stub
}

public void executeQueuedActions(boolean flushPropagations) {
Expand Down
Expand Up @@ -61,7 +61,7 @@ public interface InternalWorkingMemory

ObjectStore getObjectStore();

void executeQueuedActions();
void executeQueuedActionsForRete();

void queueWorkingMemoryAction(final WorkingMemoryAction action);

Expand Down
Expand Up @@ -260,7 +260,7 @@ public void insert(final InternalFactHandle handle,
PropagationContext pctx) {
this.kBase.executeQueuedActions();

this.wm.executeQueuedActions();
this.wm.executeQueuedActionsForRete();

if ( activation != null ) {
// release resources so that they can be GC'ed
Expand All @@ -286,7 +286,7 @@ public void insert(final InternalFactHandle handle,
object,
this.wm);

this.wm.executeQueuedActions();
this.wm.executeQueuedActionsForRete();

if ( rule == null ) {
// This is not needed for internal WM actions as the firing rule will unstage
Expand Down Expand Up @@ -443,7 +443,7 @@ public void update(InternalFactHandle handle, Object object, Object originalObje
object,
this.wm);

this.wm.executeQueuedActions();
this.wm.executeQueuedActionsForRete();

if ( rule == null ) {
// This is not needed for internal WM actions as the firing rule will unstage
Expand Down Expand Up @@ -574,7 +574,7 @@ public PropagationContext delete(InternalFactHandle handle, Object object, Objec
object,
this.wm);

this.wm.executeQueuedActions();
this.wm.executeQueuedActionsForRete();


if ( rule == null ) {
Expand Down
Expand Up @@ -1553,6 +1553,10 @@ public void update(FactHandle factHandle,
}

public void executeQueuedActions() {
flushPropagations();
}

public void executeQueuedActionsForRete() {
// NO-OP: this is necessary only for rete
}

Expand Down Expand Up @@ -2126,12 +2130,12 @@ public void flushPropagations() {
} finally {
endOperation();
}
executeQueuedActions();
executeQueuedActionsForRete();
}

public void flushNonMarshallablePropagations() {
propagationList.flushNonMarshallable(this);
executeQueuedActions();
executeQueuedActionsForRete();
}

public boolean hasPendingPropagations() {
Expand Down
@@ -1,7 +1,9 @@
package org.drools.core.phreak;

import org.drools.core.common.InternalFactHandle;
import org.drools.core.common.InternalKnowledgeRuntime;
import org.drools.core.common.InternalWorkingMemory;
import org.drools.core.impl.StatefulKnowledgeSessionImpl;
import org.drools.core.reteoo.EntryPointNode;
import org.drools.core.reteoo.ObjectTypeConf;
import org.drools.core.reteoo.ObjectTypeNode;
Expand All @@ -10,6 +12,7 @@
public interface PropagationEntry {

void execute(InternalWorkingMemory wm);
void execute(InternalKnowledgeRuntime kruntime);

PropagationEntry getNext();
void setNext(PropagationEntry next);
Expand All @@ -31,6 +34,11 @@ public PropagationEntry getNext() {
public boolean isMarshallable() {
return false;
}

@Override
public void execute(InternalKnowledgeRuntime kruntime) {
execute( ((StatefulKnowledgeSessionImpl) kruntime).getInternalWorkingMemory() );
}
}

class Insert extends AbstractPropagationEntry {
Expand Down
Expand Up @@ -1219,7 +1219,7 @@ public int fireNextItem(final AgendaFilter filter,
// otherwise cancel it and try the next

//necessary to perfom queued actions like signal to a next node in a ruleflow/jbpm process
this.workingMemory.executeQueuedActions();
this.workingMemory.executeQueuedActionsForRete();

final EventSupport eventsupport = (EventSupport) this.workingMemory;
eventsupport.getAgendaEventSupport().fireActivationCancelled( item,
Expand Down Expand Up @@ -1433,7 +1433,7 @@ public void fireUntilHalt(final AgendaFilter agendaFilter) {
while ( continueFiring( -1 ) ) {
boolean fired = fireNextItem( agendaFilter, 0, -1 ) >= 0 ||
!((ReteWorkingMemory) this.workingMemory).getActionQueue().isEmpty();
this.workingMemory.executeQueuedActions();
this.workingMemory.executeQueuedActionsForRete();
if ( !fired ) {
try {
synchronized ( this.halt ) {
Expand All @@ -1445,7 +1445,7 @@ public void fireUntilHalt(final AgendaFilter agendaFilter) {
this.halt.set( true );
}
} else {
this.workingMemory.executeQueuedActions();
this.workingMemory.executeQueuedActionsForRete();
}
}
if ( log.isTraceEnabled() ) {
Expand All @@ -1463,7 +1463,7 @@ public int fireAllRules(AgendaFilter agendaFilter,
do {
returnedFireCount = fireNextItem( agendaFilter, fireCount, fireLimit );
fireCount += returnedFireCount;
this.workingMemory.executeQueuedActions();
this.workingMemory.executeQueuedActionsForRete();
} while ( continueFiring( 0 ) && returnedFireCount != 0 && (fireLimit == -1 || (fireCount < fireLimit)) );
if ( this.focusStack.size() == 1 && getMainAgendaGroup().isEmpty() ) {
// the root MAIN agenda group is empty, reset active to false, so it can receive more activations.
Expand Down
Expand Up @@ -138,7 +138,7 @@ private int internalFireAllRules(AgendaFilter agendaFilter, int fireLimit) {
}

// do we need to call this in advance?
executeQueuedActions();
executeQueuedActionsForRete();

fireCount = this.agenda.fireAllRules( agendaFilter,
fireLimit );
Expand Down Expand Up @@ -211,7 +211,7 @@ public void addPropagation(PropagationEntry propagationEntry) {
}

@Override
public void executeQueuedActions() {
public void executeQueuedActionsForRete() {
try {
startOperation();
if ( evaluatingActionQueue.compareAndSet( false,
Expand Down
Expand Up @@ -1705,7 +1705,7 @@ public String getName() {
agenda.fireNextItem(null, 0, -1);
assertEquals(0,
ruleFlowGroup0.size());
ksession.executeQueuedActions();
ksession.executeQueuedActionsForRete();
assertEquals(0, ruleFlowGroup0.size());
agenda.fireNextItem(null, 0, -1);
assertFalse(ruleFlowGroup0.isActive());
Expand Down
Expand Up @@ -16,25 +16,19 @@

package org.drools.reteoo.common;

import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectOutput;

import org.drools.core.RuleBaseConfiguration;
import org.drools.core.beliefsystem.ModedAssertion;
import org.kie.api.runtime.rule.FactHandle;
import org.drools.core.WorkingMemory;
import org.drools.core.base.ClassObjectType;
import org.drools.core.base.DefaultKnowledgeHelper;
import org.drools.core.beliefsystem.BeliefSet;
import org.drools.core.beliefsystem.ModedAssertion;
import org.drools.core.beliefsystem.simple.SimpleLogicalDependency;
import org.drools.core.common.DefaultFactHandle;
import org.drools.core.common.EqualityKey;
import org.drools.core.common.InternalAgenda;
import org.drools.core.common.InternalFactHandle;
import org.drools.core.common.InternalWorkingMemory;
import org.drools.core.common.LogicalDependency;
import org.drools.core.common.NamedEntryPoint;
import org.drools.core.beliefsystem.simple.SimpleLogicalDependency;
import org.drools.core.common.PropagationContextFactory;
import org.drools.core.common.TruthMaintenanceSystem;
import org.drools.core.definitions.rule.impl.RuleImpl;
Expand All @@ -46,30 +40,33 @@
import org.drools.core.reteoo.MockTupleSource;
import org.drools.core.reteoo.ObjectTypeNode;
import org.drools.core.reteoo.Rete;
import org.drools.core.reteoo.ReteooBuilder.IdGenerator;
import org.drools.core.reteoo.RightTuple;
import org.drools.core.reteoo.RuleTerminalNode;
import org.drools.core.reteoo.RuleTerminalNodeLeftTuple;
import org.drools.core.reteoo.builder.BuildContext;
import org.drools.core.rule.EntryPointId;
import org.drools.core.spi.Activation;
import org.drools.core.spi.Consequence;
import org.drools.core.spi.KnowledgeHelper;
import org.drools.core.spi.PropagationContext;
import org.drools.core.test.model.Cheese;
import org.drools.core.test.model.DroolsTestCase;
import org.drools.core.util.Iterator;
import org.drools.core.util.LinkedList;
import org.drools.core.util.LinkedListEntry;
import org.drools.core.util.ObjectHashMap;
import org.drools.core.util.ObjectHashMap.ObjectEntry;
import org.drools.core.reteoo.ReteooBuilder.IdGenerator;
import org.drools.core.reteoo.builder.BuildContext;
import org.drools.core.rule.EntryPointId;
import org.drools.core.spi.Activation;
import org.drools.core.spi.Consequence;
import org.drools.core.spi.KnowledgeHelper;
import org.drools.core.spi.PropagationContext;

import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
import org.kie.api.runtime.rule.Agenda;
import org.kie.api.runtime.rule.FactHandle;
import org.kie.internal.KnowledgeBaseFactory;
import org.kie.internal.runtime.beliefs.Mode;

import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectOutput;

import static org.junit.Assert.*;

Expand Down Expand Up @@ -175,7 +172,7 @@ public String getName() {
context1,
ksession );

ksession.executeQueuedActions();
ksession.executeQueuedActionsForRete();

assertLength( 1,
sink.getRetracted() );
Expand Down Expand Up @@ -207,7 +204,7 @@ public String getName() {
context1,
ksession );

ksession.executeQueuedActions();
ksession.executeQueuedActionsForRete();

assertLength( 2,
sink.getRetracted() );
Expand Down Expand Up @@ -733,7 +730,7 @@ public String getName() {
context2,
ksession );

ksession.executeQueuedActions();
ksession.executeQueuedActionsForRete();

// because this logical fact has two relationships it shouldn't retract yet
assertLength( 0,
Expand All @@ -748,7 +745,7 @@ public String getName() {
context1,
ksession );

ksession.executeQueuedActions();
ksession.executeQueuedActionsForRete();

// Should cause the logical fact to be deleted
assertLength( 1,
Expand Down

0 comments on commit a8d64d1

Please sign in to comment.