[jboss-svn-commits] JBL Code SVN: r25749 - in labs/jbossrules/trunk: drools-compiler/src/test/resources/org/drools/integrationtests and 2 other directories.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Thu Mar 19 12:10:36 EDT 2009
Author: tirelli
Date: 2009-03-19 12:10:35 -0400 (Thu, 19 Mar 2009)
New Revision: 25749
Removed:
labs/jbossrules/trunk/drools-compiler/src/test/resources/org/drools/integrationtests/test_EntryPoint_ModifyEvent.drl
Modified:
labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/integrationtests/StreamsTest.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/DefaultKnowledgeHelper.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/AbstractWorkingMemory.java
Log:
Reverting commit #25714
Modified: labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/integrationtests/StreamsTest.java
===================================================================
--- labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/integrationtests/StreamsTest.java 2009-03-19 16:00:28 UTC (rev 25748)
+++ labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/integrationtests/StreamsTest.java 2009-03-19 16:10:35 UTC (rev 25749)
@@ -242,99 +242,4 @@
assertTrue( eps.contains( s2 ) );
assertTrue( eps.contains( s3 ) );
}
-
- public void testEventModify() throws Exception {
- // read in the source
- KnowledgeBase kbase = loadKnowledgeBase( "test_EntryPoint_ModifyEvent.drl" );
- //final RuleBase ruleBase = loadRuleBase( reader );
-
- KnowledgeSessionConfiguration conf = new SessionConfiguration();
- ((SessionConfiguration) conf).setClockType( ClockType.PSEUDO_CLOCK );
- StatefulKnowledgeSession session = kbase.newStatefulKnowledgeSession( conf, null );
-
- final List results = new ArrayList();
-
- session.setGlobal( "results",
- results );
-
- StockTick tick1 = new StockTick( 1,
- "DROO",
- 50,
- System.currentTimeMillis() );
- StockTick tick2 = new StockTick( 2,
- "ACME",
- 10,
- System.currentTimeMillis() );
- StockTick tick3 = new StockTick( 3,
- "ACME",
- 10,
- System.currentTimeMillis() );
- StockTick tick4 = new StockTick( 4,
- "DROO",
- 50,
- System.currentTimeMillis() );
-
- InternalFactHandle handle1 = (InternalFactHandle) session.insert( tick1 );
- InternalFactHandle handle2 = (InternalFactHandle) session.insert( tick2 );
- InternalFactHandle handle3 = (InternalFactHandle) session.insert( tick3 );
- InternalFactHandle handle4 = (InternalFactHandle) session.insert( tick4 );
-
- assertNotNull( handle1 );
- assertNotNull( handle2 );
- assertNotNull( handle3 );
- assertNotNull( handle4 );
-
- assertTrue( handle1.isEvent() );
- assertTrue( handle2.isEvent() );
- assertTrue( handle3.isEvent() );
- assertTrue( handle4.isEvent() );
-
- session.fireAllRules();
-
- assertEquals( 0,
- results.size() );
-
- StockTick tick5 = new StockTick( 5,
- "DROO",
- 50,
- System.currentTimeMillis() );
- StockTick tick6 = new StockTick( 6,
- "ACME",
- 10,
- System.currentTimeMillis() );
- StockTick tick7 = new StockTick( 7,
- "ACME",
- 15,
- System.currentTimeMillis() );
- StockTick tick8 = new StockTick( 8,
- "DROO",
- 50,
- System.currentTimeMillis() );
-
- WorkingMemoryEntryPoint entry = session.getWorkingMemoryEntryPoint( "StockStream" );
-
- InternalFactHandle handle5 = (InternalFactHandle) entry.insert( tick5 );
- InternalFactHandle handle6 = (InternalFactHandle) entry.insert( tick6 );
- InternalFactHandle handle7 = (InternalFactHandle) entry.insert( tick7 );
- InternalFactHandle handle8 = (InternalFactHandle) entry.insert( tick8 );
-
- assertNotNull( handle5 );
- assertNotNull( handle6 );
- assertNotNull( handle7 );
- assertNotNull( handle8 );
-
- assertTrue( handle5.isEvent() );
- assertTrue( handle6.isEvent() );
- assertTrue( handle7.isEvent() );
- assertTrue( handle8.isEvent() );
-
- session.fireAllRules();
-
- assertEquals( 1,
- results.size() );
- assertSame( tick7,
- results.get( 0 ) );
-
-
- }
}
Deleted: labs/jbossrules/trunk/drools-compiler/src/test/resources/org/drools/integrationtests/test_EntryPoint_ModifyEvent.drl
===================================================================
--- labs/jbossrules/trunk/drools-compiler/src/test/resources/org/drools/integrationtests/test_EntryPoint_ModifyEvent.drl 2009-03-19 16:00:28 UTC (rev 25748)
+++ labs/jbossrules/trunk/drools-compiler/src/test/resources/org/drools/integrationtests/test_EntryPoint_ModifyEvent.drl 2009-03-19 16:10:35 UTC (rev 25749)
@@ -1,23 +0,0 @@
-package org.drools;
-
-import org.drools.StockTick;
-
-global java.util.List results;
-
-declare StockTick
- @role( event )
-end
-
-rule "Test entry point modify event"
- #dialect "mvel"
-when
- $st : StockTick( company == "ACME", price > 10 ) from entry-point StockStream
-then
- modify( $st ){
- setPrice(10)
- }
- #modify ( $st ){
- # price = 10
- #}
- results.add( $st );
-end
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/DefaultKnowledgeHelper.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/DefaultKnowledgeHelper.java 2009-03-19 16:00:28 UTC (rev 25748)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/DefaultKnowledgeHelper.java 2009-03-19 16:10:35 UTC (rev 25749)
@@ -21,14 +21,16 @@
import java.io.ObjectInput;
import java.io.ObjectOutput;
import java.util.Collections;
-import java.util.IdentityHashMap;
import java.util.Map;
import org.drools.FactException;
+import org.drools.common.InternalFactHandle;
import org.drools.common.InternalWorkingMemoryActions;
import org.drools.impl.StatefulKnowledgeSessionImpl;
+import org.drools.reteoo.ReteooStatefulSession;
import org.drools.reteoo.ReteooWorkingMemory;
import org.drools.rule.Declaration;
+import org.drools.rule.EntryPoint;
import org.drools.rule.GroupElement;
import org.drools.rule.Rule;
import org.drools.runtime.ExitPoint;
@@ -53,19 +55,12 @@
private Tuple tuple;
private InternalWorkingMemoryActions workingMemory;
- private IdentityHashMap<Object,FactHandle> identityMap;
-
public DefaultKnowledgeHelper() {
-
- this.identityMap = new IdentityHashMap<Object,FactHandle>();
}
public DefaultKnowledgeHelper(final WorkingMemory workingMemory) {
this.workingMemory = (InternalWorkingMemoryActions) workingMemory;
-
- this.identityMap = new IdentityHashMap<Object,FactHandle>();
-
}
public void readExternal(ObjectInput in) throws IOException,
@@ -106,28 +101,25 @@
public void insert(final Object object,
final boolean dynamic) throws FactException {
- FactHandle handle = this.workingMemory.insert( object,
+ this.workingMemory.insert( object,
dynamic,
false,
this.rule,
this.activation );
- this.identityMap.put(object, handle);
}
public void insertLogical(final Object object) throws FactException {
insertLogical( object,
false );
-
}
public void insertLogical(final Object object,
final boolean dynamic) throws FactException {
- FactHandle handle = this.workingMemory.insert( object,
+ this.workingMemory.insert( object,
dynamic,
true,
this.rule,
this.activation );
- this.identityMap.put(object, handle);
}
public void update(final FactHandle handle,
@@ -160,7 +152,7 @@
}
public void retract(final Object object) throws FactException {
- FactHandle handle = identityMap.get( object );
+ FactHandle handle = this.workingMemory.getFactHandleByIdentity( object );
if ( handle == null ) {
throw new FactException( "Retract error: handle not found for object: " + object + ". Is it in the working memory?" );
}
@@ -169,12 +161,10 @@
true,
this.rule,
this.activation );
- this.identityMap.remove(object);
-
}
public void modifyRetract(final Object object) {
- FactHandle handle = identityMap.get( object );
+ FactHandle handle = this.workingMemory.getFactHandleByIdentity( object );
this.workingMemory.modifyRetract( handle,
rule,
activation );
@@ -187,13 +177,11 @@
}
public void modifyInsert(final Object object) {
- FactHandle handle = identityMap.get( object );
-
+ FactHandle handle = this.workingMemory.getFactHandleByIdentity( object );
this.workingMemory.modifyInsert( handle,
object,
rule,
activation );
- this.identityMap.put(object, handle);
}
public void modifyInsert(final FactHandle factHandle,
@@ -202,7 +190,6 @@
object,
rule,
activation );
- this.identityMap.put(object, factHandle);
}
public Rule getRule() {
@@ -264,9 +251,7 @@
}
public Declaration getDeclaration(final String identifier) {
- Declaration declaration = (Declaration) this.subrule.getOuterDeclarations().get( identifier );
- identityMap.put(tuple.get(declaration).getObject(), tuple.get(declaration));
- return declaration;
+ return (Declaration) this.subrule.getOuterDeclarations().get( identifier );
}
public void halt() {
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/AbstractWorkingMemory.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/AbstractWorkingMemory.java 2009-03-19 16:00:28 UTC (rev 25748)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/AbstractWorkingMemory.java 2009-03-19 16:10:35 UTC (rev 25749)
@@ -102,7 +102,6 @@
import org.drools.time.SessionClock;
import org.drools.time.TimerService;
import org.drools.time.TimerServiceFactory;
-import org.drools.util.ObjectHashMap;
import org.drools.workflow.core.node.EventTrigger;
import org.drools.workflow.core.node.StartNode;
import org.drools.workflow.core.node.Trigger;
@@ -330,7 +329,7 @@
initPartitionManagers();
initTransient();
}
-
+
public static class GlobalsAdapter implements GlobalResolver {
private Globals globals;
@@ -1261,13 +1260,11 @@
// the hashCode and equality has changed, so we must update the
// EqualityKey
EqualityKey key = handle.getEqualityKey();
- if(key != null){
- key.removeFactHandle( handle );
+ key.removeFactHandle( handle );
- // If the equality key is now empty, then remove it
- if ( key.isEmpty() ) {
- this.tms.remove( key );
- }
+ // If the equality key is now empty, then remove it
+ if ( key.isEmpty() ) {
+ this.tms.remove( key );
}
}
} finally {
@@ -1295,22 +1292,20 @@
final Object originalObject = handle.getObject();
if ( this.maintainTms ) {
- if(handle.getEqualityKey() != null ){
- int status = handle.getEqualityKey().getStatus();
+ int status = handle.getEqualityKey().getStatus();
- // now use an existing EqualityKey, if it exists, else create a
- // new one
- EqualityKey key = this.tms.get( object );
- if ( key == null ) {
- key = new EqualityKey( handle,
- status );
- this.tms.put( key );
- } else {
- key.addFactHandle( handle );
- }
-
- handle.setEqualityKey( key );
+ // now use an existing EqualityKey, if it exists, else create a
+ // new one
+ EqualityKey key = this.tms.get( object );
+ if ( key == null ) {
+ key = new EqualityKey( handle,
+ status );
+ this.tms.put( key );
+ } else {
+ key.addFactHandle( handle );
}
+
+ handle.setEqualityKey( key );
}
this.handleFactory.increaseFactHandleRecency( handle );
More information about the jboss-svn-commits
mailing list