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

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Mon Mar 10 08:24:25 EDT 2008


Author: mark.proctor at jboss.com
Date: 2008-03-10 08:24:25 -0400 (Mon, 10 Mar 2008)
New Revision: 18795

Added:
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/WorkingMemoryEntryPoint.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/common/ObjectTypeConfigurationRegistry.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/SharedTemporalWorkingMemoryContext.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/SharedWorkingMemoryContext.java
Removed:
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/EntryPointInterface.java
Modified:
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/WorkingMemory.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/AbstractFactHandleFactory.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/DefaultFactHandle.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/EventFactHandle.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/InternalWorkingMemory.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/InternalWorkingMemoryActions.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/EntryPointNode.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/Rete.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/ReteooFactHandleFactory.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/ReteooStatefulSession.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/ReteooStatelessSession.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/ReteooTemporalSession.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/FactHandleFactory.java
   labs/jbossrules/trunk/drools-core/src/test/java/org/drools/reteoo/DefaultFactHandleFactoryTest.java
   labs/jbossrules/trunk/drools-core/src/test/java/org/drools/reteoo/ReteTest.java
Log:
JBRULES-1498 Thead safe partitioning of WorkingMemory entry points

Deleted: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/EntryPointInterface.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/EntryPointInterface.java	2008-03-10 12:24:02 UTC (rev 18794)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/EntryPointInterface.java	2008-03-10 12:24:25 UTC (rev 18795)
@@ -1,106 +0,0 @@
-/*
- * Copyright 2007 JBoss Inc
- * 
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * 
- *      http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * Created on Dec 14, 2007
- */
-package org.drools;
-
-import java.io.Serializable;
-
-/**
- * An interface for instances that allow handling of entry-point-scoped
- * facts
- *  
- * @author etirelli
- */
-public interface EntryPointInterface
-    extends
-    Serializable {
-    
-    /**
-     * Assert a fact.
-     * 
-     * @param object
-     *            The fact object.
-     * 
-     * @return The new fact-handle associated with the object.
-     * 
-     * @throws FactException
-     *             If a RuntimeException error occurs.
-     */
-    FactHandle insert(Object object) throws FactException;
-
-    /**
-     * Insert a fact registering JavaBean <code>PropertyChangeListeners</code>
-     * on the Object to automatically trigger <code>update</code> calls
-     * if <code>dynamic</code> is <code>true</code>.
-     * 
-     * @param object
-     *            The fact object.
-     * @param dynamic
-     *            true if Drools should add JavaBean
-     *            <code>PropertyChangeListeners</code> to the object.
-     * 
-     * @return The new fact-handle associated with the object.
-     * 
-     * @throws FactException
-     *             If a RuntimeException error occurs.
-     */
-    FactHandle insert(Object object,
-                            boolean dynamic) throws FactException;
-
-    /**
-     * Retract a fact.
-     * 
-     * @param handle
-     *            The fact-handle associated with the fact to retract.
-     * 
-     * @throws FactException
-     *             If a RuntimeException error occurs.
-     */
-    void retract(FactHandle handle) throws FactException;
-
-    /**
-     * Inform the WorkingMemory that a Fact has been modified and that it
-     * should now update the network.
-     * 
-     * @param handle
-     *            The fact-handle associated with the fact to modify.
-     * @param object
-     *            The new value of the fact.
-     * 
-     * @throws FactException
-     *             If a RuntimeException error occurs.
-     */
-    void update(FactHandle handle,
-                      Object object) throws FactException;
-    
-    /**
-     * 
-     * @param factHandle
-     */
-    public void modifyRetract(final FactHandle factHandle);
-    
-    /**
-     * 
-     * @param factHandle
-     * @param object
-     */
-    public void modifyInsert(final FactHandle factHandle,
-                             final Object object);    
-
-    
-
-}

Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/WorkingMemory.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/WorkingMemory.java	2008-03-10 12:24:02 UTC (rev 18794)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/WorkingMemory.java	2008-03-10 12:24:25 UTC (rev 18795)
@@ -16,6 +16,7 @@
  * limitations under the License.
  */
 
+import java.io.Serializable;
 import java.util.Collection;
 import java.util.Iterator;
 import java.util.Map;
@@ -35,7 +36,7 @@
  * in WorkingMemories from an InputStream.
  * 
  */
-public interface WorkingMemory extends WorkingMemoryEventManager {
+public interface WorkingMemory extends WorkingMemoryEventManager, WorkingMemoryEntryPoint {
 
     /**
      * Returns the Agenda for this WorkingMemory. While the WorkingMemory interface is considered public, the Agenda interface 
@@ -205,34 +206,6 @@
         
 
     /**
-     * Assert a fact.
-     * 
-     * @param object
-     *            The fact object.
-     * 
-     * @return The new fact-handle associated with the object.
-     * 
-     * @throws FactException
-     *             If a RuntimeException error occurs.
-     */
-    FactHandle insert(Object object) throws FactException;
-    
-    /**
-     * Assert a fact with inherent duration.
-     * 
-     * @param object
-     *            The fact object.
-     * @param duration
-     *            The duration of the fact.
-     * 
-     * @return The new fact-handle associated with the object.
-     * 
-     * @throws FactException
-     *             If a RuntimeException error occurs.
-     */
-    FactHandle insert(Object object, long duration) throws FactException;
-
-    /**
      * Retrieve the QueryResults of the specified query.
      *
      * @param query
@@ -261,91 +234,9 @@
      * @throws IllegalArgumentException 
      *         if no query named "query" is found in the rulebase         
      */    
-    public QueryResults getQueryResults(String query, Object[] arguments);
+    public QueryResults getQueryResults(String query, Object[] arguments);  
 
     /**
-     * Insert a fact registering JavaBean <code>PropertyChangeListeners</code>
-     * on the Object to automatically trigger <code>update</code> calls
-     * if <code>dynamic</code> is <code>true</code>.
-     * 
-     * @param object
-     *            The fact object.
-     * @param dynamic
-     *            true if Drools should add JavaBean
-     *            <code>PropertyChangeListeners</code> to the object.
-     * 
-     * @return The new fact-handle associated with the object.
-     * 
-     * @throws FactException
-     *             If a RuntimeException error occurs.
-     */
-    FactHandle insert(Object object,
-                            boolean dynamic) throws FactException;
-    
-    /**
-     * Insert a fact with inherent duration registering JavaBean 
-     * <code>PropertyChangeListeners</code> on the Object to 
-     * automatically trigger <code>update</code> calls
-     * if <code>dynamic</code> is <code>true</code>.
-     * 
-     * @param object
-     *            The fact object.
-     * @param duration
-     *            The duration of the fact.
-     * @param dynamic
-     *            true if Drools should add JavaBean
-     *            <code>PropertyChangeListeners</code> to the object.
-     * 
-     * @return The new fact-handle associated with the object.
-     * 
-     * @throws FactException
-     *             If a RuntimeException error occurs.
-     */
-    FactHandle insert(Object object,
-    				  long duration,
-                      boolean dynamic) throws FactException;
-
-    /**
-     * Retract a fact.
-     * 
-     * @param handle
-     *            The fact-handle associated with the fact to retract.
-     * 
-     * @throws FactException
-     *             If a RuntimeException error occurs.
-     */
-    void retract(FactHandle handle) throws FactException;
-
-    /**
-     * Inform the WorkingMemory that a Fact has been modified and that it
-     * should now update the network.
-     * 
-     * @param handle
-     *            The fact-handle associated with the fact to modify.
-     * @param object
-     *            The new value of the fact.
-     * 
-     * @throws FactException
-     *             If a RuntimeException error occurs.
-     */
-    void update(FactHandle handle,
-                      Object object) throws FactException;
-    
-    /**
-     * 
-     * @param factHandle
-     */
-    public void modifyRetract(final FactHandle factHandle);
-    
-    /**
-     * 
-     * @param factHandle
-     * @param object
-     */
-    public void modifyInsert(final FactHandle factHandle,
-                             final Object object);    
-
-    /**
      * Sets the AsyncExceptionHandler to handle exceptions thrown by the Agenda
      * Scheduler used for duration rules.
      * 
@@ -413,6 +304,6 @@
      * @param id the id of the entry point, as defined in the rules file
      * @return
      */
-    public EntryPointInterface getEntryPoint( String id );
+    public WorkingMemoryEntryPoint getWorkingMemoryEntryPoint( String id );
     
 }
\ No newline at end of file

Copied: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/WorkingMemoryEntryPoint.java (from rev 18611, labs/jbossrules/trunk/drools-core/src/main/java/org/drools/EntryPointInterface.java)
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/WorkingMemoryEntryPoint.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/WorkingMemoryEntryPoint.java	2008-03-10 12:24:25 UTC (rev 18795)
@@ -0,0 +1,143 @@
+/*
+ * Copyright 2007 JBoss Inc
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Created on Dec 14, 2007
+ */
+package org.drools;
+
+import java.io.Serializable;
+
+/**
+ * An interface for instances that allow handling of entry-point-scoped
+ * facts
+ *  
+ * @author etirelli
+ */
+public interface WorkingMemoryEntryPoint
+    extends
+    Serializable {
+    /**
+     * Assert a fact.
+     * 
+     * @param object
+     *            The fact object.
+     * 
+     * @return The new fact-handle associated with the object.
+     * 
+     * @throws FactException
+     *             If a RuntimeException error occurs.
+     */
+    FactHandle insert(Object object) throws FactException;
+    
+    /**
+     * Assert a fact with inherent duration.
+     * 
+     * @param object
+     *            The fact object.
+     * @param duration
+     *            The duration of the fact.
+     * 
+     * @return The new fact-handle associated with the object.
+     * 
+     * @throws FactException
+     *             If a RuntimeException error occurs.
+     */
+    FactHandle insert(Object object, long duration) throws FactException;
+    
+    /**
+     * Insert a fact registering JavaBean <code>PropertyChangeListeners</code>
+     * on the Object to automatically trigger <code>update</code> calls
+     * if <code>dynamic</code> is <code>true</code>.
+     * 
+     * @param object
+     *            The fact object.
+     * @param dynamic
+     *            true if Drools should add JavaBean
+     *            <code>PropertyChangeListeners</code> to the object.
+     * 
+     * @return The new fact-handle associated with the object.
+     * 
+     * @throws FactException
+     *             If a RuntimeException error occurs.
+     */
+    FactHandle insert(Object object,
+                            boolean dynamic) throws FactException;
+    
+    /**
+     * Insert a fact with inherent duration registering JavaBean 
+     * <code>PropertyChangeListeners</code> on the Object to 
+     * automatically trigger <code>update</code> calls
+     * if <code>dynamic</code> is <code>true</code>.
+     * 
+     * @param object
+     *            The fact object.
+     * @param duration
+     *            The duration of the fact.
+     * @param dynamic
+     *            true if Drools should add JavaBean
+     *            <code>PropertyChangeListeners</code> to the object.
+     * 
+     * @return The new fact-handle associated with the object.
+     * 
+     * @throws FactException
+     *             If a RuntimeException error occurs.
+     */
+    FactHandle insert(Object object,
+                      long duration,
+                      boolean dynamic) throws FactException;
+
+    /**
+     * Retract a fact.
+     * 
+     * @param handle
+     *            The fact-handle associated with the fact to retract.
+     * 
+     * @throws FactException
+     *             If a RuntimeException error occurs.
+     */
+    void retract(FactHandle handle) throws FactException;
+
+    /**
+     * Inform the WorkingMemory that a Fact has been modified and that it
+     * should now update the network.
+     * 
+     * @param handle
+     *            The fact-handle associated with the fact to modify.
+     * @param object
+     *            The new value of the fact.
+     * 
+     * @throws FactException
+     *             If a RuntimeException error occurs.
+     */
+    void update(FactHandle handle,
+                      Object object) throws FactException;
+    
+    /**
+     * 
+     * @param factHandle
+     */
+    public void modifyRetract(final FactHandle factHandle);
+    
+    /**
+     * 
+     * @param factHandle
+     * @param object
+     */
+    public void modifyInsert(final FactHandle factHandle,
+                             final Object object); 
+    
+    public WorkingMemoryEntryPoint getWorkingMemoryEntryPoint(String name);    
+
+}

Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/AbstractFactHandleFactory.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/AbstractFactHandleFactory.java	2008-03-10 12:24:02 UTC (rev 18794)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/AbstractFactHandleFactory.java	2008-03-10 12:24:25 UTC (rev 18795)
@@ -16,6 +16,9 @@
  * limitations under the License.
  */
 
+import java.util.concurrent.atomic.AtomicInteger;
+import java.util.concurrent.atomic.AtomicLong;
+
 import org.drools.WorkingMemory;
 import org.drools.spi.FactHandleFactory;
 import org.drools.util.PrimitiveLongStack;
@@ -29,46 +32,58 @@
      */
     private static final long          serialVersionUID = 400L;
 
-    protected final PrimitiveLongStack factHandlePool   = new PrimitiveLongStack();
+//    protected final PrimitiveLongStack factHandlePool   = new PrimitiveLongStack();
 
     /** The fact id. */
-    private long                       id;
+    private AtomicInteger              id;
 
     /** The number of facts created - used for recency. */
-    private long                       counter;
+    private AtomicLong                 counter;
+    
+    public AbstractFactHandleFactory() {
+        this.id = new AtomicInteger(-1);
+        this.counter = new AtomicLong(-1);
+    }
 
     /* (non-Javadoc)
      * @see org.drools.reteoo.FactHandleFactory#newFactHandle()
      */
-    public final InternalFactHandle newFactHandle( final Object object, final boolean isEvent, final WorkingMemory workingMemory ) {
-        if ( !this.factHandlePool.isEmpty() ) {
-            return newFactHandle( this.factHandlePool.pop(),
-                                  object, 
-                                  isEvent,
-                                  0,
-                                  workingMemory );
-        }
+    public final InternalFactHandle newFactHandle(final Object object,
+                                                  final boolean isEvent,
+                                                  final WorkingMemory workingMemory) {
+// @FIXME make id re-cycling thread safe        
+//        if ( !this.factHandlePool.isEmpty() ) {
+//            return newFactHandle( this.factHandlePool.pop(),
+//                                  object,
+//                                  isEvent,
+//                                  0,
+//                                  workingMemory );
+//        }
 
-        return newFactHandle( this.id++,
+        return newFactHandle( this.id.incrementAndGet(),
                               object,
                               isEvent,
                               0,
                               workingMemory );
     }
-    
+
     /* (non-Javadoc)
      * @see org.drools.reteoo.FactHandleFactory#newFactHandle()
      */
-    public final InternalFactHandle newFactHandle( final Object object, final boolean isEvent, long duration, final WorkingMemory workingMemory ) {
-        if ( !this.factHandlePool.isEmpty() ) {
-            return newFactHandle( this.factHandlePool.pop(),
-                                  object, 
-                                  isEvent,
-                                  duration,
-                                  workingMemory );
-        }
+    public final InternalFactHandle newFactHandle(final Object object,
+                                                  final boolean isEvent,
+                                                  long duration,
+                                                  final WorkingMemory workingMemory) {
+// @FIXME make id re-cycling thread safe                
+//        if ( !this.factHandlePool.isEmpty() ) {
+//            return newFactHandle( this.factHandlePool.pop(),
+//                                  object,
+//                                  isEvent,
+//                                  duration,
+//                                  workingMemory );
+//        }
 
-        return newFactHandle( this.id++,
+        return newFactHandle( this.id.incrementAndGet(),
                               object,
                               isEvent,
                               duration,
@@ -78,29 +93,29 @@
     /* (non-Javadoc)
      * @see org.drools.reteoo.FactHandleFactory#newFactHandle(long)
      */
-    protected final InternalFactHandle newFactHandle(final long id,
+    protected final InternalFactHandle newFactHandle(final int id,
                                                      final Object object,
-                                                     final boolean isEvent, 
-                                                     final WorkingMemory workingMemory ) {
+                                                     final boolean isEvent,
+                                                     final WorkingMemory workingMemory) {
         return newFactHandle( id,
                               object,
-                              this.counter++,
+                              this.counter.incrementAndGet(),
                               isEvent,
                               0,
                               workingMemory );
     }
-    
+
     /* (non-Javadoc)
      * @see org.drools.reteoo.FactHandleFactory#newFactHandle(long)
      */
-    protected final InternalFactHandle newFactHandle(final long id,
+    protected final InternalFactHandle newFactHandle(final int id,
                                                      final Object object,
                                                      final boolean isEvent,
                                                      final long duration,
-                                                     final WorkingMemory workingMemory ) {
+                                                     final WorkingMemory workingMemory) {
         return newFactHandle( id,
                               object,
-                              this.counter++,
+                              this.counter.incrementAndGet(),
                               isEvent,
                               duration,
                               workingMemory );
@@ -109,31 +124,32 @@
     /* (non-Javadoc)
      * @see org.drools.reteoo.FactHandleFactory#newFactHandle(long)
      */
-    protected abstract InternalFactHandle newFactHandle(final long id,
+    protected abstract InternalFactHandle newFactHandle(final int id,
                                                         final Object object,
                                                         final long recency,
-                                                        final boolean isEvent, 
-                                                        final WorkingMemory workingMemory );
-    
+                                                        final boolean isEvent,
+                                                        final WorkingMemory workingMemory);
+
     /* (non-Javadoc)
      * @see org.drools.reteoo.FactHandleFactory#newFactHandle(long)
      */
-    protected abstract InternalFactHandle newFactHandle(final long id,
+    protected abstract InternalFactHandle newFactHandle(final int id,
                                                         final Object object,
                                                         final long recency,
                                                         final boolean isEvent,
                                                         final long duration,
-                                                        final WorkingMemory workingMemory );
+                                                        final WorkingMemory workingMemory);
 
     /* (non-Javadoc)
      * @see org.drools.reteoo.FactHandleFactory#increaseFactHandleRecency(org.drools.FactHandle)
      */
     public final void increaseFactHandleRecency(final InternalFactHandle factHandle) {
-        factHandle.setRecency( this.counter++ );
+        factHandle.setRecency( this.counter.incrementAndGet() );
     }
 
     public void destroyFactHandle(final InternalFactHandle factHandle) {
-        this.factHandlePool.push( factHandle.getId() );
+// @FIXME make id re-cycling thread safe                
+//        this.factHandlePool.push( factHandle.getId() );
         factHandle.invalidate();
     }
 

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-03-10 12:24:02 UTC (rev 18794)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/AbstractWorkingMemory.java	2008-03-10 12:24:25 UTC (rev 18795)
@@ -18,7 +18,6 @@
 
 import java.beans.PropertyChangeEvent;
 import java.beans.PropertyChangeListener;
-import java.io.Serializable;
 import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
 import java.util.ArrayList;
@@ -32,11 +31,11 @@
 import java.util.Queue;
 import java.util.Map.Entry;
 import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.atomic.AtomicLong;
 import java.util.concurrent.locks.Lock;
 import java.util.concurrent.locks.ReentrantLock;
 
 import org.drools.Agenda;
-import org.drools.EntryPointInterface;
 import org.drools.FactException;
 import org.drools.FactHandle;
 import org.drools.ObjectFilter;
@@ -46,6 +45,7 @@
 import org.drools.RuleBaseConfiguration;
 import org.drools.RuntimeDroolsException;
 import org.drools.WorkingMemory;
+import org.drools.WorkingMemoryEntryPoint;
 import org.drools.RuleBaseConfiguration.AssertBehaviour;
 import org.drools.RuleBaseConfiguration.LogicalOverride;
 import org.drools.base.MapGlobalResolver;
@@ -58,14 +58,11 @@
 import org.drools.event.RuleFlowEventSupport;
 import org.drools.event.WorkingMemoryEventListener;
 import org.drools.event.WorkingMemoryEventSupport;
-import org.drools.facttemplates.Fact;
 import org.drools.process.core.Process;
 import org.drools.process.instance.ProcessInstance;
 import org.drools.process.instance.ProcessInstanceFactory;
 import org.drools.process.instance.WorkItemManager;
-import org.drools.reteoo.ClassObjectTypeConf;
 import org.drools.reteoo.EntryPointNode;
-import org.drools.reteoo.FactTemplateTypeConf;
 import org.drools.reteoo.LIANodePropagation;
 import org.drools.reteoo.ObjectTypeConf;
 import org.drools.rule.Declaration;
@@ -81,7 +78,6 @@
 import org.drools.spi.FactHandleFactory;
 import org.drools.spi.GlobalResolver;
 import org.drools.spi.PropagationContext;
-import org.drools.temporal.SessionClock;
 
 /**
  * Implementation of <code>WorkingMemory</code>.
@@ -98,82 +94,87 @@
     // ------------------------------------------------------------
     // Constants
     // ------------------------------------------------------------
-    protected static final Class[]                       ADD_REMOVE_PROPERTY_CHANGE_LISTENER_ARG_TYPES = new Class[]{PropertyChangeListener.class};
-    private static final int                             NODE_MEMORIES_ARRAY_GROWTH                    = 32;
+    protected static final Class[]                 ADD_REMOVE_PROPERTY_CHANGE_LISTENER_ARG_TYPES = new Class[]{PropertyChangeListener.class};
+    private static final int                       NODE_MEMORIES_ARRAY_GROWTH                    = 32;
 
     // ------------------------------------------------------------
     // Instance members
     // ------------------------------------------------------------
-    protected long                                       id;
+    protected long                                 id;
 
     /** The arguments used when adding/removing a property change listener. */
-    protected final Object[]                             addRemovePropertyChangeListenerArgs           = new Object[]{this};
+    protected final Object[]                       addRemovePropertyChangeListenerArgs           = new Object[]{this};
 
     /** The actual memory for the <code>JoinNode</code>s. */
-    protected final NodeMemories                         nodeMemories;
+    protected final NodeMemories                   nodeMemories;
 
-    protected final ObjectStore                          objectStore;
+    protected final ObjectStore                    objectStore;
 
-    protected Map                                        queryResults                                  = Collections.EMPTY_MAP;
+    protected Map                                  queryResults                                  = Collections.EMPTY_MAP;
 
     /** Global values which are associated with this memory. */
-    protected GlobalResolver                             globalResolver;
+    protected GlobalResolver                       globalResolver;
 
     /** The eventSupport */
-    protected WorkingMemoryEventSupport                  workingMemoryEventSupport                     = new WorkingMemoryEventSupport();
+    protected WorkingMemoryEventSupport            workingMemoryEventSupport                     = new WorkingMemoryEventSupport();
 
-    protected AgendaEventSupport                         agendaEventSupport                            = new AgendaEventSupport();
+    protected AgendaEventSupport                   agendaEventSupport                            = new AgendaEventSupport();
 
-    protected RuleFlowEventSupport                       workflowEventSupport                          = new RuleFlowEventSupport();
+    protected RuleFlowEventSupport                 workflowEventSupport                          = new RuleFlowEventSupport();
 
-    protected List                                       __ruleBaseEventListeners                      = new LinkedList();
+    protected List                                 __ruleBaseEventListeners                      = new LinkedList();
 
     /** The <code>RuleBase</code> with which this memory is associated. */
-    protected transient InternalRuleBase                 ruleBase;
+    protected transient InternalRuleBase           ruleBase;
 
-    protected final FactHandleFactory                    handleFactory;
+    protected final FactHandleFactory              handleFactory;
 
-    protected final TruthMaintenanceSystem               tms;
+    protected final TruthMaintenanceSystem         tms;
 
     /** Rule-firing agenda. */
-    protected DefaultAgenda                              agenda;
+    protected DefaultAgenda                        agenda;
 
-    protected final Queue<WorkingMemoryAction>           actionQueue                                   = new LinkedList<WorkingMemoryAction>();
-    
-    protected boolean                                    evaluatingActionQueue;
+    protected final Queue<WorkingMemoryAction>     actionQueue                                   = new LinkedList<WorkingMemoryAction>();
 
-    protected final ReentrantLock                        lock                                          = new ReentrantLock();
+    protected boolean                              evaluatingActionQueue;
 
-    protected final boolean                              discardOnLogicalOverride;
+    protected final ReentrantLock                  lock                                          = new ReentrantLock();
 
-    protected long                                       propagationIdCounter;
+    protected final boolean                        discardOnLogicalOverride;
 
-    private final boolean                                maintainTms;
+    /**
+     * This must be thread safe as it is incremented and read via different EntryPoints
+     */
+    protected AtomicLong                           propagationIdCounter;
 
-    private final boolean                                sequential;
+    private final boolean                          maintainTms;
 
-    private List                                         liaPropagations                               = Collections.EMPTY_LIST;
+    private final boolean                          sequential;
 
+    private List                                   liaPropagations                               = Collections.EMPTY_LIST;
+
     /** Flag to determine if a rule is currently being fired. */
-    protected boolean                                    firing;
+    protected boolean                              firing;
 
-    protected boolean                                    halt;
+    protected boolean                              halt;
 
-    private Map                                          processInstances                              = new HashMap();
+    private Map                                    processInstances                              = new HashMap();
 
-    private int                                          processCounter;
+    private int                                    processCounter;
 
-    private WorkItemManager                              workItemManager;
+    private WorkItemManager                        workItemManager;
 
-    private Map<String, ProcessInstanceFactory>          processInstanceFactories                      = new HashMap();
+    private Map<String, ProcessInstanceFactory>    processInstanceFactories                      = new HashMap();
 
-    private TimeMachine                                  timeMachine                                   = new TimeMachine();
+    private TimeMachine                            timeMachine                                   = new TimeMachine();
 
-    private Map<EntryPoint, Map<Object, ObjectTypeConf>> typeConfMap;
-    
-    private EntryPoint                                   entryPoint;
-    private EntryPointNode                               entryPointNode;
+    protected ObjectTypeConfigurationRegistry        typeConfReg;
 
+    protected EntryPoint                           entryPoint;
+    protected EntryPointNode                       entryPointNode;
+
+    protected Map<String, WorkingMemoryEntryPoint> entryPoints;
+
     // ------------------------------------------------------------
     // Constructors
     // ------------------------------------------------------------
@@ -186,7 +187,6 @@
      */
     public AbstractWorkingMemory(final int id,
                                  final InternalRuleBase ruleBase,
-                                 //final EntryPoint entryPoint,
                                  final FactHandleFactory handleFactory) {
         this.id = id;
         this.ruleBase = ruleBase;
@@ -204,6 +204,8 @@
         }
 
         final RuleBaseConfiguration conf = this.ruleBase.getConfiguration();
+        
+        this.propagationIdCounter = new AtomicLong();
 
         this.objectStore = new SingleThreadedObjectStore( conf,
                                                           this.lock );
@@ -219,10 +221,14 @@
         this.processInstanceFactories.put( RuleFlowProcess.RULEFLOW_TYPE,
                                            new RuleFlowProcessInstanceFactory() );
 
-        this.typeConfMap = new ConcurrentHashMap<EntryPoint, Map<Object, ObjectTypeConf>>();
-        
-//        this.entryPoint = entryPoint;
-//        this.entryPointNode = this.ruleBase.getRete().getEntryPointNode( this.entryPoint );
+        this.typeConfReg = new ObjectTypeConfigurationRegistry( this.ruleBase );
+
+        this.entryPoint = EntryPoint.DEFAULT;
+        this.entryPointNode = this.ruleBase.getRete().getEntryPointNode( this.entryPoint );
+
+        this.entryPoints = new ConcurrentHashMap();
+        this.entryPoints.put( "DEFAULT",
+                              this );
     }
 
     // ------------------------------------------------------------
@@ -424,9 +430,7 @@
             }
         }
 
-        if ( !this.actionQueue.isEmpty() ) {
-            executeQueuedActions();
-        }
+        executeQueuedActions();
 
         boolean noneFired = true;
 
@@ -437,9 +441,7 @@
                 while ( continueFiring( fireLimit ) && this.agenda.fireNextItem( agendaFilter ) ) {
                     fireLimit = updateFireLimit( fireLimit );
                     noneFired = false;
-                    if ( !this.actionQueue.isEmpty() ) {
-                        executeQueuedActions();
-                    }
+                    executeQueuedActions();
                 }
             } finally {
                 this.firing = false;
@@ -685,8 +687,7 @@
                              boolean logical,
                              final Rule rule,
                              final Activation activation) throws FactException {
-        return this.insert( EntryPoint.DEFAULT,
-                            object,
+        return this.insert( object,
                             0,
                             dynamic,
                             logical,
@@ -695,50 +696,34 @@
 
     }
 
+    //    protected FactHandle insert(final EntryPoint entryPoint,
+    //                                final Object object,
+    //                                final boolean dynamic,
+    //                                boolean logical,
+    //                                final Rule rule,
+    //                                final Activation activation) throws FactException {
+    //        return this.insert( entryPoint,
+    //                            object,
+    //                            0,
+    //                            dynamic,
+    //                            logical,
+    //                            rule,
+    //                            activation );
+    //    }
+
     public FactHandle insert(final Object object,
                              final long duration,
                              final boolean dynamic,
                              boolean logical,
                              final Rule rule,
                              final Activation activation) throws FactException {
-        return this.insert( EntryPoint.DEFAULT,
-                            object,
-                            duration,
-                            dynamic,
-                            logical,
-                            rule,
-                            activation );
-    }
-
-    protected FactHandle insert(final EntryPoint entryPoint,
-                                final Object object,
-                                final boolean dynamic,
-                                boolean logical,
-                                final Rule rule,
-                                final Activation activation) throws FactException {
-        return this.insert( entryPoint,
-                            object,
-                            0,
-                            dynamic,
-                            logical,
-                            rule,
-                            activation );
-    }
-
-    protected FactHandle insert(final EntryPoint entryPoint,
-                                final Object object,
-                                final long duration,
-                                final boolean dynamic,
-                                boolean logical,
-                                final Rule rule,
-                                final Activation activation) throws FactException {
         if ( object == null ) {
             // you cannot assert a null object
             return null;
         }
 
-        ObjectTypeConf typeConf = getObjectTypeConf( entryPoint,
-                                                     object );
+        ObjectTypeConf typeConf = this.typeConfReg.getObjectTypeConf( this.entryPoint,
+                                                                      object );
 
         InternalFactHandle handle = null;
 
@@ -749,11 +734,11 @@
                                                        this );
             this.objectStore.addHandle( handle,
                                         object );
-            insert( entryPoint,
-                    handle,
+            insert( handle,
                     object,
                     rule,
-                    activation );
+                    activation,
+                    typeConf );
             return handle;
         }
 
@@ -914,11 +899,11 @@
                 addPropertyChangeListener( object );
             }
 
-            insert( entryPoint,
-                    handle,
+            insert( handle,
                     object,
                     rule,
-                    activation );
+                    activation,
+                    typeConf );
 
         } finally {
             this.lock.unlock();
@@ -926,18 +911,18 @@
         return handle;
     }
 
-    protected void insert(final EntryPoint entryPoint,
-                          final InternalFactHandle handle,
+    protected void insert(final InternalFactHandle handle,
                           final Object object,
                           final Rule rule,
-                          final Activation activation) {
+                          final Activation activation,
+                          ObjectTypeConf typeConf) {
         this.ruleBase.executeQueuedActions();
 
         if ( activation != null ) {
             // release resources so that they can be GC'ed
             activation.getPropagationContext().releaseResources();
         }
-        final PropagationContext propagationContext = new PropagationContextImpl( this.propagationIdCounter++,
+        final PropagationContext propagationContext = new PropagationContextImpl( getNextPropagationIdCounter(),
                                                                                   PropagationContext.ASSERTION,
                                                                                   rule,
                                                                                   activation,
@@ -945,13 +930,12 @@
                                                                                   this.agenda.getDormantActivations(),
                                                                                   entryPoint );
 
-        doInsert( handle,
-                  object,
-                  propagationContext );
+        this.entryPointNode.assertObject( handle,
+                                          propagationContext,
+                                          typeConf,
+                                          this );
 
-        if ( !this.actionQueue.isEmpty() ) {
-            executeQueuedActions();
-        }
+        executeQueuedActions();
 
         this.workingMemoryEventSupport.fireObjectInserted( propagationContext,
                                                            handle,
@@ -982,14 +966,10 @@
         }
     }
 
-    public abstract void doInsert(InternalFactHandle factHandle,
-                                  Object object,
-                                  PropagationContext propagationContext) throws FactException;
-
     protected void removePropertyChangeListener(final FactHandle handle) {
         Object object = null;
         try {
-            object = getObject( handle );
+            object = ((InternalFactHandle) handle).getObject();
 
             if ( object != null ) {
                 final Method mehod = object.getClass().getMethod( "removePropertyChangeListener",
@@ -1025,32 +1005,11 @@
                  null );
     }
 
-    public abstract void doRetract(InternalFactHandle factHandle,
-                                   PropagationContext propagationContext);
-
-    /**
-     * @see WorkingMemory
-     */
     public void retract(final FactHandle factHandle,
                         final boolean removeLogical,
                         final boolean updateEqualsMap,
                         final Rule rule,
                         final Activation activation) throws FactException {
-        this.retract( EntryPoint.DEFAULT,
-                      factHandle,
-                      removeLogical,
-                      updateEqualsMap,
-                      rule,
-                      activation );
-
-    }
-
-    protected void retract(final EntryPoint entryPoint,
-                           final FactHandle factHandle,
-                           final boolean removeLogical,
-                           final boolean updateEqualsMap,
-                           final Rule rule,
-                           final Activation activation) throws FactException {
         try {
             this.lock.lock();
             this.ruleBase.executeQueuedActions();
@@ -1066,17 +1025,22 @@
                 // release resources so that they can be GC'ed
                 activation.getPropagationContext().releaseResources();
             }
-            final PropagationContext propagationContext = new PropagationContextImpl( this.propagationIdCounter++,
+            final PropagationContext propagationContext = new PropagationContextImpl( getNextPropagationIdCounter(),
                                                                                       PropagationContext.RETRACTION,
                                                                                       rule,
                                                                                       activation,
                                                                                       this.agenda.getActiveActivations(),
                                                                                       this.agenda.getDormantActivations(),
-                                                                                      entryPoint );
+                                                                                      this.entryPoint );
 
-            doRetract( handle,
-                       propagationContext );
+            final Object object = handle.getObject();
 
+            this.entryPointNode.retractObject( handle,
+                                               propagationContext,
+                                               this.typeConfReg.getObjectTypeConf( this.entryPoint,
+                                                                                   object ),
+                                               this );
+
             if ( this.maintainTms ) {
                 // Update the equality key, which maintains a list of stated
                 // FactHandles
@@ -1098,8 +1062,6 @@
                 }
             }
 
-            final Object object = handle.getObject();
-
             this.workingMemoryEventSupport.fireObjectRetracted( propagationContext,
                                                                 handle,
                                                                 object,
@@ -1109,32 +1071,12 @@
 
             this.handleFactory.destroyFactHandle( handle );
 
-            if ( !this.actionQueue.isEmpty() ) {
-                executeQueuedActions();
-            }
+            executeQueuedActions();
         } finally {
             this.lock.unlock();
         }
     }
 
-    //    private void addHandleToMaps(InternalFactHandle handle) {
-    //        this.assertMap.put( handle,
-    //                            handle,
-    //                            false );
-    //        if ( this.ruleBase.getConfiguration().getAssertBehaviour() == AssertBehaviour.EQUALITY ) {
-    //            this.identityMap.put( handle,
-    //                                  handle,
-    //                                  false );
-    //        }
-    //    }
-    //
-    //    private void removeHandleFromMaps(final InternalFactHandle handle) {
-    //        this.assertMap.remove( handle );
-    //        if ( this.ruleBase.getConfiguration().getAssertBehaviour() == AssertBehaviour.EQUALITY ) {
-    //            this.identityMap.remove( handle );
-    //        }
-    //    }
-
     public void modifyRetract(final FactHandle factHandle) {
         modifyRetract( factHandle,
                        null,
@@ -1144,16 +1086,6 @@
     public void modifyRetract(final FactHandle factHandle,
                               final Rule rule,
                               final Activation activation) {
-        this.modifyRetract( EntryPoint.DEFAULT,
-                            factHandle,
-                            rule,
-                            activation );
-    }
-
-    protected void modifyRetract(final EntryPoint entryPoint,
-                                 final FactHandle factHandle,
-                                 final Rule rule,
-                                 final Activation activation) {
         try {
             this.lock.lock();
             this.ruleBase.executeQueuedActions();
@@ -1180,16 +1112,20 @@
                 activation.getPropagationContext().releaseResources();
             }
             // Nowretract any trace of the original fact
-            final PropagationContext propagationContext = new PropagationContextImpl( this.propagationIdCounter++,
+            final PropagationContext propagationContext = new PropagationContextImpl( getNextPropagationIdCounter(),
                                                                                       PropagationContext.MODIFICATION,
                                                                                       rule,
                                                                                       activation,
                                                                                       this.agenda.getActiveActivations(),
                                                                                       this.agenda.getDormantActivations(),
                                                                                       entryPoint );
-            doRetract( handle,
-                       propagationContext );
 
+            this.entryPointNode.retractObject( handle,
+                                               propagationContext,
+                                               this.typeConfReg.getObjectTypeConf( this.entryPoint,
+                                                                                   handle.getObject() ),
+                                               this );
+
             if ( this.maintainTms ) {
 
                 // the hashCode and equality has changed, so we must update the
@@ -1219,18 +1155,6 @@
                              final Object object,
                              final Rule rule,
                              final Activation activation) {
-        this.modifyInsert( EntryPoint.DEFAULT,
-                           factHandle,
-                           object,
-                           rule,
-                           activation );
-    }
-
-    protected void modifyInsert(final EntryPoint entryPoint,
-                                final FactHandle factHandle,
-                                final Object object,
-                                final Rule rule,
-                                final Activation activation) {
         try {
             this.lock.lock();
             this.ruleBase.executeQueuedActions();
@@ -1262,7 +1186,7 @@
                 activation.getPropagationContext().releaseResources();
             }
             // Nowretract any trace of the original fact
-            final PropagationContext propagationContext = new PropagationContextImpl( this.propagationIdCounter++,
+            final PropagationContext propagationContext = new PropagationContextImpl( getNextPropagationIdCounter(),
                                                                                       PropagationContext.MODIFICATION,
                                                                                       rule,
                                                                                       activation,
@@ -1270,9 +1194,11 @@
                                                                                       this.agenda.getDormantActivations(),
                                                                                       entryPoint );
 
-            doInsert( handle,
-                      object,
-                      propagationContext );
+            this.entryPointNode.assertObject( handle,
+                                              propagationContext,
+                                              this.typeConfReg.getObjectTypeConf( this.entryPoint,
+                                                                                  object ),
+                                              this );
 
             this.workingMemoryEventSupport.fireObjectUpdated( propagationContext,
                                                               factHandle,
@@ -1282,9 +1208,7 @@
 
             propagationContext.clearRetractedTuples();
 
-            if ( !this.actionQueue.isEmpty() ) {
-                executeQueuedActions();
-            }
+            executeQueuedActions();
         } finally {
             this.lock.unlock();
         }
@@ -1298,29 +1222,10 @@
                 null );
     }
 
-    /**
-     * modify is implemented as half way retract / assert due to the truth
-     * maintenance issues.
-     * 
-     * @see WorkingMemory
-     */
     public void update(final FactHandle factHandle,
                        final Object object,
                        final Rule rule,
                        final Activation activation) throws FactException {
-        this.update( EntryPoint.DEFAULT,
-                     factHandle,
-                     object,
-                     rule,
-                     activation );
-
-    }
-
-    protected void update(final EntryPoint entryPoint,
-                          final FactHandle factHandle,
-                          final Object object,
-                          final Rule rule,
-                          final Activation activation) throws FactException {
         try {
             this.lock.lock();
             this.ruleBase.executeQueuedActions();
@@ -1346,15 +1251,21 @@
                 activation.getPropagationContext().releaseResources();
             }
             // Nowretract any trace of the original fact
-            final PropagationContext propagationContext = new PropagationContextImpl( this.propagationIdCounter++,
+            final PropagationContext propagationContext = new PropagationContextImpl( getNextPropagationIdCounter(),
                                                                                       PropagationContext.MODIFICATION,
                                                                                       rule,
                                                                                       activation,
                                                                                       this.agenda.getActiveActivations(),
                                                                                       this.agenda.getDormantActivations(),
                                                                                       entryPoint );
-            doRetract( handle,
-                       propagationContext );
+            
+           ObjectTypeConf typeConf = this.typeConfReg.getObjectTypeConf( this.entryPoint,
+                                                                         object );
+                                                
+            this.entryPointNode.retractObject( handle,
+                                               propagationContext,
+                                               typeConf,
+                                               this );
 
             if ( (originalObject != object) || (this.ruleBase.getConfiguration().getAssertBehaviour() != AssertBehaviour.IDENTITY) ) {
                 this.objectStore.removeHandle( handle );
@@ -1393,9 +1304,10 @@
 
             this.handleFactory.increaseFactHandleRecency( handle );
 
-            doInsert( handle,
-                      object,
-                      propagationContext );
+            this.entryPointNode.assertObject( handle,
+                                              propagationContext,
+                                              typeConf,
+                                              this );
 
             this.workingMemoryEventSupport.fireObjectUpdated( propagationContext,
                                                               factHandle,
@@ -1405,20 +1317,18 @@
 
             propagationContext.clearRetractedTuples();
 
-            if ( !this.actionQueue.isEmpty() ) {
-                executeQueuedActions();
-            }
+            executeQueuedActions();
         } finally {
             this.lock.unlock();
         }
     }
 
     public void executeQueuedActions() {
-        if( ! evaluatingActionQueue ) {
+        if ( !this.actionQueue.isEmpty() && !evaluatingActionQueue ) {
             evaluatingActionQueue = true;
             WorkingMemoryAction action = null;
-            
-            while ( ( action = actionQueue.poll() ) != null ) {
+
+            while ( (action = actionQueue.poll()) != null ) {
                 action.execute( this );
             }
             evaluatingActionQueue = false;
@@ -1500,7 +1410,7 @@
     }
 
     public long getNextPropagationIdCounter() {
-        return this.propagationIdCounter++;
+        return this.propagationIdCounter.incrementAndGet();
     }
 
     public Lock getLock() {
@@ -1625,164 +1535,108 @@
     public void setTimeMachine(TimeMachine timeMachine) {
         this.timeMachine = timeMachine;
     }
-
+    
     public ExecutorService getExecutorService() {
         return null; // no executor service
     }
 
     public void setExecutorService(ExecutorService executor) {
         // no executor service, so nothing to set
-    }
+    }    
 
-    /**
-     * Returns the ObjectTypeConfiguration object for the given object or
-     * creates a new one if none is found in the cache
-     * 
-     * @param object
-     * @return
-     */
-    public ObjectTypeConf getObjectTypeConf(EntryPoint entrypoint,
-                                            Object object) {
-        Map<Object, ObjectTypeConf> map = this.typeConfMap.get( entrypoint );
-        if ( map == null ) {
-            map = new ConcurrentHashMap<Object, ObjectTypeConf>();
-            this.typeConfMap.put( entrypoint,
-                                  map );
-        }
-        ObjectTypeConf objectTypeConf;
+    public WorkingMemoryEntryPoint getWorkingMemoryEntryPoint(String name) {
+        WorkingMemoryEntryPoint wmEntryPoint = this.entryPoints.get( name );
+        if ( wmEntryPoint == null ) {
+            EntryPoint entryPoint = new EntryPoint( name );
+            EntryPointNode entryPointNode = this.ruleBase.getRete().getEntryPointNode( entryPoint );
 
-        if ( object instanceof Fact ) {
-            String key = ((Fact) object).getFactTemplate().getName();
-            objectTypeConf = map.get( key );
-            if ( objectTypeConf == null ) {
-                objectTypeConf = new FactTemplateTypeConf( entrypoint,
-                                                           ((Fact) object).getFactTemplate(),
-                                                           this.ruleBase );
-                this.addObjectTypeConf( entrypoint,
-                                        key,
-                                        objectTypeConf );
-            }
-            object = key;
-        } else {
-            Class cls = null;
-            if ( object instanceof ShadowProxy ) {
-                cls = ((ShadowProxy) object).getShadowedObject().getClass();
-            } else {
-                cls = object.getClass();
-            }
 
-            objectTypeConf = map.get( cls );
-            if ( objectTypeConf == null ) {
-
-                final boolean isEvent = this.ruleBase.isEvent( cls );
-                objectTypeConf = new ClassObjectTypeConf( entrypoint,
-                                                          cls,
-                                                          isEvent,
-                                                          this.ruleBase );
-                this.addObjectTypeConf( entrypoint,
-                                        cls,
-                                        objectTypeConf );
+            if ( entryPointNode != null ) {
+                wmEntryPoint = new NamedEntryPoint( entryPoint,
+                                                    entryPointNode,
+                                                    this );
             }
 
+            if ( wmEntryPoint != null ) {
+                this.entryPoints.put( name,
+                                      wmEntryPoint );
+            }
         }
-        return objectTypeConf;
+        return wmEntryPoint;
     }
 
-    public Map<Object, ObjectTypeConf> getObjectTypeConfMap(EntryPoint entryPoint) {
-        Map<Object, ObjectTypeConf> map = this.typeConfMap.get( entryPoint );
-        if ( map == null ) {
-            map = Collections.emptyMap();
-        }
-        return map;
-    }
+    //    protected static class EntryPointInterfaceImpl
+    //        implements
+    //        EntryPointInterface {
+    //
+    //        private static final long           serialVersionUID = 2917871170743358801L;
+    //
+    //        private final EntryPoint            entryPoint;
+    //        private final AbstractWorkingMemory wm;
+    //
+    //        public EntryPointInterfaceImpl(EntryPoint entryPoint,
+    //                                       AbstractWorkingMemory wm) {
+    //            this.entryPoint = entryPoint;
+    //            this.wm = wm;
+    //        }
+    //
+    //        public FactHandle insert(Object object) throws FactException {
+    //            return wm.insert( this.entryPoint,
+    //                              object, /* Not-Dynamic */
+    //                              false,
+    //                              false,
+    //                              null,
+    //                              null );
+    //        }
+    //
+    //        public FactHandle insert(Object object,
+    //                                 boolean dynamic) throws FactException {
+    //            return wm.insert( this.entryPoint,
+    //                              object, /* Not-Dynamic */
+    //                              dynamic,
+    //                              false,
+    //                              null,
+    //                              null );
+    //        }
+    //
+    //        public void modifyInsert(FactHandle factHandle,
+    //                                 Object object) {
+    //            wm.modifyInsert( this.entryPoint,
+    //                             factHandle,
+    //                             object,
+    //                             null,
+    //                             null );
+    //        }
+    //
+    //        public void modifyRetract(FactHandle factHandle) {
+    //            wm.modifyRetract( this.entryPoint,
+    //                              factHandle,
+    //                              null,
+    //                              null );
+    //        }
+    //
+    //        public void retract(FactHandle handle) throws FactException {
+    //            wm.retract( this.entryPoint,
+    //                        handle,
+    //                        true,
+    //                        true,
+    //                        null,
+    //                        null );
+    //        }
+    //
+    //        public void update(FactHandle handle,
+    //                           Object object) throws FactException {
+    //            wm.update( this.entryPoint,
+    //                       handle,
+    //                       object,
+    //                       null,
+    //                       null );
+    //        }
+    //
+    //    }
+    
+    public ObjectTypeConfigurationRegistry getObjectTypeConfigurationRegistry() {
+        return this.typeConfReg;
+    }    
 
-    private void addObjectTypeConf(EntryPoint entryPoint,
-                                   Object key,
-                                   ObjectTypeConf conf) {
-        Map<Object, ObjectTypeConf> map = this.typeConfMap.get( entryPoint );
-        if ( map == null ) {
-            map = new ConcurrentHashMap<Object, ObjectTypeConf>();
-            this.typeConfMap.put( entryPoint,
-                                  map );
-        }
-        map.put( key,
-                 conf );
-    }
-
-    public EntryPointInterface getEntryPoint(String id) {
-        EntryPoint ep = new EntryPoint( id );
-        return new EntryPointInterfaceImpl( ep,
-                                            this );
-    }
-
-    protected static class EntryPointInterfaceImpl
-        implements
-        EntryPointInterface {
-
-        private static final long           serialVersionUID = 2917871170743358801L;
-
-        private final EntryPoint            entryPoint;
-        private final AbstractWorkingMemory wm;
-
-        public EntryPointInterfaceImpl(EntryPoint entryPoint,
-                                       AbstractWorkingMemory wm) {
-            this.entryPoint = entryPoint;
-            this.wm = wm;
-        }
-
-        public FactHandle insert(Object object) throws FactException {
-            return wm.insert( this.entryPoint,
-                              object, /* Not-Dynamic */
-                              false,
-                              false,
-                              null,
-                              null );
-        }
-
-        public FactHandle insert(Object object,
-                                 boolean dynamic) throws FactException {
-            return wm.insert( this.entryPoint,
-                              object, /* Not-Dynamic */
-                              dynamic,
-                              false,
-                              null,
-                              null );
-        }
-
-        public void modifyInsert(FactHandle factHandle,
-                                 Object object) {
-            wm.modifyInsert( this.entryPoint,
-                             factHandle,
-                             object,
-                             null,
-                             null );
-        }
-
-        public void modifyRetract(FactHandle factHandle) {
-            wm.modifyRetract( this.entryPoint,
-                              factHandle,
-                              null,
-                              null );
-        }
-
-        public void retract(FactHandle handle) throws FactException {
-            wm.retract( this.entryPoint,
-                        handle,
-                        true,
-                        true,
-                        null,
-                        null );
-        }
-
-        public void update(FactHandle handle,
-                           Object object) throws FactException {
-            wm.update( this.entryPoint,
-                       handle,
-                       object,
-                       null,
-                       null );
-        }
-
-    }
-
 }

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-03-10 12:24:02 UTC (rev 18794)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/DefaultFactHandle.java	2008-03-10 12:24:25 UTC (rev 18795)
@@ -35,7 +35,7 @@
      */
     private static final long serialVersionUID = 400L;
     /** Handle id. */
-    private long              id;
+    private int               id;
     private long              recency;
     private Object            object;
     private EqualityKey       key;
@@ -50,7 +50,7 @@
 
     }
 
-    public DefaultFactHandle(final long id,
+    public DefaultFactHandle(final int id,
                              final Object object) {
         this( id,
               object,
@@ -63,7 +63,7 @@
      * @param id
      *            Handle id.
      */
-    public DefaultFactHandle(final long id,
+    public DefaultFactHandle(final int id,
                              final Object object,
                              final long recency) {
         this.id = id;
@@ -99,7 +99,7 @@
      * @see Object
      */
     public int hashCode() {
-        return (int) (this.id ^ (this.id >>> 32));
+        return this.id;
     }
 
     /**

Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/EventFactHandle.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/EventFactHandle.java	2008-03-10 12:24:02 UTC (rev 18794)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/EventFactHandle.java	2008-03-10 12:24:25 UTC (rev 18795)
@@ -19,7 +19,7 @@
         this.duration = 0;
     }
 
-    public EventFactHandle(final long id,
+    public EventFactHandle(final int id,
                            final Object object) {
         super( id,
                object );
@@ -33,7 +33,7 @@
      * @param id
      *            Handle id.
      */
-    public EventFactHandle(final long id,
+    public EventFactHandle(final int id,
                            final Object object,
                            final long recency) {
         super( id,
@@ -52,7 +52,7 @@
      * @param timestamp the timestamp of the occurrence of this event
      * @param duration the duration of this event. May be 0 (zero) in case this is a primitive event.
      */
-    public EventFactHandle( final long id, 
+    public EventFactHandle( final int id, 
                             final Object object,
                             final long recency,
                             final long timestamp,

Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/InternalWorkingMemory.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/InternalWorkingMemory.java	2008-03-10 12:24:02 UTC (rev 18794)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/InternalWorkingMemory.java	2008-03-10 12:24:25 UTC (rev 18795)
@@ -89,23 +89,7 @@
 	public void setTimeMachine(TimeMachine tm);
     
     public void removeProcessInstance(ProcessInstance processInstance);
-    
-    /**
-     * Returns the ObjectTypeConfiguration object for the given object
-     * or creates a new one if none is found in the cache
-     * 
-     * @param object
-     * @return
-     */
-    public ObjectTypeConf getObjectTypeConf(EntryPoint entryPoint, Object object);
-    
-    /**
-     * Returns the Map<Object key, ObjectTypeConf conf> of object type
-     * confs in this working memory
-     *  
-     * @return
-     */
-    public Map<Object, ObjectTypeConf> getObjectTypeConfMap(EntryPoint entryPoint);
+       
 
     public ExecutorService getExecutorService();
 

Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/InternalWorkingMemoryActions.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/InternalWorkingMemoryActions.java	2008-03-10 12:24:02 UTC (rev 18794)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/InternalWorkingMemoryActions.java	2008-03-10 12:24:25 UTC (rev 18795)
@@ -23,7 +23,8 @@
 
 public interface InternalWorkingMemoryActions
     extends
-    InternalWorkingMemory {
+    InternalWorkingMemory,
+    InternalWorkingMemoryEntryPoint {
     public void update(FactHandle handle,
                        Object object,
                        Rule rule,

Added: 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	                        (rev 0)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/InternalWorkingMemoryEntryPoint.java	2008-03-10 12:24:25 UTC (rev 18795)
@@ -0,0 +1,7 @@
+package org.drools.common;
+
+import org.drools.WorkingMemoryEntryPoint;
+
+public interface InternalWorkingMemoryEntryPoint extends WorkingMemoryEntryPoint {
+    ObjectTypeConfigurationRegistry getObjectTypeConfigurationRegistry();
+}

Added: 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	                        (rev 0)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/NamedEntryPoint.java	2008-03-10 12:24:25 UTC (rev 18795)
@@ -0,0 +1,493 @@
+/**
+ * 
+ */
+package org.drools.common;
+
+import java.beans.PropertyChangeListener;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.util.concurrent.locks.ReentrantLock;
+
+import org.drools.WorkingMemoryEntryPoint;
+import org.drools.FactException;
+import org.drools.FactHandle;
+import org.drools.RuntimeDroolsException;
+import org.drools.WorkingMemory;
+import org.drools.RuleBaseConfiguration.AssertBehaviour;
+import org.drools.base.ShadowProxy;
+import org.drools.event.WorkingMemoryEventSupport;
+import org.drools.reteoo.EntryPointNode;
+import org.drools.reteoo.ObjectTypeConf;
+import org.drools.rule.EntryPoint;
+import org.drools.rule.Rule;
+import org.drools.spi.Activation;
+import org.drools.spi.FactHandleFactory;
+import org.drools.spi.PropagationContext;
+
+public class NamedEntryPoint
+    implements
+    InternalWorkingMemoryEntryPoint {
+    /** The arguments used when adding/removing a property change listener. */
+    protected final Object[]                addRemovePropertyChangeListenerArgs = new Object[]{this};
+
+    private static final long               serialVersionUID                    = 500;
+
+    protected ObjectStore                   objectStore;
+
+    protected transient InternalRuleBase    ruleBase;
+
+    protected EntryPoint                    entryPoint;
+    protected EntryPointNode                entryPointNode;
+
+    private ObjectTypeConfigurationRegistry typeConfReg;
+
+    private final AbstractWorkingMemory     wm;
+
+    private FactHandleFactory               handleFactory;
+
+    protected final ReentrantLock           lock;
+
+    public NamedEntryPoint(EntryPoint entryPoint,
+                           EntryPointNode entryPointNode,
+                           AbstractWorkingMemory wm) {
+        this( entryPoint,
+              entryPointNode,
+              wm,
+              new ReentrantLock() );
+    }
+
+    public NamedEntryPoint(EntryPoint entryPoint,
+                           EntryPointNode entryPointNode,
+                           AbstractWorkingMemory wm,
+                           ReentrantLock lock) {
+        this.entryPoint = entryPoint;
+        this.entryPointNode = entryPointNode;
+        this.wm = wm;
+        this.ruleBase = (InternalRuleBase) this.wm.getRuleBase();
+        this.lock = lock;
+        this.typeConfReg = new ObjectTypeConfigurationRegistry( this.ruleBase );
+        this.handleFactory = this.wm.getFactHandleFactory();
+        this.objectStore = new SingleThreadedObjectStore( this.ruleBase.getConfiguration(),
+                                                          this.lock );
+    }
+
+    /**
+     * @see WorkingMemory
+     */
+    public FactHandle insert(final Object object) throws FactException {
+        return insert( object, /* Not-Dynamic */
+                       0,
+                       false,
+                       false,
+                       null,
+                       null );
+    }
+
+    public FactHandle insert(final Object object,
+                             final long duration) throws FactException {
+        return insert( object, /* Not-Dynamic */
+                       duration,
+                       false,
+                       false,
+                       null,
+                       null );
+    }
+
+    public FactHandle insert(final Object object,
+                             final boolean dynamic) throws FactException {
+        return insert( object,
+                       0,
+                       dynamic,
+                       false,
+                       null,
+                       null );
+    }
+
+    public FactHandle insert(final Object object,
+                             final long duration,
+                             final boolean dynamic) throws FactException {
+        return insert( object,
+                       duration,
+                       dynamic,
+                       false,
+                       null,
+                       null );
+    }
+
+    protected FactHandle insert(final Object object,
+                                final long duration,
+                                final boolean dynamic,
+                                boolean logical,
+                                final Rule rule,
+                                final Activation activation) throws FactException {
+        if ( object == null ) {
+            // you cannot assert a null object
+            return null;
+        }
+
+        ObjectTypeConf typeConf = this.typeConfReg.getObjectTypeConf( this.entryPoint,
+                                                                      object );
+
+        InternalFactHandle handle = this.handleFactory.newFactHandle( object,
+                                                                      typeConf.isEvent(),
+                                                                      duration,
+                                                                      wm );
+        this.objectStore.addHandle( handle,
+                                    object );
+
+        if ( dynamic ) {
+            addPropertyChangeListener( object );
+        }
+
+        try {
+            this.lock.lock();
+            insert( handle,
+                    object,
+                    rule,
+                    activation );
+
+        } finally {
+            this.lock.unlock();
+        }
+        return handle;
+    }
+
+    protected void insert(final InternalFactHandle handle,
+                          final Object object,
+                          final Rule rule,
+                          final Activation activation) {
+        this.ruleBase.executeQueuedActions();
+
+        if ( activation != null ) {
+            // release resources so that they can be GC'ed
+            activation.getPropagationContext().releaseResources();
+        }
+        final PropagationContext propagationContext = new PropagationContextImpl( this.wm.getNextPropagationIdCounter(),
+                                                                                  PropagationContext.ASSERTION,
+                                                                                  rule,
+                                                                                  activation,
+                                                                                  -1,
+                                                                                  -1,
+                                                                                  this.entryPoint );
+
+        this.entryPointNode.assertObject( handle,
+                                          propagationContext,
+                                          this.typeConfReg.getObjectTypeConf( this.entryPoint,
+                                                                              object ),
+                                          this.wm );
+
+        this.wm.executeQueuedActions();
+
+        this.wm.getWorkingMemoryEventSupport().fireObjectInserted( propagationContext,
+                                                                   handle,
+                                                                   object,
+                                                                   wm );
+    }
+
+    public void update(final FactHandle handle,
+                       final Object object) throws FactException {
+        update( handle,
+                object,
+                null,
+                null );
+    }
+
+    protected void update(final FactHandle factHandle,
+                          final Object object,
+                          final Rule rule,
+                          final Activation activation) throws FactException {
+        try {
+            this.lock.lock();
+            this.ruleBase.executeQueuedActions();
+
+            final InternalFactHandle handle = (InternalFactHandle) factHandle;
+            final Object originalObject = (handle.isShadowFact()) ? ((ShadowProxy) handle.getObject()).getShadowedObject() : handle.getObject();
+
+            if ( handle.getId() == -1 || object == null ) {
+                // the handle is invalid, most likely already retracted, so
+                // return
+                // and we cannot assert a null object
+                return;
+            }
+
+            ObjectTypeConf typeConf = this.typeConfReg.getObjectTypeConf( this.entryPoint,
+                                                                          object );
+
+            if ( activation != null ) {
+                // release resources so that they can be GC'ed
+                activation.getPropagationContext().releaseResources();
+            }
+            // Nowretract any trace of the original fact
+            final PropagationContext propagationContext = new PropagationContextImpl( this.wm.getNextPropagationIdCounter(),
+                                                                                      PropagationContext.MODIFICATION,
+                                                                                      rule,
+                                                                                      activation,
+                                                                                      -1,
+                                                                                      -1,
+                                                                                      this.entryPoint );
+
+            this.entryPointNode.retractObject( handle,
+                                               propagationContext,
+                                               typeConf,
+                                               this.wm );
+
+            if ( (originalObject != object) || (this.ruleBase.getConfiguration().getAssertBehaviour() != AssertBehaviour.IDENTITY) ) {
+                this.objectStore.removeHandle( handle );
+
+                // set anyway, so that it updates the hashCodes
+                handle.setObject( object );
+                this.objectStore.addHandle( handle,
+                                            object );
+            }
+
+            this.handleFactory.increaseFactHandleRecency( handle );
+
+            this.entryPointNode.assertObject( handle,
+                                              propagationContext,
+                                              typeConf,
+                                              this.wm );
+
+            this.wm.getWorkingMemoryEventSupport().fireObjectUpdated( propagationContext,
+                                                                      factHandle,
+                                                                      originalObject,
+                                                                      object,
+                                                                      this.wm );
+
+            propagationContext.clearRetractedTuples();
+
+            this.wm.executeQueuedActions();
+        } finally {
+            this.lock.unlock();
+        }
+    }
+
+    public void retract(final FactHandle handle) throws FactException {
+        retract( handle,
+                 true,
+                 true,
+                 null,
+                 null );
+    }
+
+    public void retract(final FactHandle factHandle,
+                        final boolean removeLogical,
+                        final boolean updateEqualsMap,
+                        final Rule rule,
+                        final Activation activation) throws FactException {
+        try {
+            this.lock.lock();
+            this.ruleBase.executeQueuedActions();
+
+            final InternalFactHandle handle = (InternalFactHandle) factHandle;
+            if ( handle.getId() == -1 ) {
+                // can't retract an already retracted handle
+                return;
+            }
+            removePropertyChangeListener( handle );
+
+            if ( activation != null ) {
+                // release resources so that they can be GC'ed
+                activation.getPropagationContext().releaseResources();
+            }
+            final PropagationContext propagationContext = new PropagationContextImpl( this.wm.getNextPropagationIdCounter(),
+                                                                                      PropagationContext.RETRACTION,
+                                                                                      rule,
+                                                                                      activation,
+                                                                                      -1,
+                                                                                      -1,
+                                                                                      this.entryPoint );
+
+            this.entryPointNode.retractObject( handle,
+                                               propagationContext,
+                                               this.wm );
+
+            final Object object = handle.getObject();
+
+            this.wm.getWorkingMemoryEventSupport().fireObjectRetracted( propagationContext,
+                                                                        handle,
+                                                                        object,
+                                                                        this.wm );
+
+            this.objectStore.removeHandle( handle );
+
+            this.handleFactory.destroyFactHandle( handle );
+
+            this.wm.executeQueuedActions();
+        } finally {
+            this.lock.unlock();
+        }
+    }
+
+    public void modifyRetract(final FactHandle factHandle) {
+        modifyRetract( factHandle,
+                       null,
+                       null );
+    }
+
+    public void modifyRetract(final FactHandle factHandle,
+                              final Rule rule,
+                              final Activation activation) {
+        try {
+            this.lock.lock();
+            this.ruleBase.executeQueuedActions();
+
+            final InternalFactHandle handle = (InternalFactHandle) factHandle;
+            // final Object originalObject = (handle.isShadowFact()) ?
+            // ((ShadowProxy) handle.getObject()).getShadowedObject() :
+            // handle.getObject();
+
+            if ( handle.getId() == -1 ) {
+                // the handle is invalid, most likely already retracted, so
+                // return
+                return;
+            }
+
+            if ( activation != null ) {
+                // release resources so that they can be GC'ed
+                activation.getPropagationContext().releaseResources();
+            }
+            // Nowretract any trace of the original fact
+            final PropagationContext propagationContext = new PropagationContextImpl( this.wm.getNextPropagationIdCounter(),
+                                                                                      PropagationContext.MODIFICATION,
+                                                                                      rule,
+                                                                                      activation,
+                                                                                      -1,
+                                                                                      -1,
+                                                                                      entryPoint );
+
+            this.entryPointNode.retractObject( handle,
+                                               propagationContext,
+                                               this.wm );
+
+        } finally {
+            this.lock.unlock();
+        }
+    }
+
+    public void modifyInsert(final FactHandle factHandle,
+                             final Object object) {
+        modifyInsert( factHandle,
+                      object,
+                      null,
+                      null );
+    }
+
+    public void modifyInsert(final FactHandle factHandle,
+                             final Object object,
+                             final Rule rule,
+                             final Activation activation) {
+        this.modifyInsert( EntryPoint.DEFAULT,
+                           factHandle,
+                           object,
+                           rule,
+                           activation );
+    }
+
+    protected void modifyInsert(final EntryPoint entryPoint,
+                                final FactHandle factHandle,
+                                final Object object,
+                                final Rule rule,
+                                final Activation activation) {
+        try {
+            this.lock.lock();
+            this.ruleBase.executeQueuedActions();
+
+            final InternalFactHandle handle = (InternalFactHandle) factHandle;
+            final Object originalObject = (handle.isShadowFact()) ? ((ShadowProxy) handle.getObject()).getShadowedObject() : handle.getObject();
+
+            this.handleFactory.increaseFactHandleRecency( handle );
+
+            if ( activation != null ) {
+                // release resources so that they can be GC'ed
+                activation.getPropagationContext().releaseResources();
+            }
+            // Nowretract any trace of the original fact
+            final PropagationContext propagationContext = new PropagationContextImpl( this.wm.getNextPropagationIdCounter(),
+                                                                                      PropagationContext.MODIFICATION,
+                                                                                      rule,
+                                                                                      activation,
+                                                                                      -1,
+                                                                                      -1,
+                                                                                      entryPoint );
+
+            this.entryPointNode.assertObject( handle,
+                                              propagationContext,
+                                              this.wm );
+
+            this.wm.getWorkingMemoryEventSupport().fireObjectUpdated( propagationContext,
+                                                                      factHandle,
+                                                                      originalObject,
+                                                                      object,
+                                                                      this.wm );
+
+            propagationContext.clearRetractedTuples();
+
+            this.wm.executeQueuedActions();
+        } finally {
+            this.lock.unlock();
+        }
+    }
+
+    protected void addPropertyChangeListener(final Object object) {
+        try {
+            final Method method = object.getClass().getMethod( "addPropertyChangeListener",
+                                                               AbstractWorkingMemory.ADD_REMOVE_PROPERTY_CHANGE_LISTENER_ARG_TYPES );
+
+            method.invoke( object,
+                           this.addRemovePropertyChangeListenerArgs );
+        } catch ( final NoSuchMethodException e ) {
+            System.err.println( "Warning: Method addPropertyChangeListener not found" + " on the class " + object.getClass() + " so Drools will be unable to process JavaBean" + " PropertyChangeEvents on the asserted Object" );
+        } catch ( final IllegalArgumentException e ) {
+            System.err.println( "Warning: The addPropertyChangeListener method" + " on the class " + object.getClass() + " does not take" + " a simple PropertyChangeListener argument" + " so Drools will be unable to process JavaBean"
+                                + " PropertyChangeEvents on the asserted Object" );
+        } catch ( final IllegalAccessException e ) {
+            System.err.println( "Warning: The addPropertyChangeListener method" + " on the class " + object.getClass() + " is not public" + " so Drools will be unable to process JavaBean" + " PropertyChangeEvents on the asserted Object" );
+        } catch ( final InvocationTargetException e ) {
+            System.err.println( "Warning: The addPropertyChangeListener method" + " on the class " + object.getClass() + " threw an InvocationTargetException" + " so Drools will be unable to process JavaBean"
+                                + " PropertyChangeEvents on the asserted Object: " + e.getMessage() );
+        } catch ( final SecurityException e ) {
+            System.err.println( "Warning: The SecurityManager controlling the class " + object.getClass() + " did not allow the lookup of a" + " addPropertyChangeListener method" + " so Drools will be unable to process JavaBean"
+                                + " PropertyChangeEvents on the asserted Object: " + e.getMessage() );
+        }
+    }
+
+    protected void removePropertyChangeListener(final FactHandle handle) {
+        Object object = null;
+        try {
+            object = ((InternalFactHandle) handle).getObject();
+
+            if ( object != null ) {
+                final Method mehod = object.getClass().getMethod( "removePropertyChangeListener",
+                                                                  AbstractWorkingMemory.ADD_REMOVE_PROPERTY_CHANGE_LISTENER_ARG_TYPES );
+
+                mehod.invoke( object,
+                              this.addRemovePropertyChangeListenerArgs );
+            }
+        } catch ( final NoSuchMethodException e ) {
+            // The removePropertyChangeListener method on the class
+            // was not found so Drools will be unable to
+            // stop processing JavaBean PropertyChangeEvents
+            // on the retracted Object
+        } catch ( final IllegalArgumentException e ) {
+            throw new RuntimeDroolsException( "Warning: The removePropertyChangeListener method on the class " + object.getClass() + " does not take a simple PropertyChangeListener argument so Drools will be unable to stop processing JavaBean"
+                                              + " PropertyChangeEvents on the retracted Object" );
+        } catch ( final IllegalAccessException e ) {
+            throw new RuntimeDroolsException( "Warning: The removePropertyChangeListener method on the class " + object.getClass() + " is not public so Drools will be unable to stop processing JavaBean PropertyChangeEvents on the retracted Object" );
+        } catch ( final InvocationTargetException e ) {
+            throw new RuntimeDroolsException( "Warning: The removePropertyChangeL istener method on the class " + object.getClass() + " threw an InvocationTargetException so Drools will be unable to stop processing JavaBean"
+                                              + " PropertyChangeEvents on the retracted Object: " + e.getMessage() );
+        } catch ( final SecurityException e ) {
+            throw new RuntimeDroolsException( "Warning: The SecurityManager controlling the class " + object.getClass() + " did not allow the lookup of a removePropertyChangeListener method so Drools will be unable to stop processing JavaBean"
+                                              + " PropertyChangeEvents on the retracted Object: " + e.getMessage() );
+        }
+    }
+
+    public WorkingMemoryEntryPoint getWorkingMemoryEntryPoint(String name) {
+        return this.wm.getWorkingMemoryEntryPoint( name );
+    }
+
+    public ObjectTypeConfigurationRegistry getObjectTypeConfigurationRegistry() {
+        return this.typeConfReg;
+    }
+
+}
\ No newline at end of file

Added: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/ObjectTypeConfigurationRegistry.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/ObjectTypeConfigurationRegistry.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/ObjectTypeConfigurationRegistry.java	2008-03-10 12:24:25 UTC (rev 18795)
@@ -0,0 +1,78 @@
+package org.drools.common;
+
+import java.io.Serializable;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.drools.base.ShadowProxy;
+import org.drools.facttemplates.Fact;
+import org.drools.reteoo.ClassObjectTypeConf;
+import org.drools.reteoo.FactTemplateTypeConf;
+import org.drools.reteoo.ObjectTypeConf;
+import org.drools.rule.EntryPoint;
+
+public class ObjectTypeConfigurationRegistry implements Serializable {
+    private InternalRuleBase ruleBase;
+    private Map<Object, ObjectTypeConf> typeConfMap;
+    
+
+    
+    public ObjectTypeConfigurationRegistry(InternalRuleBase ruleBase ) {
+        super();
+        this.ruleBase = ruleBase;
+        this.typeConfMap = new HashMap<Object, ObjectTypeConf>();
+    }
+
+
+
+    /**
+     * Returns the ObjectTypeConfiguration object for the given object or
+     * creates a new one if none is found in the cache
+     * 
+     * @param object
+     * @return
+     */
+    public ObjectTypeConf getObjectTypeConf(EntryPoint entrypoint,
+                                            Object object) {
+        
+        // first see if it's a ClassObjectTypeConf
+        Class cls = null;
+        if ( object instanceof ShadowProxy ) {
+            cls = ((ShadowProxy) object).getShadowedObject().getClass();
+        } else {
+            cls = object.getClass();
+        }        
+        ObjectTypeConf objectTypeConf = this.typeConfMap.get( cls );
+        
+        // Now see if it's something else 
+        if ( objectTypeConf == null ) {
+            objectTypeConf = this.typeConfMap.get( object );
+        }
+        
+        
+        // it doesn't exist, so create it.
+        if ( objectTypeConf == null ) {
+            if ( object instanceof Fact ) {
+                objectTypeConf = new FactTemplateTypeConf( entrypoint,
+                                                           ((Fact) object).getFactTemplate(),
+                                                           this.ruleBase );           
+                this.typeConfMap.put( object, objectTypeConf );
+            } else {
+                final boolean isEvent = this.ruleBase.isEvent( cls );
+                objectTypeConf = new ClassObjectTypeConf( entrypoint,
+                                                          cls,
+                                                          isEvent,
+                                                          this.ruleBase );
+                this.typeConfMap.put( cls, objectTypeConf );
+            }            
+        }
+
+        return objectTypeConf;
+    }
+
+    
+    public Collection<ObjectTypeConf> values() {
+        return this.typeConfMap.values();
+    }
+}

Added: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/SharedTemporalWorkingMemoryContext.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/SharedTemporalWorkingMemoryContext.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/SharedTemporalWorkingMemoryContext.java	2008-03-10 12:24:25 UTC (rev 18795)
@@ -0,0 +1,33 @@
+package org.drools.common;
+
+import java.util.HashMap;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+
+import org.drools.base.MapGlobalResolver;
+import org.drools.event.AgendaEventSupport;
+import org.drools.event.RuleFlowEventSupport;
+import org.drools.event.WorkingMemoryEventSupport;
+import org.drools.process.instance.ProcessInstanceFactory;
+import org.drools.process.instance.WorkItemManager;
+import org.drools.rule.TimeMachine;
+import org.drools.spi.FactHandleFactory;
+import org.drools.spi.GlobalResolver;
+import org.drools.temporal.SessionClock;
+
+public class SharedTemporalWorkingMemoryContext<T extends SessionClock>  extends SharedWorkingMemoryContext {    
+    protected T                                   sessionClock;
+    
+    public SharedTemporalWorkingMemoryContext(FactHandleFactory handleFactory, T sessionClock) {
+        super( handleFactory );        
+        this.sessionClock = sessionClock;
+    }
+
+    public T getSessionClock() {
+        return sessionClock;
+    }
+    
+            
+    
+}

Added: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/SharedWorkingMemoryContext.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/SharedWorkingMemoryContext.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/SharedWorkingMemoryContext.java	2008-03-10 12:24:25 UTC (rev 18795)
@@ -0,0 +1,119 @@
+package org.drools.common;
+
+import java.util.HashMap;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+
+import org.drools.base.MapGlobalResolver;
+import org.drools.event.AgendaEventSupport;
+import org.drools.event.RuleFlowEventSupport;
+import org.drools.event.WorkingMemoryEventSupport;
+import org.drools.process.instance.ProcessInstanceFactory;
+import org.drools.process.instance.WorkItemManager;
+import org.drools.rule.TimeMachine;
+import org.drools.spi.FactHandleFactory;
+import org.drools.spi.GlobalResolver;
+import org.drools.temporal.SessionClock;
+
+public class SharedWorkingMemoryContext {
+    protected InternalRuleBase                  ruleBase;
+
+    protected FactHandleFactory                 handleFactory;
+
+    /** Global values which are associated with this memory. */
+    protected GlobalResolver                    globalResolver;
+
+    /** The eventSupport */
+    protected WorkingMemoryEventSupport         workingMemoryEventSupport;
+
+    protected AgendaEventSupport                agendaEventSupport;
+
+    protected RuleFlowEventSupport              workflowEventSupport;
+
+    protected List                              __ruleBaseEventListeners;
+
+    protected long                              propagationIdCounter;
+
+    private Map                                 processInstances;
+
+    private int                                 processCounter;
+
+    private WorkItemManager                     workItemManager;
+
+    private Map<String, ProcessInstanceFactory> processInstanceFactories;
+
+    private TimeMachine                         timeMachine;
+
+    public SharedWorkingMemoryContext(FactHandleFactory handleFactory) {
+        this.handleFactory = handleFactory;
+
+        this.globalResolver = new MapGlobalResolver();
+
+        this.workingMemoryEventSupport = new WorkingMemoryEventSupport();
+        this.agendaEventSupport = new AgendaEventSupport();
+        this.workflowEventSupport = new RuleFlowEventSupport();
+        this.__ruleBaseEventListeners = new LinkedList();
+
+        processInstanceFactories = new HashMap();
+
+        timeMachine = new TimeMachine();
+    }
+
+    public Map getProcessInstances() {
+        return processInstances;
+    }
+
+    public void setProcessInstances(Map processInstances) {
+        this.processInstances = processInstances;
+    }
+
+    public WorkItemManager getWorkItemManager() {
+        return workItemManager;
+    }
+
+    public void setWorkItemManager(WorkItemManager workItemManager) {
+        this.workItemManager = workItemManager;
+    }
+
+    public TimeMachine getTimeMachine() {
+        return timeMachine;
+    }
+
+    public void setTimeMachine(TimeMachine timeMachine) {
+        this.timeMachine = timeMachine;
+    }
+
+    public FactHandleFactory getHandleFactory() {
+        return handleFactory;
+    }
+
+    public GlobalResolver getGlobalResolver() {
+        return globalResolver;
+    }
+
+    public WorkingMemoryEventSupport getWorkingMemoryEventSupport() {
+        return workingMemoryEventSupport;
+    }
+
+    public AgendaEventSupport getAgendaEventSupport() {
+        return agendaEventSupport;
+    }
+
+    public RuleFlowEventSupport getWorkflowEventSupport() {
+        return workflowEventSupport;
+    }
+
+    public List get__ruleBaseEventListeners() {
+        return __ruleBaseEventListeners;
+    }
+
+    public int getProcessCounter() {
+        return processCounter;
+    }
+
+    public Map<String, ProcessInstanceFactory> getProcessInstanceFactories() {
+        return processInstanceFactories;
+    }
+
+}

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-03-10 12:24:02 UTC (rev 18794)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/EntryPointNode.java	2008-03-10 12:24:25 UTC (rev 18795)
@@ -22,10 +22,12 @@
 import java.util.HashMap;
 import java.util.Map;
 
+import org.drools.WorkingMemoryEntryPoint;
 import org.drools.base.ShadowProxy;
 import org.drools.common.BaseNode;
 import org.drools.common.InternalFactHandle;
 import org.drools.common.InternalWorkingMemory;
+import org.drools.common.InternalWorkingMemoryEntryPoint;
 import org.drools.common.NodeMemory;
 import org.drools.common.PropagationContextImpl;
 import org.drools.reteoo.builder.BuildContext;
@@ -101,26 +103,11 @@
     public EntryPoint getEntryPoint() {
         return entryPoint;
     }
-
-    /**
-     * This is the entry point into the network for all asserted Facts. Iterates a cache
-     * of matching <code>ObjectTypdeNode</code>s asserting the Fact. If the cache does not
-     * exist it first iterates and builds the cache.
-     *
-     * @param handle
-     *            The FactHandle of the fact to assert
-     * @param context
-     *            The <code>PropagationContext</code> of the <code>WorkingMemory</code> action
-     * @param workingMemory
-     *            The working memory session.
-     */
+    
     public void assertObject(final InternalFactHandle handle,
                              final PropagationContext context,
+                             final ObjectTypeConf objectTypeConf,
                              final InternalWorkingMemory workingMemory) {
-
-        ObjectTypeConf objectTypeConf = workingMemory.getObjectTypeConf( this.entryPoint,
-                                                                         handle.getObject() );
-
         // checks if shadow is enabled
         if ( objectTypeConf.isShadowEnabled() ) {
             // need to improve this
@@ -140,6 +127,24 @@
                                          context,
                                          workingMemory );
         }
+    }    
+
+    /**
+     * This is the entry point into the network for all asserted Facts. Iterates a cache
+     * of matching <code>ObjectTypdeNode</code>s asserting the Fact. If the cache does not
+     * exist it first iterates and builds the cache.
+     *
+     * @param handle
+     *            The FactHandle of the fact to assert
+     * @param context
+     *            The <code>PropagationContext</code> of the <code>WorkingMemory</code> action
+     * @param workingMemory
+     *            The working memory session.
+     */
+    public void assertObject(final InternalFactHandle handle,
+                             final PropagationContext context,
+                             final InternalWorkingMemory workingMemory) {
+        // do nothing, dummy method to impl the interface
     }
 
     /**
@@ -153,11 +158,10 @@
      */
     public void retractObject(final InternalFactHandle handle,
                               final PropagationContext context,
+                              final ObjectTypeConf objectTypeConf,                              
                               final InternalWorkingMemory workingMemory) {
         final Object object = handle.getObject();
-
-        ObjectTypeConf objectTypeConf = workingMemory.getObjectTypeConf( this.entryPoint,
-                                                                         object );
+        
         ObjectTypeNode[] cachedNodes = objectTypeConf.getObjectTypeNodes();
 
         if ( cachedNodes == null ) {
@@ -171,6 +175,12 @@
                                           workingMemory );
         }
     }
+    
+    public void retractObject(final InternalFactHandle handle,
+                              final PropagationContext context,        
+                              final InternalWorkingMemory workingMemory) {
+        // do nothing, dummy method to impl the interface                
+    }
 
     /**
      * Adds the <code>ObjectSink</code> so that it may receive
@@ -249,9 +259,12 @@
                            final InternalWorkingMemory workingMemory) {
         // JBRULES-612: the cache MUST be invalidated when a new node type is added to the network, so iterate and reset all caches.
         final ObjectTypeNode node = (ObjectTypeNode) sink;
+                
         final ObjectType newObjectType = node.getObjectType();
 
-        for ( ObjectTypeConf objectTypeConf : workingMemory.getObjectTypeConfMap( this.entryPoint ).values() ) {
+        InternalWorkingMemoryEntryPoint wmEntryPoint = ( InternalWorkingMemoryEntryPoint ) workingMemory.getWorkingMemoryEntryPoint( this.entryPoint.getEntryPointId() );
+        
+        for ( ObjectTypeConf objectTypeConf : wmEntryPoint.getObjectTypeConfigurationRegistry().values() ) {            
             if ( newObjectType.isAssignableFrom( objectTypeConf.getConcreteObjectTypeNode().getObjectType() ) ) {
                 objectTypeConf.resetCache();
                 ObjectTypeNode sourceNode = objectTypeConf.getConcreteObjectTypeNode();

Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/Rete.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/Rete.java	2008-03-10 12:24:02 UTC (rev 18794)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/Rete.java	2008-03-10 12:24:25 UTC (rev 18795)
@@ -29,6 +29,7 @@
 import org.drools.common.InternalFactHandle;
 import org.drools.common.InternalRuleBase;
 import org.drools.common.InternalWorkingMemory;
+import org.drools.common.InternalWorkingMemoryEntryPoint;
 import org.drools.reteoo.builder.BuildContext;
 import org.drools.rule.EntryPoint;
 import org.drools.spi.ObjectType;
@@ -108,9 +109,12 @@
     public void assertObject(final InternalFactHandle handle,
                              final PropagationContext context,
                              final InternalWorkingMemory workingMemory) {
-        EntryPointNode node = this.entryPoints.get( context.getEntryPoint() );
+        EntryPoint entryPoint = context.getEntryPoint();
+        EntryPointNode node = this.entryPoints.get( entryPoint );
+        ObjectTypeConf typeConf = ((InternalWorkingMemoryEntryPoint) workingMemory.getWorkingMemoryEntryPoint(  entryPoint.getEntryPointId() )).getObjectTypeConfigurationRegistry().getObjectTypeConf( entryPoint, handle.getObject() );
         node.assertObject( handle,
                            context,
+                           typeConf,
                            workingMemory );
     }
 
@@ -126,9 +130,12 @@
     public void retractObject(final InternalFactHandle handle,
                               final PropagationContext context,
                               final InternalWorkingMemory workingMemory) {
-        EntryPointNode node = this.entryPoints.get( context.getEntryPoint() );
+        EntryPoint entryPoint = context.getEntryPoint();
+        EntryPointNode node = this.entryPoints.get( entryPoint );
+        ObjectTypeConf typeConf = ((InternalWorkingMemoryEntryPoint) workingMemory.getWorkingMemoryEntryPoint(  entryPoint.getEntryPointId() )).getObjectTypeConfigurationRegistry().getObjectTypeConf( entryPoint, handle.getObject() );
         node.retractObject( handle,
                             context,
+                            typeConf,
                             workingMemory );
     }
 

Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/ReteooFactHandleFactory.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/ReteooFactHandleFactory.java	2008-03-10 12:24:02 UTC (rev 18794)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/ReteooFactHandleFactory.java	2008-03-10 12:24:25 UTC (rev 18795)
@@ -28,11 +28,15 @@
 public class ReteooFactHandleFactory extends AbstractFactHandleFactory {
 
     private static final long serialVersionUID = 400L;
+    
+    public ReteooFactHandleFactory() {
+        super();
+    }
 
     /* (non-Javadoc)
      * @see org.drools.reteoo.FactHandleFactory#newFactHandle(long)
      */
-    protected final InternalFactHandle newFactHandle(final long id,
+    protected final InternalFactHandle newFactHandle(final int id,
                                                      final Object object,
                                                      final long recency,
                                                      final boolean isEvent,
@@ -54,7 +58,7 @@
     /* (non-Javadoc)
      * @see org.drools.reteoo.FactHandleFactory#newFactHandle(long)
      */
-    protected final InternalFactHandle newFactHandle(final long id,
+    protected final InternalFactHandle newFactHandle(final int id,
                                                      final Object object,
                                                      final long recency,
                                                      final boolean isEvent,

Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/ReteooStatefulSession.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/ReteooStatefulSession.java	2008-03-10 12:24:02 UTC (rev 18794)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/ReteooStatefulSession.java	2008-03-10 12:24:25 UTC (rev 18795)
@@ -5,9 +5,11 @@
 import java.util.Iterator;
 import java.util.List;
 
+import org.drools.WorkingMemoryEntryPoint;
 import org.drools.FactHandle;
 import org.drools.StatefulSession;
 import org.drools.common.InternalRuleBase;
+//import org.drools.common.AbstractWorkingMemory.EntryPointInterfaceImpl;
 import org.drools.concurrent.AssertObject;
 import org.drools.concurrent.AssertObjects;
 import org.drools.concurrent.ExecutorService;
@@ -16,6 +18,7 @@
 import org.drools.concurrent.RetractObject;
 import org.drools.concurrent.UpdateObject;
 import org.drools.event.RuleBaseEventListener;
+import org.drools.rule.EntryPoint;
 import org.drools.spi.AgendaFilter;
 import org.drools.spi.RuleBaseUpdateListener;
 import org.drools.spi.RuleBaseUpdateListenerFactory;
@@ -101,6 +104,12 @@
         }
         return this.ruleBaseListeners;
     }
+    
+//    public StatefulSession getEntryPoint(String id) {        
+//        EntryPoint ep = new EntryPoint( id );
+//        return new EntryPointInterfaceImpl( ep,
+//                                            this );
+//    }    
 
     public ExecutorService getExecutorService() {
         return executor;

Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/ReteooStatelessSession.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/ReteooStatelessSession.java	2008-03-10 12:24:02 UTC (rev 18794)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/ReteooStatelessSession.java	2008-03-10 12:24:25 UTC (rev 18795)
@@ -23,6 +23,7 @@
 import org.drools.event.WorkingMemoryEventSupport;
 import org.drools.reteoo.ReteooRuleBase.InitialFactHandleDummyObject;
 import org.drools.reteoo.ReteooWorkingMemory.WorkingMemoryReteAssertAction;
+import org.drools.rule.EntryPoint;
 import org.drools.spi.AgendaFilter;
 import org.drools.spi.ExecutorServiceFactory;
 import org.drools.spi.GlobalExporter;

Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/ReteooTemporalSession.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/ReteooTemporalSession.java	2008-03-10 12:24:02 UTC (rev 18794)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/ReteooTemporalSession.java	2008-03-10 12:24:25 UTC (rev 18795)
@@ -20,6 +20,7 @@
 import org.drools.TemporalSession;
 import org.drools.common.InternalRuleBase;
 import org.drools.concurrent.ExecutorService;
+import org.drools.rule.EntryPoint;
 import org.drools.temporal.SessionClock;
 
 /**
@@ -33,13 +34,13 @@
     TemporalSession<T> {
 
     private static final long serialVersionUID = -2129661675928809928L;
-    
-    private T sessionClock;
 
-    public ReteooTemporalSession(int id,
-                                         InternalRuleBase ruleBase,
-                                         ExecutorService executorService,
-                                         T clock) {
+    private T                 sessionClock;
+
+    public ReteooTemporalSession(final int id,
+                                 final InternalRuleBase ruleBase,
+                                 final ExecutorService executorService,
+                                 final T clock) {
         super( id,
                ruleBase,
                executorService );
@@ -49,5 +50,5 @@
     public T getSessionClock() {
         return this.sessionClock;
     }
-    
+
 }

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	2008-03-10 12:24:02 UTC (rev 18794)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/ReteooWorkingMemory.java	2008-03-10 12:24:25 UTC (rev 18795)
@@ -59,29 +59,13 @@
      *            The backing rule-base.
      */
     public ReteooWorkingMemory(final int id,
-                               final InternalRuleBase ruleBase) {
+                               final InternalRuleBase ruleBase ) {
         super( id,
                ruleBase,
                ruleBase.newFactHandleFactory() );
         this.agenda = new DefaultAgenda( this );
     }
-
-    public void doInsert(final InternalFactHandle handle,
-                               final Object object,
-                               final PropagationContext propagationContext) throws FactException {
-        this.ruleBase.assertObject( handle,
-                                    object,
-                                    propagationContext,
-                                    this );
-    }
-
-    public void doRetract(final InternalFactHandle handle,
-                          final PropagationContext propagationContext) {
-        this.ruleBase.retractObject( handle,
-                                     propagationContext,
-                                     this );
-    }
-
+    
     public QueryResults getQueryResults(final String query) {
         return getQueryResults( query, null );
     }
@@ -91,11 +75,11 @@
         Object object = new DroolsQuery( query, arguments );
         InternalFactHandle handle = this.handleFactory.newFactHandle( object, false, 0, this );
         
-        insert( EntryPoint.DEFAULT, // query dummy objects always use default entry point
-                handle,
+        insert( handle,
                 object,
                 null,
-                null );
+                null,
+                this.typeConfReg.getObjectTypeConf( this.entryPoint, object ));
         
         final QueryTerminalNode node = (QueryTerminalNode) this.queryResults.remove( query );
         Query queryObj = null;

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-03-10 12:24:02 UTC (rev 18794)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/spi/FactHandleFactory.java	2008-03-10 12:24:25 UTC (rev 18795)
@@ -38,14 +38,14 @@
      * 
      * @return The handle.
      */
-    InternalFactHandle newFactHandle(Object object, boolean isEvent, WorkingMemory workingMemory );
+    public InternalFactHandle newFactHandle(Object object, boolean isEvent, WorkingMemory workingMemory );
     
     /**
      * Construct a handle with a new id and a duration.
      * 
      * @return The handle.
      */
-    InternalFactHandle newFactHandle(Object object, boolean isEvent, long duration, WorkingMemory workingMemory );
+    public InternalFactHandle newFactHandle(Object object, boolean isEvent, long duration, WorkingMemory workingMemory );
 
     /**
      * Increases the recency of the FactHandle

Modified: labs/jbossrules/trunk/drools-core/src/test/java/org/drools/reteoo/DefaultFactHandleFactoryTest.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/test/java/org/drools/reteoo/DefaultFactHandleFactoryTest.java	2008-03-10 12:24:02 UTC (rev 18794)
+++ labs/jbossrules/trunk/drools-core/src/test/java/org/drools/reteoo/DefaultFactHandleFactoryTest.java	2008-03-10 12:24:25 UTC (rev 18795)
@@ -62,20 +62,21 @@
         // destroy handle
         factory.destroyFactHandle( handle2 );
 
-        // issue  new  fact handle and  make sure it  recycled the  id=2
-        handle = (DefaultFactHandle) factory.newFactHandle( "cheese", false, null );
-        assertEquals( 2,
-                      handle.getId() );
-        assertEquals( 5,
-                      handle.getRecency() );
+        //@FIXME recycling is currently disabled
+//        // issue  new  fact handle and  make sure it  recycled the  id=2
+//        handle = (DefaultFactHandle) factory.newFactHandle( "cheese", false, null );
+//        assertEquals( 2,
+//                      handle.getId() );
+//        assertEquals( 5,
+//                      handle.getRecency() );
+//
+//        // issue new  handle  making  sure it correctly resumes  ids  and recency
+//        handle = (DefaultFactHandle) factory.newFactHandle( "cheese", false, null );
+//        assertEquals( 4,
+//                      handle.getId() );
+//        assertEquals( 6,
+//                      handle.getRecency() );
 
-        // issue new  handle  making  sure it correctly resumes  ids  and recency
-        handle = (DefaultFactHandle) factory.newFactHandle( "cheese", false, null );
-        assertEquals( 4,
-                      handle.getId() );
-        assertEquals( 6,
-                      handle.getRecency() );
-
     }
 
 }
\ No newline at end of file

Modified: labs/jbossrules/trunk/drools-core/src/test/java/org/drools/reteoo/ReteTest.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/test/java/org/drools/reteoo/ReteTest.java	2008-03-10 12:24:02 UTC (rev 18794)
+++ labs/jbossrules/trunk/drools-core/src/test/java/org/drools/reteoo/ReteTest.java	2008-03-10 12:24:25 UTC (rev 18795)
@@ -141,14 +141,13 @@
                                                        PropagationContext.ASSERTION,
                                                        null,
                                                        null ),
-                           workingMemory );
-
-        final Map map = workingMemory.getObjectTypeConfMap( EntryPoint.DEFAULT );
-        ClassObjectTypeConf conf = (ClassObjectTypeConf) map.get( ArrayList.class );
+                           workingMemory );               
+        
+        ClassObjectTypeConf conf = ( ClassObjectTypeConf ) workingMemory.getObjectTypeConfigurationRegistry().getObjectTypeConf( this.entryPoint.getEntryPoint(), ArrayList.class );
         assertLength( 3,
                       conf.getObjectTypeNodes() );
 
-        conf = (ClassObjectTypeConf) map.get( LinkedList.class );
+        conf = ( ClassObjectTypeConf ) workingMemory.getObjectTypeConfigurationRegistry().getObjectTypeConf( this.entryPoint.getEntryPoint(), LinkedList.class );
         assertLength( 3,
                       conf.getObjectTypeNodes() );
 
@@ -249,8 +248,7 @@
                     rete.getObjectTypeNodes( EntryPoint.DEFAULT ).get( new ClassObjectType( List.class ) ) );
 
         // ArrayConf should match two ObjectTypenodes for List and ArrayList
-        Map memory = workingMemory.getObjectTypeConfMap( EntryPoint.DEFAULT );
-        ObjectTypeConf arrayConf = (ObjectTypeConf) memory.get( ArrayList.class );
+        ClassObjectTypeConf arrayConf = ( ClassObjectTypeConf ) workingMemory.getObjectTypeConfigurationRegistry().getObjectTypeConf( this.entryPoint.getEntryPoint(), ArrayList.class );
         final ObjectTypeNode arrayOtn = arrayConf.getConcreteObjectTypeNode();
         assertEquals( 2,
                       arrayConf.getObjectTypeNodes().length );




More information about the jboss-svn-commits mailing list