[jboss-svn-commits] JBL Code SVN: r24310 - in labs/jbossrules/trunk/drools-core/src/main/java/org/drools: reteoo and 1 other directories.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Mon Dec 8 18:01:29 EST 2008
Author: tirelli
Date: 2008-12-08 18:01:28 -0500 (Mon, 08 Dec 2008)
New Revision: 24310
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/DefaultAgenda.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/DefaultFactHandle.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/InternalFactHandle.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/NamedEntryPoint.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/EntryPointNode.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/spi/FactHandleFactory.java
Log:
retracting expired facts on the propper entry-point
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 2008-12-08 22:27:55 UTC (rev 24309)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/AbstractWorkingMemory.java 2008-12-08 23:01:28 UTC (rev 24310)
@@ -807,6 +807,7 @@
handle = this.handleFactory.newFactHandle( object,
typeConf,
this );
+ handle.setEntryPoint( this );
this.objectStore.addHandle( handle,
object );
insert( handle,
@@ -865,6 +866,7 @@
handle = this.handleFactory.newFactHandle( object,
typeConf,
this );
+ handle.setEntryPoint( this );
this.objectStore.addHandle( handle,
object );
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/DefaultAgenda.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/DefaultAgenda.java 2008-12-08 22:27:55 UTC (rev 24309)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/DefaultAgenda.java 2008-12-08 23:01:28 UTC (rev 24310)
@@ -932,12 +932,13 @@
for( LeftTuple tuple = (LeftTuple) activation.getTuple(); tuple != null; tuple = tuple.getParent() ) {
if( tuple.getLastHandle().isEvent() ) {
EventFactHandle handle = (EventFactHandle) tuple.getLastHandle();
+ // handles "expire" only in stream mode.
if( handle.isExpired() ) {
// decrease the activation count for the event
handle.decreaseActivationsCount();
if( handle.getActivationsCount() == 0 ) {
// and if no more activations, retract the handle
- workingMemory.retract( handle );
+ handle.getEntryPoint().retract( handle );
}
}
}
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/DefaultFactHandle.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/DefaultFactHandle.java 2008-12-08 22:27:55 UTC (rev 24309)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/DefaultFactHandle.java 2008-12-08 23:01:28 UTC (rev 24310)
@@ -16,9 +16,10 @@
* limitations under the License.
*/
+import org.drools.FactHandle;
+import org.drools.WorkingMemoryEntryPoint;
import org.drools.reteoo.LeftTuple;
import org.drools.reteoo.RightTuple;
-import org.drools.FactHandle;
/**
* Implementation of <code>FactHandle</code>.
@@ -35,15 +36,16 @@
/**
*
*/
- private static final long serialVersionUID = 400L;
+ private static final long serialVersionUID = 400L;
/** Handle id. */
- private int id;
- private long recency;
- private Object object;
- private EqualityKey key;
- private int objectHashCode;
- private RightTuple rightTuple;
- private LeftTuple leftTuple;
+ private int id;
+ private long recency;
+ private Object object;
+ private EqualityKey key;
+ private int objectHashCode;
+ private RightTuple rightTuple;
+ private LeftTuple leftTuple;
+ private WorkingMemoryEntryPoint entryPoint;
// ----------------------------------------------------------------------
// Constructors
@@ -133,6 +135,7 @@
public void invalidate() {
this.id = -1;
this.object = null;
+ this.entryPoint = null;
}
public Object getObject() {
@@ -164,7 +167,7 @@
public boolean isEvent() {
return false;
}
-
+
public RightTuple getRightTuple() {
return rightTuple;
}
@@ -172,12 +175,20 @@
public void setRightTuple(RightTuple rightTuple) {
this.rightTuple = rightTuple;
}
-
+
public void setLeftTuple(LeftTuple leftTuple) {
this.leftTuple = leftTuple;
}
-
- public LeftTuple getLeftTuple(){
+
+ public LeftTuple getLeftTuple() {
return this.leftTuple;
- }
+ }
+
+ public WorkingMemoryEntryPoint getEntryPoint() {
+ return entryPoint;
+ }
+
+ public void setEntryPoint(WorkingMemoryEntryPoint sourceNode) {
+ this.entryPoint = sourceNode;
+ }
}
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/InternalFactHandle.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/InternalFactHandle.java 2008-12-08 22:27:55 UTC (rev 24309)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/InternalFactHandle.java 2008-12-08 23:01:28 UTC (rev 24310)
@@ -16,9 +16,11 @@
* limitations under the License.
*/
+import org.drools.reteoo.EntryPointNode;
import org.drools.reteoo.LeftTuple;
import org.drools.reteoo.RightTuple;
import org.drools.FactHandle;
+import org.drools.WorkingMemoryEntryPoint;
public interface InternalFactHandle
extends
@@ -57,4 +59,9 @@
public void setLeftTuple(LeftTuple leftTuple);
public LeftTuple getLeftTuple();
+
+ public WorkingMemoryEntryPoint getEntryPoint();
+
+ public void setEntryPoint( WorkingMemoryEntryPoint ep );
+
}
\ No newline at end of file
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/NamedEntryPoint.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/NamedEntryPoint.java 2008-12-08 22:27:55 UTC (rev 24309)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/NamedEntryPoint.java 2008-12-08 23:01:28 UTC (rev 24310)
@@ -105,6 +105,7 @@
InternalFactHandle handle = this.handleFactory.newFactHandle( object,
typeConf,
wm );
+ handle.setEntryPoint( this );
this.objectStore.addHandle( handle,
object );
@@ -289,7 +290,7 @@
this.wm );
this.objectStore.removeHandle( handle );
-
+
this.handleFactory.destroyFactHandle( handle );
this.wm.executeQueuedActions();
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/EntryPointNode.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/EntryPointNode.java 2008-12-08 22:27:55 UTC (rev 24309)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/EntryPointNode.java 2008-12-08 23:01:28 UTC (rev 24310)
@@ -139,7 +139,7 @@
// know it is safe to update the information the engine can see.
((ShadowProxy) handle.getObject()).updateProxy();
}
-
+
ObjectTypeNode[] cachedNodes = objectTypeConf.getObjectTypeNodes();
for ( int i = 0, length = cachedNodes.length; i < length; i++ ) {
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/spi/FactHandleFactory.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/spi/FactHandleFactory.java 2008-12-08 22:27:55 UTC (rev 24309)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/spi/FactHandleFactory.java 2008-12-08 23:01:28 UTC (rev 24310)
@@ -16,10 +16,10 @@
* limitations under the License.
*/
+import org.drools.FactHandle;
import org.drools.common.InternalFactHandle;
import org.drools.common.InternalWorkingMemory;
import org.drools.reteoo.ObjectTypeConf;
-import org.drools.FactHandle;
/**
* Factory Interface to return new <code>FactHandle</code>s
@@ -54,7 +54,7 @@
public FactHandleFactory newInstance(int id, long counter);
- public Class getFactHandleType();
+ public Class<?> getFactHandleType();
public int getId();
More information about the jboss-svn-commits
mailing list