[jboss-svn-commits] JBL Code SVN: r13117 - in labs/jbossrules/branches/mvel-tooling-2007-06-30: documentation/manual/en/Chapter-BRMS and 26 other directories.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Thu Jul 5 16:02:12 EDT 2007


Author: pombredanne
Date: 2007-07-05 16:02:12 -0400 (Thu, 05 Jul 2007)
New Revision: 13117

Added:
   labs/jbossrules/branches/mvel-tooling-2007-06-30/documentation/manual/en/Chapter-BRMS/SnapshotDeploy.png
   labs/jbossrules/branches/mvel-tooling-2007-06-30/drools-compiler/src/test/java/org/drools/compiler/RuleErrorTest.java
Modified:
   labs/jbossrules/branches/mvel-tooling-2007-06-30/documentation/manual/en/Chapter-BRMS/Section-UserGuide.xml
   labs/jbossrules/branches/mvel-tooling-2007-06-30/documentation/manual/en/Chapter-Install/Section-Maven_build.xml
   labs/jbossrules/branches/mvel-tooling-2007-06-30/documentation/manual/en/Chapter-Install/Section-Setup.xml
   labs/jbossrules/branches/mvel-tooling-2007-06-30/documentation/manual/en/master.xml
   labs/jbossrules/branches/mvel-tooling-2007-06-30/drools-compiler/src/main/java/org/drools/compiler/PackageBuilder.java
   labs/jbossrules/branches/mvel-tooling-2007-06-30/drools-compiler/src/main/java/org/drools/compiler/RuleError.java
   labs/jbossrules/branches/mvel-tooling-2007-06-30/drools-compiler/src/test/java/org/drools/integrationtests/MiscTest.java
   labs/jbossrules/branches/mvel-tooling-2007-06-30/drools-core/.classpath
   labs/jbossrules/branches/mvel-tooling-2007-06-30/drools-core/src/main/java/org/drools/RuleBase.java
   labs/jbossrules/branches/mvel-tooling-2007-06-30/drools-core/src/main/java/org/drools/agent/RuleAgent.java
   labs/jbossrules/branches/mvel-tooling-2007-06-30/drools-core/src/main/java/org/drools/base/ShadowProxy.java
   labs/jbossrules/branches/mvel-tooling-2007-06-30/drools-core/src/main/java/org/drools/base/ShadowProxyFactory.java
   labs/jbossrules/branches/mvel-tooling-2007-06-30/drools-core/src/main/java/org/drools/base/evaluators/ObjectFactory.java
   labs/jbossrules/branches/mvel-tooling-2007-06-30/drools-core/src/main/java/org/drools/base/extractors/SelfReferenceClassFieldExtractor.java
   labs/jbossrules/branches/mvel-tooling-2007-06-30/drools-core/src/main/java/org/drools/common/AbstractRuleBase.java
   labs/jbossrules/branches/mvel-tooling-2007-06-30/drools-core/src/main/java/org/drools/common/AbstractWorkingMemory.java
   labs/jbossrules/branches/mvel-tooling-2007-06-30/drools-core/src/main/java/org/drools/common/InternalRuleBase.java
   labs/jbossrules/branches/mvel-tooling-2007-06-30/drools-core/src/main/java/org/drools/reteoo/AccumulateNode.java
   labs/jbossrules/branches/mvel-tooling-2007-06-30/drools-core/src/main/java/org/drools/reteoo/CollectNode.java
   labs/jbossrules/branches/mvel-tooling-2007-06-30/drools-core/src/main/java/org/drools/reteoo/CompositeObjectSinkAdapter.java
   labs/jbossrules/branches/mvel-tooling-2007-06-30/drools-core/src/main/java/org/drools/reteoo/ExistsNode.java
   labs/jbossrules/branches/mvel-tooling-2007-06-30/drools-core/src/main/java/org/drools/reteoo/JoinNode.java
   labs/jbossrules/branches/mvel-tooling-2007-06-30/drools-core/src/main/java/org/drools/reteoo/MemoryVisitor.java
   labs/jbossrules/branches/mvel-tooling-2007-06-30/drools-core/src/main/java/org/drools/reteoo/NotNode.java
   labs/jbossrules/branches/mvel-tooling-2007-06-30/drools-core/src/main/java/org/drools/reteoo/Rete.java
   labs/jbossrules/branches/mvel-tooling-2007-06-30/drools-core/src/main/java/org/drools/reteoo/ReteooRuleBase.java
   labs/jbossrules/branches/mvel-tooling-2007-06-30/drools-core/src/main/java/org/drools/reteoo/ReteooStatelessSession.java
   labs/jbossrules/branches/mvel-tooling-2007-06-30/drools-core/src/main/java/org/drools/util/AbstractHashTable.java
   labs/jbossrules/branches/mvel-tooling-2007-06-30/drools-core/src/test/java/org/drools/base/ShadowProxyFactoryTest.java
   labs/jbossrules/branches/mvel-tooling-2007-06-30/drools-core/src/test/java/org/drools/reteoo/AccumulateNodeTest.java
   labs/jbossrules/branches/mvel-tooling-2007-06-30/drools-core/src/test/java/org/drools/reteoo/CollectNodeTest.java
   labs/jbossrules/branches/mvel-tooling-2007-06-30/drools-core/src/test/java/org/drools/reteoo/JoinNodeTest.java
   labs/jbossrules/branches/mvel-tooling-2007-06-30/drools-core/src/test/java/org/drools/reteoo/NotNodeTest.java
   labs/jbossrules/branches/mvel-tooling-2007-06-30/drools-decisiontables/src/main/java/org/drools/decisiontable/model/SnippetBuilder.java
   labs/jbossrules/branches/mvel-tooling-2007-06-30/drools-eclipse/drools-eclipse-plugin/build.properties
   labs/jbossrules/branches/mvel-tooling-2007-06-30/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/DroolsEclipsePlugin.java
   labs/jbossrules/branches/mvel-tooling-2007-06-30/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/debug/core/DroolsDebugTarget.java
   labs/jbossrules/branches/mvel-tooling-2007-06-30/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/debug/core/DroolsThread.java
   labs/jbossrules/branches/mvel-tooling-2007-06-30/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/debug/core/MVELStackFrame.java
   labs/jbossrules/branches/mvel-tooling-2007-06-30/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/editors/DRLRuleEditor.java
   labs/jbossrules/branches/mvel-tooling-2007-06-30/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/editors/completion/DefaultCompletionProcessor.java
   labs/jbossrules/branches/mvel-tooling-2007-06-30/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/editors/completion/LocationDeterminator.java
   labs/jbossrules/branches/mvel-tooling-2007-06-30/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/editors/completion/RuleCompletionProcessor.java
   labs/jbossrules/branches/mvel-tooling-2007-06-30/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/launching/DroolsSourceLookupDirector.java
   labs/jbossrules/branches/mvel-tooling-2007-06-30/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/rulebuilder/ui/FactPatternWidget.java
   labs/jbossrules/branches/mvel-tooling-2007-06-30/drools-eclipse/drools-eclipse-plugin/src/main/resources/org/drools/eclipse/editors/keywords.properties
   labs/jbossrules/branches/mvel-tooling-2007-06-30/drools-eclipse/drools-eclipse-test/src/test/java/org/drools/eclipse/editors/completion/IncompleteParsingTest.java
   labs/jbossrules/branches/mvel-tooling-2007-06-30/drools-eclipse/drools-eclipse-test/src/test/java/org/drools/eclipse/editors/completion/LocationDeterminatorTest.java
   labs/jbossrules/branches/mvel-tooling-2007-06-30/drools-jsr94/src/main/java/org/drools/jsr94/rules/Jsr94FactHandleFactory.java
Log:
Ported r13114 from trunk to branch mvel-tooling-2007-06-30

Modified: labs/jbossrules/branches/mvel-tooling-2007-06-30/documentation/manual/en/Chapter-BRMS/Section-UserGuide.xml
===================================================================
--- labs/jbossrules/branches/mvel-tooling-2007-06-30/documentation/manual/en/Chapter-BRMS/Section-UserGuide.xml	2007-07-05 20:01:26 UTC (rev 13116)
+++ labs/jbossrules/branches/mvel-tooling-2007-06-30/documentation/manual/en/Chapter-BRMS/Section-UserGuide.xml	2007-07-05 20:02:12 UTC (rev 13117)
@@ -49,10 +49,9 @@
         <listitem>
           <para>To upload a model, use a jar which has the fact model (API)
           that you will be using in your rules and your code (go and make one
-          now if you need to !). Then click on the icon for uploading a new
-          model. When you are in the model editor screen, you can upload a jar
-          file, choose the package name from the list that you created in the
-          previous step.</para>
+          now if you need to !). When you are in the model editor screen, you
+          can upload a jar file, choose the package name from the list that
+          you created in the previous step.</para>
         </listitem>
 
         <listitem>
@@ -227,7 +226,7 @@
 
       <para>In the above example, the first Category "Finance" is a "top
       level" category. The second one: "HR/Awards/QAS" is a still a single
-      category, but its a nested category: categories are hierarchical. This
+      category, but its a nested category: Categories are hierarchical. This
       means there is a category called "HR", which contains a category
       "Awards" (it will in fact have more sub-categories of course), and
       "Awards" has a sub-category of QAS. The screen shows this as
@@ -331,12 +330,169 @@
   </section>
 
   <section>
-    <title>Integrating with your applications</title>
+    <title>Deployment: Integrating rules with your applications</title>
 
-    <para>[ how to use agent etc... ]</para>
-  </section>
+    <para>Its all very interesting to manage rules, but how to you use or
+    "consume" them in your application? This section covers the usage of the
+    RuleAgent deployment component that automates most of this for you.</para>
 
-  <section>
-    <title>Using the RuleAgent for deployment</title>
+    <section>
+      <title>The Rule Agent</title>
+
+      <para>The rule agent is a component which is embedded in the core
+      runtime of the rules engine. To use this, you don't need any extra
+      components. In fact, if you are using the BRMS, your application should
+      only need to include the drools-core.jar in its classpath, and no other
+      rules specific dependencies.</para>
+
+      <para>Once you have "built" your rules in a package in the BRMS, you are
+      ready to use the agent in your target application.</para>
+
+      <para>To use the rule agent, you will use a call in your applications
+      code like:</para>
+
+      <programlisting>RuleAgent agent = RuleAgent.newInstance("/MyRules.properties");     
+RuleBase rb = agent.getRuleBase(); 
+rb.newStatefulSession.... 
+//now assert your facts into the session and away you go !
+</programlisting>
+
+      <para>IMPORTANT: You should only have one instance of the RuleAgent per
+      rulebase you are using. This means you should (for example) keep the
+      RuleBase in JNDI.</para>
+
+      <para>This assumes that there is a MyRules.properties in the root of
+      your classpath. You can also pass in a Properties object with the
+      parameters set up (the parameters are discussed next).</para>
+
+      <para>The following shows the content of MyRules.properties:
+      <programlisting>##
+## RuleAgent configuration file example
+##
+
+newInstance=true
+file=/foo/bar/boo.pkg /foo/bar/boo2.pkg
+dir=/my/dir
+url=http://some.url/here http://some.url/here
+localCacheDir=/foo/bar/cache
+poll=30
+
+
+name=MyConfig</programlisting></para>
+
+      <para>You can only have one type of key in each configuration (eg only
+      one "file", "dir" etc - even though you can specify multiple items by
+      space separating them).</para>
+
+      <para>Referring to the above example, the "keys" in the properties are:
+      <itemizedlist>
+          <listitem>
+            <para>newInstance</para>
+
+            <para>Setting this to "true" means that the RuleBase instance will
+            be created fresh each time there is a change. this means you need
+            to do agent.getRuleBase() to get the new updated rulebase (any
+            existing ones in use will be untouched). The default is false,
+            which means rulebases are updated "in place" - ie you don't need
+            to keep calling getRuleBase() to make sure you have the latest
+            rules (also any StatefulSessions will be updated automatically
+            with rule changes).</para>
+          </listitem>
+
+          <listitem>
+            <para>file</para>
+
+            <para>This is a space-separated list of files - each file is a
+            binary package as exported by the BRMS. You can have one or many.
+            The name of the file is not important. Each package must be in its
+            own file.</para>
+          </listitem>
+
+          <listitem>
+            <para>dir</para>
+
+            <para>This is similar to file, except that instead of specifying a
+            list of files you specify a directory, and it will pick up all the
+            files in there (each one is a package) and add them to the
+            rulebase. Each package must be in its own file.</para>
+          </listitem>
+
+          <listitem>
+            <para>url</para>
+
+            <para>This is a space separated list of URLs to the BRMS which is
+            exposing the packages (see below for more details).</para>
+          </listitem>
+
+          <listitem>
+            <para>localCacheDir</para>
+
+            <para>This is used in conjunction with the url above, so that if
+            the BRMS is down (the url is not accessable) then if the runtime
+            has to start up, it can start up with the last known "good"
+            versions of the packages.</para>
+          </listitem>
+
+          <listitem>
+            <para>poll</para>
+
+            <para>This is set to the number of seconds to check for changes to
+            the resources (a timer is used).</para>
+          </listitem>
+
+          <listitem>
+            <para>name</para>
+
+            <para>This is used to specify the name of the agent which is used
+            when logging events (as typically you would have multiple agents
+            in a system).</para>
+          </listitem>
+        </itemizedlist></para>
+
+      <para>Following shows the deployment screen of the BRMS, which provides
+      URLs and downloads of packages. <figure>
+          <title>Snapshot deployment</title>
+
+          <mediaobject>
+            <imageobject>
+              <imagedata align="center" fileref="SnapshotDeploy.png"
+                         format="PNG" scalefit="1" />
+            </imageobject>
+          </mediaobject>
+        </figure></para>
+
+      <para>You can see the "Package URI" - this is the URL that you would
+      copy and paste into the agent .properties file to specify that you want
+      this package. It specifies an exact version (in this case to a snapshot)
+      - each snapshot has its own URL. If you want the "latest" - then replace
+      "NewSnapshot" with "LATEST".</para>
+
+      <para>You can also download a .pkg file from here, which you can drop in
+      a directory and use the "file" or "dir" feature of the RuleAgent if
+      needed (in some cases people will not want to have the runtime
+      automatically contact the BRMS for updates - but that is generally the
+      easiest way for many people).</para>
+    </section>
+
+    <section>
+      <title>Manual deployment</title>
+
+      <para>This section is only needed for advanced users who are integrating
+      deployment into their own mechanism. Normally you should use the rule
+      agent.</para>
+
+      <para>For those who do not wish to use the automatic deployment of the
+      RuleAgent, "rolling your own" is quite simple. The binary packages
+      emitted by the BRMS are serialized Package objects. You can deserialize
+      them and add them into any rulebase - essentially that is all you need
+      to do.</para>
+
+      <para>From the BRMS, binary packages are provided either from the latest
+      version of a package (once you have successfully validated and built a
+      package) or from the deployment snapshots. The URLs that the BRMS web
+      application exposes provide the binary package via http. You can also
+      issue a "HEAD" command to get the last time a package was
+      updated.</para>
+    </section>
   </section>
 </section>
\ No newline at end of file

Copied: labs/jbossrules/branches/mvel-tooling-2007-06-30/documentation/manual/en/Chapter-BRMS/SnapshotDeploy.png (from rev 13114, labs/jbossrules/trunk/documentation/manual/en/Chapter-BRMS/SnapshotDeploy.png)
===================================================================
(Binary files differ)

Modified: labs/jbossrules/branches/mvel-tooling-2007-06-30/documentation/manual/en/Chapter-Install/Section-Maven_build.xml
===================================================================
--- labs/jbossrules/branches/mvel-tooling-2007-06-30/documentation/manual/en/Chapter-Install/Section-Maven_build.xml	2007-07-05 20:01:26 UTC (rev 13116)
+++ labs/jbossrules/branches/mvel-tooling-2007-06-30/documentation/manual/en/Chapter-Install/Section-Maven_build.xml	2007-07-05 20:02:12 UTC (rev 13117)
@@ -6,99 +6,44 @@
     <title>Building the Source</title>
 
     <para>Now that we have the source the next step is to build and install
-    the source. We do this with <indexterm>
-        <primary>Ant</primary>
-      </indexterm>Ant, which uses maven 2 under the covers to get the needed
-    dependencies (you don't need to have maven 2 installed to build). Note
-    that the plug in is built seperatly, but the build process will update the
-    plug ins dependencies (refer to the section on building the plug in if you
-    need to build a new version of the plug in).</para>
+    the source. We do this with</para>
 
-    <para>Type <literal>'ant' </literal>to get a listing of what capabilities
-    the build script has (from the root of the project). You should then see a
-    listing which contains further instructions: <programlisting>
-<literal>C:\Projects\jboss-rules-new&gt;ant
-Buildfile: build.xml
+    <para>Since version 3.1 Drools uses <indexterm>
+        <primary>maven2</primary>
+      </indexterm> as default to build the system. There are two profiles
+    available which enable the associated modules "documentation" and
+    "eclipse"; this enables quicker building of the core modules for
+    developers. The eclipse profile will download eclipse into the
+    drools-eclipse folder, which is over 100MB download, however this only
+    needs to be done once; if you wish you can move that eclipse download into
+    another location and specify it with
+    -DlocalEclipseDrop=/folder/jboss-rules/local-eclipse-drop-mirror. The
+    following builds all the jars, the documentation and the eclipse zip with
+    a local folder specified to avoid downloading eclipse:</para>
 
-help:
-     [echo] Drools Build Help
-     [echo] -----------------
-     [echo]
-     [echo] The build process is for the following four modules:
-     [echo] drools-core
-     [echo] drools-compiler
-     [echo] drools-decisiontables
-     [echo] drools-jsr94
-     [echo]
-     [echo] Further to this there are two Eclipse project:
-     [echo] drools-examples - To use open Eclipse and import.
-     [echo]                   Requires the Drools Eclipse plugin.
-     [echo]                   Either build the plugin from drools-ide
-     [echo]                   or install from the Eclipse update site
-     [echo]                   http://anonsvn.labs.jboss.com/labs/jbossrules/updates
-     [echo] drools-ide      - To use open Eclipse and import.
-     [echo]                   Select export and plugin fragements to
-     [echo]                   generate the Drools Eclipse plugin
-     [echo]                   Depends on all the depencies being copied
-     [echo]                   to its lib directory at the end of build-all,
-     [echo]                   which calls copy-deps.
-     [echo]
-     [echo] Targets
-     [echo] -----
-     [echo]
-     [echo] clean-all - cleans all directories
-     [echo]
-     [echo] build-all - builds all modules
-     [echo]
-     [echo] javadocs  - generates the javadoc at target/docs
-     [echo]
-     [echo] manual    - generates the docbook documentation in
-     [echo]             html and single_html format at target/docs
-     [echo]
-     [echo] dist-all  - generates the distribution builds for
-     [echo]             src, bin, bin-withdeps and examples
-     [echo]
-     [echo] Each module can individually be executed with clean, compile,
-     [echo] test and build. To use simply use the following commands,
-     [echo] replace ${module} with one of the module names:
-     [echo] clean-${module}
-     [echo] compile-${module}
-     [echo] test-${module}
-     [echo] build-${module}
-     [echo]
-     [echo] Generates specific distribution builds:
-     [echo] dist-src
-     [echo] dist-bin
-     [echo] dist-bin-withdeps
-     [echo] dist-examples
-     [echo]
-     [echo] You may also pass the following system properties:
-     [echo] -Dtest.skip=true
-     [echo] -Djavadocs.skip=true
-     [echo] -Dmanual.skip=true
-     [echo]
-     [echo] Targets may be combined:
-     [echo] ant -Dtest.skip clean-all build-all
-     [echo]
-     [echo] For more help use the build system to generate the manual
-     [echo] or you can find the manual online at:
-     [echo] http://labs.jboss.com/portal/jbossrules/docs/index.html
+    <para><programlisting>mvn -Declipse=true -Ddocumentation=true clean install -DlocalEclipseDrop=/folder/jboss-rules/local-eclipse-drop-mirror </programlisting></para>
 
-BUILD SUCCESSFUL
+    <para>You can produce distribution builds, which puts everything into
+    zips, as follows:<programlisting>mvn -Declipse=true -Ddocumentation=true clean install -DlocalEclipseDrop=/folder/jboss-rules/local-eclipse-drop-mirror
 
-</literal>
-</programlisting></para>
+mvn -Ddocumentation -Declipse -Dmaven.test.skip package javadoc:javadoc assembly:assembly -DlocalEclipseDrop=/folder/jboss-rules/local-eclipse-drop-mirror
+    </programlisting></para>
 
-    <para>The most common pair of tasks to run is 'ant clean-all build-all'
-    which will clear old artifacts, and then test and built the source, and
-    report on any errors.</para>
+    <para>Note that install must be done first as javadoc:javadoc won't work
+    unless the jars are in the local maven repo, but the tests can be skipped
+    on the second run. assembly:assembly fails unless you increase the
+    available memory to Maven, on windows the following command worked well:
+    set MAVEN_OPTS=-Xmx512m</para>
 
+    <para>Type mvn clean to clear old artifacts, and then test and built the
+    source, and report on any errors.</para>
+
     <para>The resulting jars are put in the /target directory from the top
     level of the project.</para>
 
-    <para>As Ant builds each module it will install the resulting jars in the
-    local Maven 2 repository automatically. Where it can be easily used from
-    other project <literal>pom.xml</literal> or copied else where.</para>
+    <para>As maven builds each module it will install the resulting jars in
+    the local Maven 2 repository automatically. Where it can be easily used
+    from other project <literal>pom.xml</literal> or copied else where.</para>
 
     <screenshot>
       <screeninfo>Installed Drools Jars</screeninfo>

Modified: labs/jbossrules/branches/mvel-tooling-2007-06-30/documentation/manual/en/Chapter-Install/Section-Setup.xml
===================================================================
--- labs/jbossrules/branches/mvel-tooling-2007-06-30/documentation/manual/en/Chapter-Install/Section-Setup.xml	2007-07-05 20:01:26 UTC (rev 13116)
+++ labs/jbossrules/branches/mvel-tooling-2007-06-30/documentation/manual/en/Chapter-Install/Section-Setup.xml	2007-07-05 20:02:12 UTC (rev 13117)
@@ -35,6 +35,15 @@
 
     <listitem>
       <para><indexterm>
+          <primary>maven</primary>
+        </indexterm>Maven 2.0.7</para>
+
+      <para>http://maven.apache.org/</para>
+    </listitem>
+
+
+    <listitem>
+      <para><indexterm>
           <primary>ant</primary>
         </indexterm>Ant 1.6</para>
 
@@ -43,21 +52,22 @@
 
   </itemizedlist>
 
-  <para>Ensure the executeables for ant and java are in your <indexterm>
+  <para>Ensure the executables for ant, maven and java are in your <indexterm>
       <primary>path</primary>
     </indexterm>path. The examples given illustrative and are for a win32
   system:</para>
 
-  <literallayout>Path=D:\java\j2sdk1.4.2_10\bin;D:\java\apache-ant-1.6.5\bin;</literallayout>
+  <literallayout>Path=D:\java\j2sdk1.4.2_10\bin;D:\java\apache-ant-1.6.5\bin;D:\java\maven2.0.7\bin</literallayout>
 
   <para>Following environment variables will also need to be set. The examples
   given illustrative and are for a win32 system::</para>
 
   <literallayout>JAVA_HOME=D:\java\j2sdk1.4.2_10
 ANT_HOME=D:\java\apache-ant-1.6.5
+MAVEN_HOME=D:\java\maven2.0.7
 
 </literallayout>
 	<para>
-		Past releases used to use maven 2 as the build mechanism, but now ant is used as the primary mechanism. Maven is used underneath the covers as the mechanism for managing project dependencies etc. (You can of course still have maven 2 installed and use it if needed - there is a pom.xml structure for each module - this is what is used for dependency management).
+		Past releases used to use ant as the build mechanism, but now maven is used as the primary mechanism. Ant is used for document building proposes
 	</para>
 </section>
\ No newline at end of file

Modified: labs/jbossrules/branches/mvel-tooling-2007-06-30/documentation/manual/en/master.xml
===================================================================
--- labs/jbossrules/branches/mvel-tooling-2007-06-30/documentation/manual/en/master.xml	2007-07-05 20:01:26 UTC (rev 13116)
+++ labs/jbossrules/branches/mvel-tooling-2007-06-30/documentation/manual/en/master.xml	2007-07-05 20:02:12 UTC (rev 13117)
@@ -7,31 +7,41 @@
 
     <releaseinfo>4.0.0.SNAPSHOT</releaseinfo>
 
-
     <author>
       <firstname>Mark</firstname>
+
       <surname>Proctor</surname>
     </author>
 
     <author>
       <firstname>Michael</firstname>
+
       <surname>Neale</surname>
     </author>
 
     <author>
       <firstname>Michael</firstname>
+
       <surname>Frandsen</surname>
     </author>
-    
+
     <author>
-      <firstname>Sam</firstname>      
+      <firstname>Sam</firstname>
+
       <surname>Griffith Jr.</surname>
     </author>
 
     <author>
-      <firstname>Edson</firstname>      
+      <firstname>Edson</firstname>
+
       <surname>Tirelli</surname>
     </author>
+
+    <author>
+      <firstname>Fernando</firstname>
+
+      <surname>Meyer</surname>
+    </author>
   </bookinfo>
 
   <toc />
@@ -129,13 +139,14 @@
       <xi:include href="Chapter-IDE/Section-QuickStart.xml" />
     </chapter>
 
-	<chapter>
-		<title>The BRMS (Business Rule Management System)</title>
-		<xi:include href="Chapter-BRMS/Section-Introduction.xml" />
-		<xi:include href="Chapter-BRMS/Section-AdminGuide.xml" />
-	</chapter>
+    <chapter>
+      <title>The BRMS (Business Rule Management System)</title>
 
+      <xi:include href="Chapter-BRMS/Section-Introduction.xml" />
 
+      <xi:include href="Chapter-BRMS/Section-AdminGuide.xml" />
+    </chapter>
+
     <chapter>
       <title>The Java Rule Engine API</title>
 

Modified: labs/jbossrules/branches/mvel-tooling-2007-06-30/drools-compiler/src/main/java/org/drools/compiler/PackageBuilder.java
===================================================================
--- labs/jbossrules/branches/mvel-tooling-2007-06-30/drools-compiler/src/main/java/org/drools/compiler/PackageBuilder.java	2007-07-05 20:01:26 UTC (rev 13116)
+++ labs/jbossrules/branches/mvel-tooling-2007-06-30/drools-compiler/src/main/java/org/drools/compiler/PackageBuilder.java	2007-07-05 20:02:12 UTC (rev 13117)
@@ -343,7 +343,7 @@
                 pkg.addGlobal( identifier,
                                clazz );
             } catch ( final ClassNotFoundException e ) {
-                new GlobalError( identifier );
+                this.results.add(new GlobalError( identifier ));
             }
         }
     }

Modified: labs/jbossrules/branches/mvel-tooling-2007-06-30/drools-compiler/src/main/java/org/drools/compiler/RuleError.java
===================================================================
--- labs/jbossrules/branches/mvel-tooling-2007-06-30/drools-compiler/src/main/java/org/drools/compiler/RuleError.java	2007-07-05 20:01:26 UTC (rev 13116)
+++ labs/jbossrules/branches/mvel-tooling-2007-06-30/drools-compiler/src/main/java/org/drools/compiler/RuleError.java	2007-07-05 20:02:12 UTC (rev 13117)
@@ -66,7 +66,11 @@
         if ( this.object instanceof CompilationProblem[] ) {
             final CompilationProblem[] problem = (CompilationProblem[]) this.object;
             for ( int i = 0; i < problem.length; i++ ) {
-                summary = summary + " " + problem[i].getMessage();
+                if (i != 0) {
+                    summary = summary + "\n" + problem[i].getMessage();
+                } else {
+                    summary = summary + " " + problem[i].getMessage();
+                }
             }
 
         }

Copied: labs/jbossrules/branches/mvel-tooling-2007-06-30/drools-compiler/src/test/java/org/drools/compiler/RuleErrorTest.java (from rev 13114, labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/compiler/RuleErrorTest.java)
===================================================================
--- labs/jbossrules/branches/mvel-tooling-2007-06-30/drools-compiler/src/test/java/org/drools/compiler/RuleErrorTest.java	                        (rev 0)
+++ labs/jbossrules/branches/mvel-tooling-2007-06-30/drools-compiler/src/test/java/org/drools/compiler/RuleErrorTest.java	2007-07-05 20:02:12 UTC (rev 13117)
@@ -0,0 +1,65 @@
+package org.drools.compiler;
+
+import org.drools.commons.jci.problems.CompilationProblem;
+import org.drools.lang.descr.AndDescr;
+import org.drools.rule.Rule;
+
+import junit.framework.TestCase;
+
+public class RuleErrorTest extends TestCase {
+
+    public void testNewLineInMessage() {
+        CompilationProblem[] probs = new CompilationProblem[3];
+        probs[0] = new MockCompilationProblem();
+        probs[1] = new MockCompilationProblem();
+        probs[2] = new MockCompilationProblem();
+
+        
+        RuleError err = new RuleError(new Rule("ruleName"), 
+                                      new AndDescr(), 
+                                      probs, 
+                                      "IM IN YR EROR");
+        assertNotNull(err.toString());
+        String msg = err.getMessage();
+        
+        assertTrue(msg.indexOf( "IM IN YR EROR") != -1);
+        System.err.println(msg);        
+        assertEquals("IM IN YR EROR problem\nproblem\nproblem", msg);
+
+        
+    }
+    
+    
+    class MockCompilationProblem implements CompilationProblem {
+
+        public int getEndColumn() {
+            return 0;
+        }
+
+        public int getEndLine() {
+            return 0;
+        }
+
+        public String getFileName() {
+            return "X";
+        }
+
+        public String getMessage() {
+            return "problem";
+        }
+
+        public int getStartColumn() {
+            return 0;
+        }
+
+        public int getStartLine() {
+            return 0;
+        }
+
+        public boolean isError() {
+            return true;
+        }
+        
+    }
+    
+}

Modified: labs/jbossrules/branches/mvel-tooling-2007-06-30/drools-compiler/src/test/java/org/drools/integrationtests/MiscTest.java
===================================================================
--- labs/jbossrules/branches/mvel-tooling-2007-06-30/drools-compiler/src/test/java/org/drools/integrationtests/MiscTest.java	2007-07-05 20:01:26 UTC (rev 13116)
+++ labs/jbossrules/branches/mvel-tooling-2007-06-30/drools-compiler/src/test/java/org/drools/integrationtests/MiscTest.java	2007-07-05 20:02:12 UTC (rev 13117)
@@ -61,7 +61,6 @@
 import org.drools.TestParam;
 import org.drools.WorkingMemory;
 import org.drools.Cheesery.Maturity;
-import org.drools.brms.client.modeldriven.brl.RuleAttribute;
 import org.drools.common.AbstractWorkingMemory;
 import org.drools.common.DroolsObjectInputStream;
 import org.drools.compiler.DrlParser;

Modified: labs/jbossrules/branches/mvel-tooling-2007-06-30/drools-core/.classpath
===================================================================
--- labs/jbossrules/branches/mvel-tooling-2007-06-30/drools-core/.classpath	2007-07-05 20:01:26 UTC (rev 13116)
+++ labs/jbossrules/branches/mvel-tooling-2007-06-30/drools-core/.classpath	2007-07-05 20:02:12 UTC (rev 13117)
@@ -5,8 +5,8 @@
   <classpathentry kind="src" path="src/test/resources" output="target/test-classes" excluding="**/*.java"/>
   <classpathentry kind="output" path="target/classes"/>
   <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
-  <classpathentry kind="var" path="M2_REPO/xpp3/xpp3/1.1.3.4.O/xpp3-1.1.3.4.O.jar" sourcepath="M2_REPO/xpp3/xpp3/1.1.3.4.O/xpp3-1.1.3.4.O-sources.jar"/>
-  <classpathentry kind="var" path="M2_REPO/xstream/xstream/1.1.3/xstream-1.1.3.jar" sourcepath="M2_REPO/xstream/xstream/1.1.3/xstream-1.1.3-sources.jar"/>
-  <classpathentry kind="var" path="M2_REPO/junit/junit/3.8.1/junit-3.8.1.jar" sourcepath="M2_REPO/junit/junit/3.8.1/junit-3.8.1-sources.jar"/>
+  <classpathentry kind="var" path="M2_REPO/xpp3/xpp3/1.1.3.4.O/xpp3-1.1.3.4.O.jar"/>
+  <classpathentry kind="var" path="M2_REPO/junit/junit/3.8.1/junit-3.8.1.jar"/>
+  <classpathentry kind="var" path="M2_REPO/xstream/xstream/1.1.3/xstream-1.1.3.jar"/>
   <classpathentry kind="var" path="M2_REPO/org/mvel/mvel14/1.2beta27/mvel14-1.2beta27.jar"/>
 </classpath>
\ No newline at end of file

Modified: labs/jbossrules/branches/mvel-tooling-2007-06-30/drools-core/src/main/java/org/drools/RuleBase.java
===================================================================
--- labs/jbossrules/branches/mvel-tooling-2007-06-30/drools-core/src/main/java/org/drools/RuleBase.java	2007-07-05 20:01:26 UTC (rev 13116)
+++ labs/jbossrules/branches/mvel-tooling-2007-06-30/drools-core/src/main/java/org/drools/RuleBase.java	2007-07-05 20:02:12 UTC (rev 13117)
@@ -19,7 +19,6 @@
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.Serializable;
-import java.util.Set;
 
 import org.drools.rule.Package;
 import org.drools.ruleflow.common.core.Process;

Modified: labs/jbossrules/branches/mvel-tooling-2007-06-30/drools-core/src/main/java/org/drools/agent/RuleAgent.java
===================================================================
--- labs/jbossrules/branches/mvel-tooling-2007-06-30/drools-core/src/main/java/org/drools/agent/RuleAgent.java	2007-07-05 20:01:26 UTC (rev 13116)
+++ labs/jbossrules/branches/mvel-tooling-2007-06-30/drools-core/src/main/java/org/drools/agent/RuleAgent.java	2007-07-05 20:02:12 UTC (rev 13117)
@@ -21,11 +21,15 @@
 import org.drools.rule.Package;
 
 /**
- * This manages a single rulebase, based on the properties given
- * This one does most of the actual work !
+ * This manages a single rulebase, based on the properties given.
+ * You should only have ONE instance of this agent per rulebase configuration.
+ * You can get the rulebase from this agent repeatedly, as needed, or if you keep the rulebase, 
+ * under most configurations it will be automatically updated. 
+ * 
+ * How this behaves depends on the properties that you pass into it (documented below)
  *
  * CONFIG OPTIONS (to be passed in as properties):
- *  <code>newInstance</code>: means that each time the rules are changed
+ *  <code>newInstance</code>: setting this to "true" means that each time the rules are changed
  *   a new instance of the rulebase is created (as opposed to updated in place)
  *   the default is to update in place. DEFAULT: false. If you set this to true, 
  *   then you will need to call getRuleBase() each time you want to use it. If it is false, 
@@ -33,17 +37,31 @@
  *   (as well as any stateful sessions). 
  *
  *  <code>poll</code>The number of seconds to poll for changes. Polling 
- *  happens in a background thread.
+ *  happens in a background thread. eg: poll=30 #30 second polling.
  *
  *  <code>file</code>: a space seperated listing of files that make up the 
  *  packages of the rulebase. Each package can only be in one file. You can't have 
- *  packages spread across files.
+ *  packages spread across files. eg: file=/your/dir/file1.pkg file=/your/dir/file2.pkg
  *  
  *  <code>dir</code>: a single file system directory to monitor for packages.
  *  As with files, each package must be in its own file.
+ *  eg: dir=/your/dir
  *  
  *  <code>url</code>: A space seperated URL to a binary rulebase in the BRMS.
- * 
+ *  eg: url=http://server/drools-jbrms/packages/somePakage/VERSION_1
+ *  For URL you will also want a local cache directory setup:
+ *  eg: localCacheDir=/some/dir/that/exists
+ *  This is needed so that the runtime can startup and load packages even if the BRMS
+ *  is not available (or the network).
+ *  
+ *  <code>name</code>
+ *  the Name is used in any logging, so each agent can be differentiated (you may have one agent per rulebase
+ *  that you need in your application).
+ *  
+ *  There is also an AgentEventListener interface which you can provide which will call back when lifecycle 
+ *  events happen, or errors/warnings occur. As the updating happens in a background thread, this may be important.
+ *  The default event listener logs to the System.err output stream.
+ *  
  * @author Michael Neale
  */
 public class RuleAgent {

Modified: labs/jbossrules/branches/mvel-tooling-2007-06-30/drools-core/src/main/java/org/drools/base/ShadowProxy.java
===================================================================
--- labs/jbossrules/branches/mvel-tooling-2007-06-30/drools-core/src/main/java/org/drools/base/ShadowProxy.java	2007-07-05 20:01:26 UTC (rev 13116)
+++ labs/jbossrules/branches/mvel-tooling-2007-06-30/drools-core/src/main/java/org/drools/base/ShadowProxy.java	2007-07-05 20:02:12 UTC (rev 13117)
@@ -24,5 +24,7 @@
     public void updateProxy();
 
     public Object getShadowedObject();
+    
+    public void setShadowedObject(Object object);
 
 }

Modified: labs/jbossrules/branches/mvel-tooling-2007-06-30/drools-core/src/main/java/org/drools/base/ShadowProxyFactory.java
===================================================================
--- labs/jbossrules/branches/mvel-tooling-2007-06-30/drools-core/src/main/java/org/drools/base/ShadowProxyFactory.java	2007-07-05 20:01:26 UTC (rev 13116)
+++ labs/jbossrules/branches/mvel-tooling-2007-06-30/drools-core/src/main/java/org/drools/base/ShadowProxyFactory.java	2007-07-05 20:02:12 UTC (rev 13117)
@@ -19,6 +19,7 @@
 import java.lang.reflect.Method;
 import java.lang.reflect.Modifier;
 import java.util.ArrayList;
+import java.util.Collection;
 import java.util.HashMap;
 import java.util.Iterator;
 import java.util.List;
@@ -37,6 +38,8 @@
  */
 public class ShadowProxyFactory {
     private static final String UPDATE_PROXY         = "updateProxy";
+    private static final String SET_SHADOWED_OBJECT  = "setShadowedObject";
+    private static final String GET_SHADOWED_OBJECT  = "getShadowedObject";
 
     private static final String BASE_INTERFACE       = Type.getInternalName( ShadowProxy.class );
 
@@ -84,22 +87,24 @@
             throw new RuntimeDroolsException( e );
         }
     }
-    
-    protected static boolean isPossibleToGenerateTheProxyFor( final Class clazz) throws Exception {
+
+    protected static boolean isPossibleToGenerateTheProxyFor(final Class clazz) throws Exception {
         if ( (clazz.getModifiers() & Modifier.FINAL) != 0 ) {
             return false;
         }
         try {
-            Method equals = clazz.getMethod( "equals", new Class[] { Object.class } );
-            if( Modifier.isFinal( equals.getModifiers() ) ) {
+            Method equals = clazz.getMethod( "equals",
+                                             new Class[]{Object.class} );
+            if ( Modifier.isFinal( equals.getModifiers() ) ) {
                 return false;
             }
         } catch ( NoSuchMethodException e ) {
             // that's fine
         }
         try {
-            Method hashcode = clazz.getMethod( "hashCode", new Class[0] );
-            if( Modifier.isFinal( hashcode.getModifiers() ) ) {
+            Method hashcode = clazz.getMethod( "hashCode",
+                                               new Class[0] );
+            if ( Modifier.isFinal( hashcode.getModifiers() ) ) {
                 return false;
             }
         } catch ( NoSuchMethodException e ) {
@@ -114,9 +119,7 @@
      */
     public static String getInternalProxyClassNameForClass(final Class clazz) {
         String className = null;
-        if ( clazz.getPackage() != null && (
-                clazz.getPackage().getName().startsWith( "java." ) || clazz.getPackage().getName().startsWith( "javax." ) )
-                ) {
+        if ( clazz.getPackage() != null && (clazz.getPackage().getName().startsWith( "java." ) || clazz.getPackage().getName().startsWith( "javax." )) ) {
             className = "org/drools/shadow/" + Type.getInternalName( clazz ) + "ShadowProxy";
         } else {
             className = Type.getInternalName( clazz ) + "ShadowProxy";
@@ -127,9 +130,7 @@
     public static String getProxyClassNameForClass(final Class clazz) {
         String className = null;
         Package pkg = clazz.getPackage();
-        if ( pkg != null && 
-                (pkg.getName().startsWith( "java." ) || pkg.getName().startsWith( "javax." ) )
-                ) {
+        if ( pkg != null && (pkg.getName().startsWith( "java." ) || pkg.getName().startsWith( "javax." )) ) {
             className = "org.drools.shadow." + clazz.getName() + "ShadowProxy";
         } else {
             className = clazz.getName() + "ShadowProxy";
@@ -146,12 +147,18 @@
                           className,
                           cw );
 
+        buildConstructor( clazz,
+                          className,
+                          cw );
+
         buildField( ShadowProxyFactory.DELEGATE_FIELD_NAME,
                     Type.getDescriptor( clazz ),
                     cw );
 
-        final Method getShadowed = ShadowProxy.class.getDeclaredMethod( "getShadowedObject",
-                                                                  new Class[]{} );
+        final Method getShadowed = ShadowProxy.class.getDeclaredMethod( GET_SHADOWED_OBJECT,
+                                                                        new Class[]{} );
+        final Method setShadowed = ShadowProxy.class.getDeclaredMethod( SET_SHADOWED_OBJECT,
+                                                                        new Class[]{Object.class} );
         buildSimpleGetMethod( ShadowProxyFactory.DELEGATE_FIELD_NAME,
                               clazz,
                               getShadowed,
@@ -159,6 +166,51 @@
                               clazz,
                               cw );
 
+        buildSetShadowedObject( clazz,
+                                className,
+                                setShadowed,
+                                cw );
+
+        if ( Collection.class.isAssignableFrom( clazz ) ) {
+            buildCollectionClass( clazz,
+                                  className,
+                                  cw );
+        } else if ( Map.class.isAssignableFrom( clazz ) ) {
+            buildMapClass( clazz,
+                           className,
+                           cw );
+        } else {
+            buildRegularClass( clazz,
+                               className,
+                               cw );
+        }
+
+        return cw.toByteArray();
+    }
+
+    private static void buildCollectionClass(final Class clazz,
+                                             final String className,
+                                             final ClassWriter cw) {
+
+        buildCollectionUpdateProxyMethod( clazz,
+                                          className,
+                                          cw );
+
+    }
+
+    private static void buildMapClass(final Class clazz,
+                                      final String className,
+                                      final ClassWriter cw) {
+
+        buildMapUpdateProxyMethod( clazz,
+                                   className,
+                                   cw );
+
+    }
+
+    private static void buildRegularClass(final Class clazz,
+                                          final String className,
+                                          final ClassWriter cw) {
         final Map fieldTypes = new HashMap();
         final Method[] methods = getMethods( clazz );
         for ( int i = 0; i < methods.length; i++ ) {
@@ -192,10 +244,6 @@
             }
         }
 
-        buildConstructor( clazz,
-                          className,
-                          cw );
-
         buildUpdateProxyMethod( fieldTypes,
                                 className,
                                 cw );
@@ -213,8 +261,6 @@
                        className,
                        clazz,
                        fieldTypes );
-
-        return cw.toByteArray();
     }
 
     /**
@@ -650,6 +696,192 @@
         mv.visitEnd();
     }
 
+    protected static void buildSetShadowedObject(final Class clazz,
+                                                 final String className,
+                                                 final Method setShadowed,
+                                                 final ClassWriter cw) {
+        final MethodVisitor mv = cw.visitMethod( Opcodes.ACC_PUBLIC,
+                                                 setShadowed.getName(),
+                                                 Type.getMethodDescriptor( setShadowed ),
+                                                 null,
+                                                 null );
+        mv.visitCode();
+        Label l0 = new Label();
+        mv.visitLabel( l0 );
+        // this.delegate = (<clazz>) object;
+        mv.visitVarInsn( Opcodes.ALOAD,
+                         0 );
+        mv.visitVarInsn( Opcodes.ALOAD,
+                         1 );
+        mv.visitTypeInsn( Opcodes.CHECKCAST,
+                          Type.getInternalName( clazz ) );
+        mv.visitFieldInsn( Opcodes.PUTFIELD,
+                           className,
+                           DELEGATE_FIELD_NAME,
+                           Type.getDescriptor( clazz ) );
+        if ( Collection.class.isAssignableFrom( clazz ) ||
+             Map.class.isAssignableFrom( clazz ) ) {
+            Label l1 = new Label();
+            mv.visitLabel( l1 );
+            mv.visitVarInsn( Opcodes.ALOAD,
+                             0 );
+            mv.visitMethodInsn( Opcodes.INVOKEVIRTUAL,
+                                className,
+                                UPDATE_PROXY,
+                                Type.getMethodDescriptor( Type.VOID_TYPE,
+                                                          new Type[0] ) );
+        }
+        Label l2 = new Label();
+        mv.visitLabel( l2 );
+        mv.visitInsn( Opcodes.RETURN );
+        Label l3 = new Label();
+        mv.visitLabel( l3 );
+        mv.visitLocalVariable( "this",
+                               "L" + className + ";",
+                               null,
+                               l0,
+                               l3,
+                               0 );
+        mv.visitLocalVariable( "object",
+                               Type.getDescriptor( Object.class ),
+                               null,
+                               l0,
+                               l3,
+                               1 );
+        mv.visitMaxs( 0,
+                      0 );
+        mv.visitEnd();
+    }
+
+    /**
+     * Creates an update proxy method for Map classes
+     * 
+     * public void updateProxy() {
+     *     this.clear();
+     *     this.addAll( this.delegate );
+     * }
+     * 
+     * @param clazz
+     * @param className
+     * @param cw
+     */
+    protected static void buildCollectionUpdateProxyMethod(final Class clazz,
+                                                           final String className,
+                                                           final ClassWriter cw) {
+        final MethodVisitor mv = cw.visitMethod( Opcodes.ACC_PUBLIC,
+                                                 ShadowProxyFactory.UPDATE_PROXY,
+                                                 Type.getMethodDescriptor( Type.VOID_TYPE,
+                                                                           new Type[]{} ),
+                                                 null,
+                                                 null );
+        mv.visitCode();
+        final Label l0 = new Label();
+        mv.visitLabel( l0 );
+        // this.clear();
+        mv.visitVarInsn( Opcodes.ALOAD,
+                         0 );
+        mv.visitMethodInsn( Opcodes.INVOKEVIRTUAL,
+                            className,
+                            "clear",
+                            Type.getMethodDescriptor( Type.VOID_TYPE,
+                                                      new Type[0] ) );
+        Label l1 = new Label();
+        mv.visitLabel( l1 );
+        // this.addAll( this.delegate );
+        mv.visitVarInsn( Opcodes.ALOAD,
+                         0 );
+        mv.visitVarInsn( Opcodes.ALOAD,
+                         0 );
+        mv.visitFieldInsn( Opcodes.GETFIELD,
+                           className,
+                           DELEGATE_FIELD_NAME,
+                           Type.getDescriptor( clazz ) );
+        mv.visitMethodInsn( Opcodes.INVOKEVIRTUAL,
+                            className,
+                            "addAll",
+                            Type.getMethodDescriptor( Type.BOOLEAN_TYPE,
+                                                      new Type[]{Type.getType( Collection.class )} ) );
+        mv.visitInsn( Opcodes.POP );
+        Label l2 = new Label();
+        mv.visitLabel( l2 );
+        mv.visitInsn( Opcodes.RETURN );
+        Label l3 = new Label();
+        mv.visitLabel( l3 );
+        mv.visitLocalVariable( "this",
+                               "L" + className + ";",
+                               null,
+                               l0,
+                               l3,
+                               0 );
+        mv.visitMaxs( 0,
+                      0 );
+        mv.visitEnd();
+    }
+
+    /**
+     * Creates an update proxy method for Map classes
+     * 
+     * public void updateProxy() {
+     *     this.clear();
+     *     this.putAll( this.delegate );
+     * }
+     * 
+     * @param clazz
+     * @param className
+     * @param cw
+     */
+    protected static void buildMapUpdateProxyMethod(final Class clazz,
+                                                    final String className,
+                                                    final ClassWriter cw) {
+        final MethodVisitor mv = cw.visitMethod( Opcodes.ACC_PUBLIC,
+                                                 ShadowProxyFactory.UPDATE_PROXY,
+                                                 Type.getMethodDescriptor( Type.VOID_TYPE,
+                                                                           new Type[]{} ),
+                                                 null,
+                                                 null );
+        mv.visitCode();
+        final Label l0 = new Label();
+        mv.visitLabel( l0 );
+        // this.clear();
+        mv.visitVarInsn( Opcodes.ALOAD,
+                         0 );
+        mv.visitMethodInsn( Opcodes.INVOKEVIRTUAL,
+                            className,
+                            "clear",
+                            Type.getMethodDescriptor( Type.VOID_TYPE,
+                                                      new Type[0] ) );
+        Label l1 = new Label();
+        mv.visitLabel( l1 );
+        // this.putAll( this.delegate );
+        mv.visitVarInsn( Opcodes.ALOAD,
+                         0 );
+        mv.visitVarInsn( Opcodes.ALOAD,
+                         0 );
+        mv.visitFieldInsn( Opcodes.GETFIELD,
+                           className,
+                           DELEGATE_FIELD_NAME,
+                           Type.getDescriptor( clazz ) );
+        mv.visitMethodInsn( Opcodes.INVOKEVIRTUAL,
+                            className,
+                            "putAll",
+                            Type.getMethodDescriptor( Type.VOID_TYPE,
+                                                      new Type[]{Type.getType( Map.class )} ) );
+        Label l2 = new Label();
+        mv.visitLabel( l2 );
+        mv.visitInsn( Opcodes.RETURN );
+        Label l3 = new Label();
+        mv.visitLabel( l3 );
+        mv.visitLocalVariable( "this",
+                               "L" + className + ";",
+                               null,
+                               l0,
+                               l3,
+                               0 );
+        mv.visitMaxs( 0,
+                      0 );
+        mv.visitEnd();
+    }
+
     protected static void buildDelegateMethod(final Method method,
                                               final Class clazz,
                                               final String className,
@@ -725,20 +957,33 @@
             final Label l0 = new Label();
             mv.visitLabel( l0 );
 
-            // if ( this == object )
+            // if ( this == object || this.delegate == object )
             mv.visitVarInsn( Opcodes.ALOAD,
                              0 );
             mv.visitVarInsn( Opcodes.ALOAD,
                              1 );
             final Label l1 = new Label();
+            mv.visitJumpInsn( Opcodes.IF_ACMPEQ,
+                              l1 );
+            mv.visitVarInsn( Opcodes.ALOAD,
+                             0 );
+            mv.visitFieldInsn( Opcodes.GETFIELD,
+                               className,
+                               DELEGATE_FIELD_NAME,
+                               Type.getDescriptor( clazz ) );
+            mv.visitVarInsn( Opcodes.ALOAD,
+                             1 );
+            Label l2 = new Label();
             mv.visitJumpInsn( Opcodes.IF_ACMPNE,
-                              l1 );
+                              l2 );
+            mv.visitLabel( l1 );
+
             //      return true;
             mv.visitInsn( Opcodes.ICONST_1 );
             mv.visitInsn( Opcodes.IRETURN );
 
             // if (( object == null ) || ( ! ( object instanceof <class> ) ) ) 
-            mv.visitLabel( l1 );
+            mv.visitLabel( l2 );
             mv.visitVarInsn( Opcodes.ALOAD,
                              1 );
             final Label l3 = new Label();
@@ -989,25 +1234,75 @@
         }
     }
 
+    protected static void buildCollectionEquals(final ClassWriter cw,
+                                                final String className,
+                                                final Class clazz) {
+
+        final MethodVisitor mv = cw.visitMethod( Opcodes.ACC_PUBLIC,
+                                                 "equals",
+                                                 Type.getMethodDescriptor( Type.BOOLEAN_TYPE,
+                                                                           new Type[]{Type.getType( Object.class )} ),
+                                                 null,
+                                                 null );
+        // if ( this == object ) {
+        Label l0 = new Label();
+        mv.visitLabel( l0 );
+        mv.visitVarInsn( Opcodes.ALOAD,
+                         0 );
+        mv.visitVarInsn( Opcodes.ALOAD,
+                         1 );
+        Label l1 = new Label();
+        mv.visitJumpInsn( Opcodes.IF_ACMPNE,
+                          l1 );
+        //    return true;
+        Label l2 = new Label();
+        mv.visitLabel( l2 );
+        mv.visitInsn( Opcodes.ICONST_1 );
+        mv.visitInsn( Opcodes.IRETURN );
+        // }
+        mv.visitLabel( l1 );
+        // return this.delegate.equals( object );
+        mv.visitVarInsn( Opcodes.ALOAD,
+                         0 );
+        mv.visitFieldInsn( Opcodes.GETFIELD,
+                           className,
+                           DELEGATE_FIELD_NAME,
+                           Type.getDescriptor( clazz ) );
+        mv.visitVarInsn( Opcodes.ALOAD,
+                         1 );
+        mv.visitMethodInsn( Opcodes.INVOKEVIRTUAL,
+                            Type.getInternalName( clazz ),
+                            "equals",
+                            Type.getMethodDescriptor( Type.BOOLEAN_TYPE,
+                                                      new Type[]{Type.getType( Object.class )} ) );
+        mv.visitInsn( Opcodes.IRETURN );
+        Label l3 = new Label();
+        mv.visitLabel( l3 );
+        mv.visitLocalVariable( "this",
+                               "L" + className + ";",
+                               null,
+                               l0,
+                               l3,
+                               0 );
+        mv.visitLocalVariable( "object",
+                               Type.getDescriptor( Object.class ),
+                               null,
+                               l0,
+                               l3,
+                               1 );
+        mv.visitMaxs( 0,
+                      0 );
+        mv.visitEnd();
+    }
+
     /**
      *  Sample of generated code for all primitive + object types
      *  
      *  public int hashCode() {
-     *       if( ___hashCache != 0 ) {
-     *           return __hashCache;
+     *       if( ___hashCache == 0 ) {
+     *           __hashCache = this.delegate.hashCode();
      *       }
-     *       final int PRIME = 31;
-     *       int result = 1;
-     *       result = PRIME * result + (booleanAttr ? 1231 : 1237);
-     *       result = PRIME * result + charAttr;
-     *       long temp = Double.doubleToLongBits( doubleAttr );
-     *       result = PRIME * result + (int) (temp ^ (temp >>> 32));
-     *       result = PRIME * result + Float.floatToIntBits( floatAttr );
-     *       result = PRIME * result + intAttr;
-     *       result = PRIME * result + ((listAttr == null) ? 0 : listAttr.hashCode());
-     *       result = PRIME * result + (int) (longAttr ^ (longAttr >>> 32));
-     *       result = PRIME * result + shortAttr;
-     *       return result;
+     *       return this.__hashCache;
      *   }
      * 
      * @param cw
@@ -1020,7 +1315,6 @@
                                         final Class clazz,
                                         final Map fieldTypes) {
         MethodVisitor mv;
-        boolean hasDoubleAttr = false;
         // Building hashcode method
         {
             mv = cw.visitMethod( Opcodes.ACC_PUBLIC,
@@ -1031,293 +1325,59 @@
                                  null );
             mv.visitCode();
 
-            // if( __hashCache != 0 ) {
-            final Label ls = new Label();
-            mv.visitLabel( ls );
+            // if( this.__hashCache == 0 ) {
+            Label l0 = new Label();
+            mv.visitLabel( l0 );
             mv.visitVarInsn( Opcodes.ALOAD,
                              0 );
             mv.visitFieldInsn( Opcodes.GETFIELD,
                                className,
-                               ShadowProxyFactory.HASHCACHE_FIELD_NAME,
-                               Type.getDescriptor( int.class ) );
-            final Label afterIfCachedLabel = new Label();
-            mv.visitJumpInsn( Opcodes.IFEQ,
-                              afterIfCachedLabel );
-            //     return __hashCache;
-            // }
+                               HASHCACHE_FIELD_NAME,
+                               Type.INT_TYPE.getDescriptor() );
+            Label l1 = new Label();
+            mv.visitJumpInsn( Opcodes.IFNE,
+                              l1 );
+            Label l2 = new Label();
+
+            //    this.__hashCache = this.delegate.hashCode();
+            mv.visitLabel( l2 );
             mv.visitVarInsn( Opcodes.ALOAD,
                              0 );
+            mv.visitVarInsn( Opcodes.ALOAD,
+                             0 );
             mv.visitFieldInsn( Opcodes.GETFIELD,
                                className,
-                               ShadowProxyFactory.HASHCACHE_FIELD_NAME,
-                               Type.getDescriptor( int.class ) );
-            mv.visitInsn( Opcodes.IRETURN );
-            mv.visitLabel( afterIfCachedLabel );
-
-            // final int PRIME = 31;
-            final Label l0 = new Label();
-            mv.visitLabel( l0 );
-            mv.visitIntInsn( Opcodes.BIPUSH,
-                             31 );
-            mv.visitVarInsn( Opcodes.ISTORE,
-                             1 );
-
-            // int result = 1;
-            final Label l1 = new Label();
+                               DELEGATE_FIELD_NAME,
+                               Type.getDescriptor( clazz ) );
+            mv.visitMethodInsn( Opcodes.INVOKEVIRTUAL,
+                                Type.getInternalName( clazz ),
+                                "hashCode",
+                                Type.getMethodDescriptor( Type.INT_TYPE,
+                                                          new Type[0] ) );
+            mv.visitFieldInsn( Opcodes.PUTFIELD,
+                               className,
+                               HASHCACHE_FIELD_NAME,
+                               Type.INT_TYPE.getDescriptor() );
+            // }
             mv.visitLabel( l1 );
-            mv.visitInsn( Opcodes.ICONST_1 );
-            mv.visitVarInsn( Opcodes.ISTORE,
-                             2 );
 
-            // for each field:
-            int count = 0;
-            for ( final Iterator it = fieldTypes.entrySet().iterator(); it.hasNext(); ) {
-                final Map.Entry entry = (Map.Entry) it.next();
-                final String fieldName = (String) entry.getKey();
-                final Method method = (Method) entry.getValue();
-                final Class fieldType = method.getReturnType();
-                final String fieldFlag = fieldName + ShadowProxyFactory.FIELD_SET_FLAG;
-                count++;
-                final Label goNext = new Label();
-
-                // if ( ! _fieldIsSet ) {
-                final Label l5 = new Label();
-                mv.visitLabel( l5 );
-                mv.visitVarInsn( Opcodes.ALOAD,
-                                 0 );
-                mv.visitFieldInsn( Opcodes.GETFIELD,
-                                   className,
-                                   fieldFlag,
-                                   Type.BOOLEAN_TYPE.getDescriptor() );
-                final Label l6 = new Label();
-                mv.visitJumpInsn( Opcodes.IFNE,
-                                  l6 );
-
-                //     __field = this.delegate.method();
-                final Label l7 = new Label();
-                mv.visitLabel( l7 );
-                mv.visitVarInsn( Opcodes.ALOAD,
-                                 0 );
-                mv.visitVarInsn( Opcodes.ALOAD,
-                                 0 );
-                mv.visitFieldInsn( Opcodes.GETFIELD,
-                                   className,
-                                   ShadowProxyFactory.DELEGATE_FIELD_NAME,
-                                   Type.getDescriptor( clazz ) );
-                if ( clazz.isInterface() ) {
-                    mv.visitMethodInsn( Opcodes.INVOKEINTERFACE,
-                                        Type.getInternalName( clazz ),
-                                        method.getName(),
-                                        Type.getMethodDescriptor( method ) );
-                } else {
-                    mv.visitMethodInsn( Opcodes.INVOKEVIRTUAL,
-                                        Type.getInternalName( clazz ),
-                                        method.getName(),
-                                        Type.getMethodDescriptor( method ) );
-                }
-                mv.visitFieldInsn( Opcodes.PUTFIELD,
-                                   className,
-                                   fieldName,
-                                   Type.getDescriptor( fieldType ) );
-
-                //     __fieldIsSet = true;
-                final Label l8 = new Label();
-                mv.visitLabel( l8 );
-                mv.visitVarInsn( Opcodes.ALOAD,
-                                 0 );
-                mv.visitInsn( Opcodes.ICONST_1 );
-                mv.visitFieldInsn( Opcodes.PUTFIELD,
-                                   className,
-                                   fieldFlag,
-                                   Type.BOOLEAN_TYPE.getDescriptor() );
-
-                // }
-                mv.visitLabel( l6 );
-
-                if ( fieldType.isPrimitive() ) {
-                    // for primitive types
-                    // result = PRIME * result + <att hashcode>
-                    final Label l2 = new Label();
-                    if ( fieldType == Double.TYPE ) {
-                        hasDoubleAttr = true;
-                        mv.visitVarInsn( Opcodes.ALOAD,
-                                         0 );
-                        mv.visitFieldInsn( Opcodes.GETFIELD,
-                                           className,
-                                           fieldName,
-                                           Type.getDescriptor( fieldType ) );
-                        mv.visitMethodInsn( Opcodes.INVOKESTATIC,
-                                            Type.getInternalName( Double.class ),
-                                            "doubleToLongBits",
-                                            "(D)J" );
-                        mv.visitVarInsn( Opcodes.LSTORE,
-                                         3 );
-                    }
-
-                    mv.visitLabel( l2 );
-                    mv.visitIntInsn( Opcodes.BIPUSH,
-                                     31 );
-                    mv.visitVarInsn( Opcodes.ILOAD,
-                                     2 );
-                    mv.visitInsn( Opcodes.IMUL );
-
-                    if ( fieldType != Double.TYPE ) {
-                        mv.visitVarInsn( Opcodes.ALOAD,
-                                         0 );
-                        mv.visitFieldInsn( Opcodes.GETFIELD,
-                                           className,
-                                           fieldName,
-                                           Type.getDescriptor( fieldType ) );
-                    }
-
-                    if ( fieldType == Boolean.TYPE ) {
-                        // att_hashcode ::= ( boolean_attribute ) ? 1231 : 1237;
-                        final Label z1 = new Label();
-                        mv.visitJumpInsn( Opcodes.IFEQ,
-                                          z1 );
-                        mv.visitIntInsn( Opcodes.SIPUSH,
-                                         1231 );
-                        final Label z2 = new Label();
-                        mv.visitJumpInsn( Opcodes.GOTO,
-                                          z2 );
-                        mv.visitLabel( z1 );
-                        mv.visitIntInsn( Opcodes.SIPUSH,
-                                         1237 );
-                        mv.visitLabel( z2 );
-                    } else if ( fieldType == Double.TYPE ) {
-                        // long temp = Double.doubleToLongBits( doubleAttr );
-                        // att_hashcode ::= (int) (temp ^ ( temp >>> 32 ) );
-                        final Label d1 = new Label();
-                        mv.visitLabel( d1 );
-                        mv.visitVarInsn( Opcodes.LLOAD,
-                                         3 );
-                        mv.visitVarInsn( Opcodes.LLOAD,
-                                         3 );
-                        mv.visitIntInsn( Opcodes.BIPUSH,
-                                         32 );
-                        mv.visitInsn( Opcodes.LUSHR );
-                        mv.visitInsn( Opcodes.LXOR );
-                        mv.visitInsn( Opcodes.L2I );
-                    } else if ( fieldType == Float.TYPE ) {
-                        // att_hashcode ::= Float.floatToIntBits( floatAttr );
-                        mv.visitMethodInsn( Opcodes.INVOKESTATIC,
-                                            Type.getInternalName( Float.class ),
-                                            "floatToIntBits",
-                                            "(F)I" );
-
-                    } else if ( fieldType == Long.TYPE ) {
-                        // att_hashcode ::= (int) (lontattr ^( longattr >>> 32 ) );
-                        mv.visitVarInsn( Opcodes.ALOAD,
-                                         0 );
-                        mv.visitFieldInsn( Opcodes.GETFIELD,
-                                           className,
-                                           fieldName,
-                                           Type.getDescriptor( fieldType ) );
-                        mv.visitIntInsn( Opcodes.BIPUSH,
-                                         32 );
-                        mv.visitInsn( Opcodes.LUSHR );
-                        mv.visitInsn( Opcodes.LXOR );
-                        mv.visitInsn( Opcodes.L2I );
-
-                    }
-                    mv.visitInsn( Opcodes.IADD );
-                    mv.visitVarInsn( Opcodes.ISTORE,
-                                     2 );
-
-                } else {
-                    // for non primitive types
-                    // result = PRIME * result + <att hashcode>
-                    final Label l2 = new Label();
-                    mv.visitLabel( l2 );
-                    mv.visitIntInsn( Opcodes.BIPUSH,
-                                     31 );
-                    mv.visitVarInsn( Opcodes.ILOAD,
-                                     2 );
-                    mv.visitInsn( Opcodes.IMUL );
-
-                    mv.visitVarInsn( Opcodes.ALOAD,
-                                     0 );
-                    mv.visitFieldInsn( Opcodes.GETFIELD,
-                                       className,
-                                       fieldName,
-                                       Type.getDescriptor( fieldType ) );
-
-                    final Label np1 = new Label();
-                    mv.visitJumpInsn( Opcodes.IFNONNULL,
-                                      np1 );
-                    mv.visitInsn( Opcodes.ICONST_0 );
-                    final Label np2 = new Label();
-                    mv.visitJumpInsn( Opcodes.GOTO,
-                                      np2 );
-                    mv.visitLabel( np1 );
-                    mv.visitVarInsn( Opcodes.ALOAD,
-                                     0 );
-                    mv.visitFieldInsn( Opcodes.GETFIELD,
-                                       className,
-                                       fieldName,
-                                       Type.getDescriptor( fieldType ) );
-                    if ( fieldType.isInterface() ) {
-                        mv.visitMethodInsn( Opcodes.INVOKEINTERFACE,
-                                            Type.getInternalName( fieldType ),
-                                            "hashCode",
-                                            "()I" );
-                    } else {
-                        mv.visitMethodInsn( Opcodes.INVOKEVIRTUAL,
-                                            Type.getInternalName( fieldType ),
-                                            "hashCode",
-                                            "()I" );
-                    }
-                    mv.visitLabel( np2 );
-                    mv.visitInsn( Opcodes.IADD );
-                    mv.visitVarInsn( Opcodes.ISTORE,
-                                     2 );
-                }
-                mv.visitLabel( goNext );
-            }
-
-            // __hashCache = result;
+            // return this.__hashCache;
             mv.visitVarInsn( Opcodes.ALOAD,
                              0 );
-            mv.visitVarInsn( Opcodes.ILOAD,
-                             2 );
-            mv.visitFieldInsn( Opcodes.PUTFIELD,
+            mv.visitFieldInsn( Opcodes.GETFIELD,
                                className,
-                               ShadowProxyFactory.HASHCACHE_FIELD_NAME,
-                               Type.getDescriptor( int.class ) );
-
-            // return result;
-            mv.visitVarInsn( Opcodes.ILOAD,
-                             2 );
+                               HASHCACHE_FIELD_NAME,
+                               Type.INT_TYPE.getDescriptor() );
             mv.visitInsn( Opcodes.IRETURN );
-            final Label lastLabel = new Label();
-            mv.visitLabel( lastLabel );
-
+            Label l3 = new Label();
+            mv.visitLabel( l3 );
             mv.visitLocalVariable( "this",
                                    "L" + className + ";",
                                    null,
                                    l0,
-                                   lastLabel,
+                                   l3,
                                    0 );
-            mv.visitLocalVariable( "PRIME",
-                                   Type.INT_TYPE.getDescriptor(),
-                                   null,
-                                   l0,
-                                   lastLabel,
-                                   1 );
-            mv.visitLocalVariable( "result",
-                                   Type.INT_TYPE.getDescriptor(),
-                                   null,
-                                   l1,
-                                   lastLabel,
-                                   2 );
-            if ( hasDoubleAttr ) {
-                mv.visitLocalVariable( "temp",
-                                       Type.LONG_TYPE.getDescriptor(),
-                                       null,
-                                       l1,
-                                       lastLabel,
-                                       3 );
-            }
+
             mv.visitMaxs( 0,
                           0 );
             mv.visitEnd();

Modified: labs/jbossrules/branches/mvel-tooling-2007-06-30/drools-core/src/main/java/org/drools/base/evaluators/ObjectFactory.java
===================================================================
--- labs/jbossrules/branches/mvel-tooling-2007-06-30/drools-core/src/main/java/org/drools/base/evaluators/ObjectFactory.java	2007-07-05 20:01:26 UTC (rev 13116)
+++ labs/jbossrules/branches/mvel-tooling-2007-06-30/drools-core/src/main/java/org/drools/base/evaluators/ObjectFactory.java	2007-07-05 20:02:12 UTC (rev 13117)
@@ -19,6 +19,7 @@
 import java.util.Collection;
 
 import org.drools.base.BaseEvaluator;
+import org.drools.base.ShadowProxy;
 import org.drools.base.ValueType;
 import org.drools.common.InternalWorkingMemory;
 import org.drools.rule.VariableRestriction.ObjectVariableContextEntry;
@@ -104,6 +105,9 @@
             if ( value1 == null ) {
                 return value2 == null;
             }
+            if( value2 != null && value2 instanceof ShadowProxy ) {
+                return value2.equals( value1 );
+            }
             return value1.equals( value2 );
         }
 
@@ -113,6 +117,9 @@
             if ( value == null ) {
                 return ((ObjectVariableContextEntry) context).right == null;
             }
+            if( ((ObjectVariableContextEntry) context).right != null && ((ObjectVariableContextEntry) context).right instanceof ShadowProxy ) {
+                return ((ObjectVariableContextEntry) context).right.equals( value );
+            }
             return value.equals( ((ObjectVariableContextEntry) context).right );
         }
 
@@ -122,6 +129,9 @@
             if ( ((ObjectVariableContextEntry) context).left == null ) {
                 return value == null;
             }
+            if( value != null && value instanceof ShadowProxy ) {
+                return value.equals( ((ObjectVariableContextEntry) context).left );
+            }
             return ((ObjectVariableContextEntry) context).left.equals( value );
         }
 
@@ -134,6 +144,9 @@
             if ( value1 == null ) {
                 return value2 == null;
             }
+            if( value2 != null && value2 instanceof ShadowProxy ) {
+                return value2.equals( value1 );
+            }
             return value1.equals( value2 );
         }
 

Modified: labs/jbossrules/branches/mvel-tooling-2007-06-30/drools-core/src/main/java/org/drools/base/extractors/SelfReferenceClassFieldExtractor.java
===================================================================
--- labs/jbossrules/branches/mvel-tooling-2007-06-30/drools-core/src/main/java/org/drools/base/extractors/SelfReferenceClassFieldExtractor.java	2007-07-05 20:01:26 UTC (rev 13116)
+++ labs/jbossrules/branches/mvel-tooling-2007-06-30/drools-core/src/main/java/org/drools/base/extractors/SelfReferenceClassFieldExtractor.java	2007-07-05 20:02:12 UTC (rev 13117)
@@ -16,7 +16,6 @@
 
 package org.drools.base.extractors;
 
-import org.drools.base.ShadowProxy;
 import org.drools.base.ValueType;
 import org.drools.common.InternalWorkingMemory;
 
@@ -37,7 +36,8 @@
     }
 
     public Object getValue(InternalWorkingMemory workingMemory, final Object object) {
-        return (object instanceof ShadowProxy) ? ((ShadowProxy) object).getShadowedObject() : object;
+        //return (object instanceof ShadowProxy) ? ((ShadowProxy) object).getShadowedObject() : object;
+        return object;
     }   
     
     public boolean isNullValue(InternalWorkingMemory workingMemory, final Object object) {

Modified: labs/jbossrules/branches/mvel-tooling-2007-06-30/drools-core/src/main/java/org/drools/common/AbstractRuleBase.java
===================================================================
--- labs/jbossrules/branches/mvel-tooling-2007-06-30/drools-core/src/main/java/org/drools/common/AbstractRuleBase.java	2007-07-05 20:01:26 UTC (rev 13116)
+++ labs/jbossrules/branches/mvel-tooling-2007-06-30/drools-core/src/main/java/org/drools/common/AbstractRuleBase.java	2007-07-05 20:02:12 UTC (rev 13117)
@@ -73,7 +73,7 @@
     protected Map                                   pkgs;
 
     protected Map                                   processes;
-    
+
     protected Map                                   agendaGroupRuleTotals;
 
     protected transient CompositePackageClassLoader packageClassLoader;
@@ -98,7 +98,7 @@
     public AbstractRuleBase() {
 
     }
-    
+
     public synchronized int nextWorkingMemoryCounter() {
         return this.workingMemoryCounter++;
     }
@@ -120,7 +120,7 @@
         this.config = (config != null) ? config : new RuleBaseConfiguration();
         this.config.makeImmutable();
         this.factHandleFactory = factHandleFactory;
-        
+
         if ( this.config.isSequential() ) {
             this.agendaGroupRuleTotals = new HashMap();
         }
@@ -249,6 +249,10 @@
     public Package[] getPackages() {
         return (Package[]) this.pkgs.values().toArray( new Package[this.pkgs.size()] );
     }
+    
+    public Map getPackagesMap() {
+        return this.pkgs;
+    }
 
     public Map getGlobals() {
         return this.globals;
@@ -257,6 +261,7 @@
     public Map getAgendaGroupRuleTotals() {
         return this.agendaGroupRuleTotals;
     }
+
     /**
      * Add a <code>Package</code> to the network. Iterates through the
      * <code>Package</code> adding Each individual <code>Rule</code> to the
@@ -275,71 +280,74 @@
      */
     public synchronized void addPackage(final Package newPkg) throws PackageIntegrationException {
         newPkg.checkValidity();
-        final Package pkg = (Package) this.pkgs.get( newPkg.getName() );
-        // INVARIANT: lastAquiredLock always contains the index of the last aquired lock +1 
-        // in the working memory array 
-        int lastAquiredLock = 0;
-        // get a snapshot of current working memories for locking
-        final InternalWorkingMemory[] wms = getWorkingMemories();
 
-        try {
-            // Iterate each workingMemory and lock it
-            // This is so we don't update the Rete network during propagation
-            for ( lastAquiredLock = 0; lastAquiredLock < wms.length; lastAquiredLock++ ) {
-                wms[lastAquiredLock].getLock().lock();
-            }
+        synchronized ( this.pkgs ) {
+            final Package pkg = (Package) this.pkgs.get( newPkg.getName() );
+            // INVARIANT: lastAquiredLock always contains the index of the last aquired lock +1 
+            // in the working memory array 
+            int lastAquiredLock = 0;
+            // get a snapshot of current working memories for locking
+            final InternalWorkingMemory[] wms = getWorkingMemories();
 
-            if ( pkg != null ) {
-                mergePackage( pkg,
-                              newPkg );
-            } else {
-                this.pkgs.put( newPkg.getName(),
-                               newPkg );
-            }
+            try {
+                // Iterate each workingMemory and lock it
+                // This is so we don't update the Rete network during propagation
+                for ( lastAquiredLock = 0; lastAquiredLock < wms.length; lastAquiredLock++ ) {
+                    wms[lastAquiredLock].getLock().lock();
+                }
 
-            final Map newGlobals = newPkg.getGlobals();
+                if ( pkg != null ) {
+                    mergePackage( pkg,
+                                  newPkg );
+                } else {
+                    this.pkgs.put( newPkg.getName(),
+                                   newPkg );
+                }
 
-            // Check that the global data is valid, we cannot change the type
-            // of an already declared global variable
-            for ( final Iterator it = newGlobals.keySet().iterator(); it.hasNext(); ) {
-                final String identifier = (String) it.next();
-                final Class type = (Class) newGlobals.get( identifier );
-                final boolean f = this.globals.containsKey( identifier );
-                if ( f ) {
-                    final boolean y = !this.globals.get( identifier ).equals( type );
-                    if ( f && y ) {
-                        throw new PackageIntegrationException( pkg );
+                final Map newGlobals = newPkg.getGlobals();
+
+                // Check that the global data is valid, we cannot change the type
+                // of an already declared global variable
+                for ( final Iterator it = newGlobals.keySet().iterator(); it.hasNext(); ) {
+                    final String identifier = (String) it.next();
+                    final Class type = (Class) newGlobals.get( identifier );
+                    final boolean f = this.globals.containsKey( identifier );
+                    if ( f ) {
+                        final boolean y = !this.globals.get( identifier ).equals( type );
+                        if ( f && y ) {
+                            throw new PackageIntegrationException( pkg );
+                        }
                     }
                 }
-            }
-            this.globals.putAll( newGlobals );
+                this.globals.putAll( newGlobals );
 
-            final Rule[] rules = newPkg.getRules();
+                final Rule[] rules = newPkg.getRules();
 
-            for ( int i = 0; i < rules.length; ++i ) {
-                addRule( rules[i] );
-            }
+                for ( int i = 0; i < rules.length; ++i ) {
+                    addRule( rules[i] );
+                }
 
-            //and now the rule flows
-            if ( newPkg.getRuleFlows() != Collections.EMPTY_MAP ) {
-                Map flows = newPkg.getRuleFlows();
-                for ( Iterator iter = flows.entrySet().iterator(); iter.hasNext(); ) {
-                    Entry flow = (Entry) iter.next();
-                    this.processes.put( flow.getKey(),
-                                        flow.getValue() );
+                //and now the rule flows
+                if ( newPkg.getRuleFlows() != Collections.EMPTY_MAP ) {
+                    Map flows = newPkg.getRuleFlows();
+                    for ( Iterator iter = flows.entrySet().iterator(); iter.hasNext(); ) {
+                        Entry flow = (Entry) iter.next();
+                        this.processes.put( flow.getKey(),
+                                            flow.getValue() );
+                    }
                 }
-            }
 
-            this.packageClassLoader.addClassLoader( newPkg.getPackageCompilationData().getClassLoader() );
+                this.packageClassLoader.addClassLoader( newPkg.getPackageCompilationData().getClassLoader() );
 
-        } finally {
-            // Iterate each workingMemory and attempt to fire any rules, that were activated as a result 
-            // of the new rule addition. Unlock after fireAllRules();
+            } finally {
+                // Iterate each workingMemory and attempt to fire any rules, that were activated as a result 
+                // of the new rule addition. Unlock after fireAllRules();
 
-            // as per the INVARIANT defined above, we need to iterate from lastAquiredLock-1 to 0. 
-            for ( lastAquiredLock--; lastAquiredLock > -1; lastAquiredLock-- ) {
-                wms[lastAquiredLock].fireAllRules();
-                wms[lastAquiredLock].getLock().unlock();
+                // as per the INVARIANT defined above, we need to iterate from lastAquiredLock-1 to 0. 
+                for ( lastAquiredLock--; lastAquiredLock > -1; lastAquiredLock-- ) {
+                    wms[lastAquiredLock].fireAllRules();
+                    wms[lastAquiredLock].getLock().unlock();
+                }
             }
         }
 
@@ -402,88 +410,92 @@
     }
 
     public synchronized void removePackage(final String packageName) {
-        final Package pkg = (Package) this.pkgs.get( packageName );
+        synchronized ( this.pkgs ) {
+            final Package pkg = (Package) this.pkgs.get( packageName );
 
-        // INVARIANT: lastAquiredLock always contains the index of the last aquired lock +1 
-        // in the working memory array 
-        int lastAquiredLock = 0;
-        // get a snapshot of current working memories for locking
-        final InternalWorkingMemory[] wms = getWorkingMemories();
+            // INVARIANT: lastAquiredLock always contains the index of the last aquired lock +1 
+            // in the working memory array 
+            int lastAquiredLock = 0;
+            // get a snapshot of current working memories for locking
+            final InternalWorkingMemory[] wms = getWorkingMemories();
 
-        try {
-            // Iterate each workingMemory and lock it
-            // This is so we don't update the Rete network during propagation
-            for ( lastAquiredLock = 0; lastAquiredLock < wms.length; lastAquiredLock++ ) {
-                wms[lastAquiredLock].getLock().lock();
-            }
+            try {
+                // Iterate each workingMemory and lock it
+                // This is so we don't update the Rete network during propagation
+                for ( lastAquiredLock = 0; lastAquiredLock < wms.length; lastAquiredLock++ ) {
+                    wms[lastAquiredLock].getLock().lock();
+                }
 
-            final Rule[] rules = pkg.getRules();
+                final Rule[] rules = pkg.getRules();
 
-            for ( int i = 0; i < rules.length; ++i ) {
-                removeRule( rules[i] );
-            }
+                for ( int i = 0; i < rules.length; ++i ) {
+                    removeRule( rules[i] );
+                }
 
-            this.packageClassLoader.removeClassLoader( pkg.getPackageCompilationData().getClassLoader() );
+                this.packageClassLoader.removeClassLoader( pkg.getPackageCompilationData().getClassLoader() );
 
-            pkg.clear();
+                pkg.clear();
 
-            // getting the list of referenced globals 
-            final Set referencedGlobals = new HashSet();
-            for ( final Iterator it = this.pkgs.values().iterator(); it.hasNext(); ) {
-                final org.drools.rule.Package pkgref = (org.drools.rule.Package) it.next();
-                if ( pkgref != pkg ) {
-                    referencedGlobals.addAll( pkgref.getGlobals().keySet() );
+                // getting the list of referenced globals 
+                final Set referencedGlobals = new HashSet();
+                for ( final Iterator it = this.pkgs.values().iterator(); it.hasNext(); ) {
+                    final org.drools.rule.Package pkgref = (org.drools.rule.Package) it.next();
+                    if ( pkgref != pkg ) {
+                        referencedGlobals.addAll( pkgref.getGlobals().keySet() );
+                    }
                 }
-            }
-            // removing globals declared inside the package that are not shared
-            for ( final Iterator it = pkg.getGlobals().keySet().iterator(); it.hasNext(); ) {
-                final String globalName = (String) it.next();
-                if ( !referencedGlobals.contains( globalName ) ) {
-                    this.globals.remove( globalName );
+                // removing globals declared inside the package that are not shared
+                for ( final Iterator it = pkg.getGlobals().keySet().iterator(); it.hasNext(); ) {
+                    final String globalName = (String) it.next();
+                    if ( !referencedGlobals.contains( globalName ) ) {
+                        this.globals.remove( globalName );
+                    }
                 }
-            }
-            // removing the package itself from the list
-            this.pkgs.remove( pkg.getName() );
-        } finally {
-            // Iterate each workingMemory and attempt to fire any rules, that were activated as a result 
-            // of the new rule addition. Unlock after fireAllRules();
+                // removing the package itself from the list
+                this.pkgs.remove( pkg.getName() );
+            } finally {
+                // Iterate each workingMemory and attempt to fire any rules, that were activated as a result 
+                // of the new rule addition. Unlock after fireAllRules();
 
-            // as per the INVARIANT defined above, we need to iterate from lastAquiredLock-1 to 0. 
-            for ( lastAquiredLock--; lastAquiredLock > -1; lastAquiredLock-- ) {
-                wms[lastAquiredLock].fireAllRules();
-                wms[lastAquiredLock].getLock().unlock();
+                // as per the INVARIANT defined above, we need to iterate from lastAquiredLock-1 to 0. 
+                for ( lastAquiredLock--; lastAquiredLock > -1; lastAquiredLock-- ) {
+                    wms[lastAquiredLock].fireAllRules();
+                    wms[lastAquiredLock].getLock().unlock();
+                }
             }
         }
     }
 
-    public synchronized void removeRule(final String packageName,
-                                        final String ruleName) {
-        final Package pkg = (Package) this.pkgs.get( packageName );
-        final Rule rule = pkg.getRule( ruleName );
+    public void removeRule(final String packageName,
+                           final String ruleName) {
+        synchronized ( this.pkgs ) {
+            final Package pkg = (Package) this.pkgs.get( packageName );
+            final Rule rule = pkg.getRule( ruleName );
 
-        // INVARIANT: lastAquiredLock always contains the index of the last aquired lock +1 
-        // in the working memory array 
-        int lastAquiredLock = 0;
-        // get a snapshot of current working memories for locking
-        final InternalWorkingMemory[] wms = getWorkingMemories();
+            // INVARIANT: lastAquiredLock always contains the index of the last aquired lock +1 
+            // in the working memory array 
+            int lastAquiredLock = 0;
+            // get a snapshot of current working memories for locking
+            final InternalWorkingMemory[] wms = getWorkingMemories();
 
-        try {
-            // Iterate each workingMemory and lock it
-            // This is so we don't update the Rete network during propagation
-            for ( lastAquiredLock = 0; lastAquiredLock < wms.length; lastAquiredLock++ ) {
-                wms[lastAquiredLock].getLock().lock();
-            }
+            try {
+                // Iterate each workingMemory and lock it
+                // This is so we don't update the Rete network during propagation
+                for ( lastAquiredLock = 0; lastAquiredLock < wms.length; lastAquiredLock++ ) {
+                    wms[lastAquiredLock].getLock().lock();
+                }
 
-            removeRule( rule );
-            pkg.removeRule( rule );
+                removeRule( rule );
+                pkg.removeRule( rule );
 
-        } finally {
-            // Iterate each workingMemory and attempt to fire any rules, that were activated as a result 
-            // of the new rule addition. Unlock after fireAllRules();
+            } finally {
+                // Iterate each workingMemory and attempt to fire any rules, that were activated as a result 
+                // of the new rule addition. Unlock after fireAllRules();
 
-            // as per the INVARIANT defined above, we need to iterate from lastAquiredLock-1 to 0. 
-            for ( lastAquiredLock--; lastAquiredLock > -1; lastAquiredLock-- ) {
-                wms[lastAquiredLock].getLock().unlock();
+                // as per the INVARIANT defined above, we need to iterate from lastAquiredLock-1 to 0. 
+                for ( lastAquiredLock--; lastAquiredLock > -1; lastAquiredLock-- ) {
+                    wms[lastAquiredLock].getLock().unlock();
+                }
             }
         }
     }
@@ -511,7 +523,7 @@
         return (Package) this.pkgs.get( name );
     }
 
-    public StatefulSession[] getStatefulSessions() {        
+    public StatefulSession[] getStatefulSessions() {
         return (StatefulSession[]) this.statefulSessions.toArray( new StatefulSession[this.statefulSessions.size()] );
     }
 
@@ -534,16 +546,18 @@
                                                                           ClassNotFoundException {
 
         if ( this.config.isSequential() ) {
-            throw new RuntimeException( "Cannot have a stateful rule session, with sequential configuration set to true");
+            throw new RuntimeException( "Cannot have a stateful rule session, with sequential configuration set to true" );
         }
-        
+
         final DroolsObjectInputStream streamWithLoader = new DroolsObjectInputStream( stream,
                                                                                       this.packageClassLoader );
 
         final AbstractWorkingMemory workingMemory = (AbstractWorkingMemory) streamWithLoader.readObject();
-        workingMemory.setRuleBase( this );
-
-        return (StatefulSession) workingMemory;
+        
+        synchronized ( this.pkgs ) {
+            workingMemory.setRuleBase( this );
+            return (StatefulSession) workingMemory;
+        }
     }
 
     public void addClass(String className,

Modified: labs/jbossrules/branches/mvel-tooling-2007-06-30/drools-core/src/main/java/org/drools/common/AbstractWorkingMemory.java
===================================================================
--- labs/jbossrules/branches/mvel-tooling-2007-06-30/drools-core/src/main/java/org/drools/common/AbstractWorkingMemory.java	2007-07-05 20:01:26 UTC (rev 13116)
+++ labs/jbossrules/branches/mvel-tooling-2007-06-30/drools-core/src/main/java/org/drools/common/AbstractWorkingMemory.java	2007-07-05 20:02:12 UTC (rev 13117)
@@ -1167,7 +1167,7 @@
                                                                                       this.agenda.getDormantActivations() );
             doRetract( handle,
                        propagationContext );
-
+            
             if ( (originalObject != object) || (this.ruleBase.getConfiguration().getAssertBehaviour() != AssertBehaviour.IDENTITY) ) {
                 // as assertMap may be using an "identity" equality comparator,
                 // we need to remove the handle from the map, before replacing the object

Modified: labs/jbossrules/branches/mvel-tooling-2007-06-30/drools-core/src/main/java/org/drools/common/InternalRuleBase.java
===================================================================
--- labs/jbossrules/branches/mvel-tooling-2007-06-30/drools-core/src/main/java/org/drools/common/InternalRuleBase.java	2007-07-05 20:01:26 UTC (rev 13116)
+++ labs/jbossrules/branches/mvel-tooling-2007-06-30/drools-core/src/main/java/org/drools/common/InternalRuleBase.java	2007-07-05 20:02:12 UTC (rev 13117)
@@ -52,6 +52,8 @@
     public RuleBaseConfiguration getConfiguration();
     
     public Package getPackage(String name);
+    
+    public Map getPackagesMap();
 
     void disposeStatefulSession(StatefulSession statefulSession);
 

Modified: labs/jbossrules/branches/mvel-tooling-2007-06-30/drools-core/src/main/java/org/drools/reteoo/AccumulateNode.java
===================================================================
--- labs/jbossrules/branches/mvel-tooling-2007-06-30/drools-core/src/main/java/org/drools/reteoo/AccumulateNode.java	2007-07-05 20:01:26 UTC (rev 13116)
+++ labs/jbossrules/branches/mvel-tooling-2007-06-30/drools-core/src/main/java/org/drools/reteoo/AccumulateNode.java	2007-07-05 20:02:12 UTC (rev 13117)
@@ -29,7 +29,6 @@
 import org.drools.util.Entry;
 import org.drools.util.FactEntry;
 import org.drools.util.Iterator;
-import org.drools.util.AbstractHashTable.FactEntryImpl;
 import org.drools.util.ObjectHashMap.ObjectEntry;
 
 /**
@@ -119,13 +118,15 @@
 
         final BetaMemory memory = (BetaMemory) workingMemory.getNodeMemory( this );
 
-        memory.getTupleMemory().add( leftTuple );
-
         AccumulateResult accresult = new AccumulateResult();
-        memory.getCreatedHandles().put( leftTuple,
-                                        accresult,
-                                        false );
 
+        if ( !workingMemory.isSequential() ) {
+            memory.getTupleMemory().add( leftTuple );
+            memory.getCreatedHandles().put( leftTuple,
+                                            accresult,
+                                            false );
+        }
+
         final Object accContext = this.accumulate.createContext();
 
         accresult.context = accContext;
@@ -223,6 +224,11 @@
         final BetaMemory memory = (BetaMemory) workingMemory.getNodeMemory( this );
         memory.getFactHandleMemory().add( handle );
 
+        if ( workingMemory.isSequential() ) {
+            // do nothing here, as we know there are no left tuples at this stage in sequential mode.
+            return;
+        }        
+
         this.constraints.updateFromFactHandle( workingMemory,
                                                handle );
 

Modified: labs/jbossrules/branches/mvel-tooling-2007-06-30/drools-core/src/main/java/org/drools/reteoo/CollectNode.java
===================================================================
--- labs/jbossrules/branches/mvel-tooling-2007-06-30/drools-core/src/main/java/org/drools/reteoo/CollectNode.java	2007-07-05 20:01:26 UTC (rev 13116)
+++ labs/jbossrules/branches/mvel-tooling-2007-06-30/drools-core/src/main/java/org/drools/reteoo/CollectNode.java	2007-07-05 20:02:12 UTC (rev 13117)
@@ -30,7 +30,6 @@
 import org.drools.util.Entry;
 import org.drools.util.FactEntry;
 import org.drools.util.Iterator;
-import org.drools.util.AbstractHashTable.FactEntryImpl;
 import org.drools.util.ObjectHashMap.ObjectEntry;
 
 /**
@@ -130,17 +129,21 @@
 
         final BetaMemory memory = (BetaMemory) workingMemory.getNodeMemory( this );
 
-        memory.getTupleMemory().add( leftTuple );
-
         final Collection result = this.collect.instantiateResultObject();
         final InternalFactHandle resultHandle = workingMemory.getFactHandleFactory().newFactHandle( result );
         CollectResult colresult = new CollectResult();
         colresult.handle = resultHandle;
         colresult.propagated = false;
-        memory.getCreatedHandles().put( leftTuple,
-                                        colresult,
-                                        false );
+        
+        // do not add tuple and result to the memory in sequential mode
+        if( ! workingMemory.isSequential() ) {
+            memory.getTupleMemory().add( leftTuple );
+            memory.getCreatedHandles().put( leftTuple,
+                                            colresult,
+                                            false );
+        }
 
+
         final Iterator it = memory.getFactHandleMemory().iterator( leftTuple );
         this.constraints.updateFromTuple( workingMemory,
                                           leftTuple );
@@ -217,6 +220,11 @@
 
         final BetaMemory memory = (BetaMemory) workingMemory.getNodeMemory( this );
         memory.getFactHandleMemory().add( handle );
+        
+        if ( workingMemory.isSequential() ) {
+            // do nothing here, as we know there are no left tuples at this stage in sequential mode.
+            return;
+        }        
 
         this.constraints.updateFromFactHandle( workingMemory,
                                                handle );

Modified: labs/jbossrules/branches/mvel-tooling-2007-06-30/drools-core/src/main/java/org/drools/reteoo/CompositeObjectSinkAdapter.java
===================================================================
--- labs/jbossrules/branches/mvel-tooling-2007-06-30/drools-core/src/main/java/org/drools/reteoo/CompositeObjectSinkAdapter.java	2007-07-05 20:01:26 UTC (rev 13116)
+++ labs/jbossrules/branches/mvel-tooling-2007-06-30/drools-core/src/main/java/org/drools/reteoo/CompositeObjectSinkAdapter.java	2007-07-05 20:02:12 UTC (rev 13117)
@@ -179,7 +179,7 @@
         final List sinks = new ArrayList();
 
         //iterate twice as custom iterator is immutable
-        final Iterator mapIt = this.hashedSinkMap.iterator();
+        final Iterator mapIt = this.hashedSinkMap.newIterator();
         for ( ObjectHashMap.ObjectEntry e = (ObjectHashMap.ObjectEntry) mapIt.next(); e != null; ) {
 
             sinks.add( e.getValue() );
@@ -350,7 +350,7 @@
                     }
                 }
             } else if ( this.hashedSinkMap != null ) {
-                final Iterator it = this.hashedSinkMap.iterator();
+                final Iterator it = this.hashedSinkMap.newIterator();
                 for ( ObjectEntry entry = (ObjectEntry) it.next(); entry != null; entry = (ObjectEntry) it.next() ) {
                     final ObjectSink sink = (ObjectSink) entry.getValue();
                     sink.retractObject( handle,
@@ -395,7 +395,7 @@
         }
 
         if ( this.hashedSinkMap != null ) {
-            final Iterator it = this.hashedSinkMap.iterator();
+            final Iterator it = this.hashedSinkMap.newIterator();
             for ( ObjectEntry entry = (ObjectEntry) it.next(); entry != null; entry = (ObjectEntry) it.next() ) {
                 final ObjectSink sink = (ObjectSink) entry.getValue();
                 list.add( sink );

Modified: labs/jbossrules/branches/mvel-tooling-2007-06-30/drools-core/src/main/java/org/drools/reteoo/ExistsNode.java
===================================================================
--- labs/jbossrules/branches/mvel-tooling-2007-06-30/drools-core/src/main/java/org/drools/reteoo/ExistsNode.java	2007-07-05 20:01:26 UTC (rev 13116)
+++ labs/jbossrules/branches/mvel-tooling-2007-06-30/drools-core/src/main/java/org/drools/reteoo/ExistsNode.java	2007-07-05 20:02:12 UTC (rev 13117)
@@ -23,7 +23,6 @@
 import org.drools.spi.PropagationContext;
 import org.drools.util.FactEntry;
 import org.drools.util.Iterator;
-import org.drools.util.AbstractHashTable.FactEntryImpl;
 
 /**
  * <code>ExistsNode</code> extends <code>BetaNode</code> to perform tests for

Modified: labs/jbossrules/branches/mvel-tooling-2007-06-30/drools-core/src/main/java/org/drools/reteoo/JoinNode.java
===================================================================
--- labs/jbossrules/branches/mvel-tooling-2007-06-30/drools-core/src/main/java/org/drools/reteoo/JoinNode.java	2007-07-05 20:01:26 UTC (rev 13116)
+++ labs/jbossrules/branches/mvel-tooling-2007-06-30/drools-core/src/main/java/org/drools/reteoo/JoinNode.java	2007-07-05 20:02:12 UTC (rev 13117)
@@ -22,7 +22,6 @@
 import org.drools.spi.PropagationContext;
 import org.drools.util.FactEntry;
 import org.drools.util.Iterator;
-import org.drools.util.AbstractHashTable.FactEntryImpl;
 
 /**
  * <code>JoinNode</code> extends <code>BetaNode</code> to perform

Modified: labs/jbossrules/branches/mvel-tooling-2007-06-30/drools-core/src/main/java/org/drools/reteoo/MemoryVisitor.java
===================================================================
--- labs/jbossrules/branches/mvel-tooling-2007-06-30/drools-core/src/main/java/org/drools/reteoo/MemoryVisitor.java	2007-07-05 20:01:26 UTC (rev 13116)
+++ labs/jbossrules/branches/mvel-tooling-2007-06-30/drools-core/src/main/java/org/drools/reteoo/MemoryVisitor.java	2007-07-05 20:02:12 UTC (rev 13117)
@@ -38,7 +38,7 @@
     public void visitRete(final Rete rete) {
         final ObjectHashMap map = rete.getObjectTypeNodes();
 
-        final Iterator it = map.iterator();
+        final Iterator it = map.newIterator();
         for ( ObjectEntry entry = (ObjectEntry) it.next(); entry != null; entry = (ObjectEntry) it.next() ) {
             visit( entry.getValue() );
         }

Modified: labs/jbossrules/branches/mvel-tooling-2007-06-30/drools-core/src/main/java/org/drools/reteoo/NotNode.java
===================================================================
--- labs/jbossrules/branches/mvel-tooling-2007-06-30/drools-core/src/main/java/org/drools/reteoo/NotNode.java	2007-07-05 20:01:26 UTC (rev 13116)
+++ labs/jbossrules/branches/mvel-tooling-2007-06-30/drools-core/src/main/java/org/drools/reteoo/NotNode.java	2007-07-05 20:02:12 UTC (rev 13117)
@@ -23,7 +23,6 @@
 import org.drools.spi.PropagationContext;
 import org.drools.util.FactEntry;
 import org.drools.util.Iterator;
-import org.drools.util.AbstractHashTable.FactEntryImpl;
 
 /**
  * <code>NotNode</code> extends <code>BetaNode</code> to perform tests for

Modified: labs/jbossrules/branches/mvel-tooling-2007-06-30/drools-core/src/main/java/org/drools/reteoo/Rete.java
===================================================================
--- labs/jbossrules/branches/mvel-tooling-2007-06-30/drools-core/src/main/java/org/drools/reteoo/Rete.java	2007-07-05 20:01:26 UTC (rev 13116)
+++ labs/jbossrules/branches/mvel-tooling-2007-06-30/drools-core/src/main/java/org/drools/reteoo/Rete.java	2007-07-05 20:02:12 UTC (rev 13117)
@@ -19,9 +19,10 @@
 import java.io.IOException;
 import java.io.ObjectInputStream;
 import java.io.Serializable;
-import java.lang.reflect.Field;
 import java.util.ArrayList;
+import java.util.Collection;
 import java.util.List;
+import java.util.Map;
 
 import org.drools.FactException;
 import org.drools.RuleBaseConfiguration;
@@ -310,7 +311,6 @@
         protected boolean                      shadowEnabled;
         protected Class                        shadowClass;
         protected transient ObjectInstantiator instantiator;
-        protected transient Field              delegate;
 
         //private final InternalRuleBase ruleBase;
 
@@ -355,7 +355,6 @@
                 this.shadowClass = shadowClass;
                 this.shadowEnabled = true;
                 setInstantiator();
-                setDelegateFieldObject();
             }
         }
 
@@ -372,32 +371,26 @@
             this.instantiator = OBJENESIS.getInstantiatorOf( this.shadowClass );
         }
 
-        /**
-         * 
-         */
-        private void setDelegateFieldObject() {
-            try {
-                this.delegate = this.shadowClass.getDeclaredField( ShadowProxyFactory.DELEGATE_FIELD_NAME );
-                this.delegate.setAccessible( true );
-            } catch ( final Exception e ) {
-                throw new RuntimeDroolsException( "Error retriving delegate field for shadow proxy class: " + this.shadowClass.getName(),
-                                                  e );
-            }
-        }
-
         public Object getShadow(final Object fact) throws RuntimeDroolsException {
             ShadowProxy proxy = null;
             if ( isShadowEnabled() ) {
                 try {
-                    if ( this.delegate == null ) {
-                        this.setDelegateFieldObject();
+                    if( Collection.class.isAssignableFrom( this.shadowClass ) ||
+                        Map.class.isAssignableFrom( this.shadowClass ) ) {
+                        // if it is a collection, try to instantiate using constructor
+                        try {
+                            proxy = (ShadowProxy) this.shadowClass.getConstructor( new Class[] { cls } ).newInstance( new Object[] { fact } );
+                        } catch ( Exception e ) {
+                            // not possible to instantiate using constructor
+                        }
                     }
-                    if ( this.instantiator == null ) {
-                        this.setInstantiator();
+                    if( proxy == null ) {
+                        if ( this.instantiator == null ) {
+                            this.setInstantiator();
+                        }
+                        proxy = (ShadowProxy) this.instantiator.newInstance();
                     }
-                    proxy = (ShadowProxy) this.instantiator.newInstance();
-                    this.delegate.set( proxy,
-                                       fact );
+                    proxy.setShadowedObject( fact );
                 } catch ( final Exception e ) {
                     throw new RuntimeDroolsException( "Error creating shadow fact for object: " + fact,
                                                       e );
@@ -424,7 +417,7 @@
         private void buildCache(final Object object) throws FactException {
             final List cache = new ArrayList();
 
-            final Iterator it = ruleBase.getRete().getObjectTypeNodes().iterator();
+            final Iterator it = ruleBase.getRete().getObjectTypeNodes().newIterator();
             for ( ObjectEntry entry = (ObjectEntry) it.next(); entry != null; entry = (ObjectEntry) it.next() ) {
                 final ObjectTypeNode node = (ObjectTypeNode) entry.getValue();
                 if ( node.matches( object ) ) {

Modified: labs/jbossrules/branches/mvel-tooling-2007-06-30/drools-core/src/main/java/org/drools/reteoo/ReteooRuleBase.java
===================================================================
--- labs/jbossrules/branches/mvel-tooling-2007-06-30/drools-core/src/main/java/org/drools/reteoo/ReteooRuleBase.java	2007-07-05 20:01:26 UTC (rev 13116)
+++ labs/jbossrules/branches/mvel-tooling-2007-06-30/drools-core/src/main/java/org/drools/reteoo/ReteooRuleBase.java	2007-07-05 20:02:12 UTC (rev 13117)
@@ -126,7 +126,7 @@
         super( id,
                config,
                factHandleFactory );
-        this.rete = new Rete(this);
+        this.rete = new Rete( this );
         this.reteooBuilder = new ReteooBuilder( this );
     }
 
@@ -218,42 +218,45 @@
      */
     public synchronized StatefulSession newStatefulSession(final boolean keepReference) {
         if ( this.config.isSequential() ) {
-            throw new RuntimeException( "Cannot have a stateful rule session, with sequential configuration set to true");
+            throw new RuntimeException( "Cannot have a stateful rule session, with sequential configuration set to true" );
         }
+        ReteooStatefulSession session = null;
         
-        ExecutorService executor = this.config.getExecutorService();
-        final ReteooStatefulSession session = new ReteooStatefulSession( nextWorkingMemoryCounter(),
-                                                                         this,
-                                                                         executor );
-        
-        
-        executor.setCommandExecutor( new CommandExecutor( session ) );
+        synchronized ( this.pkgs ) {
+            ExecutorService executor = this.config.getExecutorService();
+            session = new ReteooStatefulSession( nextWorkingMemoryCounter(),
+                                                 this,
+                                                 executor );
 
-        if ( keepReference ) {
-            super.addStatefulSession( session );
-        }
+            executor.setCommandExecutor( new CommandExecutor( session ) );
 
-        final InitialFactHandle handle = new InitialFactHandle( session.getFactHandleFactory().newFactHandle( new InitialFactHandleDummyObject() ) );
+            if ( keepReference ) {
+                super.addStatefulSession( session );
+            }
 
-        session.queueWorkingMemoryAction( session.new WorkingMemoryReteAssertAction( handle,
-                                                                                     false,
-                                                                                     true,
-                                                                                     null,
-                                                                                     null ) );
+            final InitialFactHandle handle = new InitialFactHandle( session.getFactHandleFactory().newFactHandle( new InitialFactHandleDummyObject() ) );
 
+            session.queueWorkingMemoryAction( session.new WorkingMemoryReteAssertAction( handle,
+                                                                                         false,
+                                                                                         true,
+                                                                                         null,
+                                                                                         null ) );
+        }
         return session;
     }
-    
+
     public StatelessSession newStatelessSession() {
-        
+
         //orders the rules
         if ( this.config.isSequential() ) {
             this.reteooBuilder.order();
-        }                             
-        
-        return new ReteooStatelessSession( this );
-    }    
+        }
 
+        synchronized ( this.pkgs ) {
+            return new ReteooStatelessSession( this );
+        }
+    }
+
     protected synchronized void addRule(final Rule rule) throws InvalidPatternException {
         super.addRule( rule );
 

Modified: labs/jbossrules/branches/mvel-tooling-2007-06-30/drools-core/src/main/java/org/drools/reteoo/ReteooStatelessSession.java
===================================================================
--- labs/jbossrules/branches/mvel-tooling-2007-06-30/drools-core/src/main/java/org/drools/reteoo/ReteooStatelessSession.java	2007-07-05 20:01:26 UTC (rev 13116)
+++ labs/jbossrules/branches/mvel-tooling-2007-06-30/drools-core/src/main/java/org/drools/reteoo/ReteooStatelessSession.java	2007-07-05 20:02:12 UTC (rev 13117)
@@ -49,18 +49,20 @@
     }
 
     public InternalWorkingMemory newWorkingMemory() {
-        InternalWorkingMemory wm = new ReteooWorkingMemory( this.ruleBase.nextWorkingMemoryCounter(),
-                                                            this.ruleBase );
+        synchronized ( this.ruleBase.getPackagesMap() ) {
+            InternalWorkingMemory wm = new ReteooWorkingMemory( this.ruleBase.nextWorkingMemoryCounter(),
+                                                                this.ruleBase );
 
-        wm.setGlobals( globals );
-        if ( globalResolver != null ) {
-            wm.setGlobalResolver( this.globalResolver );
+            wm.setGlobals( globals );
+            if ( globalResolver != null ) {
+                wm.setGlobalResolver( this.globalResolver );
+            }
+            wm.setWorkingMemoryEventSupport( this.workingMemoryEventSupport );
+            wm.setAgendaEventSupport( this.agendaEventSupport );
+            wm.setRuleFlowEventSupport( ruleFlowEventSupport );
+
+            return wm;
         }
-        wm.setWorkingMemoryEventSupport( this.workingMemoryEventSupport );
-        wm.setAgendaEventSupport( this.agendaEventSupport );
-        wm.setRuleFlowEventSupport( ruleFlowEventSupport );
-
-        return wm;
     }
 
     public void addEventListener(final WorkingMemoryEventListener listener) {
@@ -113,16 +115,16 @@
         this.globalResolver = globalResolver;
     }
 
-    public void execute(Object object) {        
+    public void execute(Object object) {
         InternalWorkingMemory wm = newWorkingMemory();
-        
+
         wm.insert( object );
         wm.fireAllRules( this.agendaFilter );
     }
 
     public void execute(Object[] array) {
         InternalWorkingMemory wm = newWorkingMemory();
-        
+
         for ( int i = 0, length = array.length; i < length; i++ ) {
             wm.insert( array[i] );
         }
@@ -131,7 +133,7 @@
 
     public void execute(Collection collection) {
         InternalWorkingMemory wm = newWorkingMemory();
-        
+
         for ( Iterator it = collection.iterator(); it.hasNext(); ) {
             wm.insert( it.next() );
         }
@@ -140,37 +142,37 @@
 
     public void asyncExecute(final Object object) {
         InternalWorkingMemory wm = newWorkingMemory();
-        
+
         final AssertObject assertObject = new AssertObject( object );
         ExecutorService executor = this.ruleBase.getConfiguration().getExecutorService();
-        executor.setCommandExecutor( new CommandExecutor( wm ) );        
+        executor.setCommandExecutor( new CommandExecutor( wm ) );
         executor.submit( assertObject );
         executor.submit( new FireAllRules( this.agendaFilter ) );
     }
 
     public void asyncExecute(final Object[] array) {
         InternalWorkingMemory wm = newWorkingMemory();
-        
+
         final AssertObjects assertObjects = new AssertObjects( array );
         ExecutorService executor = this.ruleBase.getConfiguration().getExecutorService();
-        executor.setCommandExecutor( new CommandExecutor( wm ) );        
+        executor.setCommandExecutor( new CommandExecutor( wm ) );
         executor.submit( assertObjects );
         executor.submit( new FireAllRules( this.agendaFilter ) );
     }
 
     public void asyncExecute(final Collection collection) {
         InternalWorkingMemory wm = newWorkingMemory();
-        
+
         final AssertObjects assertObjects = new AssertObjects( collection );
         ExecutorService executor = this.ruleBase.getConfiguration().getExecutorService();
-        executor.setCommandExecutor( new CommandExecutor( wm ) );        
+        executor.setCommandExecutor( new CommandExecutor( wm ) );
         executor.submit( assertObjects );
         executor.submit( new FireAllRules( this.agendaFilter ) );
     }
 
     public StatelessSessionResult executeWithResults(Object object) {
         InternalWorkingMemory wm = newWorkingMemory();
-        
+
         wm.insert( object );
         wm.fireAllRules( this.agendaFilter );
         return new ReteStatelessSessionResult( wm );
@@ -178,7 +180,7 @@
 
     public StatelessSessionResult executeWithResults(Object[] array) {
         InternalWorkingMemory wm = newWorkingMemory();
-        
+
         for ( int i = 0, length = array.length; i < length; i++ ) {
             wm.insert( array[i] );
         }
@@ -188,7 +190,7 @@
 
     public StatelessSessionResult executeWithResults(Collection collection) {
         InternalWorkingMemory wm = newWorkingMemory();
-        
+
         for ( Iterator it = collection.iterator(); it.hasNext(); ) {
             wm.insert( it.next() );
         }

Modified: labs/jbossrules/branches/mvel-tooling-2007-06-30/drools-core/src/main/java/org/drools/util/AbstractHashTable.java
===================================================================
--- labs/jbossrules/branches/mvel-tooling-2007-06-30/drools-core/src/main/java/org/drools/util/AbstractHashTable.java	2007-07-05 20:01:26 UTC (rev 13116)
+++ labs/jbossrules/branches/mvel-tooling-2007-06-30/drools-core/src/main/java/org/drools/util/AbstractHashTable.java	2007-07-05 20:02:12 UTC (rev 13117)
@@ -59,6 +59,13 @@
         this.iterator.reset();
         return this.iterator;
     }
+    
+    public Iterator newIterator() {
+        HashTableIterator iterator = new HashTableIterator( this );
+        iterator.reset();
+        return iterator;
+        
+    }
 
     public void setComparator(final ObjectComparator comparator) {
         this.comparator = comparator;

Modified: labs/jbossrules/branches/mvel-tooling-2007-06-30/drools-core/src/test/java/org/drools/base/ShadowProxyFactoryTest.java
===================================================================
--- labs/jbossrules/branches/mvel-tooling-2007-06-30/drools-core/src/test/java/org/drools/base/ShadowProxyFactoryTest.java	2007-07-05 20:01:26 UTC (rev 13116)
+++ labs/jbossrules/branches/mvel-tooling-2007-06-30/drools-core/src/test/java/org/drools/base/ShadowProxyFactoryTest.java	2007-07-05 20:02:12 UTC (rev 13117)
@@ -1,7 +1,9 @@
 package org.drools.base;
 
 import java.util.ArrayList;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 
 import junit.framework.Assert;
 import junit.framework.TestCase;
@@ -173,12 +175,12 @@
             final Cheese cheeseProxy1 = (Cheese) proxy.getConstructor( new Class[]{Cheese.class} ).newInstance( new Object[]{cheese} );
             final Cheese cheeseProxy2 = (Cheese) proxy.getConstructor( new Class[]{Cheese.class} ).newInstance( new Object[]{cheese} );
 
-            final int cheesehash = cheeseHashCode( cheese );
+            int cheeseHash = cheese.hashCode();
             Assert.assertEquals( cheeseProxy1,
                                  cheeseProxy2 );
             Assert.assertEquals( cheeseProxy2,
                                  cheeseProxy1 );
-            Assert.assertEquals( cheesehash,
+            Assert.assertEquals( cheeseHash,
                                  cheeseProxy1.hashCode() );
 
             // changing original values
@@ -187,13 +189,14 @@
             cheese.setType( actualType );
             cheese.setPrice( actualPrice );
 
-            Assert.assertEquals( cheesehash,
+            Assert.assertEquals( cheeseHash,
                                  cheeseProxy1.hashCode() );
 
             // updating proxy1
             ((ShadowProxy) cheeseProxy1).updateProxy();
+            cheeseHash = cheese.hashCode();
 
-            Assert.assertEquals( cheeseHashCode( cheese ),
+            Assert.assertEquals( cheeseHash,
                                  cheeseProxy1.hashCode() );
 
             // now they are different
@@ -234,13 +237,13 @@
     //        }
     //    }
 
-    private int cheeseHashCode(final Cheese cheese) {
-        final int PRIME = 31;
-        int result = 1;
-        result = PRIME * result + ((cheese.getType() == null) ? 0 : cheese.getType().hashCode());
-        result = PRIME * result + cheese.getPrice();
-        return result;
-    }
+//    private int cheeseHashCode(final Cheese cheese) {
+//        final int PRIME = 31;
+//        int result = 1;
+//        result = PRIME * result + ((cheese.getType() == null) ? 0 : cheese.getType().hashCode());
+//        result = PRIME * result + cheese.getPrice();
+//        return result;
+//    }
 
     public void testClassWithStaticMethod() {
         try {
@@ -255,7 +258,7 @@
             final Cheese cheeseProxy1 = (Cheese) proxy.getConstructor( new Class[]{Cheese.class} ).newInstance( new Object[]{cheese} );
             final Cheese cheeseProxy2 = (Cheese) proxy.getConstructor( new Class[]{Cheese.class} ).newInstance( new Object[]{cheese} );
 
-            final int cheesehash = cheeseHashCode( cheese );
+            final int cheesehash = cheese.hashCode();
             Assert.assertEquals( cheeseProxy1,
                                  cheeseProxy2 );
             Assert.assertEquals( cheeseProxy2,
@@ -282,7 +285,7 @@
             final Cheese cheeseProxy1 = (Cheese) proxy.getConstructor( new Class[]{Cheese.class} ).newInstance( new Object[]{cheese} );
             final Cheese cheeseProxy2 = (Cheese) proxy.getConstructor( new Class[]{Cheese.class} ).newInstance( new Object[]{cheese} );
 
-            final int cheesehash = cheeseHashCode( cheese );
+            final int cheesehash = cheese.hashCode();
             Assert.assertEquals( cheeseProxy1,
                                  cheeseProxy2 );
             Assert.assertEquals( cheeseProxy2,
@@ -296,4 +299,89 @@
         }
     }
 
+    public void testProxyForCollections() {
+        try {
+            // creating original object
+            List originalList = new ArrayList();
+            originalList.add( "a" );
+            originalList.add( "b" );
+            originalList.add( "c" );
+            originalList.add( "d" );
+            
+            // creating proxy
+            final Class proxy = ShadowProxyFactory.getProxy( originalList.getClass() );
+            final List listProxy = (List) proxy.getConstructor( new Class[]{originalList.getClass()} ).newInstance( new Object[]{originalList} );
+            ((ShadowProxy)listProxy).setShadowedObject( originalList );
+
+            // proxy is proxying the values
+            Assert.assertEquals( "a",
+                                 listProxy.get( 0 ) );
+            Assert.assertTrue( listProxy.contains( "c" ) );
+            Assert.assertSame( originalList,
+                               ((ShadowProxy) listProxy).getShadowedObject() );
+
+            // proxy must recongnize the original object on equals() calls
+            Assert.assertEquals( listProxy,
+                                 originalList );
+            
+            originalList.remove( "c" );
+            originalList.add( "e" );
+            Assert.assertTrue( listProxy.contains( "c" ) );
+            Assert.assertFalse( listProxy.contains( "e" ) );
+            
+            ((ShadowProxy)listProxy).updateProxy();
+            Assert.assertFalse( listProxy.contains( "c" ) );
+            Assert.assertTrue( listProxy.contains( "e" ) );
+            
+            // proxy must recongnize the original object on equals() calls
+            Assert.assertEquals( listProxy,
+                                 originalList );
+        } catch ( final Exception e ) {
+            e.printStackTrace();
+            fail( "Error: " + e.getMessage() );
+        }
+    }
+
+    public void testProxyForMaps() {
+        try {
+            // creating original object
+            Map originalMap = new HashMap();
+            originalMap.put( "name", "Edson" );
+            originalMap.put( "surname", "Tirelli" );
+            originalMap.put( "age", "28" );
+            
+            // creating proxy
+            final Class proxy = ShadowProxyFactory.getProxy( originalMap.getClass() );
+            final Map mapProxy = (Map) proxy.getConstructor( new Class[]{originalMap.getClass()} ).newInstance( new Object[]{originalMap} );
+            ((ShadowProxy)mapProxy).setShadowedObject( originalMap );
+
+            // proxy is proxying the values
+            Assert.assertEquals( "Edson",
+                                 mapProxy.get( "name" ) );
+            Assert.assertTrue( mapProxy.containsKey( "age" ) );
+            Assert.assertSame( originalMap,
+                               ((ShadowProxy) mapProxy).getShadowedObject() );
+
+            // proxy must recongnize the original object on equals() calls
+            Assert.assertEquals( mapProxy,
+                                 originalMap );
+            
+            originalMap.remove( "age" );
+            originalMap.put( "hair", "brown" );
+            Assert.assertTrue( mapProxy.containsKey( "age" ) );
+            Assert.assertFalse( mapProxy.containsKey( "hair" ) );
+            
+            ((ShadowProxy)mapProxy).updateProxy();
+            Assert.assertFalse( mapProxy.containsKey( "age" ) );
+            Assert.assertTrue( mapProxy.containsKey( "hair" ) );
+            
+            // proxy must recongnize the original object on equals() calls
+            Assert.assertEquals( mapProxy,
+                                 originalMap );
+        } catch ( final Exception e ) {
+            e.printStackTrace();
+            fail( "Error: " + e.getMessage() );
+        }
+    }
+
 }

Modified: labs/jbossrules/branches/mvel-tooling-2007-06-30/drools-core/src/test/java/org/drools/reteoo/AccumulateNodeTest.java
===================================================================
--- labs/jbossrules/branches/mvel-tooling-2007-06-30/drools-core/src/test/java/org/drools/reteoo/AccumulateNodeTest.java	2007-07-05 20:01:26 UTC (rev 13116)
+++ labs/jbossrules/branches/mvel-tooling-2007-06-30/drools-core/src/test/java/org/drools/reteoo/AccumulateNodeTest.java	2007-07-05 20:02:12 UTC (rev 13117)
@@ -18,6 +18,7 @@
 import junit.framework.Assert;
 
 import org.drools.DroolsTestCase;
+import org.drools.RuleBaseConfiguration;
 import org.drools.RuleBaseFactory;
 import org.drools.base.ClassObjectType;
 import org.drools.common.DefaultFactHandle;
@@ -25,8 +26,8 @@
 import org.drools.common.InternalWorkingMemory;
 import org.drools.common.PropagationContextImpl;
 import org.drools.rule.Accumulate;
+import org.drools.rule.Declaration;
 import org.drools.rule.Pattern;
-import org.drools.rule.Declaration;
 import org.drools.rule.Rule;
 import org.drools.spi.MockConstraint;
 import org.drools.spi.ObjectType;
@@ -73,9 +74,6 @@
         final ObjectType srcObjType = new ClassObjectType( String.class );
         final Pattern sourcePattern = new Pattern( 0,
                                                 srcObjType );
-        final ObjectType resultObjType = new ClassObjectType( String.class );
-        final Pattern resultPattern = new Pattern( 1,
-                                                resultObjType );
         this.accumulate = new Accumulate( sourcePattern,
                                           new Declaration[0],
                                           new Declaration[0],
@@ -379,4 +377,57 @@
         assertNotNull( memory );
     }
 
+    /**
+     * Test just tuple assertions
+     * 
+     * @throws AssertionException
+     */
+    public void testAssertTupleSequentialMode() throws Exception {
+        RuleBaseConfiguration conf = new RuleBaseConfiguration();
+        conf.setSequential( true );
+
+        this.workingMemory = new ReteooWorkingMemory( 1,
+                                                      (ReteooRuleBase) RuleBaseFactory.newRuleBase( conf ) );
+        
+        this.memory = (BetaMemory) this.workingMemory.getNodeMemory( this.node );
+
+        final DefaultFactHandle f0 = (DefaultFactHandle) this.workingMemory.getFactHandleFactory().newFactHandle( "cheese" );
+        final DefaultFactHandle f1 = (DefaultFactHandle) this.workingMemory.getFactHandleFactory().newFactHandle( "other cheese" );
+
+        final ReteTuple tuple0 = new ReteTuple( f0 );
+
+        this.node.assertObject( f0,
+                                this.context,
+                                this.workingMemory );
+        this.node.assertObject( f1,
+                                this.context,
+                                this.workingMemory );
+
+        // assert tuple, should not add to left memory, since we are in sequential mode
+        this.node.assertTuple( tuple0,
+                               this.context,
+                               this.workingMemory );
+        // check memories 
+        assertNull( this.memory.getTupleMemory() );
+        assertEquals( 2,
+                      this.memory.getFactHandleMemory().size() );
+        Assert.assertEquals( "Wrong number of elements in matching objects list ",
+                             2,
+                             this.accumulator.getMatchingObjects().size() );
+
+        // assert tuple, should not add left memory 
+        final ReteTuple tuple1 = new ReteTuple( f1 );
+        this.node.assertTuple( tuple1,
+                               this.context,
+                               this.workingMemory );
+        assertNull( this.memory.getTupleMemory() );
+        Assert.assertEquals( "Wrong number of elements in matching objects list ",
+                             2,
+                             this.accumulator.getMatchingObjects().size() );
+
+        Assert.assertEquals( "Two tuples should have been propagated",
+                             2,
+                             this.sink.getAsserted().size() );
+    }
+
 }

Modified: labs/jbossrules/branches/mvel-tooling-2007-06-30/drools-core/src/test/java/org/drools/reteoo/CollectNodeTest.java
===================================================================
--- labs/jbossrules/branches/mvel-tooling-2007-06-30/drools-core/src/test/java/org/drools/reteoo/CollectNodeTest.java	2007-07-05 20:01:26 UTC (rev 13116)
+++ labs/jbossrules/branches/mvel-tooling-2007-06-30/drools-core/src/test/java/org/drools/reteoo/CollectNodeTest.java	2007-07-05 20:02:12 UTC (rev 13117)
@@ -22,6 +22,7 @@
 import junit.framework.Assert;
 
 import org.drools.DroolsTestCase;
+import org.drools.RuleBaseConfiguration;
 import org.drools.RuleBaseFactory;
 import org.drools.base.ClassObjectType;
 import org.drools.common.DefaultFactHandle;
@@ -364,4 +365,52 @@
         assertNotNull( memory );
     }
 
+    public void testAssertTupleSequentialMode() {
+        RuleBaseConfiguration conf = new RuleBaseConfiguration();
+        conf.setSequential( true );
+
+        this.workingMemory = new ReteooWorkingMemory( 1,
+                                                      (ReteooRuleBase) RuleBaseFactory.newRuleBase( conf ) );
+        
+        this.memory = (BetaMemory) this.workingMemory.getNodeMemory( this.node );
+
+        final DefaultFactHandle f0 = (DefaultFactHandle) this.workingMemory.getFactHandleFactory().newFactHandle( "cheese" );
+        final DefaultFactHandle f1 = (DefaultFactHandle) this.workingMemory.getFactHandleFactory().newFactHandle( "other cheese" );
+
+        final ReteTuple tuple0 = new ReteTuple( f0 );
+
+        this.node.assertObject( f0,
+                                this.contextAssert,
+                                this.workingMemory );
+        this.node.assertObject( f1,
+                                this.contextAssert,
+                                this.workingMemory );
+
+        // assert tuple, should not add to left memory, since we are in sequential mode
+        this.node.assertTuple( tuple0,
+                               this.contextAssert,
+                               this.workingMemory );
+        // check memories 
+        assertNull( this.memory.getTupleMemory() );
+        assertEquals( 2,
+                      this.memory.getFactHandleMemory().size() );
+        Assert.assertEquals( "Wrong number of elements in matching objects list ",
+                             2,
+                             ((Collection) ((DefaultFactHandle) ((Tuple) ((Object[]) this.sink.getAsserted().get( 0 ))[0]).get( 1 )).getObject()).size() );
+
+        // assert tuple, should not add to left memory, since we are in sequential mode
+        final ReteTuple tuple1 = new ReteTuple( f1 );
+        this.node.assertTuple( tuple1,
+                               this.contextAssert,
+                               this.workingMemory );
+        assertNull( this.memory.getTupleMemory() );
+        Assert.assertEquals( "Wrong number of elements in matching objects list ",
+                             2,
+                             ((Collection) ((DefaultFactHandle) ((Tuple) ((Object[]) this.sink.getAsserted().get( 1 ))[0]).get( 1 )).getObject()).size() );
+
+        Assert.assertEquals( "Two tuples should have been propagated",
+                             2,
+                             this.sink.getAsserted().size() );
+    }
+
 }

Modified: labs/jbossrules/branches/mvel-tooling-2007-06-30/drools-core/src/test/java/org/drools/reteoo/JoinNodeTest.java
===================================================================
--- labs/jbossrules/branches/mvel-tooling-2007-06-30/drools-core/src/test/java/org/drools/reteoo/JoinNodeTest.java	2007-07-05 20:01:26 UTC (rev 13116)
+++ labs/jbossrules/branches/mvel-tooling-2007-06-30/drools-core/src/test/java/org/drools/reteoo/JoinNodeTest.java	2007-07-05 20:02:12 UTC (rev 13117)
@@ -33,7 +33,6 @@
 import org.drools.spi.PropagationContext;
 import org.drools.util.FactEntry;
 import org.drools.util.Iterator;
-import org.drools.util.AbstractHashTable.FactEntryImpl;
 
 public class JoinNodeTest extends DroolsTestCase {
     Rule                rule;
@@ -191,9 +190,6 @@
 
         this.memory = (BetaMemory) this.workingMemory.getNodeMemory( this.node );
 
-        this.workingMemory = new ReteooWorkingMemory( 1,
-                                                      (ReteooRuleBase) RuleBaseFactory.newRuleBase( conf ) );
-
         final DefaultFactHandle f0 = new DefaultFactHandle( 0,
                                                             "cheese" );
         final ReteTuple tuple0 = new ReteTuple( f0 );
@@ -212,7 +208,7 @@
 
         assertNull( this.memory.getTupleMemory() );
 
-        assertEquals( 0,
+        assertEquals( 1,
                       this.memory.getFactHandleMemory().size() );
 
         assertEquals( new ReteTuple( tuple0,

Modified: labs/jbossrules/branches/mvel-tooling-2007-06-30/drools-core/src/test/java/org/drools/reteoo/NotNodeTest.java
===================================================================
--- labs/jbossrules/branches/mvel-tooling-2007-06-30/drools-core/src/test/java/org/drools/reteoo/NotNodeTest.java	2007-07-05 20:01:26 UTC (rev 13116)
+++ labs/jbossrules/branches/mvel-tooling-2007-06-30/drools-core/src/test/java/org/drools/reteoo/NotNodeTest.java	2007-07-05 20:02:12 UTC (rev 13117)
@@ -308,5 +308,53 @@
         assertEquals( 0,
                       constraints.length );
     }
+    
+    /**
+     * Test just tuple assertions
+     * 
+     * @throws AssertionException
+     */
+    public void testAssertTupleSequentialMode() throws Exception {
+        RuleBaseConfiguration conf = new RuleBaseConfiguration();
+        conf.setSequential( true );
 
+        this.workingMemory = new ReteooWorkingMemory( 1,
+                                                      (ReteooRuleBase) RuleBaseFactory.newRuleBase( conf ) );
+
+        // override setup, so its working in sequential mode
+        this.node = new NotNode( 15,
+                                  this.tupleSource,
+                                  this.objectSource,
+                                  new DefaultBetaConstraints( new BetaNodeFieldConstraint[]{this.constraint},
+                                                              conf ) );
+
+        this.node.addTupleSink( this.sink );
+
+        this.memory = (BetaMemory) this.workingMemory.getNodeMemory( this.node );
+
+        final DefaultFactHandle f0 = new DefaultFactHandle( 0,
+                                                            "cheese" );
+        final ReteTuple tuple0 = new ReteTuple( f0 );
+
+        this.node.assertObject( f0,
+                                this.context,
+                                this.workingMemory );
+
+        // assert tuple
+        this.node.assertTuple( tuple0,
+                               this.context,
+                               this.workingMemory );
+
+        assertEquals( 0,
+                      this.sink.getAsserted().size() );
+
+        assertNull( this.memory.getTupleMemory() );
+
+        assertEquals( 1,
+                      this.memory.getFactHandleMemory().size() );
+
+    }
+
+    
+
 }
\ No newline at end of file

Modified: labs/jbossrules/branches/mvel-tooling-2007-06-30/drools-decisiontables/src/main/java/org/drools/decisiontable/model/SnippetBuilder.java
===================================================================
--- labs/jbossrules/branches/mvel-tooling-2007-06-30/drools-decisiontables/src/main/java/org/drools/decisiontable/model/SnippetBuilder.java	2007-07-05 20:01:26 UTC (rev 13116)
+++ labs/jbossrules/branches/mvel-tooling-2007-06-30/drools-decisiontables/src/main/java/org/drools/decisiontable/model/SnippetBuilder.java	2007-07-05 20:02:12 UTC (rev 13117)
@@ -57,7 +57,7 @@
             throw new RuntimeException( "Script template is null - check for missing script definition." );
         }
 
-        if ( this._template.indexOf( SnippetBuilder.PARAM_PREFIX + "1" ) > 0 ) {
+        if ( this._template.indexOf( SnippetBuilder.PARAM_PREFIX + "1" ) >= 0 ) {
             return buildMulti( cellValue );
         } else {
             return buildSingle( cellValue );

Modified: labs/jbossrules/branches/mvel-tooling-2007-06-30/drools-eclipse/drools-eclipse-plugin/build.properties
===================================================================
--- labs/jbossrules/branches/mvel-tooling-2007-06-30/drools-eclipse/drools-eclipse-plugin/build.properties	2007-07-05 20:01:26 UTC (rev 13116)
+++ labs/jbossrules/branches/mvel-tooling-2007-06-30/drools-eclipse/drools-eclipse-plugin/build.properties	2007-07-05 20:02:12 UTC (rev 13117)
@@ -5,28 +5,17 @@
                lib/,\
                drools-eclipse-plugin.jar,\
                .,\
-               lib/drools-compiler.jar,\
-               lib/drools-core.jar,\
-               lib/drools-decisiontables.jar,\
-               lib/drools-jsr94.jar,\
-               lib/jsr94.jar,\
-               lib/junit.jar,\
-               lib/jxl.jar,\
-               lib/mvel14.jar,\
-               lib/xercesImpl.jar,\
-               lib/xml-apis.jar,\
-               lib/xpp3.jar,\
-               lib/xstream.jar,\
-               lib/antlr-runtime.jar
-src.includes = .project,\
-               .classpath,\
-               build.properties,\
+bin.excludes = lib/drools-documentation.jar   
+src.includes = META-INF/,\
                icons/,\
-               help/,\
                plugin.xml,\
-               src/,\
-               META-INF/,\
-               lib/
+               help/,\
+               lib/,\
+               .project,\
+               .classpath,\               
+               build.properties,\
+               src/
+src.excludes =  lib/drools-documentation.jar         
 jars.compile.order = .
 source.. = src/main/java/,\
            src/main/resources/

Modified: labs/jbossrules/branches/mvel-tooling-2007-06-30/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/DroolsEclipsePlugin.java
===================================================================
--- labs/jbossrules/branches/mvel-tooling-2007-06-30/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/DroolsEclipsePlugin.java	2007-07-05 20:01:26 UTC (rev 13116)
+++ labs/jbossrules/branches/mvel-tooling-2007-06-30/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/DroolsEclipsePlugin.java	2007-07-05 20:02:12 UTC (rev 13117)
@@ -18,6 +18,7 @@
 import java.io.Reader;
 import java.util.HashMap;
 import java.util.Iterator;
+import java.util.List;
 import java.util.Map;
 import java.util.MissingResourceException;
 import java.util.ResourceBundle;
@@ -301,10 +302,12 @@
 
                 // first parse the source
                 PackageDescr packageDescr = null;
+                List parserErrors = null;
                 if (useCache) {
                 	DRLInfo cachedDrlInfo = (DRLInfo) parsedRules.get(resource);
                 	if (cachedDrlInfo != null) {
                 		packageDescr = cachedDrlInfo.getPackageDescr();
+                		parserErrors = cachedDrlInfo.getParserErrors();
                 	}
                 }
                 
@@ -314,6 +317,7 @@
                 	} else {
                 		packageDescr = parser.parse(content);
                 	}
+                	parserErrors = parser.getErrors();
                 }
                 PackageBuilder builder = null;
         		DRLInfo result = null;
@@ -332,12 +336,12 @@
                     builder.addPackage(packageDescr);
         			result = new DRLInfo(
 	    				resource.getProjectRelativePath().toString(),
-	    				packageDescr, parser.getErrors(),
+	    				packageDescr, parserErrors,
 	    				builder.getPackage(), builder.getErrors().getErrors());
         		} else {
         			result = new DRLInfo(
 	    				resource.getProjectRelativePath().toString(),
-	    				packageDescr, parser.getErrors());
+	    				packageDescr, parserErrors);
         		}
         		            		
             	// cache result

Modified: labs/jbossrules/branches/mvel-tooling-2007-06-30/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/debug/core/DroolsDebugTarget.java
===================================================================
--- labs/jbossrules/branches/mvel-tooling-2007-06-30/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/debug/core/DroolsDebugTarget.java	2007-07-05 20:01:26 UTC (rev 13116)
+++ labs/jbossrules/branches/mvel-tooling-2007-06-30/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/debug/core/DroolsDebugTarget.java	2007-07-05 20:02:12 UTC (rev 13117)
@@ -51,52 +51,53 @@
     private ArrayList fThreads;
     private ThreadStartHandler fThreadStartHandler = null;
     private boolean fSuspended = true;
-    
+
     private List mvelBreakpoints = new ArrayList();
-    
+
     public DroolsDebugTarget(ILaunch launch, VirtualMachine jvm, String name, boolean supportTerminate, boolean supportDisconnect, IProcess process, boolean resume) {
         super(launch, jvm, name, supportTerminate, supportDisconnect, process, resume);
-        
+
 /*
         JdwpCommandPacket packet = new JdwpCommandPacket(JdwpCommandPacket.E_COMPOSITE);
         //packet.setData(data)
         ((VirtualMachineImpl)jvm).packetSendManager().sendPacket(packet);
-        
+
         ((MirrorImpl)jvm).requestVM(JdwpCommandPacket.E_COMPOSITE, data);
-    */  
+    */
     }
-    
+
     public void breakpointAdded(IBreakpoint breakpoint) {
         try {
             if (breakpoint instanceof DroolsLineBreakpoint) {
                 ((DroolsLineBreakpoint) breakpoint).setJavaBreakpointProperties();
-                                
+
                 DroolsLineBreakpoint d = (DroolsLineBreakpoint) breakpoint;
+                //MVEL:Logging
                 System.out.println("Got dialect "+d.getDialectName());
 
-                if (d.getDialectName().equals(MVELDialect.ID)) {                    
+                if (d.getDialectName().equals(MVELDialect.ID)) {
                     System.out.println("Adding MVEL breakpoint");
                     System.out.println("Line number "+d.getLineNumber());
                     System.out.println("Line2nr "+d.getDRLLineNumber());
                     //getBreakpoints().add( breakpoint );
                     //super.breakpointAdded(breakpoint);
                     mvelBreakpoints.add(breakpoint);
-                    
+
                     System.out.println("BREAKPOINT LINE NUMBER: "+d.getLineNumber());
-                    
+
                 } else {
-                    System.out.println("Adding Java breakpoint");    
+                    System.out.println("Adding Java breakpoint");
                     // only add breakpoint if setting Java properties of DRL
                     // breakpoint does not generate an error
                     super.breakpointAdded(breakpoint);
                }
-                
+
             } else {
                 super.breakpointAdded(breakpoint);
             }
         } catch (Throwable t) {
             // Exception will be thrown when trying to use breakpoint
-            // on drl that is incorrect (cannot be parsed or compiled) 
+            // on drl that is incorrect (cannot be parsed or compiled)
             DroolsEclipsePlugin.log(t);
         }
     }
@@ -105,11 +106,11 @@
         setThreadList(new ArrayList(5));
         super.initialize();
     }
-    
+
     protected JDIThread createThread(ThreadReference thread) {
         JDIThread jdiThread= null;
         try {
-            jdiThread= new DroolsThread(this, thread);            
+            jdiThread= new DroolsThread(this, thread);
         } catch (ObjectCollectedException exception) {
             // ObjectCollectionException can be thrown if the thread has already
             // completed (exited) in the VM.
@@ -124,7 +125,7 @@
         jdiThread.fireCreationEvent();
         return jdiThread;
     }
-    
+
     private Iterator getThreadIterator() {
         List threadList;
         synchronized (fThreads) {
@@ -147,9 +148,9 @@
         return (isSuspended() || hasSuspendedThreads())
             && isAvailable() && !isPerformingHotCodeReplace();
     }
-    
+
     protected void resume(boolean fireNotification) throws DebugException {
-        if ((!isSuspended() && !hasSuspendedThreads()) 
+        if ((!isSuspended() && !hasSuspendedThreads())
             || !isAvailable()) {
             return;
         }
@@ -169,22 +170,22 @@
         } catch (RuntimeException e) {
             setSuspended(true);
             fireSuspendEvent(DebugEvent.CLIENT_REQUEST);
-            targetRequestFailed(MessageFormat.format(JDIDebugModelMessages.JDIDebugTarget_exception_resume, new String[] {e.toString()}), e); 
-        }   
+            targetRequestFailed(MessageFormat.format(JDIDebugModelMessages.JDIDebugTarget_exception_resume, new String[] {e.toString()}), e);
+        }
     }
 
     private void setSuspended(boolean suspended) {
         fSuspended = suspended;
     }
-    
+
     public boolean isSuspended() {
         return fSuspended;
     }
-    
+
     private void setThreadList(ArrayList threads) {
         fThreads = threads;
     }
-    
+
     public IThread[] getThreads() {
         synchronized (fThreads) {
             return (IThread[])fThreads.toArray(new IThread[0]);
@@ -201,19 +202,19 @@
             fThreads.clear();
         }
     }
-    
+
     protected void initializeRequests() {
         setThreadStartHandler(new ThreadStartHandler());
-        new ThreadDeathHandler();       
+        new ThreadDeathHandler();
         new MVELTraceHandler();
     }
-    
+
     class ThreadDeathHandler implements IJDIEventListener {
-        
+
         protected ThreadDeathHandler() {
             createRequest();
         }
-        
+
         /**
          * Creates and registers a request to listen to thread
          * death events.
@@ -225,13 +226,13 @@
                     EventRequest req= manager.createThreadDeathRequest();
                     req.setSuspendPolicy(EventRequest.SUSPEND_NONE);
                     req.enable();
-                    addJDIEventListener(this, req); 
+                    addJDIEventListener(this, req);
                 } catch (RuntimeException e) {
                     logError(e);
-                }                   
+                }
             }
         }
-                
+
         /**
          * Locates the model thread associated with the underlying JDI thread
          * that has terminated, and removes it from the collection of
@@ -253,31 +254,31 @@
             }
             return true;
         }
-        
+
         /* (non-Javadoc)
          * @see org.eclipse.jdt.internal.debug.core.IJDIEventListener#wonSuspendVote(com.sun.jdi.event.Event, org.eclipse.jdt.internal.debug.core.model.JDIDebugTarget)
          */
         public void wonSuspendVote(Event event, JDIDebugTarget target) {
             // do nothing
         }
-    
+
     }
-    
+
     class ThreadStartHandler implements IJDIEventListener {
-        
+
         protected EventRequest fRequest;
-        
+
         protected ThreadStartHandler() {
             createRequest();
-        } 
-        
+        }
+
         /**
          * Creates and registers a request to handle all thread start
          * events
          */
         protected void createRequest() {
             EventRequestManager manager = getEventRequestManager();
-            if (manager != null) {          
+            if (manager != null) {
                 try {
                     EventRequest req= manager.createThreadStartRequest();
                     req.setSuspendPolicy(EventRequest.SUSPEND_NONE);
@@ -292,12 +293,12 @@
 
         /**
          * Creates a model thread for the underlying JDI thread
-         * and adds it to the collection of threads for this 
+         * and adds it to the collection of threads for this
          * debug target. As a side effect of creating the thread,
          * a create event is fired for the model thread.
          * The event is ignored if the underlying thread is already
          * marked as collected.
-         * 
+         *
          * @param event a thread start event
          * @param target the target in which the thread started
          * @return <code>true</code> - the thread should be resumed
@@ -334,7 +335,7 @@
         public void wonSuspendVote(Event event, JDIDebugTarget target) {
             // do nothing
         }
-        
+
         /**
          * Deregisters this event listener.
          */
@@ -344,7 +345,7 @@
                 setRequest(null);
             }
         }
-        
+
         protected EventRequest getRequest() {
             return fRequest;
         }
@@ -353,7 +354,7 @@
             fRequest = request;
         }
     }
-    
+
     private void disposeThreadHandler() {
         ThreadStartHandler handler = getThreadStartHandler2();
         if (handler != null) {
@@ -364,7 +365,7 @@
     public boolean hasThreads() {
         return fThreads.size() > 0;
     }
-    
+
     protected ThreadStartHandler getThreadStartHandler2() {
         return fThreadStartHandler;
     }
@@ -372,7 +373,7 @@
     protected void setThreadStartHandler(ThreadStartHandler threadStartHandler) {
         fThreadStartHandler = threadStartHandler;
     }
-    
+
     public boolean isOutOfSynch() throws DebugException {
         Iterator threads= getThreadIterator();
         while (threads.hasNext()) {
@@ -383,7 +384,7 @@
         }
         return false;
     }
-    
+
     public boolean mayBeOutOfSynch() {
         Iterator threads= getThreadIterator();
         while (threads.hasNext()) {
@@ -394,7 +395,7 @@
         }
         return false;
     }
-    
+
     public JDIThread findThread(ThreadReference tr) {
         Iterator iter= getThreadIterator();
         while (iter.hasNext()) {
@@ -404,11 +405,11 @@
         }
         return null;
     }
-    
+
     public void breakpointRemoved(IBreakpoint breakpoint, IMarkerDelta delta) {
         if (!isAvailable()) {
             return;
-        }       
+        }
         if (supportsBreakpoint(breakpoint)) {
             try {
                 ((JavaBreakpoint)breakpoint).removeFromTarget(this);
@@ -436,7 +437,7 @@
             ((DroolsThread)threads.next()).resumedByVM();
         }
     }
-    
+
     public void disconnect() throws DebugException {
 
         if (!isAvailable()) {
@@ -445,7 +446,7 @@
         }
 
         if (!canDisconnect()) {
-            notSupported(JDIDebugModelMessages.JDIDebugTarget_does_not_support_disconnect); 
+            notSupported(JDIDebugModelMessages.JDIDebugTarget_does_not_support_disconnect);
         }
 
         try {
@@ -459,7 +460,7 @@
             // normal disconnect handling
             disconnected();
         } catch (RuntimeException e) {
-            targetRequestFailed(MessageFormat.format(JDIDebugModelMessages.JDIDebugTarget_exception_disconnecting, new String[] {e.toString()}), e); 
+            targetRequestFailed(MessageFormat.format(JDIDebugModelMessages.JDIDebugTarget_exception_disconnecting, new String[] {e.toString()}), e);
         }
 
     }
@@ -469,7 +470,7 @@
             return;
         }
         if (!supportsTerminate()) {
-            notSupported(JDIDebugModelMessages.JDIDebugTarget_does_not_support_termination); 
+            notSupported(JDIDebugModelMessages.JDIDebugTarget_does_not_support_termination);
         }
         try {
             setTerminating(true);
@@ -483,7 +484,7 @@
                 process.terminate();
             }
         } catch (VMDisconnectedException e) {
-            // if the VM disconnects while exiting, perform 
+            // if the VM disconnects while exiting, perform
             // normal termination processing
             terminated();
         } catch (TimeoutException exception) {
@@ -496,10 +497,10 @@
                 disconnected();
             }
         } catch (RuntimeException e) {
-            targetRequestFailed(MessageFormat.format(JDIDebugModelMessages.JDIDebugTarget_exception_terminating, new String[] {e.toString()}), e); 
+            targetRequestFailed(MessageFormat.format(JDIDebugModelMessages.JDIDebugTarget_exception_terminating, new String[] {e.toString()}), e);
         }
     }
-    
+
     public void handleVMStart(VMStartEvent event) {
         if (isResumeOnStartup()) {
             try {
@@ -525,11 +526,11 @@
                 } catch (ObjectCollectedException e){
                 } catch (RuntimeException e) {
                     logError(e);
-                }               
+                }
             }
         }
     }
-    
+
     protected void initializeState() {
 
         List threads= null;
@@ -545,14 +546,14 @@
                 while (initialThreads.hasNext()) {
                     createThread((ThreadReference) initialThreads.next());
                 }
-            }           
+            }
         }
-        
+
         if (isResumeOnStartup()) {
             setSuspended(false);
         }
     }
-    
+
     public void suspend() throws DebugException {
         if (isSuspended()) {
             return;
@@ -568,26 +569,26 @@
         } catch (RuntimeException e) {
             setSuspended(false);
             fireResumeEvent(DebugEvent.CLIENT_REQUEST);
-            targetRequestFailed(MessageFormat.format(JDIDebugModelMessages.JDIDebugTarget_exception_suspend, new String[] {e.toString()}), e); 
+            targetRequestFailed(MessageFormat.format(JDIDebugModelMessages.JDIDebugTarget_exception_suspend, new String[] {e.toString()}), e);
         }
     }
-    
+
     public void prepareToSuspendByBreakpoint(JavaBreakpoint breakpoint) {
         setSuspended(true);
         suspendThreads();
     }
-    
+
     protected void cancelSuspendByBreakpoint(JavaBreakpoint breakpoint) throws DebugException {
         setSuspended(false);
         resumeThreads();
-    }   
+    }
 
     class MVELTraceHandler implements IJDIEventListener {
-        
+
         protected MVELTraceHandler() {
             createRequest();
         }
-        
+
         /**
          * Creates and registers a request to listen to thread
          * death events.
@@ -597,19 +598,19 @@
             if (manager != null) {
                 try {
 /*                    String className = "com.sample.DroolsTest";
-                    
+
                     List list = getVM().classesByName(className);
                     List alllist = getVM().allClasses();
-                    
+
                     System.out.println("Number of classes "+alllist.size());
                     System.out.println("they are:");
-                    
+
                     Iterator iter = alllist.iterator();
                     while (iter.hasNext()) {
                         Object o = (Object) iter.next();
                         System.out.println("allclass: "+o);
                     }
-                
+
                     System.out.println("Found classes "+list.size());
                     if (list.size()>0) {
                         System.out.println(". first "+iter.next());
@@ -619,14 +620,14 @@
                     req.addClassFilter("org.drools.base.mvel.MVELDebugHandler");
                     req.setSuspendPolicy(EventRequest.SUSPEND_ALL);
                     req.enable();
-                    addJDIEventListener(MVELTraceHandler.this, req); 
-                    
+                    addJDIEventListener(MVELTraceHandler.this, req);
+
                 } catch (RuntimeException e) {
                     logError(e);
-                }                   
+                }
             }
         }
-                
+
         /**
          * Locates the model thread associated with the underlying JDI thread
          * that has terminated, and removes it from the collection of
@@ -671,7 +672,7 @@
                                          }
 
                                          System.out.println("Suspending threads");
-     
+
                                          JDIThread thr = findThread( entryEvent.thread() );
                                          try {
                                             thr.suspend();
@@ -679,7 +680,7 @@
                                             // TODO Auto-generated catch block
                                             e.printStackTrace();
                                         }
-                                         
+
                                          System.out.println("Thread is "+entryEvent.thread().getClass());
                                          if (thr instanceof DroolsThread) {
                                              System.out.println("Drools Thread!!");
@@ -687,9 +688,9 @@
                                          }
                                          //suspendThreads();
                                          //suspendedByBreakpoint( null, false);
-                                         
-                                         
 
+
+
 /*                                         try {
                                             suspend();
                                         } catch ( DebugException e ) {
@@ -700,11 +701,11 @@
 
 /*                                         ReferenceType declaringType = entryEvent.location().declaringType();
                                          Field varsField = declaringType.fieldByName( "frameLocalVars" );
-                                         
+
                                          System.out.println("Field is "+varsField);
-                                         
+
                                          Value value = declaringType.getValue( varsField );
-                                         
+
                                          System.out.println( "Got Value: " + value );
 */
                                          return true;
@@ -718,7 +719,7 @@
                                      }
 
                                  },
-                                 req );    
+                                 req );
 
 
             //getVM().resume();
@@ -728,7 +729,7 @@
                 // TODO Auto-generated catch block
                 e.printStackTrace();
             }
-*/          
+*/
 /*          try {
                 String path = ((MethodEntryEvent)event).location().sourcePath();
                 if (path.startsWith("org.drools")) {
@@ -738,22 +739,22 @@
                 // TODO Auto-generated catch block
                 e.printStackTrace();
             }
-*/          
+*/
             //System.out.println("WOW! Got entry! "+method);
             return true;
         }
-        
+
         /* (non-Javadoc)
          * @see org.eclipse.jdt.internal.debug.core.IJDIEventListener#wonSuspendVote(com.sun.jdi.event.Event, org.eclipse.jdt.internal.debug.core.model.JDIDebugTarget)
          */
         public void wonSuspendVote(Event event, JDIDebugTarget target) {
             // do nothing
         }
-    
+
     }
 
     public Object getFirstDroolsBreakpoint() {
         return mvelBreakpoints.iterator().next();
     }
-    
+
 }

Modified: labs/jbossrules/branches/mvel-tooling-2007-06-30/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/debug/core/DroolsThread.java
===================================================================
--- labs/jbossrules/branches/mvel-tooling-2007-06-30/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/debug/core/DroolsThread.java	2007-07-05 20:01:26 UTC (rev 13116)
+++ labs/jbossrules/branches/mvel-tooling-2007-06-30/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/debug/core/DroolsThread.java	2007-07-05 20:02:12 UTC (rev 13117)
@@ -15,7 +15,6 @@
 import org.eclipse.jdt.internal.debug.core.model.JDIDebugTarget;
 import org.eclipse.jdt.internal.debug.core.model.JDIThread;
 
-import com.sun.jdi.AbsentInformationException;
 import com.sun.jdi.IncompatibleThreadStateException;
 import com.sun.jdi.InvalidStackFrameException;
 import com.sun.jdi.Location;
@@ -27,7 +26,7 @@
 
 	private List fStackFrames;
 	private boolean fRefreshChildren = true;
-	
+
 	public DroolsThread(JDIDebugTarget target, ThreadReference thread) throws ObjectCollectedException {
 		super(target, thread);
 	}
@@ -36,11 +35,11 @@
 		super.initialize();
 		fStackFrames = new ArrayList();
 	}
-	
+
 	public synchronized List computeStackFrames() throws DebugException {
 		return computeStackFrames(fRefreshChildren);
 	}
-	
+
 	protected synchronized List computeStackFrames(boolean refreshChildren) throws DebugException {
 		if (isSuspended()) {
 			if (isTerminated()) {
@@ -57,9 +56,9 @@
 				int newFrames = newSize - oldSize; // number of frames to create, if any
 				int depth = oldSize;
 				for (int i = newFrames - 1; i >= 0; i--) {
-				    
+
                     StackFrame currentFrame = (StackFrame) frames.get(i);
-                    
+
                     Location loc = currentFrame.location();
 
                     if ( loc.declaringType().name().equals( "org.drools.rule.builder.dialect.mvel.MVELDebugger" ) && loc.method().name().equals( "fireBreakpoint" ) ) {
@@ -75,7 +74,7 @@
                                                                 currentFrame,
                                                                 depth ) );
                     }
-                    
+
 					depth++;
 				}
 				int numToRebind = Math.min(newSize, oldSize); // number of frames to attempt to rebind
@@ -89,8 +88,8 @@
 					}
 					offset--;
 				}
-				
 
+
 			}
 			fRefreshChildren = false;
 		} else {
@@ -98,22 +97,22 @@
 		}
 		return fStackFrames;
 	}
-	
+
 	private List getUnderlyingFrames() throws DebugException {
 		if (!isSuspended()) {
 			// Checking isSuspended here eliminates a race condition in resume
 			// between the time stack frames are preserved and the time the
 			// underlying thread is actually resumed.
-			requestFailed(JDIDebugModelMessages.JDIThread_Unable_to_retrieve_stack_frame___thread_not_suspended__1, null, IJavaThread.ERR_THREAD_NOT_SUSPENDED); 
+			requestFailed(JDIDebugModelMessages.JDIThread_Unable_to_retrieve_stack_frame___thread_not_suspended__1, null, IJavaThread.ERR_THREAD_NOT_SUSPENDED);
 		}
 		try {
 			return getUnderlyingThread().frames();
 		} catch (IncompatibleThreadStateException e) {
-			requestFailed(JDIDebugModelMessages.JDIThread_Unable_to_retrieve_stack_frame___thread_not_suspended__1, e, IJavaThread.ERR_THREAD_NOT_SUSPENDED); 
+			requestFailed(JDIDebugModelMessages.JDIThread_Unable_to_retrieve_stack_frame___thread_not_suspended__1, e, IJavaThread.ERR_THREAD_NOT_SUSPENDED);
 		} catch (RuntimeException e) {
-			targetRequestFailed(MessageFormat.format(JDIDebugModelMessages.JDIThread_exception_retrieving_stack_frames_2, new String[] {e.toString()}), e); 
+			targetRequestFailed(MessageFormat.format(JDIDebugModelMessages.JDIThread_exception_retrieving_stack_frames_2, new String[] {e.toString()}), e);
 		} catch (InternalError e) {
-			targetRequestFailed(MessageFormat.format(JDIDebugModelMessages.JDIThread_exception_retrieving_stack_frames_2, new String[] {e.toString()}), e); 
+			targetRequestFailed(MessageFormat.format(JDIDebugModelMessages.JDIThread_exception_retrieving_stack_frames_2, new String[] {e.toString()}), e);
 		}
 		// execution will not reach this line, as
 		// #targetRequestFailed will thrown an exception
@@ -132,7 +131,7 @@
 		fStackFrames.clear();
 		fRefreshChildren = true;
 	}
-	
+
 	protected void popFrame(IStackFrame frame) throws DebugException {
 		JDIDebugTarget target= (JDIDebugTarget)getDebugTarget();
 		if (target.canPopFrames()) {
@@ -154,27 +153,27 @@
 					size= computeStackFrames().size();
 				}
 			} catch (IncompatibleThreadStateException exception) {
-				targetRequestFailed(MessageFormat.format(JDIDebugModelMessages.JDIThread_exception_popping, new String[] {exception.toString()}),exception); 
+				targetRequestFailed(MessageFormat.format(JDIDebugModelMessages.JDIThread_exception_popping, new String[] {exception.toString()}),exception);
 			} catch (InvalidStackFrameException exception) {
 				// InvalidStackFrameException can be thrown when all but the
 				// deepest frame were popped. Fire a changed notification
 				// in case this has occured.
 				fireChangeEvent(DebugEvent.CONTENT);
-				targetRequestFailed(exception.toString(),exception); 
+				targetRequestFailed(exception.toString(),exception);
 			} catch (RuntimeException exception) {
-				targetRequestFailed(MessageFormat.format(JDIDebugModelMessages.JDIThread_exception_popping, new String[] {exception.toString()}),exception); 
+				targetRequestFailed(MessageFormat.format(JDIDebugModelMessages.JDIThread_exception_popping, new String[] {exception.toString()}),exception);
 			}
 		}
 	}
-	
+
 	protected void terminated() {
 		super.terminated();
 	}
-	
+
 	protected void removeCurrentBreakpoint(IBreakpoint bp) {
 		super.removeCurrentBreakpoint(bp);
 	}
-	
+
 	protected synchronized void suspendedByVM() {
 		super.suspendedByVM();
 	}
@@ -182,15 +181,15 @@
 	protected synchronized void resumedByVM() throws DebugException {
 		super.resumedByVM();
 	}
-	
+
 	protected void setRunning(boolean running) {
 		super.setRunning(running);
 	}
-	
+
 	protected void dropToFrame(IStackFrame frame) throws DebugException {
 		super.dropToFrame(frame);
 	}
-	
+
 	protected synchronized void stepToFrame(IStackFrame frame) throws DebugException {
 		super.stepToFrame(frame);
 	}

Modified: labs/jbossrules/branches/mvel-tooling-2007-06-30/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/debug/core/MVELStackFrame.java
===================================================================
--- labs/jbossrules/branches/mvel-tooling-2007-06-30/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/debug/core/MVELStackFrame.java	2007-07-05 20:01:26 UTC (rev 13116)
+++ labs/jbossrules/branches/mvel-tooling-2007-06-30/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/debug/core/MVELStackFrame.java	2007-07-05 20:02:12 UTC (rev 13117)
@@ -32,6 +32,7 @@
         super( thread,
                frame,
                depth );
+        //MVEL:Logging
         System.out.println( "MVELStackFrame created for depth " + depth + " thread=" + thread );
 
     }
@@ -57,19 +58,19 @@
         ;
 
         /*        ReferenceType declaringType = .location().declaringType();
-         
+
          Field varsField = declaringType.fieldByName("frameLocalVars");
-         
+
          System.out.println("field is "+varsField);
-         
+
          Value value = declaringType.getValue(varsField);
-         
+
          System.out.println("value is "+value);
-         
+
          ObjectReferenceImpl valueImpl = (ObjectReferenceImpl) value;
-         
-         JDIFieldVariable var = new JDIFieldVariable((JDIDebugTarget)getDebugTarget(), varsField, valueImpl);       
 
+         JDIFieldVariable var = new JDIFieldVariable((JDIDebugTarget)getDebugTarget(), varsField, valueImpl);
+
          System.out.println("Got Value for Stack Frame!!: "+value+" with impl class "+value.getClass());
 
          result.add(var);
@@ -167,7 +168,7 @@
     /*    public int getLineNumber() throws DebugException {
      return 123;
      }
-     
+
      */
     public String getMethodName() throws DebugException {
         return "urr";

Modified: labs/jbossrules/branches/mvel-tooling-2007-06-30/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/editors/DRLRuleEditor.java
===================================================================
--- labs/jbossrules/branches/mvel-tooling-2007-06-30/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/editors/DRLRuleEditor.java	2007-07-05 20:01:26 UTC (rev 13116)
+++ labs/jbossrules/branches/mvel-tooling-2007-06-30/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/editors/DRLRuleEditor.java	2007-07-05 20:02:12 UTC (rev 13117)
@@ -166,6 +166,9 @@
             // imports
             List allImports = descr.getImports();
             this.imports = new ArrayList();
+            if (packageName != null) {
+                imports.addAll(getAllClassesInPackage(packageName));
+            }
             Iterator iterator = allImports.iterator();
             while (iterator.hasNext()) {
                 String importName = ((ImportDescr) iterator.next()).getTarget();

Modified: labs/jbossrules/branches/mvel-tooling-2007-06-30/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/editors/completion/DefaultCompletionProcessor.java
===================================================================
--- labs/jbossrules/branches/mvel-tooling-2007-06-30/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/editors/completion/DefaultCompletionProcessor.java	2007-07-05 20:01:26 UTC (rev 13116)
+++ labs/jbossrules/branches/mvel-tooling-2007-06-30/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/editors/completion/DefaultCompletionProcessor.java	2007-07-05 20:02:12 UTC (rev 13117)
@@ -198,6 +198,7 @@
 					// evalContext.newVariable((String) entry.getValue(), (String) entry.getKey(), null);
 					javaTextWithParams.append(entry.getValue() + " " + entry.getKey() + ";\n");
 				}
+				javaTextWithParams.append("org.drools.spi.KnowledgeHelper drools;");
 				javaTextWithParams.append(javaText);
 				String text = javaTextWithParams.toString();
 				evalContext.codeComplete(text, text.length(), requestor);

Modified: labs/jbossrules/branches/mvel-tooling-2007-06-30/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/editors/completion/LocationDeterminator.java
===================================================================
--- labs/jbossrules/branches/mvel-tooling-2007-06-30/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/editors/completion/LocationDeterminator.java	2007-07-05 20:01:26 UTC (rev 13116)
+++ labs/jbossrules/branches/mvel-tooling-2007-06-30/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/editors/completion/LocationDeterminator.java	2007-07-05 20:02:12 UTC (rev 13117)
@@ -15,7 +15,7 @@
 
 //    private static final Pattern PATTERN_PATTERN_START               = Pattern.compile( ".*[(,](\\s*(\\S*)\\s*:)?\\s*[^\\s<>!=:]*",
 //                                                                                Pattern.DOTALL );
-    static final Pattern PATTERN_PATTERN_OPERATOR            = Pattern.compile( ".*[(,](\\s*(\\S*)\\s*:)?\\s*([^\\s<>!=:\\(\\)]+)(\\s*([<>=!]+)\\s*[^\\s<>!=:]*\\s*(&&|\\|\\|))*\\s+",
+    static final Pattern PATTERN_PATTERN_OPERATOR            = Pattern.compile( ".*[(,](\\s*(\\S*)\\s*:)?\\s*([^\\s<>!=:\\(\\),]+)(\\s*([<>=!]+)\\s*[^\\s<>!=:]*\\s*(&&|\\|\\|))*\\s+",
                                                                                 Pattern.DOTALL );
 //    private static final Pattern PATTERN_PATTERN_CONTAINS_ARGUMENT   = Pattern.compile( ".*[(,](\\s*(\\S*)\\s*:)?\\s*([^\\s<>!=:\\(\\)]+)\\s+contains\\s+[^\\s<>!=:]*",
 //                                                                                Pattern.DOTALL );

Modified: labs/jbossrules/branches/mvel-tooling-2007-06-30/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/editors/completion/RuleCompletionProcessor.java
===================================================================
--- labs/jbossrules/branches/mvel-tooling-2007-06-30/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/editors/completion/RuleCompletionProcessor.java	2007-07-05 20:01:26 UTC (rev 13116)
+++ labs/jbossrules/branches/mvel-tooling-2007-06-30/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/editors/completion/RuleCompletionProcessor.java	2007-07-05 20:02:12 UTC (rev 13117)
@@ -10,19 +10,18 @@
 import org.drools.base.ClassTypeResolver;
 import org.drools.compiler.DrlParser;
 import org.drools.compiler.DroolsParserException;
+import org.drools.compiler.PackageBuilderConfiguration;
 import org.drools.eclipse.DroolsEclipsePlugin;
 import org.drools.eclipse.DroolsPluginImages;
 import org.drools.eclipse.editors.AbstractRuleEditor;
 import org.drools.eclipse.util.ProjectClassLoader;
 import org.drools.lang.Location;
-import org.drools.lang.descr.AccumulateDescr;
 import org.drools.lang.descr.AndDescr;
 import org.drools.lang.descr.BaseDescr;
 import org.drools.lang.descr.ExistsDescr;
 import org.drools.lang.descr.FactTemplateDescr;
 import org.drools.lang.descr.FieldBindingDescr;
 import org.drools.lang.descr.FieldTemplateDescr;
-import org.drools.lang.descr.FromDescr;
 import org.drools.lang.descr.GlobalDescr;
 import org.drools.lang.descr.NotDescr;
 import org.drools.lang.descr.OrDescr;
@@ -107,6 +106,8 @@
 					"or ", DROOLS_ICON));
 			list.add(new RuleCompletionProposal(prefix.length(), "from",
 					"from ", DROOLS_ICON));
+			list.add(new RuleCompletionProposal(prefix.length(), "forall",
+					"forall(  )", 8, DROOLS_ICON));
 			RuleCompletionProposal prop = new RuleCompletionProposal(prefix
 					.length(), "eval", "eval(  )", 6);
 			prop.setImage(DROOLS_ICON);
@@ -173,6 +174,8 @@
 		case Location.LOCATION_LHS_INSIDE_CONDITION_START:
 			String className = (String) location
 					.getProperty(Location.LOCATION_PROPERTY_CLASS_NAME);
+			String propertyName = (String) location
+					.getProperty(Location.LOCATION_PROPERTY_PROPERTY_NAME);
 			if (className != null) {
 				boolean isTemplate = addFactTemplatePropertyProposals(
 						prefix, className, list);
@@ -181,17 +184,47 @@
 							getImports(), ProjectClassLoader
 									.getProjectClassLoader(getEditor()));
 					try {
-						Class clazz = resolver.resolveType(className);
+						String currentClass = className;
+						if (propertyName != null) {
+							String[] nestedProperties = propertyName.split("\\.");
+							int nbSuperProperties = nestedProperties.length - 1;
+							if (propertyName.endsWith(".")) {
+								nbSuperProperties++;
+							}
+							for (int i = 0; i < nbSuperProperties; i++) {
+								String simplePropertyName = nestedProperties[i];
+								currentClass = getSimplePropertyClass(currentClass, simplePropertyName);
+								currentClass = convertToNonPrimitiveClass(currentClass);
+							}
+						}
+						RuleCompletionProposal p = new RuleCompletionProposal(prefix.length(), "this");
+							p.setImage(METHOD_ICON);
+							list.add(p);
+						Class clazz = resolver.resolveType(currentClass);
 						if (clazz != null) {
-							Iterator iterator2 = new ClassFieldInspector(
-									clazz).getFieldNames().keySet()
-									.iterator();
+							if (Map.class.isAssignableFrom(clazz)) {
+								p = new RuleCompletionProposal(
+									prefix.length(), "this['']", "this['']", 6);
+								p.setImage(METHOD_ICON);
+								list.add(p);
+							}
+							ClassFieldInspector inspector = new ClassFieldInspector(clazz);
+							Map types = inspector.getFieldTypes();
+							Iterator iterator2 = inspector.getFieldNames().keySet().iterator();
 							while (iterator2.hasNext()) {
 								String name = (String) iterator2.next();
-								RuleCompletionProposal p = new RuleCompletionProposal(
+								p = new RuleCompletionProposal(
 										prefix.length(), name, name + " ");
 								p.setImage(METHOD_ICON);
 								list.add(p);
+								Class type = (Class) types.get(name);
+								if (type != null && Map.class.isAssignableFrom(type)) {
+									name += "['']";
+									p = new RuleCompletionProposal(
+										prefix.length(), name, name, name.length() - 2);
+									p.setImage(METHOD_ICON);
+									list.add(p);
+								}
 							}
 						}
 					} catch (IOException exc) {
@@ -344,9 +377,9 @@
 					getRuleParameters(backText)));
 			break;
 		case Location.LOCATION_LHS_INSIDE_CONDITION_END:
-			list.add(new RuleCompletionProposal(prefix.length(), "&", "& ",
+			list.add(new RuleCompletionProposal(prefix.length(), "&&", "&& ",
 					DROOLS_ICON));
-			list.add(new RuleCompletionProposal(prefix.length(), "|", "| ",
+			list.add(new RuleCompletionProposal(prefix.length(), "||", "|| ",
 					DROOLS_ICON));
 			list.add(new RuleCompletionProposal(prefix.length(), ",", ", ",
 					DROOLS_ICON));
@@ -363,6 +396,17 @@
 								"accumulate",
 								"accumulate (  , init (  ), action (  ), result (  ) )",
 								13, DROOLS_ICON));
+				PackageBuilderConfiguration config = new PackageBuilderConfiguration(
+					ProjectClassLoader.getProjectClassLoader(getEditor()), null);
+				Map accumulateFunctions = config.getAccumulateFunctionsMap();
+				for (Iterator iterator2 = accumulateFunctions.keySet().iterator(); iterator2.hasNext(); ) {
+					String accumulateFunction = (String) iterator2.next();
+					list.add(new RuleCompletionProposal(
+							prefix.length(),
+							"accumulate " + accumulateFunction,
+							"accumulate (  , " + accumulateFunction + "(  ) )",
+							13, DROOLS_ICON));
+				}
 				list.add(new RuleCompletionProposal(prefix.length(),
 						"collect", "collect (  )", 10, DROOLS_ICON));
 				// add all functions
@@ -438,27 +482,45 @@
 				}
 				// if not found, return null
 			} else {
-				ClassTypeResolver resolver = new ClassTypeResolver(
-						getImports(), ProjectClassLoader
-								.getProjectClassLoader(getEditor()));
-				try {
-					Class clazz = resolver.resolveType(className);
-					if (clazz != null) {
-						Class clazzz = (Class) new ClassFieldInspector(clazz)
-								.getFieldTypes().get(propertyName);
-						if (clazzz != null) {
-							return clazzz.getName();
-						}
-					}
-				} catch (IOException exc) {
-					// Do nothing
-				} catch (ClassNotFoundException exc) {
-					// Do nothing
+				String[] nestedProperties = propertyName.split("\\.");
+				String currentClass = className;
+				for (int i = 0; i < nestedProperties.length; i++) {
+					String simplePropertyName = nestedProperties[i];
+					currentClass = getSimplePropertyClass(currentClass, simplePropertyName);
 				}
+				return currentClass; 
 			}
 		}
 		return null;
 	}
+	
+	private String getSimplePropertyClass(String className, String propertyName) {
+		if ("this".equals(propertyName)) {
+			return className;
+		}
+		if (propertyName.endsWith("]")) {
+			// TODO can we take advantage of generics here?
+			return "java.lang.Object";
+		}
+		ClassTypeResolver resolver = new ClassTypeResolver(
+			getImports(), ProjectClassLoader
+				.getProjectClassLoader(getEditor()));
+		try {
+			Class clazz = resolver.resolveType(className);
+			if (clazz != null) {
+				Class clazzz = (Class) new ClassFieldInspector(clazz)
+						.getFieldTypes().get(propertyName);
+				if (clazzz != null) {
+					return clazzz.getName();
+				}
+			}
+		} catch (IOException exc) {
+			// Do nothing
+		} catch (ClassNotFoundException exc) {
+			// Do nothing
+		}
+		return "java.lang.Object";
+	}
 
 	private Map getRuleParameters(String backText) {
 		Map result = new HashMap();
@@ -646,16 +708,7 @@
 			getRuleParameters(result, ((ExistsDescr) descr).getDescrs());
 		} else if (descr instanceof NotDescr) {
 			getRuleParameters(result, ((NotDescr) descr).getDescrs());
-		} else if (descr instanceof FromDescr) {
-			getRuleParameters(result, ((FromDescr) descr).getDescrs());
-		} else if (descr instanceof AccumulateDescr) {
-			AccumulateDescr accumulateDescr = (AccumulateDescr) descr;
-			getRuleParameters(result, accumulateDescr.getInputPattern());
-			if (accumulateDescr.getInputPattern() != null) {
-				getRuleParameters(result, accumulateDescr.getInputPattern());
-			}
 		}
-
 	}
 
 	private void getRuleSubParameters(Map result, List descrs, String clazz) {

Modified: labs/jbossrules/branches/mvel-tooling-2007-06-30/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/launching/DroolsSourceLookupDirector.java
===================================================================
--- labs/jbossrules/branches/mvel-tooling-2007-06-30/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/launching/DroolsSourceLookupDirector.java	2007-07-05 20:01:26 UTC (rev 13116)
+++ labs/jbossrules/branches/mvel-tooling-2007-06-30/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/launching/DroolsSourceLookupDirector.java	2007-07-05 20:02:12 UTC (rev 13117)
@@ -16,10 +16,11 @@
 
                                                             public void dispose() {
                                                                 // TODO Auto-generated method stub
-                                                                
+
                                                             }
 
                                                             public Object[] findSourceElements(Object object) throws CoreException {
+                                                            	//MVEL:Logging
                                                                 System.out.println("Searching for "+object);
                                                                 if (object instanceof MVELStackFrame) {
                                                                     MVELStackFrame frame = (MVELStackFrame) object;
@@ -40,18 +41,18 @@
 
                                                             public void init(ISourceLookupDirector director) {
                                                                 // TODO Auto-generated method stub
-                                                                
+
                                                             }
 
                                                             public void sourceContainersChanged(ISourceLookupDirector director) {
                                                                 // TODO Auto-generated method stub
-                                                                
+
                                                             }
-                                                            
+
                                                         }
-                                                        
+
         } );
-        
+
 		addParticipants(new ISourceLookupParticipant[]{new DroolsSourceLookupParticipant()});
 	}
 

Modified: labs/jbossrules/branches/mvel-tooling-2007-06-30/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/rulebuilder/ui/FactPatternWidget.java
===================================================================
--- labs/jbossrules/branches/mvel-tooling-2007-06-30/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/rulebuilder/ui/FactPatternWidget.java	2007-07-05 20:01:26 UTC (rev 13116)
+++ labs/jbossrules/branches/mvel-tooling-2007-06-30/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/rulebuilder/ui/FactPatternWidget.java	2007-07-05 20:02:12 UTC (rev 13117)
@@ -15,6 +15,8 @@
 import org.eclipse.swt.SWT;
 import org.eclipse.swt.events.ModifyEvent;
 import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.graphics.FontMetrics;
+import org.eclipse.swt.graphics.GC;
 import org.eclipse.swt.layout.GridData;
 import org.eclipse.swt.layout.GridLayout;
 import org.eclipse.swt.widgets.Combo;
@@ -603,8 +605,12 @@
                 }
             } );
 
-            toolkit.createLabel( parent,
-                                 "" );// dummy
+            GridData gd = new GridData( GridData.FILL_HORIZONTAL | 
+            		GridData.GRAB_HORIZONTAL | 
+            		GridData.HORIZONTAL_ALIGN_BEGINNING);
+            gd.horizontalSpan = 2;
+            
+            link.setLayoutData(gd);
         } else {
             switch ( c.constraintValueType ) {
                 case ISingleFieldConstraint.TYPE_LITERAL :
@@ -617,7 +623,7 @@
                               "icons/function_assets.gif" );
                     formulaValueEditor( parent,
                                         c,
-                                        new GridData( GridData.FILL_HORIZONTAL ) );
+                                        new GridData( GridData.FILL_HORIZONTAL  ) );
                     break;
                 case ISingleFieldConstraint.TYPE_VARIABLE :
                     variableEditor( parent,
@@ -638,7 +644,7 @@
         final Combo combo = new Combo( composite,
                                        SWT.READ_ONLY );
 
-        gd.horizontalSpan = 1;
+        gd.horizontalSpan = 2;
         combo.setLayoutData( gd );
         if ( c.value == null ) {
             combo.add( "Choose ..." );
@@ -674,10 +680,12 @@
         if ( c.value != null ) {
             box.setText( c.value );
         }
-
+        
         gd.horizontalSpan = 2;
+        gd.grabExcessHorizontalSpace = true;
+        gd.minimumWidth = 100;
         box.setLayoutData( gd );
-
+        
         box.addModifyListener( new ModifyListener() {
             public void modifyText(ModifyEvent e) {
                 c.value = box.getText();
@@ -696,7 +704,9 @@
         if ( c.value != null ) {
             box.setText( c.value );
         }
-
+        
+        gd.grabExcessHorizontalSpace = true;
+        gd.minimumWidth = 100;
         box.setLayoutData( gd );
 
         box.addModifyListener( new ModifyListener() {
@@ -707,6 +717,13 @@
         } );
     }
 
+	/*private int getPreferredWidth(final Text box) {
+		GC gc = new GC(box);
+        FontMetrics fm = gc.getFontMetrics();
+        int width = 7 * fm.getAverageCharWidth();
+		return width;
+	}*/
+
     private void deleteBindedFact() {
         List newPatterns = new ArrayList();
         for ( int i = 0; i < parentPattern.patterns.length; i++ ) {

Modified: labs/jbossrules/branches/mvel-tooling-2007-06-30/drools-eclipse/drools-eclipse-plugin/src/main/resources/org/drools/eclipse/editors/keywords.properties
===================================================================
--- labs/jbossrules/branches/mvel-tooling-2007-06-30/drools-eclipse/drools-eclipse-plugin/src/main/resources/org/drools/eclipse/editors/keywords.properties	2007-07-05 20:01:26 UTC (rev 13116)
+++ labs/jbossrules/branches/mvel-tooling-2007-06-30/drools-eclipse/drools-eclipse-plugin/src/main/resources/org/drools/eclipse/editors/keywords.properties	2007-07-05 20:02:12 UTC (rev 13117)
@@ -34,4 +34,5 @@
 collect
 date-effective
 date-expires
-enabled
\ No newline at end of file
+enabled
+forall
\ No newline at end of file

Modified: labs/jbossrules/branches/mvel-tooling-2007-06-30/drools-eclipse/drools-eclipse-test/src/test/java/org/drools/eclipse/editors/completion/IncompleteParsingTest.java
===================================================================
--- labs/jbossrules/branches/mvel-tooling-2007-06-30/drools-eclipse/drools-eclipse-test/src/test/java/org/drools/eclipse/editors/completion/IncompleteParsingTest.java	2007-07-05 20:01:26 UTC (rev 13116)
+++ labs/jbossrules/branches/mvel-tooling-2007-06-30/drools-eclipse/drools-eclipse-test/src/test/java/org/drools/eclipse/editors/completion/IncompleteParsingTest.java	2007-07-05 20:02:12 UTC (rev 13117)
@@ -6,13 +6,13 @@
 
 import org.drools.compiler.DrlParser;
 import org.drools.compiler.DroolsParserException;
-import org.drools.lang.descr.PatternDescr;
 import org.drools.lang.descr.EvalDescr;
 import org.drools.lang.descr.FieldBindingDescr;
 import org.drools.lang.descr.FieldConstraintDescr;
 import org.drools.lang.descr.FromDescr;
 import org.drools.lang.descr.LiteralRestrictionDescr;
 import org.drools.lang.descr.PackageDescr;
+import org.drools.lang.descr.PatternDescr;
 import org.drools.lang.descr.RestrictionConnectiveDescr;
 import org.drools.lang.descr.RuleDescr;
 import org.drools.lang.descr.VariableRestrictionDescr;
@@ -177,6 +177,20 @@
         assertEquals(-1, field.getEndCharacter());
 
         input = 
+        	"rule MyRule \n" + 
+        	"	when \n" + 
+        	"		Class ( name['xyz'].subname.subsubn";
+        rule = parseRuleString(input);
+        assertEquals(1, rule.getLhs().getDescrs().size());
+        pattern = (PatternDescr) rule.getLhs().getDescrs().get(0);
+        assertEquals("Class", pattern.getObjectType());
+        assertEquals(-1, pattern.getEndCharacter());
+        assertEquals(1, pattern.getDescrs().size());
+        field = (FieldConstraintDescr) pattern.getDescrs().get(0); 
+        assertEquals( "na", field.getFieldName() );
+        assertEquals(-1, field.getEndCharacter());
+
+        input = 
         	"rule MyRule \n" +
         	"	when \n" +
         	"		Class ( condition == true, ";
@@ -192,6 +206,19 @@
         input = 
         	"rule MyRule \n" +
         	"	when \n" +
+        	"		Class ( c : condition, ";
+        rule = parseRuleString(input);
+        assertEquals(1, rule.getLhs().getDescrs().size());
+        pattern = (PatternDescr) rule.getLhs().getDescrs().get(0);
+        assertEquals("Class", pattern.getObjectType());
+        assertEquals(-1, pattern.getEndCharacter());
+        assertEquals(1, pattern.getDescrs().size());
+        FieldBindingDescr fieldBinding = (FieldBindingDescr) pattern.getDescrs().get(0); 
+        assertEquals(-1, fieldBinding.getEndCharacter());
+
+        input = 
+        	"rule MyRule \n" +
+        	"	when \n" +
         	"		Class ( condition == true, na";
         rule = parseRuleString(input);
         assertEquals(1, rule.getLhs().getDescrs().size());

Modified: labs/jbossrules/branches/mvel-tooling-2007-06-30/drools-eclipse/drools-eclipse-test/src/test/java/org/drools/eclipse/editors/completion/LocationDeterminatorTest.java
===================================================================
--- labs/jbossrules/branches/mvel-tooling-2007-06-30/drools-eclipse/drools-eclipse-test/src/test/java/org/drools/eclipse/editors/completion/LocationDeterminatorTest.java	2007-07-05 20:01:26 UTC (rev 13116)
+++ labs/jbossrules/branches/mvel-tooling-2007-06-30/drools-eclipse/drools-eclipse-test/src/test/java/org/drools/eclipse/editors/completion/LocationDeterminatorTest.java	2007-07-05 20:02:12 UTC (rev 13117)
@@ -124,10 +124,20 @@
         location = LocationDeterminator.getLocation(input);
         assertEquals(Location.LOCATION_LHS_INSIDE_CONDITION_START, location.getType());
         assertEquals("Class", location.getProperty(Location.LOCATION_PROPERTY_CLASS_NAME));
+        assertEquals("na", location.getProperty(Location.LOCATION_PROPERTY_PROPERTY_NAME));
     
         input = 
         	"rule MyRule \n" +
         	"	when \n" +
+        	"		Class ( name.subProperty['test'].subsu";
+        location = LocationDeterminator.getLocation(input);
+        assertEquals(Location.LOCATION_LHS_INSIDE_CONDITION_START, location.getType());
+        assertEquals("Class", location.getProperty(Location.LOCATION_PROPERTY_CLASS_NAME));
+        assertEquals("name.subProperty['test'].subsu", location.getProperty(Location.LOCATION_PROPERTY_PROPERTY_NAME));
+    
+        input = 
+        	"rule MyRule \n" +
+        	"	when \n" +
         	"		Class ( condition == true, ";
         location = LocationDeterminator.getLocation(input);
         assertEquals(Location.LOCATION_LHS_INSIDE_CONDITION_START, location.getType());
@@ -162,6 +172,15 @@
         input = 
         	"rule MyRule \n" +
         	"	when \n" +
+        	"		Class ( c: condition, \n" +
+        	"			";
+        location = LocationDeterminator.getLocation(input);
+        assertEquals(Location.LOCATION_LHS_INSIDE_CONDITION_START, location.getType());
+        assertEquals("Class", location.getProperty(Location.LOCATION_PROPERTY_CLASS_NAME));
+    
+        input = 
+        	"rule MyRule \n" +
+        	"	when \n" +
         	"		Class ( name : ";
         location = LocationDeterminator.getLocation(input);
         assertEquals(Location.LOCATION_LHS_INSIDE_CONDITION_START, location.getType());
@@ -1350,6 +1369,11 @@
         	"	salience 12 activation-group \"my";
         location = LocationDeterminator.getLocation(input);
         assertEquals(Location.LOCATION_RULE_HEADER, location.getType());
+
+        input = 
+        	"rule \"Hello World\" ruleflow-group \"hello\" s";
+        location = LocationDeterminator.getLocation(input);
+        assertEquals(Location.LOCATION_RULE_HEADER, location.getType());
     }
     
     public void testCheckQueryLocationDetermination() {

Modified: labs/jbossrules/branches/mvel-tooling-2007-06-30/drools-jsr94/src/main/java/org/drools/jsr94/rules/Jsr94FactHandleFactory.java
===================================================================
--- labs/jbossrules/branches/mvel-tooling-2007-06-30/drools-jsr94/src/main/java/org/drools/jsr94/rules/Jsr94FactHandleFactory.java	2007-07-05 20:01:26 UTC (rev 13116)
+++ labs/jbossrules/branches/mvel-tooling-2007-06-30/drools-jsr94/src/main/java/org/drools/jsr94/rules/Jsr94FactHandleFactory.java	2007-07-05 20:02:12 UTC (rev 13117)
@@ -46,6 +46,6 @@
     }
 
     public Class getFactHandleType() {
-        return DefaultFactHandle.class;
+        return Jsr94FactHandle.class;
     }
 }




More information about the jboss-svn-commits mailing list