[jboss-svn-commits] JBL Code SVN: r25965 - in labs/jbossrules/trunk: drools-core/src/main/java/org/drools/base and 6 other directories.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Sun Apr 5 21:25:38 EDT 2009


Author: salaboy21
Date: 2009-04-05 21:25:37 -0400 (Sun, 05 Apr 2009)
New Revision: 25965

Modified:
   labs/jbossrules/trunk/drools-compiler/src/main/resources/org/drools/rule/builder/dialect/java/javaInvokers.mvel
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/DefaultKnowledgeHelper.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/SequentialKnowledgeHelper.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/mvel/DroolsMVELFactory.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/mvel/DroolsMVELPreviousDeclarationVariable.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/AbstractWorkingMemory.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/InternalWorkingMemoryEntryPoint.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/NamedEntryPoint.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/impl/StatefulKnowledgeSessionImpl.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/marshalling/impl/InputMarshaller.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/marshalling/impl/OutputMarshaller.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/LeftTuple.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/ReteooWorkingMemory.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/spi/KnowledgeHelper.java
Log:
fix bug, use the correct entryPoints in java and MVEL dialects, plus marshal and unmarshall the entryPoint in output and inputmarshallers

Modified: labs/jbossrules/trunk/drools-compiler/src/main/resources/org/drools/rule/builder/dialect/java/javaInvokers.mvel
===================================================================
--- labs/jbossrules/trunk/drools-compiler/src/main/resources/org/drools/rule/builder/dialect/java/javaInvokers.mvel	2009-04-06 00:53:25 UTC (rev 25964)
+++ labs/jbossrules/trunk/drools-compiler/src/main/resources/org/drools/rule/builder/dialect/java/javaInvokers.mvel	2009-04-06 01:25:37 UTC (rev 25965)
@@ -334,8 +334,9 @@
 
         @foreach{type : declarationTypes, declr : declarations, index : indexes, notPattern : notPatterns}
           org.drools.common.InternalFactHandle @{declr.identifier}__Handle__ = ( org.drools.common.InternalFactHandle ) tuple.get( knowledgeHelper.getDeclaration( declarations[@{index}].getIdentifier() ) );
-          @{type} @{declr.identifier} = ( @{type} )  declarations[@{index}].@{declr.nativeReadMethod.name}( (org.drools.common.InternalWorkingMemory) workingMemory, @{declr.identifier}__Handle__.getObject() );
+          @{type} @{declr.identifier} = ( @{type} )  declarations[@{index}].@{declr.nativeReadMethod.name}((org.drools.common.InternalWorkingMemory) workingMemory, @{declr.identifier}__Handle__.getObject() );
           @if{notPattern}@{declr.identifier}__Handle__ =  (org.drools.common.InternalFactHandle) knowledgeHelper.getWorkingMemory().getFactHandle( @{declr.identifier} );@end{}
+          knowledgeHelper.getIdentityMap().put(@{declr.identifier}, @{declr.identifier}__Handle__ );
         @end{}
 
         @foreach{type : globalTypes, identifier : globals} @{type} @{identifier} = ( @{type} ) workingMemory.getGlobal( "@{identifier}" );

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-04-06 00:53:25 UTC (rev 25964)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/DefaultKnowledgeHelper.java	2009-04-06 01:25:37 UTC (rev 25965)
@@ -21,6 +21,7 @@
 import java.io.ObjectInput;
 import java.io.ObjectOutput;
 import java.util.Collections;
+import java.util.IdentityHashMap;
 import java.util.Map;
 
 import org.drools.FactException;
@@ -35,6 +36,10 @@
 import org.drools.runtime.ExitPoint;
 import org.drools.runtime.KnowledgeRuntime;
 import org.drools.runtime.rule.WorkingMemoryEntryPoint;
+import org.drools.FactHandle;
+import org.drools.WorkingMemory;
+import org.drools.common.InternalFactHandle;
+import org.drools.common.InternalWorkingMemoryEntryPoint;
 import org.drools.spi.Activation;
 import org.drools.spi.KnowledgeHelper;
 import org.drools.spi.Tuple;
@@ -52,12 +57,17 @@
     private Tuple                        tuple;
     private InternalWorkingMemoryActions workingMemory;
 
+    private IdentityHashMap<Object,FactHandle>              identityMap;
+
     public DefaultKnowledgeHelper() {
 
     }
 
     public DefaultKnowledgeHelper(final WorkingMemory workingMemory) {
         this.workingMemory = (InternalWorkingMemoryActions) workingMemory;
+
+       this.identityMap =  new IdentityHashMap<Object,FactHandle>();
+
     }
 
     public void readExternal(ObjectInput in) throws IOException,
@@ -67,6 +77,7 @@
         activation = (Activation) in.readObject();
         tuple = (Tuple) in.readObject();
         workingMemory = (InternalWorkingMemoryActions) in.readObject();
+        identityMap = (IdentityHashMap<Object,FactHandle> ) in.readObject();
     }
 
     public void writeExternal(ObjectOutput out) throws IOException {
@@ -75,6 +86,7 @@
         out.writeObject( activation );
         out.writeObject( tuple );
         out.writeObject( workingMemory );
+         out.writeObject( identityMap );
     }
 
     public void setActivation(final Activation agendaItem) {
@@ -89,6 +101,7 @@
         this.subrule = null;
         this.activation = null;
         this.tuple = null;
+        this.identityMap.clear();
     }
 
     public void insert(final Object object) throws FactException {
@@ -98,11 +111,12 @@
 
     public void insert(final Object object,
                        final boolean dynamic) throws FactException {
-        this.workingMemory.insert( object,
+         FactHandle handle = this.workingMemory.insert( object,
                                    dynamic,
                                    false,
                                    this.rule,
                                    this.activation );
+         this.getIdentityMap().put(object, handle);
     }
 
     public void insertLogical(final Object object) throws FactException {
@@ -112,81 +126,99 @@
 
     public void insertLogical(final Object object,
                               final boolean dynamic) throws FactException {
-        this.workingMemory.insert( object,
+      FactHandle handle = this.workingMemory.insert( object,
                                    dynamic,
                                    true,
                                    this.rule,
                                    this.activation );
+        this.getIdentityMap().put(object, handle);
     }
 
     public void update(final FactHandle handle,
                        final Object newObject) throws FactException {
         // only update if this fact exists in the wm
-        this.workingMemory.update( handle,
+
+        ((InternalWorkingMemoryEntryPoint)((InternalFactHandle)handle).getEntryPoint())
+                                .update( handle,
                                    newObject,
                                    this.rule,
                                    this.activation );
+        this.getIdentityMap().put(newObject, handle);
     }
 
     public void update(final Object object) throws FactException {
-        FactHandle handle = this.workingMemory.getFactHandleByIdentity( object );
+        FactHandle handle = identityMap.get(object);
         if ( handle == null ) {
             throw new FactException( "Update error: handle not found for object: " + object + ". Is it in the working memory?" );
         }
         // only update if this fact exists in the wm
-        this.workingMemory.update( handle,
+       ((InternalWorkingMemoryEntryPoint)((InternalFactHandle)handle).getEntryPoint())
+                            .update( handle,
                                    object,
                                    this.rule,
                                    this.activation );
+       this.getIdentityMap().put(object, handle);
     }
 
     public void retract(final FactHandle handle) throws FactException {
-        this.workingMemory.retract( handle,
+        ((InternalWorkingMemoryEntryPoint)((InternalFactHandle)handle).getEntryPoint())
+                            .retract( handle,
                                     true,
                                     true,
                                     this.rule,
                                     this.activation );
+         this.getIdentityMap().remove(((InternalFactHandle)handle).getObject());
     }
 
     public void retract(final Object object) throws FactException {
-        FactHandle handle = this.workingMemory.getFactHandleByIdentity( object );
+        FactHandle handle = getIdentityMap().get( object );
         if ( handle == null ) {
             throw new FactException( "Retract error: handle not found for object: " + object + ". Is it in the working memory?" );
         }
-        this.workingMemory.retract( handle,
+        ((InternalWorkingMemoryEntryPoint)((InternalFactHandle)handle).getEntryPoint())
+                           .retract( handle,
                                     true,
                                     true,
                                     this.rule,
                                     this.activation );
+        this.getIdentityMap().remove(object);
+
     }
 
     public void modifyRetract(final Object object) {
-        FactHandle handle = this.workingMemory.getFactHandleByIdentity( object );
-        this.workingMemory.modifyRetract( handle,
+        FactHandle handle =  getIdentityMap().get( object );
+        ((InternalWorkingMemoryEntryPoint)((InternalFactHandle)handle).getEntryPoint())
+                            .modifyRetract( handle,
                                           rule,
                                           activation );
     }
 
     public void modifyRetract(final FactHandle factHandle) {
-        this.workingMemory.modifyRetract( factHandle,
+        ((InternalWorkingMemoryEntryPoint)((InternalFactHandle)factHandle).getEntryPoint())
+                        .modifyRetract( factHandle,
                                           rule,
                                           activation );
     }
 
     public void modifyInsert(final Object object) {
-        FactHandle handle = this.workingMemory.getFactHandleByIdentity( object );
-        this.workingMemory.modifyInsert( handle,
+        FactHandle handle =  getIdentityMap().get( object );
+
+       ((InternalWorkingMemoryEntryPoint)((InternalFactHandle)handle).getEntryPoint())
+                            .modifyInsert( handle,
                                          object,
                                          rule,
                                          activation );
+        this.getIdentityMap().put(object, handle);
     }
 
     public void modifyInsert(final FactHandle factHandle,
                              final Object object) {
-        this.workingMemory.modifyInsert( factHandle,
+        ((InternalWorkingMemoryEntryPoint)((InternalFactHandle)factHandle).getEntryPoint())
+                            .modifyInsert( factHandle,
                                          object,
                                          rule,
                                          activation );
+        this.getIdentityMap().put(object, factHandle);
     }
 
     public Rule getRule() {
@@ -243,12 +275,22 @@
     //    }
 
     public Object get(final Declaration declaration) {
-        return declaration.getValue( workingMemory,
+         InternalWorkingMemoryEntryPoint wmTmp = ((InternalWorkingMemoryEntryPoint)(this.tuple.get(declaration)).getEntryPoint());
+         
+        if(wmTmp != null){
+        Object object = declaration.getValue( wmTmp.getInternalWorkingMemory() ,
                                      this.tuple.get( declaration ).getObject() );
+
+                getIdentityMap().put(object, wmTmp.getFactHandleByIdentity(object));
+                return object;
+        }
+        return null;
+      //  return declaration.getValue( workingMemory,
+      //                               this.tuple.get( declaration ).getObject() );
     }
 
     public Declaration getDeclaration(final String identifier) {
-        return (Declaration) this.subrule.getOuterDeclarations().get( identifier );
+             return (Declaration) this.subrule.getOuterDeclarations().get( identifier );
     }
 
     public void halt() {
@@ -270,4 +312,18 @@
     public Map<String, ExitPoint> getExitPoints() {
         return Collections.unmodifiableMap( this.workingMemory.getExitPoints() );
     }
+
+    /**
+     * @return the identityMap
+     */
+    public IdentityHashMap<Object, FactHandle> getIdentityMap() {
+        return identityMap;
 }
+
+    /**
+     * @param identityMap the identityMap to set
+     */
+    public void setIdentityMap(IdentityHashMap<Object, FactHandle> identityMap) {
+        this.identityMap = identityMap;
+    }
+}

Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/SequentialKnowledgeHelper.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/SequentialKnowledgeHelper.java	2009-04-06 00:53:25 UTC (rev 25964)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/SequentialKnowledgeHelper.java	2009-04-06 01:25:37 UTC (rev 25965)
@@ -17,6 +17,7 @@
  */
 
 import java.util.Collections;
+import java.util.IdentityHashMap;
 import java.util.Map;
 
 import org.drools.FactException;
@@ -47,6 +48,7 @@
     private Activation                         activation;
     private Tuple                              tuple;
     private final InternalWorkingMemoryActions workingMemory;
+    private IdentityHashMap<Object,FactHandle>              identityMap;
 
     public SequentialKnowledgeHelper(final WorkingMemory workingMemory) {
         this.workingMemory = (InternalWorkingMemoryActions) workingMemory;
@@ -57,6 +59,7 @@
         this.subrule = agendaItem.getSubRule();
         this.activation = agendaItem;
         this.tuple = agendaItem.getTuple();
+        this.identityMap = new IdentityHashMap<Object,FactHandle>();
     }
     
     public void reset() {
@@ -204,4 +207,12 @@
     public Map<String, ExitPoint> getExitPoints() {
         return Collections.unmodifiableMap( this.workingMemory.getExitPoints() );
     }
+
+    public IdentityHashMap<Object, FactHandle> getIdentityMap() {
+        return this.identityMap;
+    }
+
+    public void setIdentityMap(IdentityHashMap<Object, FactHandle> identityMap) {
+        this.identityMap = identityMap;
+    }
 }

Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/mvel/DroolsMVELFactory.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/mvel/DroolsMVELFactory.java	2009-04-06 00:53:25 UTC (rev 25964)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/mvel/DroolsMVELFactory.java	2009-04-06 01:25:37 UTC (rev 25965)
@@ -8,7 +8,9 @@
 import java.util.HashMap;
 import java.util.Map;
 
+import org.drools.FactHandle;
 import org.drools.WorkingMemory;
+import org.drools.common.InternalFactHandle;
 import org.drools.reteoo.LeftTuple;
 import org.drools.rule.Declaration;
 import org.drools.spi.KnowledgeHelper;
@@ -33,7 +35,7 @@
     /**
      * Holds the instance of the variables.
      */
-    private Object[] tupleObjects;
+    private InternalFactHandle[] tupleObjects;
  
     private KnowledgeHelper knowledgeHelper;
  
@@ -79,7 +81,7 @@
  
     public void readExternal(ObjectInput in) throws IOException,
             ClassNotFoundException {
-        tupleObjects = (Object[]) in.readObject();
+        tupleObjects = (InternalFactHandle[]) in.readObject();
         knowledgeHelper = (KnowledgeHelper) in.readObject();
         object = in.readObject();
         localDeclarations = (Map) in.readObject();
@@ -143,7 +145,7 @@
                            final WorkingMemory workingMemory,
                            final Map variables) {
         if (tuple != null) {
-            this.tupleObjects = ((LeftTuple) tuple).toObjectArray();
+            this.tupleObjects = ((LeftTuple) tuple).toFactHandles();
         }
         this.knowledgeHelper = knowledgeHelper;
         this.object = object;
@@ -167,6 +169,10 @@
  
     public Object getValue(final Declaration declaration) {
         int i = declaration.getPattern().getOffset();
+        return this.tupleObjects[i].getObject();
+    }
+    public InternalFactHandle getFactHandle(final Declaration declaration){
+        int i = declaration.getPattern().getOffset();
         return this.tupleObjects[i];
     }
  

Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/mvel/DroolsMVELPreviousDeclarationVariable.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/mvel/DroolsMVELPreviousDeclarationVariable.java	2009-04-06 00:53:25 UTC (rev 25964)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/mvel/DroolsMVELPreviousDeclarationVariable.java	2009-04-06 01:25:37 UTC (rev 25965)
@@ -5,8 +5,12 @@
 import java.io.ObjectInput;
 import java.io.ObjectOutput;
 
+
+import org.drools.common.InternalFactHandle;
 import org.drools.common.InternalWorkingMemory;
+import org.drools.common.NamedEntryPoint;
 import org.drools.rule.Declaration;
+import org.drools.runtime.rule.WorkingMemoryEntryPoint;
 import org.mvel2.integration.VariableResolver;
 
 public class DroolsMVELPreviousDeclarationVariable
@@ -46,10 +50,24 @@
 
     public Object getValue() {
         Declaration decl = this.declaration;
+       
         if( this.factory.getKnowledgeHelper() != null ) {
             decl = this.factory.getKnowledgeHelper().getDeclaration( this.declaration.getIdentifier() );
+            
+            InternalFactHandle factHandle = (InternalFactHandle)this.factory.getFactHandle(decl);
+            WorkingMemoryEntryPoint entryPoint = factHandle.getEntryPoint();
+            if(entryPoint !=  null){
+
+                this.factory.getKnowledgeHelper()
+                        .getIdentityMap()
+                        .put(entryPoint.getObject(factHandle), factHandle);
+            }
         }
+        
+
+        
         return decl.getValue( (InternalWorkingMemory) this.factory.getWorkingMemory(), this.factory.getValue( decl ) );
+
     }    
 
     public void setValue(final Object value) {

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-04-06 00:53:25 UTC (rev 25964)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/AbstractWorkingMemory.java	2009-04-06 01:25:37 UTC (rev 25965)
@@ -1260,6 +1260,7 @@
                 // the hashCode and equality has changed, so we must update the
                 // EqualityKey
                 EqualityKey key = handle.getEqualityKey();
+                if(key != null){
                 key.removeFactHandle( handle );
 
                 // If the equality key is now empty, then remove it
@@ -1267,6 +1268,7 @@
                     this.tms.remove( key );
                 }
             }
+            }
         } finally {
             this.lock.unlock();
         }
@@ -1292,6 +1294,7 @@
             final Object originalObject = handle.getObject();
 
             if ( this.maintainTms ) {
+                if(handle.getEqualityKey() != null ){
                 int status = handle.getEqualityKey().getStatus();
 
                 // now use an existing EqualityKey, if it exists, else create a
@@ -1307,6 +1310,7 @@
 
                 handle.setEqualityKey( key );
             }
+            }
 
             this.handleFactory.increaseFactHandleRecency( handle );
 
@@ -1345,7 +1349,14 @@
                 null,
                 null );
     }
+   public void update(final org.drools.runtime.rule.FactHandle factHandle,
+                       final Object object,
+                       final Rule rule,
+                       final Activation activation) throws FactException {
 
+       update((org.drools.FactHandle)factHandle, object, rule, activation);
+   }
+
     /**
      * modify is implemented as half way retract / assert due to the truth
      * maintenance issues.

Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/InternalWorkingMemoryEntryPoint.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/InternalWorkingMemoryEntryPoint.java	2009-04-06 00:53:25 UTC (rev 25964)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/InternalWorkingMemoryEntryPoint.java	2009-04-06 01:25:37 UTC (rev 25965)
@@ -1,9 +1,36 @@
 package org.drools.common;
 
+import org.drools.FactException;
+import org.drools.FactHandle;
 import org.drools.RuleBase;
+import org.drools.rule.EntryPoint;
+import org.drools.rule.Rule;
+
+
 import org.drools.runtime.rule.WorkingMemoryEntryPoint;
+import org.drools.spi.Activation;
 
 public interface InternalWorkingMemoryEntryPoint extends WorkingMemoryEntryPoint {
     ObjectTypeConfigurationRegistry getObjectTypeConfigurationRegistry();
     RuleBase getRuleBase();
+    public void retract(final FactHandle factHandle,
+                        final boolean removeLogical,
+                        final boolean updateEqualsMap,
+                        final Rule rule,
+                        final Activation activation) throws FactException;
+    public void update(org.drools.runtime.rule.FactHandle handle,
+                       Object object,
+                       Rule rule,
+                       Activation activation) throws FactException;
+    public void modifyRetract(final FactHandle factHandle,
+                              final Rule rule,
+                              final Activation activation);
+    public void modifyInsert(final FactHandle factHandle,
+                             final Object object,
+                             final Rule rule,
+                             final Activation activation);
+    public EntryPoint getEntryPoint();
+    public InternalWorkingMemory getInternalWorkingMemory();
+
+    public FactHandle getFactHandleByIdentity(final Object object);
 }

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	2009-04-06 00:53:25 UTC (rev 25964)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/NamedEntryPoint.java	2009-04-06 01:25:37 UTC (rev 25965)
@@ -171,7 +171,7 @@
                 null );
     }
 
-    protected void update(final org.drools.runtime.rule.FactHandle factHandle,
+    public void update(final org.drools.runtime.rule.FactHandle factHandle,
                           final Object object,
                           final Rule rule,
                           final Activation activation) throws FactException {
@@ -484,11 +484,21 @@
     public RuleBase getRuleBase() {
         return this.ruleBase;
     }
-    
+        
     public FactHandle getFactHandle(Object object) {
         return this.objectStore.getHandleForObject( object );
     }
 
+    public EntryPoint getEntryPoint() {
+        return this.entryPoint;
+    }
+    
+    public InternalWorkingMemory getInternalWorkingMemory() {
+        return this.wm;
+    }
+    public FactHandle getFactHandleByIdentity(final Object object) {
+        return this.objectStore.getHandleForObjectIdentity( object );
+    }
     public Object getObject(org.drools.runtime.rule.FactHandle factHandle) {
         return this.objectStore.getObjectForHandle( (InternalFactHandle) factHandle );
     }    
@@ -517,4 +527,4 @@
                                        ObjectStoreWrapper.OBJECT );
     }    
 
-}
\ No newline at end of file
+}

Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/impl/StatefulKnowledgeSessionImpl.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/impl/StatefulKnowledgeSessionImpl.java	2009-04-06 00:53:25 UTC (rev 25964)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/impl/StatefulKnowledgeSessionImpl.java	2009-04-06 01:25:37 UTC (rev 25965)
@@ -8,10 +8,12 @@
 import java.util.List;
 import java.util.Map;
 
+import org.drools.FactException;
 import org.drools.KnowledgeBase;
 import org.drools.RuleBase;
 import org.drools.WorkingMemory;
 import org.drools.command.Command;
+import org.drools.common.AbstractWorkingMemory;
 import org.drools.common.InternalAgenda;
 import org.drools.common.InternalFactHandle;
 import org.drools.common.InternalWorkingMemory;
@@ -49,6 +51,8 @@
 import org.drools.event.rule.impl.ObjectRetractedEventImpl;
 import org.drools.event.rule.impl.ObjectUpdatedEventImpl;
 import org.drools.reteoo.ReteooWorkingMemory;
+import org.drools.rule.EntryPoint;
+import org.drools.rule.Rule;
 import org.drools.runtime.BatchExecutionResults;
 import org.drools.runtime.BatchExecutor;
 import org.drools.runtime.Environment;
@@ -324,6 +328,34 @@
                                        ObjectStoreWrapper.OBJECT );
     }
 
+    public void retract(org.drools.FactHandle factHandle, boolean removeLogical, boolean updateEqualsMap, Rule rule, Activation activation) throws FactException {
+        ((AbstractWorkingMemory)this.session).retract(factHandle, removeLogical, updateEqualsMap, rule, activation);
+    }
+
+    public void update(FactHandle factHandle, Object object, Rule rule, Activation activation) throws FactException {
+        ((AbstractWorkingMemory)this.session).update((org.drools.FactHandle)factHandle, object, rule, activation);
+    }
+
+    public void modifyRetract(org.drools.FactHandle factHandle, Rule rule, Activation activation) {
+        ((AbstractWorkingMemory)this.session).modifyRetract(factHandle, rule, activation);
+    }
+
+    public void modifyInsert(org.drools.FactHandle factHandle, Object object, Rule rule, Activation activation) {
+        ((AbstractWorkingMemory)this.session).modifyInsert(factHandle, object, rule, activation);
+    }
+
+    public EntryPoint getEntryPoint() {
+        return session.getEntryPoint();
+    }
+
+    public InternalWorkingMemory getInternalWorkingMemory() {
+        return session;
+    }
+
+    public org.drools.FactHandle getFactHandleByIdentity(Object object) {
+        return session.getFactHandleByIdentity(object);
+    }
+
     public static abstract class AbstractImmutableCollection
         implements
         Collection {

Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/marshalling/impl/InputMarshaller.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/marshalling/impl/InputMarshaller.java	2009-04-06 00:53:25 UTC (rev 25964)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/marshalling/impl/InputMarshaller.java	2009-04-06 01:25:37 UTC (rev 25965)
@@ -365,6 +365,12 @@
         InternalFactHandle handle = new DefaultFactHandle( id,
                                                            object,
                                                            recency );
+        if(context.readBoolean()){
+            String  entryPoint = context.readUTF();
+            if(entryPoint != null && !entryPoint.equals("")){
+                handle.setEntryPoint(context.wm.getEntryPoints().get(entryPoint));
+            }
+        }
         return handle;
     }
 

Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/marshalling/impl/OutputMarshaller.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/marshalling/impl/OutputMarshaller.java	2009-04-06 00:53:25 UTC (rev 25964)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/marshalling/impl/OutputMarshaller.java	2009-04-06 01:25:37 UTC (rev 25965)
@@ -22,6 +22,7 @@
 import org.drools.common.InternalFactHandle;
 import org.drools.common.InternalRuleBase;
 import org.drools.common.InternalWorkingMemory;
+import org.drools.common.InternalWorkingMemoryEntryPoint;
 import org.drools.common.LogicalDependency;
 import org.drools.common.NodeMemory;
 import org.drools.common.ObjectStore;
@@ -276,6 +277,19 @@
 
         strategy.write( stream,
                         object );
+        if( handle.getEntryPoint() instanceof InternalWorkingMemoryEntryPoint ){
+            String entryPoint = ((InternalWorkingMemoryEntryPoint)handle.getEntryPoint()).getEntryPoint().getEntryPointId();
+            if(entryPoint!=null && !entryPoint.equals("")){
+                stream.writeBoolean(true);
+                stream.writeUTF(entryPoint);
+            }
+            else{
+                stream.writeBoolean(false);
+            }
+        }else{
+            stream.writeBoolean(false);
+        }
+
     }
 
     public static InternalFactHandle[] orderFacts(ObjectStore objectStore) {

Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/LeftTuple.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/LeftTuple.java	2009-04-06 00:53:25 UTC (rev 25964)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/LeftTuple.java	2009-04-06 01:25:37 UTC (rev 25965)
@@ -320,6 +320,16 @@
         }
         return handles;
     }
+     public InternalFactHandle[] toFactHandles() {
+        InternalFactHandle[] handles = new InternalFactHandle[this.index + 1];
+        LeftTuple entry = this;
+
+        while ( entry != null ) {
+            handles[entry.index] = entry.handle;
+            entry = entry.parent;
+        }
+        return handles;
+    }
     
     public long getRecency() {
         return this.recency;

Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/ReteooWorkingMemory.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/ReteooWorkingMemory.java	2009-04-06 00:53:25 UTC (rev 25964)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/ReteooWorkingMemory.java	2009-04-06 01:25:37 UTC (rev 25965)
@@ -349,6 +349,12 @@
             }
         }
     }
+  public EntryPoint getEntryPoint() {
+        return this.entryPoint;
+  }
+   public InternalWorkingMemory getInternalWorkingMemory() {
+        return this;
+    }
 
     public Collection< ? extends FactHandle> getFactHandles() {
         throw new UnsupportedOperationException("this is implementedby StatefulKnowledgeImpl");

Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/spi/KnowledgeHelper.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/spi/KnowledgeHelper.java	2009-04-06 00:53:25 UTC (rev 25964)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/spi/KnowledgeHelper.java	2009-04-06 01:25:37 UTC (rev 25965)
@@ -17,6 +17,7 @@
  */
 
 import java.io.Serializable;
+import java.util.IdentityHashMap;
 import java.util.Map;
 
 import org.drools.FactException;
@@ -127,4 +128,7 @@
     
     public void halt();
 
+     public IdentityHashMap<Object, FactHandle> getIdentityMap();
+
+    public void setIdentityMap(IdentityHashMap<Object, FactHandle> identityMap);
 }
\ No newline at end of file




More information about the jboss-svn-commits mailing list