[jboss-svn-commits] JBL Code SVN: r27931 - in labs/jbossrules/trunk: drools-api and 23 other directories.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Mon Jul 13 02:08:07 EDT 2009


Author: mark.proctor at jboss.com
Date: 2009-07-13 02:08:05 -0400 (Mon, 13 Jul 2009)
New Revision: 27931

Added:
   labs/jbossrules/trunk/drools-api/src/main/java/org/drools/command/Context.java
   labs/jbossrules/trunk/drools-api/src/main/java/org/drools/command/ContextManager.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/command/impl/ContextImpl.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/command/impl/GenericCommand.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/command/impl/KnowledgeCommandContext.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/command/AssertEquals.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/command/DisposeCommand.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/command/ExecuteCommand.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/runtime/impl/ExecutionResultImpl.java
   labs/jbossrules/trunk/drools-simulator/
   labs/jbossrules/trunk/drools-simulator/.classpath
   labs/jbossrules/trunk/drools-simulator/.project
   labs/jbossrules/trunk/drools-simulator/pom.xml
   labs/jbossrules/trunk/drools-simulator/src/
   labs/jbossrules/trunk/drools-simulator/src/main/
   labs/jbossrules/trunk/drools-simulator/src/main/java/
   labs/jbossrules/trunk/drools-simulator/src/main/java/org/
   labs/jbossrules/trunk/drools-simulator/src/main/java/org/drools/
   labs/jbossrules/trunk/drools-simulator/src/main/java/org/drools/simulation/
   labs/jbossrules/trunk/drools-simulator/src/main/java/org/drools/simulation/GetVariableCommand.java
   labs/jbossrules/trunk/drools-simulator/src/main/java/org/drools/simulation/KnowledgeBaseAddKnowledgePackagesCommand.java
   labs/jbossrules/trunk/drools-simulator/src/main/java/org/drools/simulation/KnowledgeBaseCommand.java
   labs/jbossrules/trunk/drools-simulator/src/main/java/org/drools/simulation/KnowledgeBuilderAddCommand.java
   labs/jbossrules/trunk/drools-simulator/src/main/java/org/drools/simulation/KnowledgeBuilderCommand.java
   labs/jbossrules/trunk/drools-simulator/src/main/java/org/drools/simulation/KnowledgeContextResolveFromContextCommand.java
   labs/jbossrules/trunk/drools-simulator/src/main/java/org/drools/simulation/NewKnowledgeBaseCommand.java
   labs/jbossrules/trunk/drools-simulator/src/main/java/org/drools/simulation/NewKnowledgeBuilderCommand.java
   labs/jbossrules/trunk/drools-simulator/src/main/java/org/drools/simulation/NewStatefulKnowledgeSessionCommand.java
   labs/jbossrules/trunk/drools-simulator/src/main/java/org/drools/simulation/Path.java
   labs/jbossrules/trunk/drools-simulator/src/main/java/org/drools/simulation/SetVariableCommand.java
   labs/jbossrules/trunk/drools-simulator/src/main/java/org/drools/simulation/Simulation.java
   labs/jbossrules/trunk/drools-simulator/src/main/java/org/drools/simulation/Step.java
   labs/jbossrules/trunk/drools-simulator/src/main/java/org/drools/simulation/impl/
   labs/jbossrules/trunk/drools-simulator/src/main/java/org/drools/simulation/impl/JUnitSimulationRunner.java
   labs/jbossrules/trunk/drools-simulator/src/main/java/org/drools/simulation/impl/PathImpl.java
   labs/jbossrules/trunk/drools-simulator/src/main/java/org/drools/simulation/impl/SimulationImpl.java
   labs/jbossrules/trunk/drools-simulator/src/main/java/org/drools/simulation/impl/SimulationTest.java
   labs/jbossrules/trunk/drools-simulator/src/main/java/org/drools/simulation/impl/Simulator.java
   labs/jbossrules/trunk/drools-simulator/src/main/java/org/drools/simulation/impl/StepImpl.java
   labs/jbossrules/trunk/drools-simulator/src/main/java/org/drools/simulation/impl/TestGroupCommand.java
   labs/jbossrules/trunk/drools-simulator/src/main/resources/
   labs/jbossrules/trunk/drools-simulator/src/test/
   labs/jbossrules/trunk/drools-simulator/src/test/java/
   labs/jbossrules/trunk/drools-simulator/src/test/resources/
Removed:
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/command/Command.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/runtime/impl/BatchExecutionResultImpl.java
Modified:
   labs/jbossrules/trunk/drools-api/.classpath
   labs/jbossrules/trunk/drools-api/.project
   labs/jbossrules/trunk/drools-api/pom.xml
   labs/jbossrules/trunk/drools-api/src/main/java/org/drools/command/Command.java
   labs/jbossrules/trunk/drools-compiler/.classpath
   labs/jbossrules/trunk/drools-compiler/.project
   labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/integrationtests/StatefulSessionTest.java
   labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/testframework/MockWorkingMemory.java
   labs/jbossrules/trunk/drools-core/.classpath
   labs/jbossrules/trunk/drools-core/.project
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/audit/WorkingMemoryLogger.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/command/impl/CommandFactoryProviderImpl.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/InternalWorkingMemory.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/impl/StatefulKnowledgeSessionImpl.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/impl/StatelessKnowledgeSessionImpl.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/command/AbortWorkItemCommand.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/command/AddEventListenerCommand.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/command/AgendaGroupSetFocusCommand.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/command/ClearActivationGroupCommand.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/command/ClearAgendaCommand.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/command/ClearAgendaGroupCommand.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/command/ClearRuleFlowGroupCommand.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/command/CommandService.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/command/CompleteWorkItemCommand.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/command/FireAllRulesCommand.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/command/FireUntilHaltCommand.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/command/GetAgendaEventListenersCommand.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/command/GetEnvironmentCommand.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/command/GetFactHandleCommand.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/command/GetFactHandlesCommand.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/command/GetGlobalCommand.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/command/GetGlobalsCommand.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/command/GetKnowledgeBaseCommand.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/command/GetObjectCommand.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/command/GetObjectsCommand.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/command/GetProcessEventListenersCommand.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/command/GetProcessInstanceCommand.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/command/GetProcessInstancesCommand.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/command/GetSessionClockCommand.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/command/GetWorkingMemoryEntryPointCommand.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/command/GetWorkingMemoryEntryPointsCommand.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/command/GetWorkingMemoryEventListenersCommand.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/command/HaltCommand.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/command/InsertElementsCommand.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/command/InsertObjectCommand.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/command/ModifyCommand.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/command/QueryCommand.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/command/RegisterExitPointCommand.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/command/RegisterWorkItemHandlerCommand.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/command/RemoveEventListenerCommand.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/command/RetractCommand.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/command/SetGlobalCommand.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/command/SetProcessInstanceStateCommand.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/command/SignalEventCommand.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/command/StartProcessCommand.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/command/UnregisterExitPointCommand.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/command/UpdateCommand.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/command/impl/AbstractInterceptor.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/command/impl/AsynchronousInterceptor.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/command/impl/CommandBasedStatefulKnowledgeSession.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/command/impl/DefaultCommandService.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/command/impl/LoggingInterceptor.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/runtime/help/impl/BatchExecutionHelperProviderImpl.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/runtime/impl/BatchExecutionImpl.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/xml/ExtensibleXmlParser.java
Log:
JBRULES-2126 Simulation and testing framwork

Modified: labs/jbossrules/trunk/drools-api/.classpath
===================================================================
--- labs/jbossrules/trunk/drools-api/.classpath	2009-07-13 05:17:35 UTC (rev 27930)
+++ labs/jbossrules/trunk/drools-api/.classpath	2009-07-13 06:08:05 UTC (rev 27931)
@@ -1,39 +1,39 @@
-<classpath>
-  <classpathentry kind="src" path="src/main/java"/>
-  <classpathentry kind="src" path="src/main/resources" excluding="**/*.java"/>
-  <classpathentry kind="src" path="src/test/java" output="target/test-classes"/>
-  <classpathentry kind="src" path="src/test/resources" output="target/test-classes" including="**" excluding="**/*.java"/>
-  <classpathentry kind="output" path="target/classes"/>
-  <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
-  <classpathentry kind="var" path="M2_REPO/javax/activation/activation/1.1/activation-1.1.jar"/>
-  <classpathentry kind="var" path="M2_REPO/cglib/cglib-nodep/2.1_3/cglib-nodep-2.1_3.jar"/>
-  <classpathentry kind="var" path="M2_REPO/commons-beanutils/commons-beanutils/1.7.0/commons-beanutils-1.7.0.jar"/>
-  <classpathentry kind="var" path="M2_REPO/commons-collections/commons-collections/3.1/commons-collections-3.1.jar"/>
-  <classpathentry kind="var" path="M2_REPO/commons-digester/commons-digester/1.8/commons-digester-1.8.jar"/>
-  <classpathentry kind="var" path="M2_REPO/commons-jexl/commons-jexl/1.1/commons-jexl-1.1.jar"/>
-  <classpathentry kind="var" path="M2_REPO/commons-lang/commons-lang/2.3/commons-lang-2.3.jar"/>
-  <classpathentry kind="var" path="M2_REPO/commons-logging/commons-logging/1.0.4/commons-logging-1.0.4.jar"/>
-  <classpathentry kind="var" path="M2_REPO/org/freemarker/freemarker/2.3.9/freemarker-2.3.9.jar"/>
-  <classpathentry kind="var" path="M2_REPO/org/hamcrest/hamcrest-core/1.1/hamcrest-core-1.1.jar"/>
-  <classpathentry kind="var" path="M2_REPO/org/hamcrest/hamcrest-library/1.1/hamcrest-library-1.1.jar"/>
-  <classpathentry kind="var" path="M2_REPO/javax/xml/bind/jaxb-api/2.1/jaxb-api-2.1.jar"/>
-  <classpathentry kind="var" path="M2_REPO/com/sun/xml/bind/jaxb-impl/2.1.9/jaxb-impl-2.1.9.jar"/>
-  <classpathentry kind="var" path="M2_REPO/com/sun/xml/bind/jaxb-xjc/2.1.9/jaxb-xjc-2.1.9.jar"/>
-  <classpathentry kind="var" path="M2_REPO/org/jmock/jmock/2.5.1/jmock-2.5.1.jar"/>
-  <classpathentry kind="var" path="M2_REPO/org/jmock/jmock-legacy/2.5.1/jmock-legacy-2.5.1.jar"/>
-  <classpathentry kind="var" path="M2_REPO/javax/jms/jms/1.1/jms-1.1.jar"/>
-  <classpathentry kind="var" path="M2_REPO/junit/junit/3.8.1/junit-3.8.1.jar"/>
-  <classpathentry kind="var" path="M2_REPO/net/sf/jxls/jxls-reader/0.9.6/jxls-reader-0.9.6.jar"/>
-  <classpathentry kind="var" path="M2_REPO/log4j/log4j/1.2.14/log4j-1.2.14.jar"/>
-  <classpathentry kind="var" path="M2_REPO/org/milyn/milyn-commons/1.1/milyn-commons-1.1.jar"/>
-  <classpathentry kind="var" path="M2_REPO/org/milyn/milyn-smooks-core/1.1/milyn-smooks-core-1.1.jar"/>
-  <classpathentry kind="var" path="M2_REPO/org/milyn/milyn-smooks-javabean/1.1/milyn-smooks-javabean-1.1.jar"/>
-  <classpathentry kind="var" path="M2_REPO/org/mvel/mvel/1.3.12-java1.5/mvel-1.3.12-java1.5.jar"/>
-  <classpathentry kind="var" path="M2_REPO/org/objenesis/objenesis/1.0/objenesis-1.0.jar"/>
-  <classpathentry kind="var" path="M2_REPO/org/apache/poi/poi/3.0.2-FINAL/poi-3.0.2-FINAL.jar"/>
-  <classpathentry kind="var" path="M2_REPO/javax/xml/stream/stax-api/1.0-2/stax-api-1.0-2.jar"/>
-  <classpathentry kind="var" path="M2_REPO/xerces/xercesImpl/2.9.1/xercesImpl-2.9.1.jar"/>
-  <classpathentry kind="var" path="M2_REPO/xml-apis/xml-apis/2.0.2/xml-apis-2.0.2.jar"/>
-  <classpathentry kind="var" path="M2_REPO/xpp3/xpp3_min/1.1.4c/xpp3_min-1.1.4c.jar"/>
-  <classpathentry kind="var" path="M2_REPO/com/thoughtworks/xstream/xstream/1.3.1/xstream-1.3.1.jar"/>
+<classpath>
+  <classpathentry kind="src" path="src/main/java"/>
+  <classpathentry kind="src" path="src/main/resources" excluding="**/*.java"/>
+  <classpathentry kind="src" path="src/test/java" output="target/test-classes"/>
+  <classpathentry kind="src" path="src/test/resources" output="target/test-classes" including="**" excluding="**/*.java"/>
+  <classpathentry kind="output" path="target/classes"/>
+  <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+  <classpathentry kind="var" path="M2_REPO/javax/activation/activation/1.1/activation-1.1.jar"/>
+  <classpathentry kind="var" path="M2_REPO/cglib/cglib-nodep/2.1_3/cglib-nodep-2.1_3.jar"/>
+  <classpathentry kind="var" path="M2_REPO/commons-beanutils/commons-beanutils/1.7.0/commons-beanutils-1.7.0.jar"/>
+  <classpathentry kind="var" path="M2_REPO/commons-collections/commons-collections/3.1/commons-collections-3.1.jar"/>
+  <classpathentry kind="var" path="M2_REPO/commons-digester/commons-digester/1.8/commons-digester-1.8.jar"/>
+  <classpathentry kind="var" path="M2_REPO/commons-jexl/commons-jexl/1.1/commons-jexl-1.1.jar"/>
+  <classpathentry kind="var" path="M2_REPO/commons-lang/commons-lang/2.3/commons-lang-2.3.jar"/>
+  <classpathentry kind="var" path="M2_REPO/commons-logging/commons-logging/1.0.4/commons-logging-1.0.4.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/freemarker/freemarker/2.3.9/freemarker-2.3.9.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/hamcrest/hamcrest-core/1.1/hamcrest-core-1.1.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/hamcrest/hamcrest-library/1.1/hamcrest-library-1.1.jar"/>
+  <classpathentry kind="var" path="M2_REPO/javax/xml/bind/jaxb-api/2.1/jaxb-api-2.1.jar"/>
+  <classpathentry kind="var" path="M2_REPO/com/sun/xml/bind/jaxb-impl/2.1.9/jaxb-impl-2.1.9.jar"/>
+  <classpathentry kind="var" path="M2_REPO/com/sun/xml/bind/jaxb-xjc/2.1.9/jaxb-xjc-2.1.9.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/jmock/jmock/2.5.1/jmock-2.5.1.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/jmock/jmock-legacy/2.5.1/jmock-legacy-2.5.1.jar"/>
+  <classpathentry kind="var" path="M2_REPO/javax/jms/jms/1.1/jms-1.1.jar"/>
+  <classpathentry kind="var" path="M2_REPO/junit/junit/4.6/junit-4.6.jar"/>
+  <classpathentry kind="var" path="M2_REPO/net/sf/jxls/jxls-reader/0.9.6/jxls-reader-0.9.6.jar"/>
+  <classpathentry kind="var" path="M2_REPO/log4j/log4j/1.2.14/log4j-1.2.14.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/milyn/milyn-commons/1.1/milyn-commons-1.1.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/milyn/milyn-smooks-core/1.1/milyn-smooks-core-1.1.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/milyn/milyn-smooks-javabean/1.1/milyn-smooks-javabean-1.1.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/mvel/mvel/1.3.12-java1.5/mvel-1.3.12-java1.5.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/objenesis/objenesis/1.0/objenesis-1.0.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/apache/poi/poi/3.0.2-FINAL/poi-3.0.2-FINAL.jar"/>
+  <classpathentry kind="var" path="M2_REPO/javax/xml/stream/stax-api/1.0-2/stax-api-1.0-2.jar"/>
+  <classpathentry kind="var" path="M2_REPO/xerces/xercesImpl/2.9.1/xercesImpl-2.9.1.jar"/>
+  <classpathentry kind="var" path="M2_REPO/xml-apis/xml-apis/2.0.2/xml-apis-2.0.2.jar"/>
+  <classpathentry kind="var" path="M2_REPO/xpp3/xpp3_min/1.1.4c/xpp3_min-1.1.4c.jar"/>
+  <classpathentry kind="var" path="M2_REPO/com/thoughtworks/xstream/xstream/1.3.1/xstream-1.3.1.jar" sourcepath="M2_REPO/com/thoughtworks/xstream/xstream/1.3.1/xstream-1.3.1-sources.jar"/>
 </classpath>
\ No newline at end of file

Modified: labs/jbossrules/trunk/drools-api/.project
===================================================================
--- labs/jbossrules/trunk/drools-api/.project	2009-07-13 05:17:35 UTC (rev 27930)
+++ labs/jbossrules/trunk/drools-api/.project	2009-07-13 06:08:05 UTC (rev 27931)
@@ -1,20 +1,20 @@
-<projectDescription>
-  <name>drools-api</name>
-  <comment>A rule production system</comment>
-  <projects/>
-  <buildSpec>
-    <buildCommand>
-      <name>org.eclipse.jdt.core.javabuilder</name>
-    </buildCommand>
-    <buildCommand>
-      <name>org.drools.eclipse.droolsbuilder</name>
-    </buildCommand>
-    <buildCommand>
-      <name>org.devzuz.q.maven.jdt.core.mavenIncrementalBuilder</name>
-    </buildCommand>
-  </buildSpec>
-  <natures>
-    <nature>org.eclipse.jdt.core.javanature</nature>
-    <nature>org.devzuz.q.maven.jdt.core.mavenNature</nature>
-  </natures>
+<projectDescription>
+  <name>drools-api</name>
+  <comment>A rule production system</comment>
+  <projects/>
+  <buildSpec>
+    <buildCommand>
+      <name>org.eclipse.jdt.core.javabuilder</name>
+    </buildCommand>
+    <buildCommand>
+      <name>org.drools.eclipse.droolsbuilder</name>
+    </buildCommand>
+    <buildCommand>
+      <name>org.devzuz.q.maven.jdt.core.mavenIncrementalBuilder</name>
+    </buildCommand>
+  </buildSpec>
+  <natures>
+    <nature>org.eclipse.jdt.core.javanature</nature>
+    <nature>org.devzuz.q.maven.jdt.core.mavenNature</nature>
+  </natures>
 </projectDescription>
\ No newline at end of file

Modified: labs/jbossrules/trunk/drools-api/pom.xml
===================================================================
--- labs/jbossrules/trunk/drools-api/pom.xml	2009-07-13 05:17:35 UTC (rev 27930)
+++ labs/jbossrules/trunk/drools-api/pom.xml	2009-07-13 06:08:05 UTC (rev 27931)
@@ -88,11 +88,11 @@
               
                 <configuration>
                     <aggregate>false</aggregate>
-                    <!--doclet>ydoc.doclets.YStandard</doclet>
+                    <doclet>ydoc.doclets.YStandard</doclet>
                     <docletPath>                        ${ydoc.home}/lib/ydoc.jar${path.separator}${ydoc.home}/lib/class2svg.jar${path.separator}${ydoc.home}/resources
                     </docletPath>
                     <additionalparam>-umlautogen -tag y.precondition -tag y.postcondition -tag y.complexity -tag param -tag return -tag see -tag y.uml
-                    </additionalparam-->                            
+                    </additionalparam>                            
                     <links>
                         <link>http://java.sun.com/j2se/1.5.0/docs/api</link>
                     </links>

Modified: labs/jbossrules/trunk/drools-api/src/main/java/org/drools/command/Command.java
===================================================================
--- labs/jbossrules/trunk/drools-api/src/main/java/org/drools/command/Command.java	2009-07-13 05:17:35 UTC (rev 27930)
+++ labs/jbossrules/trunk/drools-api/src/main/java/org/drools/command/Command.java	2009-07-13 06:08:05 UTC (rev 27931)
@@ -1,5 +1,7 @@
 package org.drools.command;
 
-public interface Command<T> {
+import java.io.Serializable;
 
+public interface Command<T> extends Serializable {
+
 }

Added: labs/jbossrules/trunk/drools-api/src/main/java/org/drools/command/Context.java
===================================================================
--- labs/jbossrules/trunk/drools-api/src/main/java/org/drools/command/Context.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-api/src/main/java/org/drools/command/Context.java	2009-07-13 06:08:05 UTC (rev 27931)
@@ -0,0 +1,13 @@
+package org.drools.command;
+
+public interface Context {
+    
+    ContextManager getContextManager();
+    
+    String getName();
+    
+    Object get(String identifier);
+
+    void set(String identifier,
+             Object value);    
+}

Added: labs/jbossrules/trunk/drools-api/src/main/java/org/drools/command/ContextManager.java
===================================================================
--- labs/jbossrules/trunk/drools-api/src/main/java/org/drools/command/ContextManager.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-api/src/main/java/org/drools/command/ContextManager.java	2009-07-13 06:08:05 UTC (rev 27931)
@@ -0,0 +1,6 @@
+package org.drools.command;
+
+
+public interface ContextManager {
+    public Context getContext(String identifier);
+}

Modified: labs/jbossrules/trunk/drools-compiler/.classpath
===================================================================
--- labs/jbossrules/trunk/drools-compiler/.classpath	2009-07-13 05:17:35 UTC (rev 27930)
+++ labs/jbossrules/trunk/drools-compiler/.classpath	2009-07-13 06:08:05 UTC (rev 27931)
@@ -1,31 +1,31 @@
-<classpath>
-  <classpathentry kind="src" path="src/main/java"/>
-  <classpathentry kind="src" path="src/main/resources" excluding="**/*.java"/>
-  <classpathentry kind="src" path="src/test/java" output="target/test-classes"/>
-  <classpathentry kind="src" path="src/test/resources" output="target/test-classes" including="**" excluding="**/*.java"/>
-  <classpathentry kind="output" path="target/classes"/>
-  <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
-  <classpathentry kind="var" path="M2_REPO/antlr/antlr/2.7.7/antlr-2.7.7.jar"/>
-  <classpathentry kind="var" path="M2_REPO/org/antlr/antlr/3.1.1/antlr-3.1.1.jar"/>
-  <classpathentry kind="var" path="M2_REPO/org/antlr/antlr-runtime/3.1.1/antlr-runtime-3.1.1.jar"/>
-  <classpathentry kind="var" path="M2_REPO/cglib/cglib-nodep/2.1_3/cglib-nodep-2.1_3.jar"/>
-  <classpathentry kind="var" path="M2_REPO/org/eclipse/jdt/core/3.4.2.v_883_R34x/core-3.4.2.v_883_R34x.jar"/>
-  <classpathentry kind="src" path="/drools-api"/>
-  <classpathentry kind="src" path="/drools-core"/>
-  <classpathentry kind="var" path="M2_REPO/org/hamcrest/hamcrest-core/1.1/hamcrest-core-1.1.jar"/>
-  <classpathentry kind="var" path="M2_REPO/org/hamcrest/hamcrest-library/1.1/hamcrest-library-1.1.jar"/>
-  <classpathentry kind="var" path="M2_REPO/janino/janino/2.5.15/janino-2.5.15.jar"/>
-  <classpathentry kind="var" path="M2_REPO/org/mortbay/jetty/jetty/6.1.15/jetty-6.1.15.jar"/>
-  <classpathentry kind="var" path="M2_REPO/org/mortbay/jetty/jetty-embedded/6.1.15/jetty-embedded-6.1.15.jar"/>
-  <classpathentry kind="var" path="M2_REPO/org/mortbay/jetty/jetty-util/6.1.15/jetty-util-6.1.15.jar"/>
-  <classpathentry kind="var" path="M2_REPO/org/jmock/jmock/2.5.1/jmock-2.5.1.jar"/>
-  <classpathentry kind="var" path="M2_REPO/org/jmock/jmock-legacy/2.5.1/jmock-legacy-2.5.1.jar"/>
-  <classpathentry kind="var" path="M2_REPO/joda-time/joda-time/1.6/joda-time-1.6.jar"/>
-  <classpathentry kind="var" path="M2_REPO/javax/servlet/jsp/jsp-api/2.1/jsp-api-2.1.jar"/>
-  <classpathentry kind="var" path="M2_REPO/junit/junit/3.8.1/junit-3.8.1.jar"/>
-  <classpathentry kind="var" path="M2_REPO/org/mvel/mvel2/2.0.10/mvel2-2.0.10.jar"/>
-  <classpathentry kind="var" path="M2_REPO/org/objenesis/objenesis/1.0/objenesis-1.0.jar"/>
-  <classpathentry kind="var" path="M2_REPO/org/mortbay/jetty/servlet-api/2.5-20081211/servlet-api-2.5-20081211.jar"/>
-  <classpathentry kind="var" path="M2_REPO/xpp3/xpp3_min/1.1.4c/xpp3_min-1.1.4c.jar"/>
-  <classpathentry kind="var" path="M2_REPO/com/thoughtworks/xstream/xstream/1.3.1/xstream-1.3.1.jar"/>
+<classpath>
+  <classpathentry kind="src" path="src/main/java"/>
+  <classpathentry kind="src" path="src/main/resources" excluding="**/*.java"/>
+  <classpathentry kind="src" path="src/test/java" output="target/test-classes"/>
+  <classpathentry kind="src" path="src/test/resources" output="target/test-classes" including="**" excluding="**/*.java"/>
+  <classpathentry kind="output" path="target/classes"/>
+  <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+  <classpathentry kind="var" path="M2_REPO/antlr/antlr/2.7.7/antlr-2.7.7.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/antlr/antlr/3.1.1/antlr-3.1.1.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/antlr/antlr-runtime/3.1.1/antlr-runtime-3.1.1.jar"/>
+  <classpathentry kind="var" path="M2_REPO/cglib/cglib-nodep/2.1_3/cglib-nodep-2.1_3.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/eclipse/jdt/core/3.4.2.v_883_R34x/core-3.4.2.v_883_R34x.jar"/>
+  <classpathentry kind="src" path="/drools-api"/>
+  <classpathentry kind="src" path="/drools-core"/>
+  <classpathentry kind="var" path="M2_REPO/org/hamcrest/hamcrest-core/1.1/hamcrest-core-1.1.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/hamcrest/hamcrest-library/1.1/hamcrest-library-1.1.jar"/>
+  <classpathentry kind="var" path="M2_REPO/janino/janino/2.5.15/janino-2.5.15.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/mortbay/jetty/jetty/6.1.15/jetty-6.1.15.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/mortbay/jetty/jetty-embedded/6.1.15/jetty-embedded-6.1.15.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/mortbay/jetty/jetty-util/6.1.15/jetty-util-6.1.15.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/jmock/jmock/2.5.1/jmock-2.5.1.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/jmock/jmock-legacy/2.5.1/jmock-legacy-2.5.1.jar"/>
+  <classpathentry kind="var" path="M2_REPO/joda-time/joda-time/1.6/joda-time-1.6.jar"/>
+  <classpathentry kind="var" path="M2_REPO/javax/servlet/jsp/jsp-api/2.1/jsp-api-2.1.jar"/>
+  <classpathentry kind="var" path="M2_REPO/junit/junit/4.6/junit-4.6.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/mvel/mvel2/2.0.12-SNAPSHOT/mvel2-2.0.12-SNAPSHOT.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/objenesis/objenesis/1.0/objenesis-1.0.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/mortbay/jetty/servlet-api/2.5-20081211/servlet-api-2.5-20081211.jar"/>
+  <classpathentry kind="var" path="M2_REPO/xpp3/xpp3_min/1.1.4c/xpp3_min-1.1.4c.jar"/>
+  <classpathentry kind="var" path="M2_REPO/com/thoughtworks/xstream/xstream/1.3.1/xstream-1.3.1.jar" sourcepath="M2_REPO/com/thoughtworks/xstream/xstream/1.3.1/xstream-1.3.1-sources.jar"/>
 </classpath>
\ No newline at end of file

Modified: labs/jbossrules/trunk/drools-compiler/.project
===================================================================
--- labs/jbossrules/trunk/drools-compiler/.project	2009-07-13 05:17:35 UTC (rev 27930)
+++ labs/jbossrules/trunk/drools-compiler/.project	2009-07-13 06:08:05 UTC (rev 27931)
@@ -1,16 +1,16 @@
-<projectDescription>
-  <name>drools-compiler</name>
-  <comment>A rule production system</comment>
-  <projects>
-    <project>drools-api</project>
-    <project>drools-core</project>
-  </projects>
-  <buildSpec>
-    <buildCommand>
-      <name>org.eclipse.jdt.core.javabuilder</name>
-    </buildCommand>
-  </buildSpec>
-  <natures>
-    <nature>org.eclipse.jdt.core.javanature</nature>
-  </natures>
+<projectDescription>
+  <name>drools-compiler</name>
+  <comment>A rule production system</comment>
+  <projects>
+    <project>drools-api</project>
+    <project>drools-core</project>
+  </projects>
+  <buildSpec>
+    <buildCommand>
+      <name>org.eclipse.jdt.core.javabuilder</name>
+    </buildCommand>
+  </buildSpec>
+  <natures>
+    <nature>org.eclipse.jdt.core.javanature</nature>
+  </natures>
 </projectDescription>
\ No newline at end of file

Modified: labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/integrationtests/StatefulSessionTest.java
===================================================================
--- labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/integrationtests/StatefulSessionTest.java	2009-07-13 05:17:35 UTC (rev 27930)
+++ labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/integrationtests/StatefulSessionTest.java	2009-07-13 06:08:05 UTC (rev 27931)
@@ -22,7 +22,7 @@
 import org.drools.runtime.ExecutionResults;
 import org.drools.runtime.StatefulKnowledgeSession;
 import org.drools.runtime.StatelessKnowledgeSession;
-import org.drools.runtime.impl.BatchExecutionResultImpl;
+import org.drools.runtime.impl.ExecutionResultImpl;
 
 import java.io.InputStreamReader;
 import java.util.ArrayList;

Modified: labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/testframework/MockWorkingMemory.java
===================================================================
--- labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/testframework/MockWorkingMemory.java	2009-07-13 05:17:35 UTC (rev 27930)
+++ labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/testframework/MockWorkingMemory.java	2009-07-13 06:08:05 UTC (rev 27931)
@@ -48,7 +48,7 @@
 import org.drools.runtime.ExitPoint;
 import org.drools.runtime.KnowledgeRuntime;
 import org.drools.runtime.ObjectFilter;
-import org.drools.runtime.impl.BatchExecutionResultImpl;
+import org.drools.runtime.impl.ExecutionResultImpl;
 import org.drools.spi.Activation;
 import org.drools.spi.AgendaFilter;
 import org.drools.spi.AsyncExceptionHandler;
@@ -532,7 +532,7 @@
         
     }
 
-    public BatchExecutionResultImpl getExecutionResult() {
+    public ExecutionResultImpl getExecutionResult() {
         // TODO Auto-generated method stub
         return null;
     }

Modified: labs/jbossrules/trunk/drools-core/.classpath
===================================================================
--- labs/jbossrules/trunk/drools-core/.classpath	2009-07-13 05:17:35 UTC (rev 27930)
+++ labs/jbossrules/trunk/drools-core/.classpath	2009-07-13 06:08:05 UTC (rev 27931)
@@ -1,20 +1,20 @@
-<classpath>
-  <classpathentry kind="src" path="src/main/java"/>
-  <classpathentry kind="src" path="src/main/resources" excluding="**/*.java"/>
-  <classpathentry kind="src" path="src/test/java" output="target/test-classes"/>
-  <classpathentry kind="src" path="src/test/resources" output="target/test-classes" including="**" excluding="**/*.java"/>
-  <classpathentry kind="output" path="target/classes"/>
-  <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
-  <classpathentry kind="var" path="M2_REPO/cglib/cglib-nodep/2.1_3/cglib-nodep-2.1_3.jar"/>
-  <classpathentry kind="src" path="/drools-api"/>
-  <classpathentry kind="var" path="M2_REPO/org/hamcrest/hamcrest-core/1.1/hamcrest-core-1.1.jar"/>
-  <classpathentry kind="var" path="M2_REPO/org/hamcrest/hamcrest-library/1.1/hamcrest-library-1.1.jar"/>
-  <classpathentry kind="var" path="M2_REPO/org/jmock/jmock/2.5.1/jmock-2.5.1.jar"/>
-  <classpathentry kind="var" path="M2_REPO/org/jmock/jmock-legacy/2.5.1/jmock-legacy-2.5.1.jar"/>
-  <classpathentry kind="var" path="M2_REPO/joda-time/joda-time/1.6/joda-time-1.6.jar"/>
-  <classpathentry kind="var" path="M2_REPO/junit/junit/3.8.1/junit-3.8.1.jar"/>
-  <classpathentry kind="var" path="M2_REPO/org/mvel/mvel2/2.0.10/mvel2-2.0.10.jar"/>
-  <classpathentry kind="var" path="M2_REPO/org/objenesis/objenesis/1.0/objenesis-1.0.jar"/>
-  <classpathentry kind="var" path="M2_REPO/xpp3/xpp3_min/1.1.4c/xpp3_min-1.1.4c.jar"/>
-  <classpathentry kind="var" path="M2_REPO/com/thoughtworks/xstream/xstream/1.3.1/xstream-1.3.1.jar"/>
+<classpath>
+  <classpathentry kind="src" path="src/main/java"/>
+  <classpathentry kind="src" path="src/main/resources" excluding="**/*.java"/>
+  <classpathentry kind="src" path="src/test/java" output="target/test-classes"/>
+  <classpathentry kind="src" path="src/test/resources" output="target/test-classes" including="**" excluding="**/*.java"/>
+  <classpathentry kind="output" path="target/classes"/>
+  <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+  <classpathentry kind="var" path="M2_REPO/cglib/cglib-nodep/2.1_3/cglib-nodep-2.1_3.jar"/>
+  <classpathentry kind="src" path="/drools-api"/>
+  <classpathentry kind="var" path="M2_REPO/org/hamcrest/hamcrest-core/1.1/hamcrest-core-1.1.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/hamcrest/hamcrest-library/1.1/hamcrest-library-1.1.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/jmock/jmock/2.5.1/jmock-2.5.1.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/jmock/jmock-legacy/2.5.1/jmock-legacy-2.5.1.jar"/>
+  <classpathentry kind="var" path="M2_REPO/joda-time/joda-time/1.6/joda-time-1.6.jar"/>
+  <classpathentry kind="var" path="M2_REPO/junit/junit/4.6/junit-4.6.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/mvel/mvel2/2.0.12-SNAPSHOT/mvel2-2.0.12-SNAPSHOT.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/objenesis/objenesis/1.0/objenesis-1.0.jar"/>
+  <classpathentry kind="var" path="M2_REPO/xpp3/xpp3_min/1.1.4c/xpp3_min-1.1.4c.jar"/>
+  <classpathentry kind="var" path="M2_REPO/com/thoughtworks/xstream/xstream/1.3.1/xstream-1.3.1.jar" sourcepath="M2_REPO/com/thoughtworks/xstream/xstream/1.3.1/xstream-1.3.1-sources.jar"/>
 </classpath>
\ No newline at end of file

Modified: labs/jbossrules/trunk/drools-core/.project
===================================================================
--- labs/jbossrules/trunk/drools-core/.project	2009-07-13 05:17:35 UTC (rev 27930)
+++ labs/jbossrules/trunk/drools-core/.project	2009-07-13 06:08:05 UTC (rev 27931)
@@ -1,22 +1,22 @@
-<projectDescription>
-  <name>drools-core</name>
-  <comment>A rule production system</comment>
-  <projects>
-    <project>drools-api</project>
-  </projects>
-  <buildSpec>
-    <buildCommand>
-      <name>org.eclipse.jdt.core.javabuilder</name>
-    </buildCommand>
-    <buildCommand>
-      <name>org.drools.eclipse.droolsbuilder</name>
-    </buildCommand>
-    <buildCommand>
-      <name>org.devzuz.q.maven.jdt.core.mavenIncrementalBuilder</name>
-    </buildCommand>
-  </buildSpec>
-  <natures>
-    <nature>org.eclipse.jdt.core.javanature</nature>
-    <nature>org.devzuz.q.maven.jdt.core.mavenNature</nature>
-  </natures>
+<projectDescription>
+  <name>drools-core</name>
+  <comment>A rule production system</comment>
+  <projects>
+    <project>drools-api</project>
+  </projects>
+  <buildSpec>
+    <buildCommand>
+      <name>org.eclipse.jdt.core.javabuilder</name>
+    </buildCommand>
+    <buildCommand>
+      <name>org.drools.eclipse.droolsbuilder</name>
+    </buildCommand>
+    <buildCommand>
+      <name>org.devzuz.q.maven.jdt.core.mavenIncrementalBuilder</name>
+    </buildCommand>
+  </buildSpec>
+  <natures>
+    <nature>org.eclipse.jdt.core.javanature</nature>
+    <nature>org.devzuz.q.maven.jdt.core.mavenNature</nature>
+  </natures>
 </projectDescription>
\ No newline at end of file

Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/audit/WorkingMemoryLogger.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/audit/WorkingMemoryLogger.java	2009-07-13 05:17:35 UTC (rev 27930)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/audit/WorkingMemoryLogger.java	2009-07-13 06:08:05 UTC (rev 27931)
@@ -35,6 +35,7 @@
 import org.drools.audit.event.RuleFlowGroupLogEvent;
 import org.drools.audit.event.RuleFlowLogEvent;
 import org.drools.audit.event.RuleFlowNodeLogEvent;
+import org.drools.command.impl.KnowledgeCommandContext;
 import org.drools.common.InternalFactHandle;
 import org.drools.common.InternalWorkingMemory;
 import org.drools.definition.process.Node;
@@ -135,7 +136,7 @@
     		((StatelessKnowledgeSessionImpl) session).getRuleBase().addEventListener( this );
     	} else if (session instanceof CommandBasedStatefulKnowledgeSession) {
     		WorkingMemoryEventManager eventManager = 
-    			((CommandBasedStatefulKnowledgeSession) session).getCommandService().getSession();
+    			((StatefulKnowledgeSessionImpl)((KnowledgeCommandContext)((CommandBasedStatefulKnowledgeSession) session).getCommandService().getContext()).getStatefulKnowledgesession()).session;
     		eventManager.addEventListener( (WorkingMemoryEventListener) this );
     		eventManager.addEventListener( (AgendaEventListener) this );
     		eventManager.addEventListener( (RuleFlowEventListener) this );

Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/command/impl/CommandFactoryProviderImpl.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/command/impl/CommandFactoryProviderImpl.java	2009-07-13 05:17:35 UTC (rev 27930)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/command/impl/CommandFactoryProviderImpl.java	2009-07-13 06:08:05 UTC (rev 27931)
@@ -146,6 +146,6 @@
 
 	public Command newBatchExecution(List<? extends Command> commands) {
 		return new BatchExecutionImpl(
-				(List<org.drools.process.command.Command>) commands);
+				(List<GenericCommand>) commands);
 	}
 }

Added: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/command/impl/ContextImpl.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/command/impl/ContextImpl.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/command/impl/ContextImpl.java	2009-07-13 06:08:05 UTC (rev 27931)
@@ -0,0 +1,67 @@
+package org.drools.command.impl;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.drools.command.Context;
+import org.drools.command.ContextManager;
+
+public class ContextImpl
+    implements
+    Context {
+    
+    private ContextManager      manager;
+    
+    private String              name;
+    
+    private Map<String, Object> context = new HashMap<String, Object>();
+
+    private Context             delegate;
+       
+    private int depth;
+    
+    public ContextImpl(String name, ContextManager manager) {
+        this.name = name;
+        this.manager = manager;
+        this.depth = 0;
+    }
+    
+    public ContextImpl(String name, ContextManager manager, Context delegate) {
+        this.name = name;
+        this.manager = manager;
+        setDelegate( delegate );
+        this.depth = ((ContextImpl)delegate).getDepth() + 1;
+    }
+
+    public void setDelegate(Context delegate) {
+        this.delegate = delegate;
+    }
+    
+
+    public ContextManager getContextManager() {
+        return this.manager;
+    }
+
+    public String getName() {
+        return this.name;
+    }    
+
+    public Object get(String identifier) {
+        Object object = context.get( identifier );
+        if ( object == null && delegate != null ) {
+            object = this.delegate.get( identifier );
+        }
+        return object;
+    }
+
+    public void set(String name,
+                    Object object) {
+        context.put( name,
+                     object );
+    }
+    
+    public int getDepth() {
+        return this.depth;
+    }
+
+}

Added: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/command/impl/GenericCommand.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/command/impl/GenericCommand.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/command/impl/GenericCommand.java	2009-07-13 06:08:05 UTC (rev 27931)
@@ -0,0 +1,11 @@
+package org.drools.command.impl;
+
+import org.drools.builder.KnowledgeBuilder;
+import org.drools.command.Context;
+import org.drools.reteoo.ReteooWorkingMemory;
+
+public interface GenericCommand<T> extends org.drools.command.Command {
+	
+	T execute(Context context);
+	
+}

Added: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/command/impl/KnowledgeCommandContext.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/command/impl/KnowledgeCommandContext.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/command/impl/KnowledgeCommandContext.java	2009-07-13 06:08:05 UTC (rev 27931)
@@ -0,0 +1,57 @@
+package org.drools.command.impl;
+
+import org.drools.KnowledgeBase;
+import org.drools.builder.KnowledgeBuilder;
+import org.drools.command.Context;
+import org.drools.command.ContextManager;
+import org.drools.runtime.StatefulKnowledgeSession;
+
+public class KnowledgeCommandContext
+    implements
+    Context {
+    private Context                  context;
+    private KnowledgeBuilder         kbuilder;
+    private KnowledgeBase            kbase;
+    private StatefulKnowledgeSession statefulKsession;
+
+    public KnowledgeCommandContext(Context context,
+                                   KnowledgeBuilder kbuilder,
+                                   KnowledgeBase kbase,
+                                   StatefulKnowledgeSession statefulKsession) {
+        this.context = context;
+        this.kbuilder = kbuilder;
+        this.kbase = kbase;
+        this.statefulKsession = statefulKsession;
+    }
+
+    public KnowledgeBuilder getKnowledgeBuilder() {
+        return kbuilder;
+    }
+
+    public KnowledgeBase getKnowledgeBase() {
+        return this.kbase;
+    }       
+
+    public StatefulKnowledgeSession getStatefulKnowledgesession() {
+        return statefulKsession;
+    }
+
+    public ContextManager getContextManager() {
+        return context.getContextManager();
+    }
+
+    public String getName() {
+        return context.getName();
+    }
+
+    public Object get(String identifier) {
+        return context.get( identifier );
+    }
+
+    public void set(String identifier,
+                    Object value) {
+        context.set( identifier,
+                     value );
+    }
+
+}

Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/AbstractWorkingMemory.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/AbstractWorkingMemory.java	2009-07-13 05:17:35 UTC (rev 27930)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/AbstractWorkingMemory.java	2009-07-13 06:08:05 UTC (rev 27931)
@@ -87,7 +87,7 @@
 import org.drools.runtime.ExitPoint;
 import org.drools.runtime.Globals;
 import org.drools.runtime.KnowledgeRuntime;
-import org.drools.runtime.impl.BatchExecutionResultImpl;
+import org.drools.runtime.impl.ExecutionResultImpl;
 import org.drools.runtime.process.EventListener;
 import org.drools.runtime.process.WorkItemHandler;
 import org.drools.spi.Activation;
@@ -1918,11 +1918,11 @@
     public void startBatchExecution() {
         this.ruleBase.readLock();
         this.lock.lock();
-        this.batchExecutionResult = new BatchExecutionResultImpl();
+        this.batchExecutionResult = new ExecutionResultImpl();
     }
 
-    public BatchExecutionResultImpl getExecutionResult() {
-        return (BatchExecutionResultImpl) this.batchExecutionResult;
+    public ExecutionResultImpl getExecutionResult() {
+        return (ExecutionResultImpl) this.batchExecutionResult;
     }
 
     public void endBatchExecution() {

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	2009-07-13 05:17:35 UTC (rev 27930)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/InternalWorkingMemory.java	2009-07-13 06:08:05 UTC (rev 27931)
@@ -21,7 +21,7 @@
 import org.drools.runtime.ExecutionResults;
 import org.drools.runtime.ExitPoint;
 import org.drools.runtime.KnowledgeRuntime;
-import org.drools.runtime.impl.BatchExecutionResultImpl;
+import org.drools.runtime.impl.ExecutionResultImpl;
 import org.drools.runtime.rule.WorkingMemoryEntryPoint;
 import org.drools.spi.Activation;
 import org.drools.spi.FactHandleFactory;
@@ -136,7 +136,7 @@
     
     public void startBatchExecution();
     
-    public BatchExecutionResultImpl getExecutionResult();
+    public ExecutionResultImpl getExecutionResult();
     
     public void endBatchExecution();
     

Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/impl/StatefulKnowledgeSessionImpl.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/impl/StatefulKnowledgeSessionImpl.java	2009-07-13 05:17:35 UTC (rev 27930)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/impl/StatefulKnowledgeSessionImpl.java	2009-07-13 06:08:05 UTC (rev 27931)
@@ -13,6 +13,9 @@
 import org.drools.RuleBase;
 import org.drools.WorkingMemory;
 import org.drools.command.Command;
+import org.drools.command.impl.ContextImpl;
+import org.drools.command.impl.GenericCommand;
+import org.drools.command.impl.KnowledgeCommandContext;
 import org.drools.common.AbstractWorkingMemory;
 import org.drools.common.InternalAgenda;
 import org.drools.common.InternalFactHandle;
@@ -688,10 +691,12 @@
         return new NativeQueryResults( this.session.getQueryResults( query, arguments ) );
     }
     
+    private KnowledgeCommandContext commandContext = new KnowledgeCommandContext( new ContextImpl("ksession", null), null, this.kbase, this);
+    
     public ExecutionResults execute(Command command) {        
         try {
             session.startBatchExecution();
-            ((org.drools.process.command.Command)command).execute( session );
+            ((GenericCommand)command).execute( commandContext );
             ExecutionResults result = session.getExecutionResult();
             return result;
         } finally {

Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/impl/StatelessKnowledgeSessionImpl.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/impl/StatelessKnowledgeSessionImpl.java	2009-07-13 05:17:35 UTC (rev 27930)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/impl/StatelessKnowledgeSessionImpl.java	2009-07-13 06:08:05 UTC (rev 27931)
@@ -13,6 +13,9 @@
 import org.drools.agent.KnowledgeAgent;
 import org.drools.base.MapGlobalResolver;
 import org.drools.command.Command;
+import org.drools.command.impl.ContextImpl;
+import org.drools.command.impl.GenericCommand;
+import org.drools.command.impl.KnowledgeCommandContext;
 import org.drools.common.InternalRuleBase;
 import org.drools.common.InternalWorkingMemory;
 import org.drools.event.AgendaEventSupport;
@@ -34,17 +37,18 @@
 import org.drools.runtime.Environment;
 import org.drools.runtime.Globals;
 import org.drools.runtime.KnowledgeSessionConfiguration;
+import org.drools.runtime.StatefulKnowledgeSession;
 import org.drools.runtime.StatelessKnowledgeSession;
 import org.drools.runtime.StatelessKnowledgeSessionResults;
 import org.drools.runtime.impl.BatchExecutionImpl;
-import org.drools.spi.AgendaFilter;
+import org.drools.runtime.rule.AgendaFilter;
 
 public class StatelessKnowledgeSessionImpl
     implements
     StatelessKnowledgeSession {
 
     private InternalRuleBase                                                  ruleBase;
-    private KnowledgeAgent                                                     kagent;
+    private KnowledgeAgent                                                    kagent;
     private AgendaFilter                                                      agendaFilter;
     private MapGlobalResolver                                                 sessionGlobals            = new MapGlobalResolver();
 
@@ -71,37 +75,41 @@
         this.kagent = kagent;
         this.conf = (conf != null) ? conf : new SessionConfiguration();
         this.environment = EnvironmentFactory.newEnvironment();
-        
+
         if ( this.ruleBase != null ) {
             synchronized ( this.ruleBase.getPackagesMap() ) {
                 if ( ruleBase.getConfiguration().isSequential() ) {
                     this.ruleBase.getReteooBuilder().order();
                 }
-            }    
+            }
         }
     }
 
     public InternalRuleBase getRuleBase() {
         if ( this.kagent != null ) {
             // if we have an agent always get the rulebase from there
-            this.ruleBase = ( InternalRuleBase ) ((KnowledgeBaseImpl)this.kagent.getKnowledgeBase()).ruleBase;
-        }       
+            this.ruleBase = (InternalRuleBase) ((KnowledgeBaseImpl) this.kagent.getKnowledgeBase()).ruleBase;
+        }
         return this.ruleBase;
     }
 
-    public InternalWorkingMemory newWorkingMemory() {
+    public StatefulKnowledgeSession newWorkingMemory() {
         if ( this.kagent != null ) {
             // if we have an agent always get the rulebase from there
-            this.ruleBase = ( InternalRuleBase ) ((KnowledgeBaseImpl)this.kagent.getKnowledgeBase()).ruleBase;
+            this.ruleBase = (InternalRuleBase) ((KnowledgeBaseImpl) this.kagent.getKnowledgeBase()).ruleBase;
         }
         synchronized ( this.ruleBase.getPackagesMap() ) {
             ReteooWorkingMemory wm = new ReteooWorkingMemory( this.ruleBase.nextWorkingMemoryCounter(),
-                                                                this.ruleBase,
-                                                                (SessionConfiguration) this.conf,
-                                                                this.environment );
+                                                              this.ruleBase,
+                                                              (SessionConfiguration) this.conf,
+                                                              this.environment );
 
-            StatefulKnowledgeSessionImpl ksession = new StatefulKnowledgeSessionImpl( wm, new KnowledgeBaseImpl( this.ruleBase ), mappedWorkingMemoryListeners, mappedAgendaListeners, mappedProcessListeners ); 
-            
+            StatefulKnowledgeSessionImpl ksession = new StatefulKnowledgeSessionImpl( wm,
+                                                                                      new KnowledgeBaseImpl( this.ruleBase ),
+                                                                                      mappedWorkingMemoryListeners,
+                                                                                      mappedAgendaListeners,
+                                                                                      mappedProcessListeners );
+
             ((Globals) wm.getGlobalResolver()).setDelegate( this.sessionGlobals );
             wm.setKnowledgeRuntime( ksession );
             wm.setWorkingMemoryEventSupport( this.workingMemoryEventSupport );
@@ -119,7 +127,7 @@
                                                                             true,
                                                                             null,
                                                                             null ) );
-            return wm;
+            return ksession;
         }
     }
 
@@ -127,19 +135,18 @@
         if ( this.mappedWorkingMemoryListeners == null ) {
             this.mappedWorkingMemoryListeners = new IdentityHashMap<WorkingMemoryEventListener, WorkingMemoryEventListenerWrapper>();
         }
-        
+
         WorkingMemoryEventListenerWrapper wrapper = new WorkingMemoryEventListenerWrapper( listener );
         this.mappedWorkingMemoryListeners.put( listener,
                                                wrapper );
         this.workingMemoryEventSupport.addEventListener( wrapper );
     }
 
-    
     public void removeEventListener(WorkingMemoryEventListener listener) {
         if ( this.mappedWorkingMemoryListeners == null ) {
             this.mappedWorkingMemoryListeners = new IdentityHashMap<WorkingMemoryEventListener, WorkingMemoryEventListenerWrapper>();
         }
-        
+
         WorkingMemoryEventListenerWrapper wrapper = this.mappedWorkingMemoryListeners.remove( listener );
         this.workingMemoryEventSupport.removeEventListener( wrapper );
     }
@@ -148,7 +155,7 @@
         if ( this.mappedWorkingMemoryListeners == null ) {
             this.mappedWorkingMemoryListeners = new IdentityHashMap<WorkingMemoryEventListener, WorkingMemoryEventListenerWrapper>();
         }
-        
+
         return Collections.unmodifiableCollection( this.mappedWorkingMemoryListeners.keySet() );
     }
 
@@ -156,7 +163,7 @@
         if ( this.mappedAgendaListeners == null ) {
             this.mappedAgendaListeners = new IdentityHashMap<AgendaEventListener, AgendaEventListenerWrapper>();
         }
-        
+
         AgendaEventListenerWrapper wrapper = new AgendaEventListenerWrapper( listener );
         this.mappedAgendaListeners.put( listener,
                                         wrapper );
@@ -167,7 +174,7 @@
         if ( this.mappedAgendaListeners == null ) {
             this.mappedAgendaListeners = new IdentityHashMap<AgendaEventListener, AgendaEventListenerWrapper>();
         }
-        
+
         return Collections.unmodifiableCollection( this.mappedAgendaListeners.keySet() );
     }
 
@@ -175,7 +182,7 @@
         if ( this.mappedAgendaListeners == null ) {
             this.mappedAgendaListeners = new IdentityHashMap<AgendaEventListener, AgendaEventListenerWrapper>();
         }
-        
+
         AgendaEventListenerWrapper wrapper = this.mappedAgendaListeners.remove( listener );
         this.agendaEventSupport.removeEventListener( wrapper );
     }
@@ -184,7 +191,7 @@
         if ( this.mappedProcessListeners == null ) {
             this.mappedProcessListeners = new IdentityHashMap<ProcessEventListener, ProcessEventListenerWrapper>();
         }
-        
+
         ProcessEventListenerWrapper wrapper = new ProcessEventListenerWrapper( listener );
         this.mappedProcessListeners.put( listener,
                                          wrapper );
@@ -195,7 +202,7 @@
         if ( this.mappedProcessListeners == null ) {
             this.mappedProcessListeners = new IdentityHashMap<ProcessEventListener, ProcessEventListenerWrapper>();
         }
-        
+
         return Collections.unmodifiableCollection( this.mappedProcessListeners.keySet() );
     }
 
@@ -203,7 +210,7 @@
         if ( this.mappedProcessListeners == null ) {
             this.mappedProcessListeners = new IdentityHashMap<ProcessEventListener, ProcessEventListenerWrapper>();
         }
-        
+
         ProcessEventListenerWrapper wrapper = this.mappedProcessListeners.get( listener );
         this.ruleFlowEventSupport.removeEventListener( wrapper );
     }
@@ -213,53 +220,60 @@
         this.sessionGlobals.setGlobal( identifier,
                                        value );
     }
-    
+
     public Globals getGlobals() {
         return this.sessionGlobals;
-    }
+    }    
 
-    public ExecutionResults execute(Command command) {        
-        ReteooWorkingMemory session = ( ReteooWorkingMemory ) newWorkingMemory();
+    public ExecutionResults execute(Command command) {
+        StatefulKnowledgeSession ksession = newWorkingMemory();
+
+        KnowledgeCommandContext context = new KnowledgeCommandContext( new ContextImpl( "ksession",
+                                                                                        null ),
+                                                                       null,
+                                                                       null,
+                                                                       ksession );
+
         try {
-            session.startBatchExecution();
-            ((org.drools.process.command.Command)command).execute( session );
+            ((StatefulKnowledgeSessionImpl) ksession).session.startBatchExecution();
+
+            ((GenericCommand) command).execute( context );
             // did the user take control of fireAllRules, if not we will auto execute
             boolean autoFireAllRules = true;
             if ( command instanceof FireAllRulesCommand ) {
-            	autoFireAllRules = false;
+                autoFireAllRules = false;
             } else if ( command instanceof BatchExecutionImpl ) {
-            	for ( Command nestedCmd : ((BatchExecutionImpl)command).getCommands() ) {
-            		if ( nestedCmd instanceof FireAllRulesCommand ) {
-            			autoFireAllRules = false;
-            			break;
+                for ( Command nestedCmd : ((BatchExecutionImpl) command).getCommands() ) {
+                    if ( nestedCmd instanceof FireAllRulesCommand ) {
+                        autoFireAllRules = false;
+                        break;
                     }
-            	}
+                }
             }
             if ( autoFireAllRules ) {
-            	session.fireAllRules( this.agendaFilter );
+                ksession.fireAllRules( );
             }
-            ExecutionResults result = session.getExecutionResult();
+            ExecutionResults result = ((StatefulKnowledgeSessionImpl) ksession).session.getExecutionResult();
             return result;
         } finally {
-            session.endBatchExecution();
+            ((StatefulKnowledgeSessionImpl) ksession).session.endBatchExecution();
         }
     }
 
     public void execute(Object object) {
-        InternalWorkingMemory wm = newWorkingMemory();
+        StatefulKnowledgeSession ksession = newWorkingMemory();
 
-        wm.insert( object );
-        wm.fireAllRules( this.agendaFilter );
+        ksession.insert( object );
+        ksession.fireAllRules( );
     }
 
     public void execute(Iterable objects) {
-        InternalWorkingMemory wm = newWorkingMemory();
+        StatefulKnowledgeSession ksession = newWorkingMemory();
 
         for ( Object object : objects ) {
-            wm.insert( object );
+            ksession.insert( object );
         }
-        wm.fireAllRules( this.agendaFilter );
+        ksession.fireAllRules( );
     }
 
-
 }

Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/command/AbortWorkItemCommand.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/command/AbortWorkItemCommand.java	2009-07-13 05:17:35 UTC (rev 27930)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/command/AbortWorkItemCommand.java	2009-07-13 06:08:05 UTC (rev 27931)
@@ -1,10 +1,14 @@
 package org.drools.process.command;
 
+import org.drools.command.Context;
+import org.drools.command.impl.GenericCommand;
+import org.drools.command.impl.KnowledgeCommandContext;
 import org.drools.reteoo.ReteooWorkingMemory;
+import org.drools.runtime.StatefulKnowledgeSession;
 
 public class AbortWorkItemCommand
     implements
-    Command<Object> {
+    GenericCommand<Object> {
 
     private long workItemId;
     
@@ -24,8 +28,9 @@
         this.workItemId = workItemId;
     }
 
-    public Object execute(ReteooWorkingMemory session) {
-        session.getWorkItemManager().abortWorkItem( workItemId );
+    public Void execute(Context context) {
+        StatefulKnowledgeSession ksession = ((KnowledgeCommandContext) context).getStatefulKnowledgesession();
+        ksession.getWorkItemManager().abortWorkItem( workItemId );
         return null;
     }
 

Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/command/AddEventListenerCommand.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/command/AddEventListenerCommand.java	2009-07-13 05:17:35 UTC (rev 27930)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/command/AddEventListenerCommand.java	2009-07-13 06:08:05 UTC (rev 27931)
@@ -1,17 +1,23 @@
 package org.drools.process.command;
 
-import org.drools.event.AgendaEventListener;
-import org.drools.event.RuleFlowEventListener;
-import org.drools.event.WorkingMemoryEventListener;
+import org.drools.command.Context;
+import org.drools.command.impl.GenericCommand;
+import org.drools.command.impl.KnowledgeCommandContext;
+import org.drools.event.process.ProcessEventListener;
+import org.drools.event.rule.AgendaEventListener;
+import org.drools.event.rule.WorkingMemoryEventListener;
+import org.drools.impl.StatefulKnowledgeSessionImpl;
+import org.drools.reteoo.ReteooStatefulSession;
 import org.drools.reteoo.ReteooWorkingMemory;
+import org.drools.runtime.StatefulKnowledgeSession;
 
 public class AddEventListenerCommand
     implements
-    Command<Object> {
+    GenericCommand<Object> {
 
     private WorkingMemoryEventListener workingMemoryEventlistener = null;
     private AgendaEventListener        agendaEventlistener        = null;
-    private RuleFlowEventListener      ruleFlowEventlistener      = null;
+    private ProcessEventListener       processEventListener       = null;
 
     public AddEventListenerCommand(WorkingMemoryEventListener listener) {
         this.workingMemoryEventlistener = listener;
@@ -20,18 +26,21 @@
     public AddEventListenerCommand(AgendaEventListener listener) {
         this.agendaEventlistener = listener;
     }
+    
+    public AddEventListenerCommand(ProcessEventListener listener) {
+        this.processEventListener = listener;
+    }    
 
-    public AddEventListenerCommand(RuleFlowEventListener listener) {
-        this.ruleFlowEventlistener = listener;
-    }
 
-    public Object execute(ReteooWorkingMemory session) {
+    public Void execute(Context context) {
+        StatefulKnowledgeSession ksession = ((KnowledgeCommandContext) context).getStatefulKnowledgesession();
+        
         if ( workingMemoryEventlistener != null ) {
-            session.addEventListener( workingMemoryEventlistener );
+            ksession.addEventListener( workingMemoryEventlistener );
         } else if ( agendaEventlistener != null ) {
-            session.addEventListener( agendaEventlistener );
+            ksession.addEventListener( agendaEventlistener );
         } else {
-            session.addEventListener( ruleFlowEventlistener );
+            ksession.addEventListener( processEventListener );
         }
         return null;
     }
@@ -41,8 +50,10 @@
             return "session.addEventListener( " + workingMemoryEventlistener + " );";
         } else if ( agendaEventlistener != null ) {
             return "session.addEventListener( " + agendaEventlistener + " );";
-        } else {
-            return "session.addEventListener( " + ruleFlowEventlistener + " );";
-        }
+        }  else  if ( processEventListener != null ) {
+            return "session.addEventListener( " + processEventListener + " );";
+        } 
+        
+        return "AddEventListenerCommand";
     }
 }

Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/command/AgendaGroupSetFocusCommand.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/command/AgendaGroupSetFocusCommand.java	2009-07-13 05:17:35 UTC (rev 27930)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/command/AgendaGroupSetFocusCommand.java	2009-07-13 06:08:05 UTC (rev 27931)
@@ -1,10 +1,14 @@
 package org.drools.process.command;
 
+import org.drools.command.Context;
+import org.drools.command.impl.GenericCommand;
+import org.drools.command.impl.KnowledgeCommandContext;
 import org.drools.common.InternalAgenda;
 import org.drools.reteoo.ReteooWorkingMemory;
+import org.drools.runtime.StatefulKnowledgeSession;
 import org.drools.runtime.rule.impl.AgendaImpl;
 
-public class AgendaGroupSetFocusCommand implements Command<Object> {
+public class AgendaGroupSetFocusCommand implements GenericCommand<Object> {
 
 	private String name;
 	
@@ -16,8 +20,9 @@
 		this.name = name;
 	}
 
-	public Object execute(ReteooWorkingMemory session) {
-		new AgendaImpl((InternalAgenda) session.getAgenda()).getAgendaGroup(name).setFocus();
+    public Void execute(Context context) {
+        StatefulKnowledgeSession ksession = ((KnowledgeCommandContext) context).getStatefulKnowledgesession();
+        ksession.getAgenda().getAgendaGroup( this.name ).setFocus();
 		return null;
 	}
 

Added: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/command/AssertEquals.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/command/AssertEquals.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/command/AssertEquals.java	2009-07-13 06:08:05 UTC (rev 27931)
@@ -0,0 +1,79 @@
+package org.drools.process.command;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import junit.framework.Assert;
+import junit.framework.TestCase;
+
+import org.drools.command.Command;
+import org.drools.command.Context;
+import org.drools.command.impl.GenericCommand;
+import org.drools.command.impl.KnowledgeCommandContext;
+import org.drools.impl.StatefulKnowledgeSessionImpl;
+import org.drools.reteoo.ReteooWorkingMemory;
+import org.drools.runtime.StatefulKnowledgeSession;
+import org.drools.runtime.rule.AgendaFilter;
+import org.mvel2.MVEL;
+
+public class AssertEquals
+    implements
+    GenericCommand<Void> {
+
+    private String  message;
+    private Object  expectedObject;
+    private String  expectedIdentifier;
+
+    private Command command;
+    private String  mvelString;
+
+    public AssertEquals(String message,
+                        Object expectedObject,
+                        Command command,
+                        String mvelString) {
+        this.message = message;
+        this.expectedObject = expectedObject;
+        this.command = command;
+        this.mvelString = mvelString;
+    }
+
+    public AssertEquals(String message,
+                        String expectedIdentifier,
+                        Command command,
+                        String mvelString) {
+        this.message = message;
+        this.expectedIdentifier = expectedIdentifier;
+        this.command = command;
+        this.mvelString = mvelString;
+    }
+
+    public Void execute(Context context) {
+        Object actualObject = ((GenericCommand) command).execute( context );
+
+        if ( this.mvelString != null ) {
+            actualObject = MVEL.eval( this.mvelString,
+                                      actualObject );
+        }
+
+        if ( this.expectedIdentifier != null ) {
+            this.expectedObject = context.get( this.expectedIdentifier );
+        }
+
+        Map vars = new HashMap();
+        vars.put( "expected",
+                  expectedObject );
+        vars.put( "actual",
+                  actualObject );
+
+        Assert.assertTrue( this.message,
+                           (Boolean) MVEL.eval( "expected == actual",
+                                                vars ) );
+
+        return null;
+    }
+
+    public String toString() {
+        return "assert";
+    }
+
+}

Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/command/ClearActivationGroupCommand.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/command/ClearActivationGroupCommand.java	2009-07-13 05:17:35 UTC (rev 27930)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/command/ClearActivationGroupCommand.java	2009-07-13 06:08:05 UTC (rev 27931)
@@ -1,10 +1,14 @@
 package org.drools.process.command;
 
+import org.drools.command.Context;
+import org.drools.command.impl.GenericCommand;
+import org.drools.command.impl.KnowledgeCommandContext;
 import org.drools.common.InternalAgenda;
 import org.drools.reteoo.ReteooWorkingMemory;
+import org.drools.runtime.StatefulKnowledgeSession;
 import org.drools.runtime.rule.impl.AgendaImpl;
 
-public class ClearActivationGroupCommand implements Command<Object> {
+public class ClearActivationGroupCommand implements GenericCommand<Object> {
 
 	private String name;
 	
@@ -16,8 +20,9 @@
 		this.name = name;
 	}
 
-	public Object execute(ReteooWorkingMemory session) {
-		new AgendaImpl((InternalAgenda) session.getAgenda()).getActivationGroup(name).clear();
+    public Void execute(Context context) {
+        StatefulKnowledgeSession ksession = ((KnowledgeCommandContext) context).getStatefulKnowledgesession();
+        ksession.getAgenda().getActivationGroup( this.name ).clear();
 		return null;
 	}
 

Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/command/ClearAgendaCommand.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/command/ClearAgendaCommand.java	2009-07-13 05:17:35 UTC (rev 27930)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/command/ClearAgendaCommand.java	2009-07-13 06:08:05 UTC (rev 27931)
@@ -1,13 +1,18 @@
 package org.drools.process.command;
 
+import org.drools.command.Context;
+import org.drools.command.impl.GenericCommand;
+import org.drools.command.impl.KnowledgeCommandContext;
 import org.drools.common.InternalAgenda;
 import org.drools.reteoo.ReteooWorkingMemory;
+import org.drools.runtime.StatefulKnowledgeSession;
 import org.drools.runtime.rule.impl.AgendaImpl;
 
-public class ClearAgendaCommand implements Command<Object> {
+public class ClearAgendaCommand implements GenericCommand<Object> {
 
-	public Object execute(ReteooWorkingMemory session) {
-		new AgendaImpl((InternalAgenda) session.getAgenda()).clear();
+    public Void execute(Context context) {
+        StatefulKnowledgeSession ksession = ((KnowledgeCommandContext) context).getStatefulKnowledgesession();
+        ksession.getAgenda().clear();
 		return null;
 	}
 

Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/command/ClearAgendaGroupCommand.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/command/ClearAgendaGroupCommand.java	2009-07-13 05:17:35 UTC (rev 27930)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/command/ClearAgendaGroupCommand.java	2009-07-13 06:08:05 UTC (rev 27931)
@@ -1,10 +1,14 @@
 package org.drools.process.command;
 
+import org.drools.command.Context;
+import org.drools.command.impl.GenericCommand;
+import org.drools.command.impl.KnowledgeCommandContext;
 import org.drools.common.InternalAgenda;
 import org.drools.reteoo.ReteooWorkingMemory;
+import org.drools.runtime.StatefulKnowledgeSession;
 import org.drools.runtime.rule.impl.AgendaImpl;
 
-public class ClearAgendaGroupCommand implements Command<Object> {
+public class ClearAgendaGroupCommand implements GenericCommand<Object> {
 
 	private String name;
 	
@@ -16,8 +20,9 @@
 		this.name = name;
 	}
 
-	public Object execute(ReteooWorkingMemory session) {
-		new AgendaImpl((InternalAgenda) session.getAgenda()).getAgendaGroup(name).clear();
+    public Void execute(Context context) {
+        StatefulKnowledgeSession ksession = ((KnowledgeCommandContext) context).getStatefulKnowledgesession();
+        ksession.getAgenda().getAgendaGroup( this.name ).clear();
 		return null;
 	}
 

Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/command/ClearRuleFlowGroupCommand.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/command/ClearRuleFlowGroupCommand.java	2009-07-13 05:17:35 UTC (rev 27930)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/command/ClearRuleFlowGroupCommand.java	2009-07-13 06:08:05 UTC (rev 27931)
@@ -1,10 +1,15 @@
 package org.drools.process.command;
 
+import org.drools.command.Context;
+import org.drools.command.impl.GenericCommand;
+import org.drools.command.impl.KnowledgeCommandContext;
 import org.drools.common.InternalAgenda;
+import org.drools.impl.StatefulKnowledgeSessionImpl;
 import org.drools.reteoo.ReteooWorkingMemory;
+import org.drools.runtime.StatefulKnowledgeSession;
 import org.drools.runtime.rule.impl.AgendaImpl;
 
-public class ClearRuleFlowGroupCommand implements Command<Object> {
+public class ClearRuleFlowGroupCommand implements GenericCommand<Object> {
 
 	private String name;
 	
@@ -16,8 +21,9 @@
 		this.name = name;
 	}
 
-	public Object execute(ReteooWorkingMemory session) {
-		new AgendaImpl((InternalAgenda) session.getAgenda()).getRuleFlowGroup(name).clear();
+    public Void execute(Context context) {
+        StatefulKnowledgeSession ksession = ((KnowledgeCommandContext) context).getStatefulKnowledgesession();
+        ((StatefulKnowledgeSessionImpl)ksession).session.getAgenda().getRuleFlowGroup( this.name ).clear();
 		return null;
 	}
 

Deleted: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/command/Command.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/command/Command.java	2009-07-13 05:17:35 UTC (rev 27930)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/command/Command.java	2009-07-13 06:08:05 UTC (rev 27931)
@@ -1,9 +0,0 @@
-package org.drools.process.command;
-
-import org.drools.reteoo.ReteooWorkingMemory;
-
-public interface Command<T> extends org.drools.command.Command {
-	
-	T execute(ReteooWorkingMemory session);
-	
-}

Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/command/CommandService.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/command/CommandService.java	2009-07-13 05:17:35 UTC (rev 27930)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/command/CommandService.java	2009-07-13 06:08:05 UTC (rev 27931)
@@ -1,13 +1,12 @@
 package org.drools.process.command;
 
 import org.drools.StatefulSession;
+import org.drools.command.Context;
+import org.drools.command.impl.GenericCommand;
 
 public interface CommandService {
 	
-	<T> T execute(Command<T> command);
+	<T> T execute(GenericCommand<T> command);
 
-	StatefulSession getSession();
-	
-	void dispose();
-	
+	Context getContext();	
 }

Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/command/CompleteWorkItemCommand.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/command/CompleteWorkItemCommand.java	2009-07-13 05:17:35 UTC (rev 27930)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/command/CompleteWorkItemCommand.java	2009-07-13 06:08:05 UTC (rev 27931)
@@ -3,9 +3,13 @@
 import java.util.HashMap;
 import java.util.Map;
 
+import org.drools.command.Context;
+import org.drools.command.impl.GenericCommand;
+import org.drools.command.impl.KnowledgeCommandContext;
 import org.drools.reteoo.ReteooWorkingMemory;
+import org.drools.runtime.StatefulKnowledgeSession;
 
-public class CompleteWorkItemCommand implements Command<Object> {
+public class CompleteWorkItemCommand implements GenericCommand<Object> {
 	
 	private long workItemId;
 	private Map<String, Object> results = new HashMap<String, Object>();
@@ -37,8 +41,9 @@
 		this.results = results;
 	}
 
-	public Object execute(ReteooWorkingMemory session) {
-		session.getWorkItemManager().completeWorkItem(workItemId, results);
+    public Void execute(Context context) {
+        StatefulKnowledgeSession ksession = ((KnowledgeCommandContext) context).getStatefulKnowledgesession();
+		ksession.getWorkItemManager().completeWorkItem(workItemId, results);
 		return null;
 	}
 

Added: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/command/DisposeCommand.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/command/DisposeCommand.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/command/DisposeCommand.java	2009-07-13 06:08:05 UTC (rev 27931)
@@ -0,0 +1,25 @@
+package org.drools.process.command;
+
+import org.drools.command.Context;
+import org.drools.command.impl.GenericCommand;
+import org.drools.command.impl.KnowledgeCommandContext;
+import org.drools.impl.StatefulKnowledgeSessionImpl;
+import org.drools.reteoo.ReteooWorkingMemory;
+import org.drools.runtime.StatefulKnowledgeSession;
+import org.drools.runtime.rule.AgendaFilter;
+
+public class DisposeCommand
+    implements
+    GenericCommand<Void> {
+
+    public Void execute(Context context) {
+        StatefulKnowledgeSession ksession = ((KnowledgeCommandContext) context).getStatefulKnowledgesession();
+        ksession.dispose();
+        return null;
+    }
+
+    public String toString() {
+        return "ksession.dispose();";
+    }
+
+}

Added: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/command/ExecuteCommand.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/command/ExecuteCommand.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/command/ExecuteCommand.java	2009-07-13 06:08:05 UTC (rev 27931)
@@ -0,0 +1,55 @@
+package org.drools.process.command;
+
+import org.drools.command.Command;
+import org.drools.command.Context;
+import org.drools.command.impl.GenericCommand;
+import org.drools.command.impl.KnowledgeCommandContext;
+import org.drools.common.InternalFactHandle;
+import org.drools.impl.StatefulKnowledgeSessionImpl;
+import org.drools.reteoo.ReteooWorkingMemory;
+import org.drools.runtime.ExecutionResults;
+import org.drools.runtime.StatefulKnowledgeSession;
+import org.drools.runtime.rule.FactHandle;
+
+public class ExecuteCommand
+    implements
+    GenericCommand<ExecutionResults> {
+
+    private Command  command;
+
+    public ExecuteCommand(Command  command) {
+        this.command = command;
+    }
+
+    public ExecutionResults execute(Context context) {
+        StatefulKnowledgeSession ksession = ((KnowledgeCommandContext) context).getStatefulKnowledgesession();
+      
+        return ksession.execute( this.command );
+
+    }
+
+    public Command getCommand() {
+        return this.command;
+    }
+
+//    public String getOutIdentifier() {
+//        return this.outIdentifier;
+//    }
+//
+//    public void setOutIdentifier(String outIdentifier) {
+//        this.outIdentifier = outIdentifier;
+//    }
+
+//    public boolean isReturnObject() {
+//        return returnObject;
+//    }
+//
+//    public void setReturnObject(boolean returnObject) {
+//        this.returnObject = returnObject;
+//    }
+
+    public String toString() {
+        return "session.execute(" + this.command + ");";
+    }
+
+}

Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/command/FireAllRulesCommand.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/command/FireAllRulesCommand.java	2009-07-13 05:17:35 UTC (rev 27930)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/command/FireAllRulesCommand.java	2009-07-13 06:08:05 UTC (rev 27931)
@@ -1,12 +1,16 @@
 package org.drools.process.command;
 
+import org.drools.command.Context;
+import org.drools.command.impl.GenericCommand;
+import org.drools.command.impl.KnowledgeCommandContext;
 import org.drools.impl.StatefulKnowledgeSessionImpl;
 import org.drools.reteoo.ReteooWorkingMemory;
+import org.drools.runtime.StatefulKnowledgeSession;
 import org.drools.runtime.rule.AgendaFilter;
 
 public class FireAllRulesCommand
     implements
-    Command<Integer> {
+    GenericCommand<Integer> {
 
     private int          max          = -1;
     private AgendaFilter agendaFilter = null;
@@ -26,13 +30,14 @@
         return this.max;
     }
 
-    public Integer execute(ReteooWorkingMemory session) {
+    public Integer execute(Context context) {
+        StatefulKnowledgeSession ksession = ((KnowledgeCommandContext) context).getStatefulKnowledgesession();
         if ( max != -1 ) {
-            return session.fireAllRules( max );
+            return ksession.fireAllRules( max );
         } else if ( agendaFilter != null ) {
-            return session.fireAllRules( new StatefulKnowledgeSessionImpl.AgendaFilterWrapper( agendaFilter ) );
+            return ((StatefulKnowledgeSessionImpl)ksession).session.fireAllRules( new StatefulKnowledgeSessionImpl.AgendaFilterWrapper( agendaFilter ) );
         } else {
-            return session.fireAllRules();
+            return ksession.fireAllRules();
         }
     }
 

Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/command/FireUntilHaltCommand.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/command/FireUntilHaltCommand.java	2009-07-13 05:17:35 UTC (rev 27930)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/command/FireUntilHaltCommand.java	2009-07-13 06:08:05 UTC (rev 27931)
@@ -1,12 +1,16 @@
 package org.drools.process.command;
 
+import org.drools.command.Context;
+import org.drools.command.impl.GenericCommand;
+import org.drools.command.impl.KnowledgeCommandContext;
 import org.drools.impl.StatefulKnowledgeSessionImpl;
 import org.drools.reteoo.ReteooWorkingMemory;
+import org.drools.runtime.StatefulKnowledgeSession;
 import org.drools.runtime.rule.AgendaFilter;
 
 public class FireUntilHaltCommand
     implements
-    Command<Object> {
+    GenericCommand<Object> {
 
     private AgendaFilter agendaFilter = null;
 
@@ -17,7 +21,9 @@
         this.agendaFilter = agendaFilter;
     }
 
-    public Object execute(ReteooWorkingMemory session) {
+    public Integer execute(Context context) {
+        StatefulKnowledgeSession ksession = ((KnowledgeCommandContext) context).getStatefulKnowledgesession();
+        ReteooWorkingMemory session = ((StatefulKnowledgeSessionImpl)ksession).session;
         if ( agendaFilter != null ) {
             session.fireUntilHalt( new StatefulKnowledgeSessionImpl.AgendaFilterWrapper( agendaFilter ) );
         } else {

Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/command/GetAgendaEventListenersCommand.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/command/GetAgendaEventListenersCommand.java	2009-07-13 05:17:35 UTC (rev 27930)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/command/GetAgendaEventListenersCommand.java	2009-07-13 06:08:05 UTC (rev 27931)
@@ -2,15 +2,21 @@
 
 import java.util.Collection;
 
-import org.drools.event.AgendaEventListener;
+import org.drools.command.Context;
+import org.drools.command.impl.GenericCommand;
+import org.drools.command.impl.KnowledgeCommandContext;
+import org.drools.event.process.ProcessEventListener;
+import org.drools.event.rule.AgendaEventListener;
 import org.drools.reteoo.ReteooWorkingMemory;
+import org.drools.runtime.StatefulKnowledgeSession;
 
 public class GetAgendaEventListenersCommand
     implements
-    Command<Collection<AgendaEventListener>> {
+    GenericCommand<Collection<AgendaEventListener>> {
 
-    public Collection<AgendaEventListener> execute(ReteooWorkingMemory session) {
-        return session.getAgendaEventListeners();
+    public Collection<AgendaEventListener> execute(Context context) {
+        StatefulKnowledgeSession ksession = ((KnowledgeCommandContext) context).getStatefulKnowledgesession();
+        return ksession.getAgendaEventListeners();
     }
 
     public String toString() {

Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/command/GetEnvironmentCommand.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/command/GetEnvironmentCommand.java	2009-07-13 05:17:35 UTC (rev 27930)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/command/GetEnvironmentCommand.java	2009-07-13 06:08:05 UTC (rev 27931)
@@ -1,14 +1,19 @@
 package org.drools.process.command;
 
+import org.drools.command.Context;
+import org.drools.command.impl.GenericCommand;
+import org.drools.command.impl.KnowledgeCommandContext;
 import org.drools.reteoo.ReteooWorkingMemory;
 import org.drools.runtime.Environment;
+import org.drools.runtime.StatefulKnowledgeSession;
 
 public class GetEnvironmentCommand
     implements
-    Command<Environment> {
+    GenericCommand<Environment> {
 
-    public Environment execute(ReteooWorkingMemory session) {
-        return session.getEnvironment();
+    public Environment execute(Context context) {
+        StatefulKnowledgeSession ksession = ((KnowledgeCommandContext) context).getStatefulKnowledgesession();
+        return ksession.getEnvironment();
     }
 
     public String toString() {

Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/command/GetFactHandleCommand.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/command/GetFactHandleCommand.java	2009-07-13 05:17:35 UTC (rev 27930)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/command/GetFactHandleCommand.java	2009-07-13 06:08:05 UTC (rev 27931)
@@ -1,11 +1,15 @@
 package org.drools.process.command;
 
+import org.drools.command.Context;
+import org.drools.command.impl.GenericCommand;
+import org.drools.command.impl.KnowledgeCommandContext;
 import org.drools.reteoo.ReteooWorkingMemory;
+import org.drools.runtime.StatefulKnowledgeSession;
 import org.drools.runtime.rule.FactHandle;
 
 public class GetFactHandleCommand
     implements
-    Command<FactHandle> {
+    GenericCommand<FactHandle> {
 
     private Object object;
 
@@ -13,12 +17,12 @@
         this.object = object;
     }
 
-    public FactHandle execute(ReteooWorkingMemory session) {
-        session.getFactHandle( object );
-        return null;
+    public FactHandle execute(Context context) {
+        StatefulKnowledgeSession ksession = ((KnowledgeCommandContext) context).getStatefulKnowledgesession();
+        return ksession.getFactHandle( object );
     }
 
     public String toString() {
-        return "session.getFactHandle( " + object + " );";
+        return "ksession.getFactHandle( " + object + " );";
     }
 }

Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/command/GetFactHandlesCommand.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/command/GetFactHandlesCommand.java	2009-07-13 05:17:35 UTC (rev 27930)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/command/GetFactHandlesCommand.java	2009-07-13 06:08:05 UTC (rev 27931)
@@ -2,15 +2,19 @@
 
 import java.util.Collection;
 
+import org.drools.command.Context;
+import org.drools.command.impl.GenericCommand;
+import org.drools.command.impl.KnowledgeCommandContext;
 import org.drools.impl.StatefulKnowledgeSessionImpl.ObjectStoreWrapper;
 import org.drools.reteoo.ReteooStatefulSession;
 import org.drools.reteoo.ReteooWorkingMemory;
 import org.drools.runtime.ObjectFilter;
+import org.drools.runtime.StatefulKnowledgeSession;
 import org.drools.runtime.rule.FactHandle;
 
 public class GetFactHandlesCommand
     implements
-    Command<Collection< FactHandle >> {
+    GenericCommand<Collection<FactHandle>> {
 
     private ObjectFilter filter = null;
 
@@ -21,17 +25,13 @@
         this.filter = filter;
     }
 
-    public Collection< FactHandle > execute(ReteooWorkingMemory session) {
-        ReteooStatefulSession reteooStatefulSession = (ReteooStatefulSession) session;
+    public Collection<FactHandle> execute(Context context) {
+        StatefulKnowledgeSession ksession = ((KnowledgeCommandContext) context).getStatefulKnowledgesession();        
 
         if ( filter != null ) {
-            return new ObjectStoreWrapper( reteooStatefulSession.getObjectStore(),
-                                           null,
-                                           ObjectStoreWrapper.FACT_HANDLE );
+            return ksession.getFactHandles( this.filter );
         } else {
-            return new ObjectStoreWrapper( reteooStatefulSession.getObjectStore(),
-                                           filter,
-                                           ObjectStoreWrapper.FACT_HANDLE );
+            return ksession.getFactHandles( this.filter );
         }
     }
 

Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/command/GetGlobalCommand.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/command/GetGlobalCommand.java	2009-07-13 05:17:35 UTC (rev 27930)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/command/GetGlobalCommand.java	2009-07-13 06:08:05 UTC (rev 27931)
@@ -1,10 +1,20 @@
 package org.drools.process.command;
 
+import java.util.Collection;
+
+import org.drools.command.Context;
+import org.drools.command.impl.GenericCommand;
+import org.drools.command.impl.KnowledgeCommandContext;
+import org.drools.impl.StatefulKnowledgeSessionImpl;
 import org.drools.reteoo.ReteooWorkingMemory;
+import org.drools.runtime.ExecutionResults;
+import org.drools.runtime.StatefulKnowledgeSession;
+import org.drools.runtime.impl.ExecutionResultImpl;
+import org.drools.runtime.rule.FactHandle;
 
 public class GetGlobalCommand
     implements
-    Command<Object> {
+    GenericCommand<Object> {
 
     private String identifier;
     private String outIdentifier;
@@ -25,10 +35,15 @@
         return identifier;
     }
 
-    public Object execute(ReteooWorkingMemory session) {
-        Object object = session.getGlobal( this.identifier );
-        session.getExecutionResult().getResults().put( (this.outIdentifier != null) ? this.outIdentifier : this.identifier,
-                                                            object );
+    public Object execute(Context context) {
+        StatefulKnowledgeSession ksession = ((KnowledgeCommandContext) context).getStatefulKnowledgesession();
+
+        Object object = ksession.getGlobal( identifier );
+        ExecutionResultImpl results = (ExecutionResultImpl) ((StatefulKnowledgeSessionImpl) ksession).session.getExecutionResult();
+        if ( results != null ) {
+            results.getResults().put( (this.outIdentifier != null) ? this.outIdentifier : this.identifier,
+                                      object );
+        }
         return object;
     }
 

Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/command/GetGlobalsCommand.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/command/GetGlobalsCommand.java	2009-07-13 05:17:35 UTC (rev 27930)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/command/GetGlobalsCommand.java	2009-07-13 06:08:05 UTC (rev 27931)
@@ -1,14 +1,19 @@
 package org.drools.process.command;
 
+import org.drools.command.Context;
+import org.drools.command.impl.GenericCommand;
+import org.drools.command.impl.KnowledgeCommandContext;
 import org.drools.reteoo.ReteooWorkingMemory;
 import org.drools.runtime.Globals;
+import org.drools.runtime.StatefulKnowledgeSession;
 
 public class GetGlobalsCommand
     implements
-    Command<Globals> {
+    GenericCommand<Globals> {
 
-    public Globals execute(ReteooWorkingMemory session) {
-        return (Globals) session.getGlobalResolver();
+    public Globals execute(Context context) {
+        StatefulKnowledgeSession ksession = ((KnowledgeCommandContext) context).getStatefulKnowledgesession();
+        return (Globals) ksession.getGlobals();
     }
 
     public String toString() {

Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/command/GetKnowledgeBaseCommand.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/command/GetKnowledgeBaseCommand.java	2009-07-13 05:17:35 UTC (rev 27930)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/command/GetKnowledgeBaseCommand.java	2009-07-13 06:08:05 UTC (rev 27931)
@@ -2,20 +2,23 @@
 
 import org.drools.KnowledgeBase;
 import org.drools.RuleBase;
+import org.drools.command.Context;
+import org.drools.command.impl.GenericCommand;
+import org.drools.command.impl.KnowledgeCommandContext;
 import org.drools.impl.KnowledgeBaseImpl;
 import org.drools.reteoo.ReteooWorkingMemory;
+import org.drools.runtime.StatefulKnowledgeSession;
 
 public class GetKnowledgeBaseCommand
     implements
-    Command<KnowledgeBase> {
+    GenericCommand<KnowledgeBase> {
 
     public GetKnowledgeBaseCommand() {
     }
 
-    public KnowledgeBase execute(ReteooWorkingMemory session) {
-        RuleBase ruleBase = session.getRuleBase();
-
-        return new KnowledgeBaseImpl( ruleBase );
+    public KnowledgeBase execute(Context context) {
+        StatefulKnowledgeSession ksession = ((KnowledgeCommandContext) context).getStatefulKnowledgesession();
+        return ksession.getKnowledgeBase();
     }
 
     public String toString() {

Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/command/GetObjectCommand.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/command/GetObjectCommand.java	2009-07-13 05:17:35 UTC (rev 27930)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/command/GetObjectCommand.java	2009-07-13 06:08:05 UTC (rev 27931)
@@ -1,11 +1,16 @@
 package org.drools.process.command;
 
+import org.drools.command.Context;
+import org.drools.command.impl.GenericCommand;
+import org.drools.command.impl.KnowledgeCommandContext;
+import org.drools.impl.StatefulKnowledgeSessionImpl;
 import org.drools.reteoo.ReteooWorkingMemory;
+import org.drools.runtime.StatefulKnowledgeSession;
 import org.drools.runtime.rule.FactHandle;
 
 public class GetObjectCommand
     implements
-    Command<Object> {
+    GenericCommand<Object> {
 
     private FactHandle factHandle;
     private String     outIdentifier;
@@ -22,9 +27,12 @@
         this.outIdentifier = outIdentifier;
     }
 
-    public Object execute(ReteooWorkingMemory session) {
-        Object object = session.getObject( factHandle );
-        session.getExecutionResult().getResults().put( this.outIdentifier,
+    public Object execute(Context context) {
+        StatefulKnowledgeSession ksession = ((KnowledgeCommandContext) context).getStatefulKnowledgesession();
+        
+        Object object = ksession.getObject( factHandle );
+        
+        ((StatefulKnowledgeSessionImpl)ksession).session.getExecutionResult().getResults().put( this.outIdentifier,
                                                        object );
 
         return object;

Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/command/GetObjectsCommand.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/command/GetObjectsCommand.java	2009-07-13 05:17:35 UTC (rev 27930)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/command/GetObjectsCommand.java	2009-07-13 06:08:05 UTC (rev 27931)
@@ -5,13 +5,18 @@
 import java.util.Iterator;
 import java.util.List;
 
+import org.drools.command.Context;
+import org.drools.command.impl.GenericCommand;
+import org.drools.command.impl.KnowledgeCommandContext;
+import org.drools.impl.StatefulKnowledgeSessionImpl;
 import org.drools.impl.StatefulKnowledgeSessionImpl.ObjectStoreWrapper;
 import org.drools.reteoo.ReteooWorkingMemory;
 import org.drools.runtime.ObjectFilter;
+import org.drools.runtime.StatefulKnowledgeSession;
 
 public class GetObjectsCommand
     implements
-    Command<Collection> {
+    GenericCommand<Collection> {
 
     public String getOutIdentifier() {
 		return outIdentifier;
@@ -32,19 +37,22 @@
         this.filter = filter;
     }
 
-    public Collection execute(ReteooWorkingMemory session) {        
+    public Collection execute(Context context) {
+        StatefulKnowledgeSession ksession = ((KnowledgeCommandContext) context).getStatefulKnowledgesession();
+        
         Collection col = null;
         
         if ( filter != null ) {
-            col =  getObjects( session, filter );
+            
+            col =  ksession.getObjects( this.filter );
         } else {
-            col =  getObjects(session);
+            col =  ksession.getObjects( );
         }
         
         if ( this.outIdentifier != null ) {
             List objects = new ArrayList( col );
             
-            session.getExecutionResult().getResults().put( this.outIdentifier, objects );
+            ((StatefulKnowledgeSessionImpl)ksession).session.getExecutionResult().getResults().put( this.outIdentifier, objects );
         }
         
         return col;

Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/command/GetProcessEventListenersCommand.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/command/GetProcessEventListenersCommand.java	2009-07-13 05:17:35 UTC (rev 27930)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/command/GetProcessEventListenersCommand.java	2009-07-13 06:08:05 UTC (rev 27931)
@@ -2,18 +2,25 @@
 
 import java.util.Collection;
 
+import org.drools.command.Context;
+import org.drools.command.impl.GenericCommand;
+import org.drools.command.impl.KnowledgeCommandContext;
 import org.drools.event.RuleFlowEventListener;
+import org.drools.event.process.ProcessEventListener;
 import org.drools.reteoo.ReteooWorkingMemory;
+import org.drools.runtime.StatefulKnowledgeSession;
+import org.drools.runtime.process.ProcessInstance;
 
 public class GetProcessEventListenersCommand
     implements
-    Command<Collection<RuleFlowEventListener>> {
+    GenericCommand<Collection<ProcessEventListener> > {
 
-    public Collection<RuleFlowEventListener> execute(ReteooWorkingMemory session) {
-        return session.getRuleFlowEventListeners();
+    public Collection<ProcessEventListener> execute(Context context) {
+        StatefulKnowledgeSession ksession = ((KnowledgeCommandContext) context).getStatefulKnowledgesession();
+        return ksession.getProcessEventListeners();
     }
 
     public String toString() {
-        return "session.getRuleFlowEventListeners();";
+        return "session.getProcessEventListeners();";
     }
 }

Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/command/GetProcessInstanceCommand.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/command/GetProcessInstanceCommand.java	2009-07-13 05:17:35 UTC (rev 27930)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/command/GetProcessInstanceCommand.java	2009-07-13 06:08:05 UTC (rev 27931)
@@ -1,9 +1,15 @@
 package org.drools.process.command;
 
-import org.drools.process.instance.ProcessInstance;
+import java.util.Collection;
+
+import org.drools.command.Context;
+import org.drools.command.impl.GenericCommand;
+import org.drools.command.impl.KnowledgeCommandContext;
 import org.drools.reteoo.ReteooWorkingMemory;
+import org.drools.runtime.StatefulKnowledgeSession;
+import org.drools.runtime.process.ProcessInstance;
 
-public class GetProcessInstanceCommand implements Command<ProcessInstance> {
+public class GetProcessInstanceCommand implements GenericCommand<ProcessInstance> {
 	
 	private Long processInstanceId;
 	
@@ -15,11 +21,12 @@
 		this.processInstanceId = processInstanceId;
 	}
 	
-	public ProcessInstance execute(ReteooWorkingMemory session) {
+    public ProcessInstance execute(Context context) {
+        StatefulKnowledgeSession ksession = ((KnowledgeCommandContext) context).getStatefulKnowledgesession();
 		if (processInstanceId == null) {
 			return null;
 		}
-		return session.getProcessInstance(processInstanceId);
+		return ksession.getProcessInstance(processInstanceId);
 	}
 
 	public String toString() {

Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/command/GetProcessInstancesCommand.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/command/GetProcessInstancesCommand.java	2009-07-13 05:17:35 UTC (rev 27930)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/command/GetProcessInstancesCommand.java	2009-07-13 06:08:05 UTC (rev 27931)
@@ -3,15 +3,20 @@
 import java.util.ArrayList;
 import java.util.Collection;
 
-import org.drools.reteoo.ReteooWorkingMemory;
+import org.drools.command.Context;
+import org.drools.command.impl.GenericCommand;
+import org.drools.command.impl.KnowledgeCommandContext;
+import org.drools.runtime.StatefulKnowledgeSession;
 import org.drools.runtime.process.ProcessInstance;
 
 public class GetProcessInstancesCommand
     implements
-    Command<Collection<ProcessInstance>> {
+    GenericCommand<Collection<ProcessInstance>> {
 
-    public Collection<ProcessInstance> execute(ReteooWorkingMemory session) {
-        Collection<org.drools.process.instance.ProcessInstance> instances = session.getProcessInstances();
+    public Collection<ProcessInstance> execute(Context context) {
+        StatefulKnowledgeSession ksession = ((KnowledgeCommandContext) context).getStatefulKnowledgesession();
+        
+        Collection<ProcessInstance> instances = ksession.getProcessInstances();
         Collection<ProcessInstance> result = new ArrayList<ProcessInstance>();
 
         for ( ProcessInstance instance : instances ) {

Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/command/GetSessionClockCommand.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/command/GetSessionClockCommand.java	2009-07-13 05:17:35 UTC (rev 27930)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/command/GetSessionClockCommand.java	2009-07-13 06:08:05 UTC (rev 27931)
@@ -1,14 +1,19 @@
 package org.drools.process.command;
 
+import org.drools.command.Context;
+import org.drools.command.impl.GenericCommand;
+import org.drools.command.impl.KnowledgeCommandContext;
 import org.drools.reteoo.ReteooWorkingMemory;
+import org.drools.runtime.StatefulKnowledgeSession;
 import org.drools.time.SessionClock;
 
 public class GetSessionClockCommand
     implements
-    Command<SessionClock> {
+    GenericCommand<SessionClock> {
 
-    public SessionClock execute(ReteooWorkingMemory session) {
-        return session.getSessionClock();
+    public SessionClock execute(Context context) {
+        StatefulKnowledgeSession ksession = ((KnowledgeCommandContext) context).getStatefulKnowledgesession();
+        return ksession.getSessionClock();
     }
 
     public String toString() {

Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/command/GetWorkingMemoryEntryPointCommand.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/command/GetWorkingMemoryEntryPointCommand.java	2009-07-13 05:17:35 UTC (rev 27930)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/command/GetWorkingMemoryEntryPointCommand.java	2009-07-13 06:08:05 UTC (rev 27931)
@@ -1,11 +1,16 @@
 package org.drools.process.command;
 
+import org.drools.command.Context;
+import org.drools.command.impl.GenericCommand;
+import org.drools.command.impl.KnowledgeCommandContext;
 import org.drools.reteoo.ReteooWorkingMemory;
+import org.drools.runtime.StatefulKnowledgeSession;
 import org.drools.runtime.rule.WorkingMemoryEntryPoint;
+import org.drools.time.SessionClock;
 
 public class GetWorkingMemoryEntryPointCommand
     implements
-    Command<WorkingMemoryEntryPoint> {
+    GenericCommand<WorkingMemoryEntryPoint> {
 
     private String name;
 
@@ -13,8 +18,9 @@
         this.name = name;
     }
 
-    public WorkingMemoryEntryPoint execute(ReteooWorkingMemory session) {
-        return session.getWorkingMemoryEntryPoint( name );
+    public WorkingMemoryEntryPoint execute(Context context) {
+        StatefulKnowledgeSession ksession = ((KnowledgeCommandContext) context).getStatefulKnowledgesession();
+        return ksession.getWorkingMemoryEntryPoint( name );
     }
 
     public String toString() {

Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/command/GetWorkingMemoryEntryPointsCommand.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/command/GetWorkingMemoryEntryPointsCommand.java	2009-07-13 05:17:35 UTC (rev 27930)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/command/GetWorkingMemoryEntryPointsCommand.java	2009-07-13 06:08:05 UTC (rev 27931)
@@ -2,18 +2,23 @@
 
 import java.util.Collection;
 
+import org.drools.command.Context;
+import org.drools.command.impl.GenericCommand;
+import org.drools.command.impl.KnowledgeCommandContext;
 import org.drools.reteoo.ReteooWorkingMemory;
+import org.drools.runtime.StatefulKnowledgeSession;
 import org.drools.runtime.rule.WorkingMemoryEntryPoint;
 
 public class GetWorkingMemoryEntryPointsCommand
     implements
-    Command<Collection<? extends WorkingMemoryEntryPoint>> {
+    GenericCommand<Collection< ? extends WorkingMemoryEntryPoint>> {
 
     public GetWorkingMemoryEntryPointsCommand() {
     }
 
-    public Collection<? extends WorkingMemoryEntryPoint> execute(ReteooWorkingMemory session) {
-        return session.getWorkingMemoryEntryPoints();
+    public Collection< ? extends WorkingMemoryEntryPoint> execute(Context context) {
+        StatefulKnowledgeSession ksession = ((KnowledgeCommandContext) context).getStatefulKnowledgesession();
+        return ksession.getWorkingMemoryEntryPoints();
     }
 
     public String toString() {

Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/command/GetWorkingMemoryEventListenersCommand.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/command/GetWorkingMemoryEventListenersCommand.java	2009-07-13 05:17:35 UTC (rev 27930)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/command/GetWorkingMemoryEventListenersCommand.java	2009-07-13 06:08:05 UTC (rev 27931)
@@ -2,15 +2,21 @@
 
 import java.util.Collection;
 
-import org.drools.event.WorkingMemoryEventListener;
+import org.drools.command.Context;
+import org.drools.command.impl.GenericCommand;
+import org.drools.command.impl.KnowledgeCommandContext;
+import org.drools.event.rule.WorkingMemoryEventListener;
 import org.drools.reteoo.ReteooWorkingMemory;
+import org.drools.runtime.Globals;
+import org.drools.runtime.StatefulKnowledgeSession;
 
 public class GetWorkingMemoryEventListenersCommand
     implements
-    Command<Collection<WorkingMemoryEventListener>> {
+    GenericCommand<Collection<WorkingMemoryEventListener>> {
 
-    public Collection<WorkingMemoryEventListener> execute(ReteooWorkingMemory session) {
-        return session.getWorkingMemoryEventListeners();
+    public Collection<WorkingMemoryEventListener> execute(Context context) {
+        StatefulKnowledgeSession ksession = ((KnowledgeCommandContext) context).getStatefulKnowledgesession();
+        return ksession.getWorkingMemoryEventListeners();
     }
 
     public String toString() {

Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/command/HaltCommand.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/command/HaltCommand.java	2009-07-13 05:17:35 UTC (rev 27930)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/command/HaltCommand.java	2009-07-13 06:08:05 UTC (rev 27931)
@@ -1,13 +1,18 @@
 package org.drools.process.command;
 
+import org.drools.command.Context;
+import org.drools.command.impl.GenericCommand;
+import org.drools.command.impl.KnowledgeCommandContext;
 import org.drools.reteoo.ReteooWorkingMemory;
+import org.drools.runtime.StatefulKnowledgeSession;
 
 public class HaltCommand
     implements
-    Command<Object> {
+    GenericCommand<Void> {
 
-    public Object execute(ReteooWorkingMemory session) {
-        session.halt();
+    public Void execute(Context context) {
+        StatefulKnowledgeSession ksession = ((KnowledgeCommandContext) context).getStatefulKnowledgesession();
+        ksession.halt();
         return null;
     }
 

Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/command/InsertElementsCommand.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/command/InsertElementsCommand.java	2009-07-13 05:17:35 UTC (rev 27930)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/command/InsertElementsCommand.java	2009-07-13 06:08:05 UTC (rev 27931)
@@ -4,14 +4,19 @@
 import java.util.Collection;
 import java.util.List;
 
+import org.drools.command.Context;
+import org.drools.command.impl.GenericCommand;
+import org.drools.command.impl.KnowledgeCommandContext;
+import org.drools.impl.StatefulKnowledgeSessionImpl;
 import org.drools.reteoo.ReteooWorkingMemory;
+import org.drools.runtime.StatefulKnowledgeSession;
 import org.drools.runtime.rule.FactHandle;
 
 import com.thoughtworks.xstream.annotations.XStreamImplicit;
 
 public class InsertElementsCommand
     implements
-    Command<Collection<FactHandle>> {
+    GenericCommand<Collection<FactHandle>> {
     public Iterable objects;
 
     private String  outIdentifier;
@@ -34,18 +39,19 @@
         this.objects = objects;
     }
 
-    public Collection<FactHandle> execute(ReteooWorkingMemory session) {
+    public Collection<FactHandle> execute(Context context) {
+        StatefulKnowledgeSession ksession = ((KnowledgeCommandContext) context).getStatefulKnowledgesession();
         List<FactHandle> handles = new ArrayList<FactHandle>();
         for ( Object object : objects ) {
-            handles.add( session.insert( object ) );
+            handles.add( ksession.insert( object ) );
         }
 
         if ( outIdentifier != null ) {
             if ( this.returnObject ) {
-                session.getExecutionResult().getResults().put( this.outIdentifier,
+                ((StatefulKnowledgeSessionImpl)ksession).session.getExecutionResult().getResults().put( this.outIdentifier,
                                                                objects );
             }
-            session.getExecutionResult().getFactHandles().put( this.outIdentifier,
+            ((StatefulKnowledgeSessionImpl)ksession).session.getExecutionResult().getFactHandles().put( this.outIdentifier,
                                                                handles );
         }
         return handles;

Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/command/InsertObjectCommand.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/command/InsertObjectCommand.java	2009-07-13 05:17:35 UTC (rev 27930)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/command/InsertObjectCommand.java	2009-07-13 06:08:05 UTC (rev 27931)
@@ -1,12 +1,17 @@
 package org.drools.process.command;
 
+import org.drools.command.Context;
+import org.drools.command.impl.GenericCommand;
+import org.drools.command.impl.KnowledgeCommandContext;
 import org.drools.common.InternalFactHandle;
+import org.drools.impl.StatefulKnowledgeSessionImpl;
 import org.drools.reteoo.ReteooWorkingMemory;
+import org.drools.runtime.StatefulKnowledgeSession;
 import org.drools.runtime.rule.FactHandle;
 
 public class InsertObjectCommand
     implements
-    Command<FactHandle> {
+    GenericCommand<FactHandle> {
 
     private Object  object;
 
@@ -18,8 +23,11 @@
         this.object = object;
     }
 
-    public FactHandle execute(ReteooWorkingMemory session) {
-        FactHandle factHandle = session.insert( object );
+    public FactHandle execute(Context context) {
+        StatefulKnowledgeSession ksession = ((KnowledgeCommandContext) context).getStatefulKnowledgesession();
+        FactHandle factHandle = ksession.insert( object );
+        
+        ReteooWorkingMemory session = ((StatefulKnowledgeSessionImpl)ksession).session;
 
         if ( outIdentifier != null ) {
             if ( this.returnObject ) {

Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/command/ModifyCommand.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/command/ModifyCommand.java	2009-07-13 05:17:35 UTC (rev 27930)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/command/ModifyCommand.java	2009-07-13 06:08:05 UTC (rev 27931)
@@ -1,15 +1,20 @@
 package org.drools.process.command;
 
+import java.util.Collection;
 import java.util.List;
 
+import org.drools.command.Context;
 import org.drools.command.Setter;
+import org.drools.command.impl.GenericCommand;
+import org.drools.command.impl.KnowledgeCommandContext;
 import org.drools.reteoo.ReteooWorkingMemory;
+import org.drools.runtime.StatefulKnowledgeSession;
 import org.drools.runtime.rule.FactHandle;
 import org.mvel2.MVEL;
 
 public class ModifyCommand
     implements
-    Command<Object> {
+    GenericCommand<Object> {
 
     /**
      * if this is true, modify can be any MVEL expressions. If false, it will only allow literal values.
@@ -28,12 +33,13 @@
         this.setters = setters;
     }
 
-    public Object execute(ReteooWorkingMemory session) {
-        Object object = session.getObject( this.handle );
+    public Object execute(Context context) {
+        StatefulKnowledgeSession ksession = ((KnowledgeCommandContext) context).getStatefulKnowledgesession();
+        Object object = ksession.getObject( this.handle );
         MVEL.eval( getMvelExpr(),
                    object );
 
-        session.update( handle,
+        ksession.update( handle,
                         object );
         return object;
     }

Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/command/QueryCommand.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/command/QueryCommand.java	2009-07-13 05:17:35 UTC (rev 27930)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/command/QueryCommand.java	2009-07-13 06:08:05 UTC (rev 27931)
@@ -1,11 +1,19 @@
 package org.drools.process.command;
 
+import java.util.Collection;
+
+import org.drools.command.Context;
+import org.drools.command.impl.GenericCommand;
+import org.drools.command.impl.KnowledgeCommandContext;
+import org.drools.impl.StatefulKnowledgeSessionImpl;
 import org.drools.reteoo.ReteooWorkingMemory;
 import org.drools.runtime.ExecutionResults;
+import org.drools.runtime.StatefulKnowledgeSession;
+import org.drools.runtime.rule.FactHandle;
 import org.drools.runtime.rule.QueryResults;
 import org.drools.runtime.rule.impl.NativeQueryResults;
 
-public class QueryCommand  implements Command<QueryResults> {
+public class QueryCommand  implements GenericCommand<QueryResults> {
     private String outIdentifier;
     private String name;
     private Object[] arguments;
@@ -37,17 +45,19 @@
         this.arguments = arguments;
     }
 
-    public QueryResults execute(ReteooWorkingMemory session) {
+    public QueryResults execute(Context context) {
+        StatefulKnowledgeSession ksession = ((KnowledgeCommandContext) context).getStatefulKnowledgesession();
+        
         QueryResults results = null;
         
         if ( arguments == null || arguments.length == 0 ) {
-            results = new NativeQueryResults( session.getQueryResults( name ) );
+            results = ksession.getQueryResults( name );
         } else {
-            results = new NativeQueryResults( session.getQueryResults( name, this.arguments ) );
+            results = ksession.getQueryResults( name, this.arguments );
         }
         
         if ( this.outIdentifier != null ) {
-            session.getExecutionResult().getResults().put( this.outIdentifier, results );
+            ((StatefulKnowledgeSessionImpl)ksession).session.getExecutionResult().getResults().put( this.outIdentifier, results );
         }
 
         return results;

Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/command/RegisterExitPointCommand.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/command/RegisterExitPointCommand.java	2009-07-13 05:17:35 UTC (rev 27930)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/command/RegisterExitPointCommand.java	2009-07-13 06:08:05 UTC (rev 27931)
@@ -1,12 +1,19 @@
 package org.drools.process.command;
 
+import java.util.Collection;
+
+import org.drools.command.Context;
+import org.drools.command.impl.GenericCommand;
+import org.drools.command.impl.KnowledgeCommandContext;
 import org.drools.reteoo.ReteooStatefulSession;
 import org.drools.reteoo.ReteooWorkingMemory;
 import org.drools.runtime.ExitPoint;
+import org.drools.runtime.StatefulKnowledgeSession;
+import org.drools.runtime.rule.FactHandle;
 
 public class RegisterExitPointCommand
     implements
-    Command<Object> {
+    GenericCommand<Object> {
 
     private String    name;
     private ExitPoint exitPoint;
@@ -17,11 +24,11 @@
         this.exitPoint = exitPoint;
     }
 
-    public Object execute(ReteooWorkingMemory session) {
-        ReteooStatefulSession reteooStatefulSession = (ReteooStatefulSession) session;
+    public Object execute(Context context) {
+        StatefulKnowledgeSession ksession = ((KnowledgeCommandContext) context).getStatefulKnowledgesession();
 
-        reteooStatefulSession.registerExitPoint( name,
-                                                 exitPoint );
+        ksession.registerExitPoint( name,
+                                    exitPoint );
 
         return null;
     }

Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/command/RegisterWorkItemHandlerCommand.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/command/RegisterWorkItemHandlerCommand.java	2009-07-13 05:17:35 UTC (rev 27930)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/command/RegisterWorkItemHandlerCommand.java	2009-07-13 06:08:05 UTC (rev 27931)
@@ -1,9 +1,16 @@
 package org.drools.process.command;
 
+import java.util.Collection;
+
+import org.drools.command.Context;
+import org.drools.command.impl.GenericCommand;
+import org.drools.command.impl.KnowledgeCommandContext;
 import org.drools.reteoo.ReteooWorkingMemory;
+import org.drools.runtime.StatefulKnowledgeSession;
 import org.drools.runtime.process.WorkItemHandler;
+import org.drools.runtime.rule.FactHandle;
 
-public class RegisterWorkItemHandlerCommand implements Command<Object> {
+public class RegisterWorkItemHandlerCommand implements GenericCommand<Object> {
 	
 	private WorkItemHandler handler;
 	private String workItemName;
@@ -24,8 +31,9 @@
 		this.workItemName = workItemName;
 	}
 
-	public Object execute(ReteooWorkingMemory session) {
-		session.getWorkItemManager().registerWorkItemHandler(workItemName, handler);
+    public Object execute(Context context) {
+        StatefulKnowledgeSession ksession = ((KnowledgeCommandContext) context).getStatefulKnowledgesession();        
+        ksession.getWorkItemManager().registerWorkItemHandler(workItemName, handler);
 		return null;
 	}
 

Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/command/RemoveEventListenerCommand.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/command/RemoveEventListenerCommand.java	2009-07-13 05:17:35 UTC (rev 27930)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/command/RemoveEventListenerCommand.java	2009-07-13 06:08:05 UTC (rev 27931)
@@ -1,17 +1,21 @@
 package org.drools.process.command;
 
-import org.drools.event.AgendaEventListener;
+import org.drools.command.Context;
+import org.drools.command.impl.GenericCommand;
+import org.drools.command.impl.KnowledgeCommandContext;
 import org.drools.event.RuleFlowEventListener;
-import org.drools.event.WorkingMemoryEventListener;
-import org.drools.reteoo.ReteooWorkingMemory;
+import org.drools.event.process.ProcessEventListener;
+import org.drools.event.rule.AgendaEventListener;
+import org.drools.event.rule.WorkingMemoryEventListener;
+import org.drools.runtime.StatefulKnowledgeSession;
 
 public class RemoveEventListenerCommand
     implements
-    Command<Object> {
+    GenericCommand<Object> {
 
     private WorkingMemoryEventListener workingMemoryEventListener = null;
     private AgendaEventListener        agendaEventListener        = null;
-    private RuleFlowEventListener      ruleFlowEventListener      = null;
+    private ProcessEventListener       processEventListener       = null;
 
     public RemoveEventListenerCommand(WorkingMemoryEventListener listener) {
         this.workingMemoryEventListener = listener;
@@ -21,17 +25,18 @@
         this.agendaEventListener = listener;
     }
 
-    public RemoveEventListenerCommand(RuleFlowEventListener listener) {
-        this.ruleFlowEventListener = listener;
+    public RemoveEventListenerCommand(ProcessEventListener listener) {
+        this.processEventListener = listener;
     }
 
-    public Object execute(ReteooWorkingMemory session) {
+    public Object execute(Context context) {
+        StatefulKnowledgeSession ksession = ((KnowledgeCommandContext) context).getStatefulKnowledgesession();
         if ( workingMemoryEventListener != null ) {
-            session.removeEventListener( workingMemoryEventListener );
+            ksession.removeEventListener( workingMemoryEventListener );
         } else if ( agendaEventListener != null ) {
-            session.removeEventListener( agendaEventListener );
+            ksession.removeEventListener( agendaEventListener );
         } else {
-            session.removeEventListener( ruleFlowEventListener );
+            ksession.removeEventListener( processEventListener );
         }
         return null;
     }
@@ -42,7 +47,7 @@
         } else if ( agendaEventListener != null ) {
             return "session.removeEventListener( " + agendaEventListener + " );";
         } else {
-            return "session.removeEventListener( " + ruleFlowEventListener + " );";
+            return "session.removeEventListener( " + processEventListener + " );";
         }
     }
 }

Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/command/RetractCommand.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/command/RetractCommand.java	2009-07-13 05:17:35 UTC (rev 27930)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/command/RetractCommand.java	2009-07-13 06:08:05 UTC (rev 27931)
@@ -1,11 +1,17 @@
 package org.drools.process.command;
 
+import java.util.Collection;
+
+import org.drools.command.Context;
+import org.drools.command.impl.GenericCommand;
+import org.drools.command.impl.KnowledgeCommandContext;
 import org.drools.reteoo.ReteooWorkingMemory;
+import org.drools.runtime.StatefulKnowledgeSession;
 import org.drools.runtime.rule.FactHandle;
 
 public class RetractCommand
     implements
-    Command<Object> {
+    GenericCommand<Object> {
 
     private FactHandle handle;
 
@@ -13,8 +19,9 @@
         this.handle = handle;
     }
 
-    public Object execute(ReteooWorkingMemory session) {
-        session.retract( handle );
+    public Object execute(Context context) {
+        StatefulKnowledgeSession ksession = ((KnowledgeCommandContext) context).getStatefulKnowledgesession();
+        ksession.retract( handle );
         return null;
     }
     

Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/command/SetGlobalCommand.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/command/SetGlobalCommand.java	2009-07-13 05:17:35 UTC (rev 27930)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/command/SetGlobalCommand.java	2009-07-13 06:08:05 UTC (rev 27931)
@@ -1,16 +1,22 @@
 package org.drools.process.command;
 
+import org.drools.KnowledgeBase;
+import org.drools.command.Context;
+import org.drools.command.impl.GenericCommand;
+import org.drools.command.impl.KnowledgeCommandContext;
+import org.drools.impl.StatefulKnowledgeSessionImpl;
 import org.drools.reteoo.ReteooWorkingMemory;
+import org.drools.runtime.StatefulKnowledgeSession;
 
 public class SetGlobalCommand
     implements
-    Command<Void> {
+    GenericCommand<Void> {
 
-    private String identifier;
-    private Object object;
-    
-    private String outIdentifier;
-    
+    private String  identifier;
+    private Object  object;
+
+    private String  outIdentifier;
+
     private boolean out;
 
     public SetGlobalCommand(String identifier,
@@ -19,14 +25,16 @@
         this.object = object;
     }
 
-    public Void execute(ReteooWorkingMemory session) {
+    public Void execute(Context context) {
+        StatefulKnowledgeSession ksession = ((KnowledgeCommandContext) context).getStatefulKnowledgesession();
+
         if ( this.out ) {
-            session.getExecutionResult().getResults().put( ( this.outIdentifier != null ) ? this.outIdentifier : this.identifier, 
-                                                                object );
+            ((StatefulKnowledgeSessionImpl) ksession).session.getExecutionResult().getResults().put( (this.outIdentifier != null) ? this.outIdentifier : this.identifier,
+                                                                                                     object );
         }
-        
-        session.setGlobal( this.identifier,
-                           this.object );
+
+        ksession.setGlobal( this.identifier,
+                            this.object );
         return null;
     }
 
@@ -53,8 +61,8 @@
 
     public void setOut(boolean out) {
         this.out = out;
-    }    
-    
+    }
+
     public String toString() {
         return "session.setGlobal(" + this.identifier + ", " + this.object + ");";
     }

Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/command/SetProcessInstanceStateCommand.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/command/SetProcessInstanceStateCommand.java	2009-07-13 05:17:35 UTC (rev 27930)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/command/SetProcessInstanceStateCommand.java	2009-07-13 06:08:05 UTC (rev 27931)
@@ -1,9 +1,16 @@
 package org.drools.process.command;
 
+import java.util.Collection;
+
+import org.drools.command.Context;
+import org.drools.command.impl.GenericCommand;
+import org.drools.command.impl.KnowledgeCommandContext;
 import org.drools.process.instance.ProcessInstance;
 import org.drools.reteoo.ReteooWorkingMemory;
+import org.drools.runtime.StatefulKnowledgeSession;
+import org.drools.runtime.rule.FactHandle;
 
-public class SetProcessInstanceStateCommand implements Command<Object> {
+public class SetProcessInstanceStateCommand implements GenericCommand<Object> {
 	
 	private Long processInstanceId;
 	private int state;
@@ -24,11 +31,12 @@
 		this.state = state;
 	}
 
-	public Object execute(ReteooWorkingMemory session) {
+    public Object execute(Context context) {
+        StatefulKnowledgeSession ksession = ((KnowledgeCommandContext) context).getStatefulKnowledgesession();
 		if (processInstanceId == null) {
 			return null;
 		}
-		((ProcessInstance) session.getProcessInstance(processInstanceId)).setState(state);
+		((ProcessInstance) ksession.getProcessInstance(processInstanceId)).setState(state);
 		return null;
 	}
 

Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/command/SignalEventCommand.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/command/SignalEventCommand.java	2009-07-13 05:17:35 UTC (rev 27930)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/command/SignalEventCommand.java	2009-07-13 06:08:05 UTC (rev 27931)
@@ -1,9 +1,12 @@
 package org.drools.process.command;
 
-import org.drools.process.instance.ProcessInstance;
-import org.drools.reteoo.ReteooWorkingMemory;
+import org.drools.command.Context;
+import org.drools.command.impl.GenericCommand;
+import org.drools.command.impl.KnowledgeCommandContext;
+import org.drools.runtime.StatefulKnowledgeSession;
+import org.drools.runtime.process.ProcessInstance;
 
-public class SignalEventCommand implements Command<Object> {
+public class SignalEventCommand implements GenericCommand<Object> {
 	
 	private long processInstanceId = -1;
 	private String eventType;
@@ -50,11 +53,13 @@
 		this.event = event;
 	}
 
-	public Object execute(ReteooWorkingMemory session) {
+    public Object execute(Context context) {
+        StatefulKnowledgeSession ksession = ((KnowledgeCommandContext) context).getStatefulKnowledgesession();
+        
 		if (processInstanceId == -1) {
-			session.getSignalManager().signalEvent(eventType, event);
+		    ksession.signalEvent(eventType, event);
 		} else {
-			ProcessInstance processInstance = session.getProcessInstance(processInstanceId);
+			ProcessInstance processInstance = ksession.getProcessInstance(processInstanceId);
 			if (processInstance != null) {
 				processInstance.signalEvent(eventType, event);
 			}

Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/command/StartProcessCommand.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/command/StartProcessCommand.java	2009-07-13 05:17:35 UTC (rev 27930)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/command/StartProcessCommand.java	2009-07-13 06:08:05 UTC (rev 27931)
@@ -4,10 +4,14 @@
 import java.util.List;
 import java.util.Map;
 
+import org.drools.command.Context;
+import org.drools.command.impl.GenericCommand;
+import org.drools.command.impl.KnowledgeCommandContext;
 import org.drools.process.instance.ProcessInstance;
 import org.drools.reteoo.ReteooWorkingMemory;
+import org.drools.runtime.StatefulKnowledgeSession;
 
-public class StartProcessCommand implements Command<ProcessInstance> {
+public class StartProcessCommand implements GenericCommand<ProcessInstance> {
 	
 	private String processId;
 	private Map<String, Object> parameters = new HashMap<String, Object>();
@@ -37,13 +41,15 @@
 		this.data = data;
 	}
 
-	public ProcessInstance execute(ReteooWorkingMemory session) {
+    public ProcessInstance execute(Context context) {
+        StatefulKnowledgeSession ksession = ((KnowledgeCommandContext) context).getStatefulKnowledgesession();
+        
 		if (data != null) {
 			for (Object o: data) {
-				session.insert(o);
+				ksession.insert(o);
 			}
 		}
-		ProcessInstance processInstance = (ProcessInstance) session.startProcess(processId, parameters);
+		ProcessInstance processInstance = (ProcessInstance) ksession.startProcess(processId, parameters);
 		return processInstance;
 	}
 

Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/command/UnregisterExitPointCommand.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/command/UnregisterExitPointCommand.java	2009-07-13 05:17:35 UTC (rev 27930)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/command/UnregisterExitPointCommand.java	2009-07-13 06:08:05 UTC (rev 27931)
@@ -1,11 +1,15 @@
 package org.drools.process.command;
 
+import org.drools.command.Context;
+import org.drools.command.impl.GenericCommand;
+import org.drools.command.impl.KnowledgeCommandContext;
 import org.drools.reteoo.ReteooStatefulSession;
 import org.drools.reteoo.ReteooWorkingMemory;
+import org.drools.runtime.StatefulKnowledgeSession;
 
 public class UnregisterExitPointCommand
     implements
-    Command<Object> {
+    GenericCommand<Object> {
 
     private String name;
 
@@ -13,10 +17,10 @@
         this.name = name;
     }
 
-    public Object execute(ReteooWorkingMemory session) {
-        ReteooStatefulSession reteooStatefulSession = (ReteooStatefulSession) session;
+    public Object execute(Context context) {
+        StatefulKnowledgeSession ksession = ((KnowledgeCommandContext) context).getStatefulKnowledgesession();
 
-        reteooStatefulSession.unregisterExitPoint( name );
+        ksession.unregisterExitPoint( name );
 
         return null;
     }

Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/command/UpdateCommand.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/command/UpdateCommand.java	2009-07-13 05:17:35 UTC (rev 27930)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/command/UpdateCommand.java	2009-07-13 06:08:05 UTC (rev 27931)
@@ -1,11 +1,15 @@
 package org.drools.process.command;
 
+import org.drools.command.Context;
+import org.drools.command.impl.GenericCommand;
+import org.drools.command.impl.KnowledgeCommandContext;
 import org.drools.reteoo.ReteooWorkingMemory;
+import org.drools.runtime.StatefulKnowledgeSession;
 import org.drools.runtime.rule.FactHandle;
 
 public class UpdateCommand
     implements
-    Command<Object> {
+    GenericCommand<Object> {
 
     private FactHandle handle;
     private Object     object;
@@ -16,8 +20,10 @@
         this.object = object;
     }
 
-    public Object execute(ReteooWorkingMemory session) {
-        session.update( handle,
+    public Object execute(Context context) {
+        StatefulKnowledgeSession ksession = ((KnowledgeCommandContext) context).getStatefulKnowledgesession();
+        
+        ksession.update( handle,
                         object );
         return null;
     }

Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/command/impl/AbstractInterceptor.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/command/impl/AbstractInterceptor.java	2009-07-13 05:17:35 UTC (rev 27930)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/command/impl/AbstractInterceptor.java	2009-07-13 06:08:05 UTC (rev 27931)
@@ -1,7 +1,8 @@
 package org.drools.process.command.impl;
 
 import org.drools.StatefulSession;
-import org.drools.process.command.Command;
+import org.drools.command.Context;
+import org.drools.command.impl.GenericCommand;
 import org.drools.process.command.CommandService;
 import org.drools.process.command.Interceptor;
 
@@ -9,8 +10,8 @@
 
 	private CommandService next;
 	
-	public StatefulSession getSession() {
-		return next.getSession();
+	public Context getContext() {
+		return next.getContext();
 	}
 	
 	public void setNext(CommandService commandService) {
@@ -21,12 +22,8 @@
 		return next;
 	}
 
-	protected <T> T executeNext(Command<T> command) {
+	protected <T> T executeNext(GenericCommand<T> command) {
 		return next.execute(command);
 	}
-	
-	public void dispose() {
-		next.dispose();
-	}
 
 }

Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/command/impl/AsynchronousInterceptor.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/command/impl/AsynchronousInterceptor.java	2009-07-13 05:17:35 UTC (rev 27930)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/command/impl/AsynchronousInterceptor.java	2009-07-13 06:08:05 UTC (rev 27931)
@@ -1,10 +1,10 @@
 package org.drools.process.command.impl;
 
-import org.drools.process.command.Command;
+import org.drools.command.impl.GenericCommand;
 
 public class AsynchronousInterceptor extends AbstractInterceptor {
 
-	public <T> T execute(final Command<T> command) {
+	public <T> T execute(final GenericCommand<T> command) {
 		new Thread(new Runnable() {
 			public void run() {
 				executeNext(command);

Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/command/impl/CommandBasedStatefulKnowledgeSession.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/command/impl/CommandBasedStatefulKnowledgeSession.java	2009-07-13 05:17:35 UTC (rev 27930)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/command/impl/CommandBasedStatefulKnowledgeSession.java	2009-07-13 06:08:05 UTC (rev 27931)
@@ -1,19 +1,15 @@
 package org.drools.process.command.impl;
 
-import java.util.ArrayList;
 import java.util.Collection;
-import java.util.HashMap;
 import java.util.Map;
 
 import org.drools.KnowledgeBase;
 import org.drools.command.Command;
+import org.drools.command.impl.KnowledgeCommandContext;
 import org.drools.event.process.ProcessEventListener;
 import org.drools.event.rule.AgendaEventListener;
 import org.drools.event.rule.WorkingMemoryEventListener;
 import org.drools.impl.StatefulKnowledgeSessionImpl;
-import org.drools.impl.StatefulKnowledgeSessionImpl.AgendaEventListenerWrapper;
-import org.drools.impl.StatefulKnowledgeSessionImpl.ProcessEventListenerWrapper;
-import org.drools.impl.StatefulKnowledgeSessionImpl.WorkingMemoryEventListenerWrapper;
 import org.drools.process.command.AbortWorkItemCommand;
 import org.drools.process.command.AddEventListenerCommand;
 import org.drools.process.command.AgendaGroupSetFocusCommand;
@@ -23,6 +19,8 @@
 import org.drools.process.command.ClearRuleFlowGroupCommand;
 import org.drools.process.command.CommandService;
 import org.drools.process.command.CompleteWorkItemCommand;
+import org.drools.process.command.DisposeCommand;
+import org.drools.process.command.ExecuteCommand;
 import org.drools.process.command.FireAllRulesCommand;
 import org.drools.process.command.FireUntilHaltCommand;
 import org.drools.process.command.GetAgendaEventListenersCommand;
@@ -54,7 +52,6 @@
 import org.drools.process.command.StartProcessCommand;
 import org.drools.process.command.UnregisterExitPointCommand;
 import org.drools.process.command.UpdateCommand;
-import org.drools.reteoo.ReteooWorkingMemory;
 import org.drools.runtime.Environment;
 import org.drools.runtime.ExecutionResults;
 import org.drools.runtime.ExitPoint;
@@ -78,20 +75,16 @@
     implements
     StatefulKnowledgeSession {
 
-    private CommandService                                                    commandService;
-    private transient WorkItemManager                                         workItemManager;
-    private transient Agenda												  agenda;
+    private CommandService            commandService;
+    private transient WorkItemManager workItemManager;
+    private transient Agenda          agenda;
 
-    public Map<WorkingMemoryEventListener, WorkingMemoryEventListenerWrapper> mappedWorkingMemoryListeners = new HashMap<WorkingMemoryEventListener, WorkingMemoryEventListenerWrapper>();
-    public Map<AgendaEventListener, AgendaEventListenerWrapper>               mappedAgendaListeners = new HashMap<AgendaEventListener, AgendaEventListenerWrapper>();
-    public Map<ProcessEventListener, ProcessEventListenerWrapper>             mappedProcessListeners = new HashMap<ProcessEventListener, ProcessEventListenerWrapper>();
-
     public CommandBasedStatefulKnowledgeSession(CommandService commandService) {
         this.commandService = commandService;
     }
-    
+
     public int getId() {
-        return ((ReteooWorkingMemory)this.commandService.getSession()).getId();
+        return ((StatefulKnowledgeSessionImpl) ((KnowledgeCommandContext) this.commandService.getContext()).getStatefulKnowledgesession()).getId();
     }
 
     public ProcessInstance getProcessInstance(long id) {
@@ -99,11 +92,11 @@
         command.setProcessInstanceId( id );
         return commandService.execute( command );
     }
-    
+
     public void abortProcessInstance(long id) {
-    	SetProcessInstanceStateCommand command = new SetProcessInstanceStateCommand();
-    	command.setProcessInstanceId( id );
-    	command.setState( ProcessInstance.STATE_ABORTED );
+        SetProcessInstanceStateCommand command = new SetProcessInstanceStateCommand();
+        command.setProcessInstanceId( id );
+        command.setState( ProcessInstance.STATE_ABORTED );
         commandService.execute( command );
     }
 
@@ -146,7 +139,8 @@
 
     public void signalEvent(String type,
                             Object event) {
-        SignalEventCommand command = new SignalEventCommand(type, event);
+        SignalEventCommand command = new SignalEventCommand( type,
+                                                             event );
         commandService.execute( command );
     }
 
@@ -164,7 +158,7 @@
     }
 
     public void dispose() {
-        commandService.dispose();
+        commandService.execute( new DisposeCommand() );
     }
 
     public int fireAllRules() {
@@ -205,54 +199,58 @@
     public Agenda getAgenda() {
         if ( agenda == null ) {
             agenda = new Agenda() {
-				public void clear() {
+                public void clear() {
                     ClearAgendaCommand command = new ClearAgendaCommand();
                     commandService.execute( command );
-				}
+                }
 
-				public ActivationGroup getActivationGroup(final String name) {
-					return new ActivationGroup() {
-						public void clear() {
-							ClearActivationGroupCommand command = new ClearActivationGroupCommand();
-							command.setName(name);
-						    commandService.execute( command );
-						}
-						public String getName() {
-							return name;
-						}
-					};
-				}
+                public ActivationGroup getActivationGroup(final String name) {
+                    return new ActivationGroup() {
+                        public void clear() {
+                            ClearActivationGroupCommand command = new ClearActivationGroupCommand();
+                            command.setName( name );
+                            commandService.execute( command );
+                        }
 
-				public AgendaGroup getAgendaGroup(final String name) {
-					return new AgendaGroup() {
-						public void clear() {
-							ClearAgendaGroupCommand command = new ClearAgendaGroupCommand();
-							command.setName(name);
-						    commandService.execute( command );
-						}
-						public String getName() {
-							return name;
-						}
-						public void setFocus() {
-							AgendaGroupSetFocusCommand command = new AgendaGroupSetFocusCommand();
-							command.setName(name);
-						    commandService.execute( command );
-						}
-					};
-				}
+                        public String getName() {
+                            return name;
+                        }
+                    };
+                }
 
-				public RuleFlowGroup getRuleFlowGroup(final String name) {
-					return new RuleFlowGroup() {
-						public void clear() {
-							ClearRuleFlowGroupCommand command = new ClearRuleFlowGroupCommand();
-							command.setName(name);
-						    commandService.execute( command );
-						}
-						public String getName() {
-							return name;
-						}
-					};
-				}
+                public AgendaGroup getAgendaGroup(final String name) {
+                    return new AgendaGroup() {
+                        public void clear() {
+                            ClearAgendaGroupCommand command = new ClearAgendaGroupCommand();
+                            command.setName( name );
+                            commandService.execute( command );
+                        }
+
+                        public String getName() {
+                            return name;
+                        }
+
+                        public void setFocus() {
+                            AgendaGroupSetFocusCommand command = new AgendaGroupSetFocusCommand();
+                            command.setName( name );
+                            commandService.execute( command );
+                        }
+                    };
+                }
+
+                public RuleFlowGroup getRuleFlowGroup(final String name) {
+                    return new RuleFlowGroup() {
+                        public void clear() {
+                            ClearRuleFlowGroupCommand command = new ClearRuleFlowGroupCommand();
+                            command.setName( name );
+                            commandService.execute( command );
+                        }
+
+                        public String getName() {
+                            return name;
+                        }
+                    };
+                }
             };
         }
         return agenda;
@@ -262,20 +260,20 @@
         return this.commandService.execute( new GetFactHandleCommand( object ) );
     }
 
-    public <T extends org.drools.runtime.rule.FactHandle> Collection< T > getFactHandles() {
+    public <T extends org.drools.runtime.rule.FactHandle> Collection<T> getFactHandles() {
         return (Collection<T>) this.commandService.execute( new GetFactHandlesCommand() );
 
     }
 
-    public <T extends org.drools.runtime.rule.FactHandle> Collection< T > getFactHandles(ObjectFilter filter) {
+    public <T extends org.drools.runtime.rule.FactHandle> Collection<T> getFactHandles(ObjectFilter filter) {
         return (Collection<T>) this.commandService.execute( new GetFactHandlesCommand( filter ) );
     }
 
-    public Collection< Object > getObjects() {
+    public Collection<Object> getObjects() {
         return getObjects( null );
     }
 
-    public Collection< Object > getObjects(ObjectFilter filter) {
+    public Collection<Object> getObjects(ObjectFilter filter) {
         Collection result = commandService.execute( new GetObjectsCommand( filter ) );
         return result;
     }
@@ -292,7 +290,7 @@
     public Collection< ? extends WorkingMemoryEntryPoint> getWorkingMemoryEntryPoints() {
         return this.commandService.execute( new GetWorkingMemoryEntryPointsCommand() );
     }
-    
+
     public void halt() {
         this.commandService.execute( new HaltCommand() );
     }
@@ -312,84 +310,39 @@
     }
 
     public void addEventListener(WorkingMemoryEventListener listener) {
-        WorkingMemoryEventListenerWrapper wrapper = new StatefulKnowledgeSessionImpl.WorkingMemoryEventListenerWrapper( listener );
-
-        this.mappedWorkingMemoryListeners.put( listener,
-                                               wrapper );
-
-        commandService.execute( new AddEventListenerCommand( wrapper ) );
+        commandService.execute( new AddEventListenerCommand( listener ) );
     }
 
     public void addEventListener(AgendaEventListener listener) {
-        AgendaEventListenerWrapper wrapper = new StatefulKnowledgeSessionImpl.AgendaEventListenerWrapper( listener );
-
-        this.mappedAgendaListeners.put( listener,
-                                        wrapper );
-
-        commandService.execute( new AddEventListenerCommand( wrapper ) );
+        commandService.execute( new AddEventListenerCommand( listener ) );
     }
 
     public Collection<AgendaEventListener> getAgendaEventListeners() {
-        Collection<org.drools.event.AgendaEventListener> listeners = commandService.execute( new GetAgendaEventListenersCommand() );
-        Collection<AgendaEventListener> result = new ArrayList<AgendaEventListener>();
-
-        for ( org.drools.event.AgendaEventListener listener : listeners ) {
-            AgendaEventListenerWrapper wrapper = (AgendaEventListenerWrapper) listener;
-            result.add( wrapper.unWrap() );
-        }
-
-        return result;
+        return commandService.execute( new GetAgendaEventListenersCommand() );
     }
 
     public Collection<WorkingMemoryEventListener> getWorkingMemoryEventListeners() {
-        Collection<org.drools.event.WorkingMemoryEventListener> listeners = commandService.execute( new GetWorkingMemoryEventListenersCommand() );
-        Collection<WorkingMemoryEventListener> result = new ArrayList<WorkingMemoryEventListener>();
-
-        for ( org.drools.event.WorkingMemoryEventListener listener : listeners ) {
-            WorkingMemoryEventListenerWrapper wrapper = (WorkingMemoryEventListenerWrapper) listener;
-            result.add( wrapper.unWrap() );
-        }
-
-        return result;
+        return commandService.execute( new GetWorkingMemoryEventListenersCommand() );
     }
 
     public void removeEventListener(WorkingMemoryEventListener listener) {
-        WorkingMemoryEventListenerWrapper wrapper = this.mappedWorkingMemoryListeners.remove( listener );
-
-        commandService.execute( new RemoveEventListenerCommand( wrapper ) );
+        commandService.execute( new RemoveEventListenerCommand( listener ) );
     }
 
     public void removeEventListener(AgendaEventListener listener) {
-        AgendaEventListenerWrapper wrapper = this.mappedAgendaListeners.remove( listener );
-
-        commandService.execute( new RemoveEventListenerCommand( wrapper ) );
+        commandService.execute( new RemoveEventListenerCommand( listener ) );
     }
 
     public void addEventListener(ProcessEventListener listener) {
-        ProcessEventListenerWrapper wrapper = new StatefulKnowledgeSessionImpl.ProcessEventListenerWrapper( listener );
-
-        this.mappedProcessListeners.put( listener,
-                                         wrapper );
-
-        commandService.execute( new AddEventListenerCommand( wrapper ) );
+        commandService.execute( new AddEventListenerCommand( listener ) );
     }
 
     public Collection<ProcessEventListener> getProcessEventListeners() {
-        Collection<org.drools.event.RuleFlowEventListener> listeners = commandService.execute( new GetProcessEventListenersCommand() );
-        Collection<ProcessEventListener> result = new ArrayList<ProcessEventListener>();
-
-        for ( org.drools.event.RuleFlowEventListener listener : listeners ) {
-            ProcessEventListenerWrapper wrapper = (ProcessEventListenerWrapper) listener;
-            result.add( wrapper.unWrap() );
-        }
-
-        return result;
+        return commandService.execute( new GetProcessEventListenersCommand() );
     }
 
     public void removeEventListener(ProcessEventListener listener) {
-        ProcessEventListenerWrapper wrapper = this.mappedProcessListeners.remove( listener );
-
-        commandService.execute( new RemoveEventListenerCommand( wrapper ) );
+        commandService.execute( new RemoveEventListenerCommand( listener ) );
     }
 
     public Object getGlobal(String identifier) {
@@ -413,29 +366,24 @@
     public Environment getEnvironment() {
         return commandService.execute( new GetEnvironmentCommand() );
     }
-    
-    public ExecutionResults execute(Command command) {        
-        try {            
-            ((ReteooWorkingMemory)this.commandService.getSession()).startBatchExecution();
-            
-            this.commandService.execute( (org.drools.process.command.Command) command );
-            
-            ExecutionResults result = ((ReteooWorkingMemory)this.commandService.getSession()).getExecutionResult();
-            return result;
-        } finally {
-            ((ReteooWorkingMemory)this.commandService.getSession()).endBatchExecution();
-        }
+
+    public ExecutionResults execute(Command command) {
+        return this.commandService.execute( new ExecuteCommand( command ) );
     }
 
     public QueryResults getQueryResults(String query) {
-        QueryCommand cmd = new QueryCommand(null, query, null);
+        QueryCommand cmd = new QueryCommand( null,
+                                             query,
+                                             null );
         return this.commandService.execute( cmd );
     }
 
     public QueryResults getQueryResults(String query,
                                         Object[] arguments) {
-        QueryCommand cmd = new QueryCommand(null, query, arguments);
+        QueryCommand cmd = new QueryCommand( null,
+                                             query,
+                                             arguments );
         return this.commandService.execute( cmd );
-    }    
+    }
 
 }
\ No newline at end of file

Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/command/impl/DefaultCommandService.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/command/impl/DefaultCommandService.java	2009-07-13 05:17:35 UTC (rev 27930)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/command/impl/DefaultCommandService.java	2009-07-13 06:08:05 UTC (rev 27931)
@@ -1,28 +1,25 @@
 package org.drools.process.command.impl;
 
 import org.drools.StatefulSession;
-import org.drools.process.command.Command;
+import org.drools.command.Context;
+import org.drools.command.impl.GenericCommand;
 import org.drools.process.command.CommandService;
 import org.drools.reteoo.ReteooWorkingMemory;
 
 public class DefaultCommandService implements CommandService {
 
-	private ReteooWorkingMemory session;
+	private Context context;
 	
-	public DefaultCommandService(StatefulSession session) {
-		this.session = ( ReteooWorkingMemory ) session;
+	public DefaultCommandService(Context context) {
+		this.context = context;
 	}
 	
-	public StatefulSession getSession() {
-		return ( StatefulSession ) session;
+	public Context getContext() {
+		return context;
 	}
 	
-	public <T> T execute(Command<T> command) {
-		return command.execute(session);
+	public <T> T execute(GenericCommand<T> command) {
+		return command.execute(context);
 	}
-	
-	public void dispose() {
-		session.dispose();
-	}
 
-}
+}
\ No newline at end of file

Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/command/impl/LoggingInterceptor.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/command/impl/LoggingInterceptor.java	2009-07-13 05:17:35 UTC (rev 27930)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/process/command/impl/LoggingInterceptor.java	2009-07-13 06:08:05 UTC (rev 27931)
@@ -1,10 +1,12 @@
 package org.drools.process.command.impl;
 
-import org.drools.process.command.Command;
+import org.drools.command.Command;
+import org.drools.command.impl.GenericCommand;
 
+
 public class LoggingInterceptor extends AbstractInterceptor {
 
-	public <T> T execute(Command<T> command) {
+	public <T> T execute(GenericCommand<T> command) {
 		System.out.println("Executing --> " + command);
 		T result = executeNext(command);
 		System.out.println("Done executing --> " + command);

Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/runtime/help/impl/BatchExecutionHelperProviderImpl.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/runtime/help/impl/BatchExecutionHelperProviderImpl.java	2009-07-13 05:17:35 UTC (rev 27930)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/runtime/help/impl/BatchExecutionHelperProviderImpl.java	2009-07-13 06:08:05 UTC (rev 27931)
@@ -35,7 +35,7 @@
 import org.drools.runtime.ExecutionResults;
 import org.drools.runtime.help.BatchExecutionHelperProvider;
 import org.drools.runtime.impl.BatchExecutionImpl;
-import org.drools.runtime.impl.BatchExecutionResultImpl;
+import org.drools.runtime.impl.ExecutionResultImpl;
 import org.drools.runtime.rule.FactHandle;
 import org.drools.runtime.rule.QueryResults;
 import org.drools.runtime.rule.QueryResultsRow;
@@ -94,7 +94,7 @@
         xstream.alias( "get-objects",
                        GetObjectsCommand.class );
         xstream.alias( "execution-results",
-                       BatchExecutionResultImpl.class );
+                       ExecutionResultImpl.class );
         xstream.alias( "fire-all-rules",
                        FireAllRulesCommand.class );
         xstream.alias( "query",
@@ -870,7 +870,7 @@
                 writer.endNode();
             }
 
-            for ( String identifier : ((BatchExecutionResultImpl) result).getFactHandles().keySet() ) {
+            for ( String identifier : ((ExecutionResultImpl) result).getFactHandles().keySet() ) {
 
                 Object handle = result.getFactHandle( identifier );
                 if ( handle instanceof FactHandle ) {
@@ -900,7 +900,7 @@
 
         public Object unmarshal(HierarchicalStreamReader reader,
                                 UnmarshallingContext context) {
-            BatchExecutionResultImpl result = new BatchExecutionResultImpl();
+            ExecutionResultImpl result = new ExecutionResultImpl();
             Map results = result.getResults();
             Map facts = result.getFactHandles();
 

Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/runtime/impl/BatchExecutionImpl.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/runtime/impl/BatchExecutionImpl.java	2009-07-13 05:17:35 UTC (rev 27930)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/runtime/impl/BatchExecutionImpl.java	2009-07-13 06:08:05 UTC (rev 27931)
@@ -1,26 +1,31 @@
 package org.drools.runtime.impl;
 
+import java.util.Collection;
 import java.util.List;
 
-import org.drools.process.command.Command;
+import org.drools.command.Context;
+import org.drools.command.impl.GenericCommand;
+import org.drools.command.impl.KnowledgeCommandContext;
 import org.drools.reteoo.ReteooWorkingMemory;
+import org.drools.runtime.StatefulKnowledgeSession;
+import org.drools.runtime.process.ProcessInstance;
 
 
-public class BatchExecutionImpl implements Command<Void> {
-	private List<Command> commands;
+public class BatchExecutionImpl implements GenericCommand<Void> {
+	private List<GenericCommand> commands;
 
-	public BatchExecutionImpl(List<Command> commands) {
+	public BatchExecutionImpl(List<GenericCommand> commands) {
         super();
         this.commands = commands;
     }
 
-    public List<Command> getCommands() {
+    public List<GenericCommand> getCommands() {
         return commands;
     }
 
-    public Void execute(ReteooWorkingMemory session) {
-        for ( Command command : commands ) {
-            ((org.drools.process.command.Command)command).execute( session );
+    public Void execute(Context context) {
+        for ( GenericCommand command : commands ) {
+            ((GenericCommand)command).execute( context );
         }
         return null;
     }	

Deleted: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/runtime/impl/BatchExecutionResultImpl.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/runtime/impl/BatchExecutionResultImpl.java	2009-07-13 05:17:35 UTC (rev 27930)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/runtime/impl/BatchExecutionResultImpl.java	2009-07-13 06:08:05 UTC (rev 27931)
@@ -1,46 +0,0 @@
-package org.drools.runtime.impl;
-
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Map;
-
-import org.drools.runtime.ExecutionResults;
-
-public class BatchExecutionResultImpl implements ExecutionResults {
-    Map<String, Object> results = new HashMap<String, Object>();    
-    Map<String, Object> facts = new HashMap<String, Object>();
-    
-    /* (non-Javadoc)
-     * @see org.drools.batchexecution.BatchExecutionResult#getIdentifiers()
-     */
-    public Collection<String> getIdentifiers() {
-        return this.results.keySet();
-    }
-    
-    public Object getValue(String identifier) {
-        return this.results.get( identifier );
-    }
-    
-    public Object getFactHandle(String identifier) {
-        return this.facts.get( identifier );
-    }
-
-    /* (non-Javadoc)
-     * @see org.drools.batchexecution.BatchExecutionResult#getResults()
-     */
-    public Map<String, Object> getResults() {
-        return this.results;
-    }
-
-    public void setResults(Map<String, Object> results) {
-        this.results = results;
-    }
-    
-    public Map<String, Object> getFactHandles() {
-        return this.facts;
-    }    
-    
-    public void setFactHandles(Map<String, Object> facts) {
-        this.facts = facts;
-    }
-}

Copied: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/runtime/impl/ExecutionResultImpl.java (from rev 27859, labs/jbossrules/trunk/drools-core/src/main/java/org/drools/runtime/impl/BatchExecutionResultImpl.java)
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/runtime/impl/ExecutionResultImpl.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/runtime/impl/ExecutionResultImpl.java	2009-07-13 06:08:05 UTC (rev 27931)
@@ -0,0 +1,46 @@
+package org.drools.runtime.impl;
+
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.drools.runtime.ExecutionResults;
+
+public class ExecutionResultImpl implements ExecutionResults {
+    Map<String, Object> results = new HashMap<String, Object>();    
+    Map<String, Object> facts = new HashMap<String, Object>();
+    
+    /* (non-Javadoc)
+     * @see org.drools.batchexecution.BatchExecutionResult#getIdentifiers()
+     */
+    public Collection<String> getIdentifiers() {
+        return this.results.keySet();
+    }
+    
+    public Object getValue(String identifier) {
+        return this.results.get( identifier );
+    }
+    
+    public Object getFactHandle(String identifier) {
+        return this.facts.get( identifier );
+    }
+
+    /* (non-Javadoc)
+     * @see org.drools.batchexecution.BatchExecutionResult#getResults()
+     */
+    public Map<String, Object> getResults() {
+        return this.results;
+    }
+
+    public void setResults(Map<String, Object> results) {
+        this.results = results;
+    }
+    
+    public Map<String, Object> getFactHandles() {
+        return this.facts;
+    }    
+    
+    public void setFactHandles(Map<String, Object> facts) {
+        this.facts = facts;
+    }
+}

Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/xml/ExtensibleXmlParser.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/xml/ExtensibleXmlParser.java	2009-07-13 05:17:35 UTC (rev 27930)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/xml/ExtensibleXmlParser.java	2009-07-13 06:08:05 UTC (rev 27931)
@@ -251,7 +251,7 @@
         if ( !localParser.isNamespaceAware() ) {
             throw new RuntimeException( "parser must be namespace-aware" );
         }
-
+        
         localParser.parse( in,
                            this );
 


Property changes on: labs/jbossrules/trunk/drools-simulator
___________________________________________________________________
Name: svn:ignore
   + .settings
target


Added: labs/jbossrules/trunk/drools-simulator/.classpath
===================================================================
--- labs/jbossrules/trunk/drools-simulator/.classpath	                        (rev 0)
+++ labs/jbossrules/trunk/drools-simulator/.classpath	2009-07-13 06:08:05 UTC (rev 27931)
@@ -0,0 +1,23 @@
+<classpath>
+  <classpathentry kind="src" path="src/main/java"/>
+  <classpathentry kind="src" path="src/main/resources" excluding="**/*.java"/>
+  <classpathentry kind="src" path="src/test/java" output="target/test-classes"/>
+  <classpathentry kind="src" path="src/test/resources" output="target/test-classes" including="**" excluding="**/*.java"/>
+  <classpathentry kind="output" path="target/classes"/>
+  <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+  <classpathentry kind="var" path="M2_REPO/org/antlr/antlr-runtime/3.1.1/antlr-runtime-3.1.1.jar"/>
+  <classpathentry kind="var" path="M2_REPO/cglib/cglib-nodep/2.1_3/cglib-nodep-2.1_3.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/eclipse/jdt/core/3.4.2.v_883_R34x/core-3.4.2.v_883_R34x.jar"/>
+  <classpathentry kind="src" path="/drools-api"/>
+  <classpathentry kind="src" path="/drools-compiler"/>
+  <classpathentry kind="src" path="/drools-core"/>
+  <classpathentry kind="var" path="M2_REPO/org/hamcrest/hamcrest-core/1.1/hamcrest-core-1.1.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/hamcrest/hamcrest-library/1.1/hamcrest-library-1.1.jar"/>
+  <classpathentry kind="var" path="M2_REPO/janino/janino/2.5.15/janino-2.5.15.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/jmock/jmock/2.5.1/jmock-2.5.1.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/jmock/jmock-legacy/2.5.1/jmock-legacy-2.5.1.jar"/>
+  <classpathentry kind="var" path="M2_REPO/joda-time/joda-time/1.6/joda-time-1.6.jar"/>
+  <classpathentry kind="var" path="M2_REPO/junit/junit/4.6/junit-4.6.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/mvel/mvel2/2.0.12-SNAPSHOT/mvel2-2.0.12-SNAPSHOT.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/objenesis/objenesis/1.0/objenesis-1.0.jar"/>
+</classpath>
\ No newline at end of file

Added: labs/jbossrules/trunk/drools-simulator/.project
===================================================================
--- labs/jbossrules/trunk/drools-simulator/.project	                        (rev 0)
+++ labs/jbossrules/trunk/drools-simulator/.project	2009-07-13 06:08:05 UTC (rev 27931)
@@ -0,0 +1,17 @@
+<projectDescription>
+  <name>drools-simulator</name>
+  <comment>A rule production system</comment>
+  <projects>
+    <project>drools-api</project>
+    <project>drools-compiler</project>
+    <project>drools-core</project>
+  </projects>
+  <buildSpec>
+    <buildCommand>
+      <name>org.eclipse.jdt.core.javabuilder</name>
+    </buildCommand>
+  </buildSpec>
+  <natures>
+    <nature>org.eclipse.jdt.core.javanature</nature>
+  </natures>
+</projectDescription>
\ No newline at end of file

Added: labs/jbossrules/trunk/drools-simulator/pom.xml
===================================================================
--- labs/jbossrules/trunk/drools-simulator/pom.xml	                        (rev 0)
+++ labs/jbossrules/trunk/drools-simulator/pom.xml	2009-07-13 06:08:05 UTC (rev 27931)
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+  <modelVersion>4.0.0</modelVersion>
+  <parent>
+    <artifactId>drools</artifactId>
+    <groupId>org.drools</groupId>
+  <version>5.1.0.SNAPSHOT</version>
+  </parent>
+
+  <artifactId>drools-simulator</artifactId>
+  <packaging>jar</packaging>
+  <name>Drools :: Simulator</name>
+  
+  
+  <dependencies>
+    <!-- Internal dependencies -->
+    <dependency>
+      <groupId>org.drools</groupId>
+      <artifactId>drools-core</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.drools</groupId>
+      <artifactId>drools-compiler</artifactId>
+    </dependency>      
+  </dependencies>
+
+</project>

Added: labs/jbossrules/trunk/drools-simulator/src/main/java/org/drools/simulation/GetVariableCommand.java
===================================================================
--- labs/jbossrules/trunk/drools-simulator/src/main/java/org/drools/simulation/GetVariableCommand.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-simulator/src/main/java/org/drools/simulation/GetVariableCommand.java	2009-07-13 06:08:05 UTC (rev 27931)
@@ -0,0 +1,31 @@
+package org.drools.simulation;
+
+import org.drools.builder.KnowledgeBuilder;
+import org.drools.builder.KnowledgeBuilderConfiguration;
+import org.drools.builder.KnowledgeBuilderFactory;
+import org.drools.builder.ResourceConfiguration;
+import org.drools.builder.ResourceType;
+import org.drools.command.Command;
+import org.drools.command.Context;
+import org.drools.command.impl.GenericCommand;
+import org.drools.io.Resource;
+import org.drools.simulation.impl.Simulator;
+
+public class GetVariableCommand
+    implements
+    GenericCommand<Object> {
+    private String identifier;
+    private String contextName;
+
+    public GetVariableCommand(String identifier,
+                              String contextName) {
+        this.identifier = identifier;
+        this.contextName = contextName;
+    }
+
+    public Object execute(Context ctx) {
+        ctx = ctx.getContextManager().getContext( this.contextName );
+        return ctx.get( this.identifier );
+    }
+
+}

Added: labs/jbossrules/trunk/drools-simulator/src/main/java/org/drools/simulation/KnowledgeBaseAddKnowledgePackagesCommand.java
===================================================================
--- labs/jbossrules/trunk/drools-simulator/src/main/java/org/drools/simulation/KnowledgeBaseAddKnowledgePackagesCommand.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-simulator/src/main/java/org/drools/simulation/KnowledgeBaseAddKnowledgePackagesCommand.java	2009-07-13 06:08:05 UTC (rev 27931)
@@ -0,0 +1,27 @@
+package org.drools.simulation;
+
+import org.drools.KnowledgeBase;
+import org.drools.builder.KnowledgeBuilder;
+import org.drools.builder.ResourceConfiguration;
+import org.drools.builder.ResourceType;
+import org.drools.command.Context;
+import org.drools.command.impl.GenericCommand;
+import org.drools.command.impl.KnowledgeCommandContext;
+import org.drools.io.Resource;
+
+public class KnowledgeBaseAddKnowledgePackagesCommand
+    implements
+    GenericCommand<Void> {
+
+    public KnowledgeBaseAddKnowledgePackagesCommand() {
+    }
+
+    public Void execute(Context context) {
+        KnowledgeBuilder kbuilder = ((KnowledgeCommandContext) context).getKnowledgeBuilder();
+        KnowledgeBase kbase = ((KnowledgeCommandContext) context).getKnowledgeBase();
+        
+        kbase.addKnowledgePackages( kbuilder.getKnowledgePackages() );
+        return null;
+    }
+
+}

Added: labs/jbossrules/trunk/drools-simulator/src/main/java/org/drools/simulation/KnowledgeBaseCommand.java
===================================================================
--- labs/jbossrules/trunk/drools-simulator/src/main/java/org/drools/simulation/KnowledgeBaseCommand.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-simulator/src/main/java/org/drools/simulation/KnowledgeBaseCommand.java	2009-07-13 06:08:05 UTC (rev 27931)
@@ -0,0 +1,11 @@
+package org.drools.simulation;
+
+import org.drools.builder.KnowledgeBuilder;
+import org.drools.command.Context;
+import org.drools.reteoo.ReteooWorkingMemory;
+
+public interface KnowledgeBaseCommand<T> extends org.drools.command.Command {
+	
+	T execute(Context context, Object[] args);
+	
+}

Added: labs/jbossrules/trunk/drools-simulator/src/main/java/org/drools/simulation/KnowledgeBuilderAddCommand.java
===================================================================
--- labs/jbossrules/trunk/drools-simulator/src/main/java/org/drools/simulation/KnowledgeBuilderAddCommand.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-simulator/src/main/java/org/drools/simulation/KnowledgeBuilderAddCommand.java	2009-07-13 06:08:05 UTC (rev 27931)
@@ -0,0 +1,40 @@
+package org.drools.simulation;
+
+import org.drools.builder.KnowledgeBuilder;
+import org.drools.builder.ResourceConfiguration;
+import org.drools.builder.ResourceType;
+import org.drools.command.Context;
+import org.drools.command.impl.GenericCommand;
+import org.drools.command.impl.KnowledgeCommandContext;
+import org.drools.io.Resource;
+
+public class KnowledgeBuilderAddCommand
+    implements
+    GenericCommand<Void> {
+
+    private Resource              resource;
+    private ResourceType          resourceType;
+    private ResourceConfiguration resourceConfiguration;
+
+    public KnowledgeBuilderAddCommand(Resource resource,
+                                      ResourceType resourceType,
+                                      ResourceConfiguration resourceConfiguration) {
+        this.resource = resource;
+        this.resourceType = resourceType;
+        this.resourceConfiguration = resourceConfiguration;
+    }
+
+    public Void execute(Context context) {
+        KnowledgeBuilder kbuilder = ((KnowledgeCommandContext) context).getKnowledgeBuilder();
+        if ( resourceConfiguration == null ) {
+            kbuilder.add( resource,
+                          resourceType );
+        } else {
+            kbuilder.add( resource,
+                          resourceType,
+                          resourceConfiguration );
+        }
+        return null;
+    }
+
+}

Added: labs/jbossrules/trunk/drools-simulator/src/main/java/org/drools/simulation/KnowledgeBuilderCommand.java
===================================================================
--- labs/jbossrules/trunk/drools-simulator/src/main/java/org/drools/simulation/KnowledgeBuilderCommand.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-simulator/src/main/java/org/drools/simulation/KnowledgeBuilderCommand.java	2009-07-13 06:08:05 UTC (rev 27931)
@@ -0,0 +1,11 @@
+package org.drools.simulation;
+
+import org.drools.builder.KnowledgeBuilder;
+import org.drools.command.Context;
+import org.drools.reteoo.ReteooWorkingMemory;
+
+public interface KnowledgeBuilderCommand<T> extends org.drools.command.Command {
+	
+	T execute(Context context, Object[] args);
+	
+}

Added: labs/jbossrules/trunk/drools-simulator/src/main/java/org/drools/simulation/KnowledgeContextResolveFromContextCommand.java
===================================================================
--- labs/jbossrules/trunk/drools-simulator/src/main/java/org/drools/simulation/KnowledgeContextResolveFromContextCommand.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-simulator/src/main/java/org/drools/simulation/KnowledgeContextResolveFromContextCommand.java	2009-07-13 06:08:05 UTC (rev 27931)
@@ -0,0 +1,44 @@
+package org.drools.simulation;
+
+import org.drools.KnowledgeBase;
+import org.drools.KnowledgeBaseConfiguration;
+import org.drools.KnowledgeBaseFactory;
+import org.drools.builder.KnowledgeBuilder;
+import org.drools.command.Command;
+import org.drools.command.Context;
+import org.drools.command.impl.GenericCommand;
+import org.drools.command.impl.KnowledgeCommandContext;
+import org.drools.runtime.StatefulKnowledgeSession;
+
+public class KnowledgeContextResolveFromContextCommand
+    implements
+    GenericCommand {
+
+    private String  kbaseIdentifier;
+    private String  kbuilderIdentifier;
+    private String  statefulKsessionName;
+    private Command command;
+
+    public KnowledgeContextResolveFromContextCommand(Command command,
+                                                     String kbuilderIdentifier,
+                                                     String kbaseIdentifier,
+                                                     String statefulKsessionName) {
+        this.command = command;
+        this.kbuilderIdentifier = kbuilderIdentifier;
+        this.kbaseIdentifier = kbaseIdentifier;
+        this.statefulKsessionName = statefulKsessionName;
+    }
+
+    public Object execute(Context context) {
+        KnowledgeCommandContext kcContext = new KnowledgeCommandContext( context,
+                                                                   (KnowledgeBuilder) context.get( this.kbuilderIdentifier ),
+                                                                   (KnowledgeBase) context.get( this.kbaseIdentifier ),
+                                                                   (StatefulKnowledgeSession) context.get( this.statefulKsessionName ));
+        return ((GenericCommand)command).execute( kcContext );
+    }
+    
+    public Command getCommand() {
+        return this.command;
+    }
+
+}

Added: labs/jbossrules/trunk/drools-simulator/src/main/java/org/drools/simulation/NewKnowledgeBaseCommand.java
===================================================================
--- labs/jbossrules/trunk/drools-simulator/src/main/java/org/drools/simulation/NewKnowledgeBaseCommand.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-simulator/src/main/java/org/drools/simulation/NewKnowledgeBaseCommand.java	2009-07-13 06:08:05 UTC (rev 27931)
@@ -0,0 +1,30 @@
+package org.drools.simulation;
+
+import org.drools.KnowledgeBase;
+import org.drools.KnowledgeBaseConfiguration;
+import org.drools.KnowledgeBaseFactory;
+import org.drools.command.Context;
+import org.drools.command.impl.GenericCommand;
+
+public class NewKnowledgeBaseCommand
+    implements
+    GenericCommand<KnowledgeBase> {
+
+    private KnowledgeBaseConfiguration kbaseConf;
+
+    public NewKnowledgeBaseCommand(KnowledgeBaseConfiguration kbaseConf) {
+        this.kbaseConf = kbaseConf;
+    }
+
+    public KnowledgeBase execute(Context context) {
+        KnowledgeBase kbase = null;
+        if ( this.kbaseConf == null ) {
+            kbase = KnowledgeBaseFactory.newKnowledgeBase();
+        } else {
+            kbase = KnowledgeBaseFactory.newKnowledgeBase( this.kbaseConf );
+        }
+
+        return kbase;
+    }
+
+}

Added: labs/jbossrules/trunk/drools-simulator/src/main/java/org/drools/simulation/NewKnowledgeBuilderCommand.java
===================================================================
--- labs/jbossrules/trunk/drools-simulator/src/main/java/org/drools/simulation/NewKnowledgeBuilderCommand.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-simulator/src/main/java/org/drools/simulation/NewKnowledgeBuilderCommand.java	2009-07-13 06:08:05 UTC (rev 27931)
@@ -0,0 +1,33 @@
+package org.drools.simulation;
+
+import org.drools.builder.KnowledgeBuilder;
+import org.drools.builder.KnowledgeBuilderConfiguration;
+import org.drools.builder.KnowledgeBuilderFactory;
+import org.drools.builder.ResourceConfiguration;
+import org.drools.builder.ResourceType;
+import org.drools.command.Context;
+import org.drools.command.impl.GenericCommand;
+import org.drools.io.Resource;
+
+public class NewKnowledgeBuilderCommand
+    implements
+    GenericCommand<KnowledgeBuilder> {
+
+    private KnowledgeBuilderConfiguration kbuilderConf;
+
+    public NewKnowledgeBuilderCommand(KnowledgeBuilderConfiguration kbuilderConf) {
+        this.kbuilderConf = kbuilderConf;
+    }
+
+    public KnowledgeBuilder execute(Context context) {
+        KnowledgeBuilder kbuilder = null;
+        if ( this.kbuilderConf == null ) {
+            kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();            
+        } else {
+            kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder( this.kbuilderConf );
+        }
+        
+        return kbuilder;
+    }
+
+}

Added: labs/jbossrules/trunk/drools-simulator/src/main/java/org/drools/simulation/NewStatefulKnowledgeSessionCommand.java
===================================================================
--- labs/jbossrules/trunk/drools-simulator/src/main/java/org/drools/simulation/NewStatefulKnowledgeSessionCommand.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-simulator/src/main/java/org/drools/simulation/NewStatefulKnowledgeSessionCommand.java	2009-07-13 06:08:05 UTC (rev 27931)
@@ -0,0 +1,35 @@
+package org.drools.simulation;
+
+import org.drools.KnowledgeBase;
+import org.drools.KnowledgeBaseConfiguration;
+import org.drools.KnowledgeBaseFactory;
+import org.drools.command.Context;
+import org.drools.command.impl.GenericCommand;
+import org.drools.command.impl.KnowledgeCommandContext;
+import org.drools.runtime.KnowledgeSessionConfiguration;
+import org.drools.runtime.StatefulKnowledgeSession;
+
+public class NewStatefulKnowledgeSessionCommand
+    implements
+    GenericCommand<StatefulKnowledgeSession> {
+
+    private KnowledgeSessionConfiguration ksessionConf;
+
+    public NewStatefulKnowledgeSessionCommand(KnowledgeSessionConfiguration ksessionConf) {
+        this.ksessionConf = ksessionConf;
+    }
+
+    public StatefulKnowledgeSession execute(Context context) {
+        KnowledgeBase kbase = ((KnowledgeCommandContext) context).getKnowledgeBase();
+        StatefulKnowledgeSession ksession;
+        
+        if ( this.ksessionConf == null ) {
+            ksession = kbase.newStatefulKnowledgeSession();
+        } else {
+            ksession = kbase.newStatefulKnowledgeSession( this.ksessionConf, null );
+        }
+
+        return ksession;
+    }
+
+}

Added: labs/jbossrules/trunk/drools-simulator/src/main/java/org/drools/simulation/Path.java
===================================================================
--- labs/jbossrules/trunk/drools-simulator/src/main/java/org/drools/simulation/Path.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-simulator/src/main/java/org/drools/simulation/Path.java	2009-07-13 06:08:05 UTC (rev 27931)
@@ -0,0 +1,9 @@
+package org.drools.simulation;
+
+import java.util.Collection;
+
+public interface Path {
+    String getName();
+    
+    Collection<Step> getSteps();
+}

Added: labs/jbossrules/trunk/drools-simulator/src/main/java/org/drools/simulation/SetVariableCommand.java
===================================================================
--- labs/jbossrules/trunk/drools-simulator/src/main/java/org/drools/simulation/SetVariableCommand.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-simulator/src/main/java/org/drools/simulation/SetVariableCommand.java	2009-07-13 06:08:05 UTC (rev 27931)
@@ -0,0 +1,27 @@
+package org.drools.simulation;
+
+import org.drools.command.Command;
+import org.drools.command.Context;
+import org.drools.command.impl.GenericCommand;
+
+public class SetVariableCommand
+    implements
+    GenericCommand<Void> {
+    private String identifier;
+    private String contextName;
+    private Command cmd;
+
+    public SetVariableCommand(String contextName,
+                              String identifier,                              
+                              Command cmd) {
+        this.identifier = identifier;
+        this.contextName = contextName;
+        this.cmd = cmd;
+    }
+
+    public Void execute(Context context) {
+        context.getContextManager().getContext( this.contextName ).set( this.identifier, ((GenericCommand)this.cmd).execute( context ) );
+        return null;
+    }
+
+}

Added: labs/jbossrules/trunk/drools-simulator/src/main/java/org/drools/simulation/Simulation.java
===================================================================
--- labs/jbossrules/trunk/drools-simulator/src/main/java/org/drools/simulation/Simulation.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-simulator/src/main/java/org/drools/simulation/Simulation.java	2009-07-13 06:08:05 UTC (rev 27931)
@@ -0,0 +1,7 @@
+package org.drools.simulation;
+
+import java.util.Map;
+
+public interface Simulation {
+    Map<String, Path> getPaths();
+}

Added: labs/jbossrules/trunk/drools-simulator/src/main/java/org/drools/simulation/Step.java
===================================================================
--- labs/jbossrules/trunk/drools-simulator/src/main/java/org/drools/simulation/Step.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-simulator/src/main/java/org/drools/simulation/Step.java	2009-07-13 06:08:05 UTC (rev 27931)
@@ -0,0 +1,10 @@
+package org.drools.simulation;
+
+import java.util.Collection;
+
+import org.drools.command.Command;
+
+public interface Step {
+    long getTemporalDistance();
+    Collection<Command> getCommands();
+}

Added: labs/jbossrules/trunk/drools-simulator/src/main/java/org/drools/simulation/impl/JUnitSimulationRunner.java
===================================================================
--- labs/jbossrules/trunk/drools-simulator/src/main/java/org/drools/simulation/impl/JUnitSimulationRunner.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-simulator/src/main/java/org/drools/simulation/impl/JUnitSimulationRunner.java	2009-07-13 06:08:05 UTC (rev 27931)
@@ -0,0 +1,139 @@
+package org.drools.simulation.impl;
+
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.drools.command.Command;
+import org.drools.command.Context;
+import org.drools.command.impl.GenericCommand;
+import org.drools.simulation.Path;
+import org.drools.simulation.Simulation;
+import org.drools.simulation.Step;
+import org.drools.simulation.impl.Simulator.CommandExecutionHandler;
+import org.junit.Test;
+import org.junit.runner.Description;
+import org.junit.runner.JUnitCore;
+import org.junit.runner.Request;
+import org.junit.runner.Runner;
+import org.junit.runner.notification.Failure;
+import org.junit.runner.notification.RunNotifier;
+
+public class JUnitSimulationRunner extends Runner {
+
+    private Description              descr;
+    private Map<String, Description> testGroups  = new HashMap<String, Description>();
+
+    private List<Simulation>         simulations = new ArrayList<Simulation>();
+
+    public JUnitSimulationRunner(Class cls) {
+        this.descr = Description.createSuiteDescription( cls );
+
+        Object object = null;
+        try {
+            object = cls.newInstance();
+        } catch ( Exception e ) {
+
+        }
+
+        List<Method> methods = new ArrayList<Method>();
+        for ( Method method : cls.getDeclaredMethods() ) {
+            if ( method.getReturnType().equals( Simulation.class ) && method.getAnnotation( Test.class ) != null ) {
+                methods.add( method );
+            }
+        }
+
+        try {
+            for ( Method method : methods ) {
+
+                Simulation simulation = (Simulation) method.invoke( object,
+                                                                    null );
+
+                for ( Path path : simulation.getPaths().values() ) {
+                    for ( Step step : path.getSteps() ) {
+                        for ( Command command : step.getCommands() ) {
+                            if ( command instanceof TestGroupCommand ) {
+                                String testName = ((TestGroupCommand) command).getName();
+                                Description testGroupDescr = Description.createTestDescription( cls,
+                                                                                                testName );
+                                this.descr.addChild( testGroupDescr );
+                                this.testGroups.put( testName,
+                                                     testGroupDescr );
+                            }
+                        }
+                    }
+                }
+
+                simulations.add( simulation );
+            }
+        } catch ( Exception e ) {
+        }
+
+        //        
+        //        System.out.println( "class:" + cls );
+        //        this.descr = Description.createSuiteDescription( cls );
+        //        this.descr1 = Description.createTestDescription( cls, "test1" );
+        //        this.descr2 = Description.createTestDescription( cls, "test2" );
+        //        
+        //        this.descr.addChild( descr1 );
+        //        this.descr.addChild( descr2 );                       
+
+    }
+
+    @Override
+    public Description getDescription() {
+        return this.descr;
+    }
+
+    @Override
+    public void run(RunNotifier notifier) {
+        JunitCommandExecutionHandler executionHandler = new JunitCommandExecutionHandler( notifier,
+                                                                                          this.testGroups );
+        for ( Simulation simulation : simulations ) {
+            Simulator simulator = new Simulator( simulation,
+                                                 System.currentTimeMillis() );
+            simulator.setCommandExecutionHandler( executionHandler );
+            simulator.run();
+        }
+
+    }
+
+    public static class JunitCommandExecutionHandler
+        implements
+        CommandExecutionHandler {
+        private RunNotifier              notifier;
+        private Map<String, Description> testGroups;
+
+        public JunitCommandExecutionHandler(RunNotifier notifier,
+                                            Map<String, Description> testGroups) {
+            super();
+            this.notifier = notifier;
+            this.testGroups = testGroups;
+        }
+
+        public Object execute(GenericCommand command,
+                              Context context) {
+            if ( command instanceof TestGroupCommand ) {
+                TestGroupCommand testGroupCmd = (TestGroupCommand) command;
+                Description descr = this.testGroups.get( testGroupCmd.getName() );
+                this.notifier.fireTestStarted( descr );
+                try {
+                    command.execute( context );
+                    this.notifier.fireTestFinished( descr );
+                    return null;
+                } catch ( Exception e ) {
+                    this.notifier.fireTestFailure( new Failure( descr,
+                                                                e ) );
+                    return null;
+                }
+            } else {
+                return command.execute( context );
+            }
+        }
+
+    }
+
+}

Added: labs/jbossrules/trunk/drools-simulator/src/main/java/org/drools/simulation/impl/PathImpl.java
===================================================================
--- labs/jbossrules/trunk/drools-simulator/src/main/java/org/drools/simulation/impl/PathImpl.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-simulator/src/main/java/org/drools/simulation/impl/PathImpl.java	2009-07-13 06:08:05 UTC (rev 27931)
@@ -0,0 +1,39 @@
+package org.drools.simulation.impl;
+
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.drools.command.Context;
+import org.drools.simulation.Path;
+import org.drools.simulation.Simulation;
+import org.drools.simulation.Step;
+
+public class PathImpl
+    implements
+    Path {
+    private SimulationImpl   simulation;
+
+    private String           name;
+
+    private Collection<Step> steps;
+
+    public PathImpl(Simulation simulation,
+                    String name) {
+        this.name = name;
+        this.simulation = (SimulationImpl) simulation;
+    }
+
+    public void setSteps(Collection<Step> steps) {
+        this.steps = steps;
+    }
+
+    public String getName() {
+        return this.name;
+    }
+
+    public Collection<Step> getSteps() {
+        return this.steps;
+    }
+
+}

Added: labs/jbossrules/trunk/drools-simulator/src/main/java/org/drools/simulation/impl/SimulationImpl.java
===================================================================
--- labs/jbossrules/trunk/drools-simulator/src/main/java/org/drools/simulation/impl/SimulationImpl.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-simulator/src/main/java/org/drools/simulation/impl/SimulationImpl.java	2009-07-13 06:08:05 UTC (rev 27931)
@@ -0,0 +1,21 @@
+package org.drools.simulation.impl;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.drools.command.Context;
+import org.drools.simulation.Path;
+import org.drools.simulation.Simulation;
+
+public class SimulationImpl implements Simulation {    
+    private Map<String, Path> paths;
+    
+    public SimulationImpl() {
+        this.paths = new HashMap<String, Path>();
+    }
+    
+    public Map<String, Path> getPaths() {
+        return this.paths;
+    }
+        
+}

Added: labs/jbossrules/trunk/drools-simulator/src/main/java/org/drools/simulation/impl/SimulationTest.java
===================================================================
--- labs/jbossrules/trunk/drools-simulator/src/main/java/org/drools/simulation/impl/SimulationTest.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-simulator/src/main/java/org/drools/simulation/impl/SimulationTest.java	2009-07-13 06:08:05 UTC (rev 27931)
@@ -0,0 +1,397 @@
+package org.drools.simulation.impl;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.drools.KnowledgeBase;
+import org.drools.KnowledgeBaseFactory;
+import org.drools.Person;
+import org.drools.builder.KnowledgeBuilder;
+import org.drools.builder.KnowledgeBuilderFactory;
+import org.drools.builder.ResourceType;
+import org.drools.command.Command;
+import org.drools.io.ResourceFactory;
+import org.drools.process.command.AssertEquals;
+import org.drools.process.command.FireAllRulesCommand;
+import org.drools.process.command.GetGlobalCommand;
+import org.drools.process.command.InsertObjectCommand;
+import org.drools.process.command.SetGlobalCommand;
+import org.drools.runtime.KnowledgeSessionConfiguration;
+import org.drools.runtime.StatefulKnowledgeSession;
+import org.drools.runtime.conf.ClockTypeOption;
+import org.drools.simulation.KnowledgeBaseAddKnowledgePackagesCommand;
+import org.drools.simulation.KnowledgeContextResolveFromContextCommand;
+import org.drools.simulation.NewStatefulKnowledgeSessionCommand;
+import org.drools.simulation.SetVariableCommand;
+import org.drools.simulation.KnowledgeBuilderAddCommand;
+import org.drools.simulation.NewKnowledgeBaseCommand;
+import org.drools.simulation.NewKnowledgeBuilderCommand;
+import org.drools.simulation.Simulation;
+import org.drools.simulation.Statement;
+import org.drools.simulation.Step;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import com.sun.org.apache.xalan.internal.xsltc.compiler.util.TestGenerator;
+
+import junit.framework.TestCase;
+
+import static junit.framework.Assert.*;
+
+ at RunWith(JUnitSimulationRunner.class)
+public class SimulationTest {
+
+    @Test
+    public Simulation testOnePathNoDSL() {
+
+        Simulation simulation = new SimulationImpl();
+
+        String str = "";
+        str += "package org.drools \n";
+        str += "global java.util.List list \n";
+        str += "rule rule1 \n";
+        str += "    dialect \"java\" \n";
+        str += "when \n";
+        str += "    $p : Person() \n";
+        str += "then \n";
+        str += "    list.add( $p ); \n";
+        str += "end \n";
+
+        PathImpl path = new PathImpl( simulation,
+                                      "path1" );
+
+        List<Step> steps = new ArrayList<Step>();
+
+        List<Command> cmds = new ArrayList<Command>();
+
+        cmds.add( new SetVariableCommand( "path1",
+                                          "kbuilder",
+                                          new NewKnowledgeBuilderCommand( null ) ) );
+
+        cmds.add( new KnowledgeContextResolveFromContextCommand( new KnowledgeBuilderAddCommand( ResourceFactory.newByteArrayResource( str.getBytes() ),
+                                                                                                 ResourceType.DRL,
+                                                                                                 null ),
+                                                                 "kbuilder",
+                                                                 null,
+                                                                 null ) );
+
+        cmds.add( new SetVariableCommand( "path1",
+                                          "kbase",
+                                          new NewKnowledgeBaseCommand( null ) ) );
+
+        cmds.add( new KnowledgeContextResolveFromContextCommand( new KnowledgeBaseAddKnowledgePackagesCommand(),
+                                                                 "kbuilder",
+                                                                 "kbase",
+                                                                 null ) );
+
+        KnowledgeSessionConfiguration ksessionConf = KnowledgeBaseFactory.newKnowledgeSessionConfiguration();
+        ksessionConf.setOption( ClockTypeOption.get( "pseudo" ) );
+
+        cmds.add( new SetVariableCommand( "path1",
+                                          "ksession",
+                                          new KnowledgeContextResolveFromContextCommand( new NewStatefulKnowledgeSessionCommand( ksessionConf ),
+                                                                                         "kbuilder",
+                                                                                         "kbase",
+                                                                                         null ) ) );
+
+        List list = new ArrayList();
+
+        cmds.add( new KnowledgeContextResolveFromContextCommand( new SetGlobalCommand( "list",
+                                                                                       list ),
+                                                                 "kbuilder",
+                                                                 "kbase",
+                                                                 "ksession" ) );
+
+        steps.add( new StepImpl( path,
+                                 cmds,
+                                 0 ) );
+
+        cmds = new ArrayList<Command>();
+        cmds.add( new KnowledgeContextResolveFromContextCommand( new InsertObjectCommand( new Person( "darth",
+                                                                                                      97 ) ),
+                                                                 "kbuilder",
+                                                                 "kbase",
+                                                                 "ksession" ) );
+        cmds.add( new KnowledgeContextResolveFromContextCommand( new FireAllRulesCommand(),
+                                                                 "kbuilder",
+                                                                 "kbase",
+                                                                 "ksession" ) );
+        steps.add( new StepImpl( path,
+                                 cmds,
+                                 2000 ) );
+
+        cmds = new ArrayList<Command>();
+        cmds.add( new KnowledgeContextResolveFromContextCommand( new InsertObjectCommand( new Person( "yoda",
+                                                                                                      98 ) ),
+                                                                 "kbuilder",
+                                                                 "kbase",
+                                                                 "ksession" ) );
+
+        cmds.add( new KnowledgeContextResolveFromContextCommand( new FireAllRulesCommand(),
+                                                                 "kbuilder",
+                                                                 "kbase",
+                                                                 "ksession" ) );
+        steps.add( new StepImpl( path,
+                                 cmds,
+                                 4000 ) );
+
+        cmds = new ArrayList<Command>();
+
+        cmds.add( new KnowledgeContextResolveFromContextCommand( new AssertEquals( "Check List size",
+                                                                                   2,
+                                                                                   new GetGlobalCommand( "list" ),
+                                                                                   "size()" ),
+                                                                 "kbuilder",
+                                                                 "kbase",
+                                                                 "ksession" ) );
+
+        cmds.add( new KnowledgeContextResolveFromContextCommand( new AssertEquals( "Check Person",
+                                                                                   new Person( "darth",
+                                                                                               97 ),
+                                                                                   new GetGlobalCommand( "list" ),
+                                                                                   "get( 0 )" ),
+                                                                 "kbuilder",
+                                                                 "kbase",
+                                                                 "ksession" ) );
+
+        cmds.add( new KnowledgeContextResolveFromContextCommand( new AssertEquals( "Check Person",
+                                                                                   new Person( "yoda",
+                                                                                               98 ),
+                                                                                   new GetGlobalCommand( "list" ),
+                                                                                   "get( 1 )" ),
+                                                                 "kbuilder",
+                                                                 "kbase",
+                                                                 "ksession" ) );
+
+        steps.add( new StepImpl( path,
+                                 new TestGroupCommand( "test1",
+                                                       cmds ),
+                                 5000 ) );
+
+        path.setSteps( steps );
+
+        simulation.getPaths().put( "path1",
+                                   path );
+
+        return simulation;
+
+        //        Simulator simulator = new Simulator( simulation,
+        //                                             System.currentTimeMillis() );
+        //
+        //        simulator.run();
+    }
+
+    @Test
+    public Simulation testTwoPathsNoDSL() {
+
+        Simulation simulation = new SimulationImpl();
+
+        String str = "";
+        str += "package org.drools \n";
+        str += "global java.util.List list \n";
+        str += "rule rule1 \n";
+        str += "    dialect \"java\" \n";
+        str += "when \n";
+        str += "    $p : Person() \n";
+        str += "then \n";
+        str += "    list.add( $p ); \n";
+        str += "end \n";
+
+        PathImpl path = new PathImpl( simulation,
+                                      "path1" );
+
+        List<Step> steps = new ArrayList<Step>();
+
+        List<Command> cmds = new ArrayList<Command>();
+
+        cmds.add( new SetVariableCommand( "ROOT",
+                                          "kbuilder",
+                                          new NewKnowledgeBuilderCommand( null ) ) );
+
+        cmds.add( new KnowledgeContextResolveFromContextCommand( new KnowledgeBuilderAddCommand( ResourceFactory.newByteArrayResource( str.getBytes() ),
+                                                                                                 ResourceType.DRL,
+                                                                                                 null ),
+                                                                 "kbuilder",
+                                                                 null,
+                                                                 null ) );
+
+        cmds.add( new SetVariableCommand( "ROOT",
+                                          "kbase",
+                                          new NewKnowledgeBaseCommand( null ) ) );
+
+        cmds.add( new KnowledgeContextResolveFromContextCommand( new KnowledgeBaseAddKnowledgePackagesCommand(),
+                                                                 "kbuilder",
+                                                                 "kbase",
+                                                                 null ) );
+
+        KnowledgeSessionConfiguration ksessionConf = KnowledgeBaseFactory.newKnowledgeSessionConfiguration();
+        ksessionConf.setOption( ClockTypeOption.get( "pseudo" ) );
+
+        cmds.add( new SetVariableCommand( "ROOT",
+                                          "ksession",
+                                          new KnowledgeContextResolveFromContextCommand( new NewStatefulKnowledgeSessionCommand( ksessionConf ),
+                                                                                         "kbuilder",
+                                                                                         "kbase",
+                                                                                         null ) ) );
+
+        List list = new ArrayList();
+
+        cmds.add( new KnowledgeContextResolveFromContextCommand( new SetGlobalCommand( "list",
+                                                                                       list ),
+                                                                 "kbuilder",
+                                                                 "kbase",
+                                                                 "ksession" ) );
+
+        steps.add( new StepImpl( path,
+                                 cmds,
+                                 0 ) );
+
+        cmds = new ArrayList<Command>();
+        cmds.add( new KnowledgeContextResolveFromContextCommand( new InsertObjectCommand( new Person( "darth",
+                                                                                                      97 ) ),
+                                                                 "kbuilder",
+                                                                 "kbase",
+                                                                 "ksession" ) );
+        cmds.add( new KnowledgeContextResolveFromContextCommand( new FireAllRulesCommand(),
+                                                                 "kbuilder",
+                                                                 "kbase",
+                                                                 "ksession" ) );
+        steps.add( new StepImpl( path,
+                                 cmds,
+                                 2000 ) );
+
+        cmds = new ArrayList<Command>();
+        cmds.add( new KnowledgeContextResolveFromContextCommand( new InsertObjectCommand( new Person( "yoda",
+                                                                                                      98 ) ),
+                                                                 "kbuilder",
+                                                                 "kbase",
+                                                                 "ksession" ) );
+        cmds.add( new KnowledgeContextResolveFromContextCommand( new FireAllRulesCommand(),
+                                                                 "kbuilder",
+                                                                 "kbase",
+                                                                 "ksession" ) );
+        steps.add( new StepImpl( path,
+                                 cmds,
+                                 4000 ) );
+
+        path.setSteps( steps );
+
+        simulation.getPaths().put( "path1",
+                                   path );
+
+        path = new PathImpl( simulation,
+                             "path2" );
+
+        steps = new ArrayList<Step>();
+
+        cmds = new ArrayList<Command>();
+        cmds.add( new KnowledgeContextResolveFromContextCommand( new InsertObjectCommand( new Person( "bobba",
+                                                                                                      77 ) ),
+                                                                 "kbuilder",
+                                                                 "kbase",
+                                                                 "ksession" ) );
+        cmds.add( new KnowledgeContextResolveFromContextCommand( new FireAllRulesCommand(),
+                                                                 "kbuilder",
+                                                                 "kbase",
+                                                                 "ksession" ) );
+        steps.add( new StepImpl( path,
+                                 cmds,
+                                 1500 ) );
+
+        cmds = new ArrayList<Command>();
+        cmds.add( new KnowledgeContextResolveFromContextCommand( new InsertObjectCommand( new Person( "luke",
+                                                                                                      30 ) ),
+                                                                 "kbuilder",
+                                                                 "kbase",
+                                                                 "ksession" ) );
+        cmds.add( new KnowledgeContextResolveFromContextCommand( new FireAllRulesCommand(),
+                                                                 "kbuilder",
+                                                                 "kbase",
+                                                                 "ksession" ) );
+        steps.add( new StepImpl( path,
+                                 cmds,
+                                 2200 ) );
+
+        cmds = new ArrayList<Command>();
+        cmds.add( new KnowledgeContextResolveFromContextCommand( new InsertObjectCommand( new Person( "ben",
+                                                                                                      150 ) ),
+                                                                 "kbuilder",
+                                                                 "kbase",
+                                                                 "ksession" ) );
+        cmds.add( new KnowledgeContextResolveFromContextCommand( new FireAllRulesCommand(),
+                                                                 "kbuilder",
+                                                                 "kbase",
+                                                                 "ksession" ) );
+        steps.add( new StepImpl( path,
+                                 cmds,
+                                 4500 ) );
+
+        cmds = new ArrayList<Command>();
+
+        cmds.add( new KnowledgeContextResolveFromContextCommand( new AssertEquals( "Check List size",
+                                                                                   5,
+                                                                                   new GetGlobalCommand( "list" ),
+                                                                                   "size()" ),
+                                                                 "kbuilder",
+                                                                 "kbase",
+                                                                 "ksession" ) );
+
+        cmds.add( new KnowledgeContextResolveFromContextCommand( new AssertEquals( "Check Person",
+                                                                                   new Person( "bobba",
+                                                                                               77 ),
+                                                                                   new GetGlobalCommand( "list" ),
+                                                                                   "get( 0 )" ),
+                                                                 "kbuilder",
+                                                                 "kbase",
+                                                                 "ksession" ) );
+
+        cmds.add( new KnowledgeContextResolveFromContextCommand( new AssertEquals( "Check Person",
+                                                                                   new Person( "darth",
+                                                                                               97 ),
+                                                                                   new GetGlobalCommand( "list" ),
+                                                                                   "get( 1 )" ),
+                                                                 "kbuilder",
+                                                                 "kbase",
+                                                                 "ksession" ) );
+
+        cmds.add( new KnowledgeContextResolveFromContextCommand( new AssertEquals( "Check Person",
+                                                                                   new Person( "luke",
+                                                                                               30 ),
+                                                                                   new GetGlobalCommand( "list" ),
+                                                                                   "get( 2 )" ),
+                                                                 "kbuilder",
+                                                                 "kbase",
+                                                                 "ksession" ) );
+
+        cmds.add( new KnowledgeContextResolveFromContextCommand( new AssertEquals( "Check Person",
+                                                                                   new Person( "yoda",
+                                                                                               98 ),
+                                                                                   new GetGlobalCommand( "list" ),
+                                                                                   "get( 3 )" ),
+                                                                 "kbuilder",
+                                                                 "kbase",
+                                                                 "ksession" ) );
+
+        cmds.add( new KnowledgeContextResolveFromContextCommand( new AssertEquals( "Check Person",
+                                                                                   new Person( "ben",
+                                                                                               150 ),
+                                                                                   new GetGlobalCommand( "list" ),
+                                                                                   "get( 4 )" ),
+                                                                 "kbuilder",
+                                                                 "kbase",
+                                                                 "ksession" ) );
+
+        steps.add( new StepImpl( path,
+                                 new TestGroupCommand( "test2",
+                                                       cmds ),
+                                 5000 ) );
+
+        path.setSteps( steps );
+
+        simulation.getPaths().put( "path2",
+                                   path );
+
+        return simulation;
+
+    }
+}

Added: labs/jbossrules/trunk/drools-simulator/src/main/java/org/drools/simulation/impl/Simulator.java
===================================================================
--- labs/jbossrules/trunk/drools-simulator/src/main/java/org/drools/simulation/impl/Simulator.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-simulator/src/main/java/org/drools/simulation/impl/Simulator.java	2009-07-13 06:08:05 UTC (rev 27931)
@@ -0,0 +1,201 @@
+package org.drools.simulation.impl;
+
+import java.util.Comparator;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.PriorityQueue;
+import java.util.Set;
+import java.util.concurrent.TimeUnit;
+
+import org.drools.StatefulSession;
+import org.drools.command.Command;
+import org.drools.command.Context;
+import org.drools.command.ContextManager;
+import org.drools.command.impl.ContextImpl;
+import org.drools.command.impl.GenericCommand;
+import org.drools.impl.StatefulKnowledgeSessionImpl;
+import org.drools.reteoo.ReteooStatefulSession;
+import org.drools.reteoo.ReteooWorkingMemory;
+import org.drools.runtime.StatefulKnowledgeSession;
+import org.drools.simulation.KnowledgeBuilderAddCommand;
+import org.drools.simulation.KnowledgeContextResolveFromContextCommand;
+import org.drools.simulation.NewStatefulKnowledgeSessionCommand;
+import org.drools.simulation.Path;
+import org.drools.simulation.Simulation;
+import org.drools.simulation.Step;
+import org.drools.time.SessionPseudoClock;
+
+public class Simulator
+    implements
+    ContextManager {
+
+    private PriorityQueue<Step>  queue;
+    private SimulationImpl       simulation;
+    //    private SessionPseudoClock  clock;
+    private long                 startTime;
+
+    private Context              root;
+    private Map<String, Context> contexts;
+
+    private String               ROOT = "ROOT";
+    
+    private Set<StatefulKnowledgeSession> ksessions;
+    
+    private CommandExecutionHandler executionHandler = new DefaultCommandExecutionHandler();
+
+    Simulator(Simulation simulation,
+              //SessionPseudoClock clock,
+              long startTime) {
+        //        this.clock = clock;
+        this.ksessions = new HashSet<StatefulKnowledgeSession>();
+        
+        this.startTime = startTime;
+        this.simulation = (SimulationImpl) simulation;
+        this.root = new ContextImpl( ROOT,
+                                     this );
+
+        this.contexts = new HashMap<String, Context>();
+        this.contexts.put( ROOT,
+                           this.root );
+
+        Map<String, Path> paths = this.simulation.getPaths();
+
+        // calculate capacity
+        int capacity = 0;
+        for ( Path path : paths.values() ) {
+            this.contexts.put( path.getName(),
+                               new ContextImpl( path.getName(),
+                                                this,
+                                                root ) );
+
+            capacity += path.getSteps().size();
+        }
+
+        if ( capacity == 0 ) {
+            return;
+        }
+
+        this.queue = new PriorityQueue( capacity,
+                                        new Comparator<Step>() {
+                                            public int compare(Step s1,
+                                                               Step s2) {
+                                                return (int) (s1.getTemporalDistance() - s2.getTemporalDistance());
+                                            }
+                                        } );
+
+        for ( Path path : paths.values() ) {
+            for ( Step step : path.getSteps() )
+                this.queue.add( step );
+        }
+    }
+
+    public void run() {
+        Step step;
+        while ( (step = executeNextStep()) != null ) {
+
+        }
+    }    
+
+    public Step executeNextStep() {
+        if ( this.queue.isEmpty() ) {
+            return null;
+        }
+        StepImpl step = (StepImpl) this.queue.remove();
+        PathImpl path = (PathImpl) step.getPath();
+
+        Context pathContext = this.contexts.get( path.getName() );
+        
+        // increment the clock for all the registered ksessions
+        for ( StatefulKnowledgeSession ksession : this.ksessions ) {
+          SessionPseudoClock clock = (SessionPseudoClock) ksession.getSessionClock();
+  
+          long newTime = this.startTime + step.getTemporalDistance();
+          long currentTime = clock.getCurrentTime();
+          clock.advanceTime( (currentTime + (newTime - currentTime)),
+                             TimeUnit.MICROSECONDS );            
+        }
+        
+        for ( Command cmd : step.getCommands() ) {
+            if ( cmd instanceof KnowledgeContextResolveFromContextCommand) {
+                if ( ((KnowledgeContextResolveFromContextCommand)cmd).getCommand() instanceof NewStatefulKnowledgeSessionCommand ) {
+                    // instantiate the ksession, set it's clock and register it
+                    StatefulKnowledgeSession ksession = ( StatefulKnowledgeSession ) executionHandler.execute( (GenericCommand) cmd, pathContext );
+                    if ( ksession != null ) {
+                        SessionPseudoClock clock = (SessionPseudoClock) ksession.getSessionClock();
+                        if ( clock.getCurrentTime() == 0 ) {
+                            clock.advanceTime( startTime,
+                                               TimeUnit.MILLISECONDS );
+                        }
+                        this.ksessions.add( ksession );
+                    }
+                } else if ( cmd instanceof GenericCommand) {
+                    executionHandler.execute( (GenericCommand) cmd, pathContext );
+                }
+            }  else if ( cmd instanceof GenericCommand) {
+                executionHandler.execute( (GenericCommand) cmd, pathContext );
+            }
+        }
+
+        return step;
+    }
+    
+    public void setCommandExecutionHandler(CommandExecutionHandler executionHandler) {
+        this.executionHandler = executionHandler;
+    }
+
+    public Context getContext(String identifier) {
+        return this.contexts.get( identifier );
+    }
+    
+    public Simulation getSimulation() {
+        return this.simulation;
+    }
+    
+    public static interface CommandExecutionHandler  {
+        public Object execute(GenericCommand command, Context context);
+    }
+    
+    public static class DefaultCommandExecutionHandler implements CommandExecutionHandler  {
+        public Object execute(GenericCommand command, Context context) {
+            return command.execute( context );
+        }
+    }    
+
+
+//    public static interface CommandExecutorService<T> {
+//        T execute(Command command);
+//    }
+//    
+//    public static class SimulatorCommandExecutorService<T> implements CommandExecutorService {
+//        Map map = new HashMap() {
+//            {
+//               put( KnowledgeBuilderAddCommand.class, null); 
+//            }
+//        };
+//        
+//        public  T execute(Command command) {
+//            return null;
+//        }
+//    }
+//    
+//    public static interface CommandContextAdapter {
+//        Context getContext();
+//    }
+//    
+//    public static class KnowledgeBuilderCommandContextAdapter implements CommandContextAdapter {
+//
+//        public Context getContext() {
+//            return new KnowledgeBuilderCommandContext();
+//        }
+//        
+//    }
+    
+    //    public void runUntil(Step step) {
+    //        
+    //    }
+    //    
+    //    public void runForTemporalDistance(long distance) {
+    //        
+    //    }
+}

Added: labs/jbossrules/trunk/drools-simulator/src/main/java/org/drools/simulation/impl/StepImpl.java
===================================================================
--- labs/jbossrules/trunk/drools-simulator/src/main/java/org/drools/simulation/impl/StepImpl.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-simulator/src/main/java/org/drools/simulation/impl/StepImpl.java	2009-07-13 06:08:05 UTC (rev 27931)
@@ -0,0 +1,47 @@
+package org.drools.simulation.impl;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+import org.drools.command.Command;
+import org.drools.simulation.Path;
+import org.drools.simulation.Step;
+
+public class StepImpl
+    implements
+    Step {
+    private Path                path;
+    private Collection<Command> commands;
+    private long                distance;
+
+    public StepImpl(Path path,
+                    Collection<Command> commands,
+                    long distance) {
+        this.path = path;
+        this.commands = commands;
+        this.distance = distance;
+    }
+    
+    public StepImpl(Path path,
+                    Command command,
+                    long distance) {
+        this.path = path;
+        commands = new ArrayList<Command>();
+        ((List<Command>)this.commands).add( command );
+        this.distance = distance;
+    }    
+
+    public Collection<Command> getCommands() {
+        return commands;
+    }
+
+    public long getTemporalDistance() {
+        return distance;
+    }
+
+    public Path getPath() {
+        return this.path;
+    }
+
+}

Added: labs/jbossrules/trunk/drools-simulator/src/main/java/org/drools/simulation/impl/TestGroupCommand.java
===================================================================
--- labs/jbossrules/trunk/drools-simulator/src/main/java/org/drools/simulation/impl/TestGroupCommand.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-simulator/src/main/java/org/drools/simulation/impl/TestGroupCommand.java	2009-07-13 06:08:05 UTC (rev 27931)
@@ -0,0 +1,53 @@
+package org.drools.simulation.impl;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import junit.framework.Assert;
+import junit.framework.TestCase;
+
+import org.drools.command.Command;
+import org.drools.command.Context;
+import org.drools.command.impl.GenericCommand;
+import org.drools.command.impl.KnowledgeCommandContext;
+import org.drools.impl.StatefulKnowledgeSessionImpl;
+import org.drools.reteoo.ReteooWorkingMemory;
+import org.drools.runtime.StatefulKnowledgeSession;
+import org.drools.runtime.rule.AgendaFilter;
+import org.mvel2.MVEL;
+
+public class TestGroupCommand
+    implements
+    GenericCommand<Void> {
+
+    private String        name;
+    private List<Command> commands;
+
+    public TestGroupCommand(String name,
+                       List<Command> commands) {
+        super();
+        this.name = name;
+        this.commands = commands;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public List<Command> getCommands() {
+        return commands;
+    }
+
+    public Void execute(Context context) {
+        for ( Command command : commands ) {
+            ((GenericCommand) command).execute( context );
+        }
+        return null;
+    }
+
+    public String toString() {
+        return "test";
+    }
+
+}




More information about the jboss-svn-commits mailing list