[jboss-svn-commits] JBL Code SVN: r13762 - labs/jbossrules/trunk/documentation/manual/en/Chapter-Release_Notes.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Tue Jul 24 10:23:49 EDT 2007


Author: tirelli
Date: 2007-07-24 10:23:49 -0400 (Tue, 24 Jul 2007)
New Revision: 13762

Added:
   labs/jbossrules/trunk/documentation/manual/en/Chapter-Release_Notes/Section-Upgrade_tips.xml
Log:
Adding upgrade tips

Added: labs/jbossrules/trunk/documentation/manual/en/Chapter-Release_Notes/Section-Upgrade_tips.xml
===================================================================
--- labs/jbossrules/trunk/documentation/manual/en/Chapter-Release_Notes/Section-Upgrade_tips.xml	                        (rev 0)
+++ labs/jbossrules/trunk/documentation/manual/en/Chapter-Release_Notes/Section-Upgrade_tips.xml	2007-07-24 14:23:49 UTC (rev 13762)
@@ -0,0 +1,189 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<section>
+  <title>Upgrade tips from Drools 3.0.x to Drools 4.0.x</title>
+
+  <para>As mentioned before Drools 4.0 is a major update over the previous
+  Drools 3.0.x series. Unfortunatelly, in order to achieve the goals set for
+  this release, some backward compatibility issues were introduced, as
+  discussed in the maiil list and blogs.</para>
+
+  <para>This section of the manual is a work in progress and will document a
+  simple how-to on upgrading from Drools 3.0.x to Drools 4.0.x. </para>
+
+  <section>
+    <title>API changes</title>
+
+    <para>There are a few API changes that are visible to regular users and
+    need to be fixed.</para>
+
+    <section>
+      <title>Working Memory creation</title>
+
+      <para>Drools 3.0.x had only one working memory type that worked like a
+      stateful working memory. Drools 4.0.x introduces separate APIs for
+      Stateful and Stateless working memories that are called now Rule
+      Sessions. In Drools 3.0.x, the code to create a working memory
+      was:</para>
+
+      <para><example>
+          <title>Drools 3.0.x: Working Memory Creation</title>
+
+          <programlisting>WorkingMemory wm = rulebase.newWorkingMemory();</programlisting>
+        </example>In Drools 4.0.x it must be changed to:</para>
+
+      <para><example>
+          <title>Drools 4.0.x: Stateful Rule Session Creation</title>
+
+          <programlisting>StatefulSession wm = rulebase.newStatefulSession();</programlisting>
+        </example>The StatefulSession object has the same behavior as the
+      Drools 3.0.x WorkingMemory (it even extends the WorkingMemory
+      interface), so there should be no other problems with this fix.</para>
+    </section>
+
+    <section>
+      <title>Working Memory Actions</title>
+
+      <para>Drools 4.0.x now supports pluggable dialects and has built-in
+      support for Java and MVEL scripting language. In order to avoid keyword
+      conflicts, the working memory actions were renamed as showed
+      bellow:</para>
+
+      <para></para>
+
+      <table>
+        <title>Working Memory Actions equivalent API methods</title>
+
+        <tgroup cols="2">
+          <tbody>
+            <row>
+              <entry><emphasis role="bold">Drools 3.0.x</emphasis></entry>
+
+              <entry><emphasis role="bold">Drools 4.0.x</emphasis></entry>
+            </row>
+
+            <row>
+              <entry>WorkingMemory.assertObject()</entry>
+
+              <entry>WorkingMemory.insert()</entry>
+            </row>
+
+            <row>
+              <entry>WorkingMemory.assertLogicalObject()</entry>
+
+              <entry>WorkingMemory.insertLogical()</entry>
+            </row>
+
+            <row>
+              <entry>WorkingMemory.modifyObject()</entry>
+
+              <entry>WorkingMemory.update()</entry>
+            </row>
+          </tbody>
+        </tgroup>
+      </table>
+    </section>
+  </section>
+
+  <section>
+    <title>Rule Language Changes</title>
+
+    <para>The DRL Rule Language also has some backward incompatible changes as
+    detailed bellow.</para>
+
+    <section>
+      <title>Working Memory Actions</title>
+
+      <para>The Working Memory actions in rule consequences were also changed
+      in a similar way to the change made in the API. The following table
+      sumarizes the change:</para>
+
+      <table>
+        <title>Working Memory Actions equivalent DRL commands</title>
+
+        <tgroup cols="2">
+          <tbody>
+            <row>
+              <entry><emphasis role="bold">Drools 3.0.x</emphasis></entry>
+
+              <entry><emphasis role="bold">Drools 4.0.x</emphasis></entry>
+            </row>
+
+            <row>
+              <entry>assert()</entry>
+
+              <entry>insert()</entry>
+            </row>
+
+            <row>
+              <entry>assertLogical()</entry>
+
+              <entry>insertLogical()</entry>
+            </row>
+
+            <row>
+              <entry>modify()</entry>
+
+              <entry>update()</entry>
+            </row>
+          </tbody>
+        </tgroup>
+      </table>
+    </section>
+
+    <section>
+      <title>Primitive support and unboxing</title>
+
+      <para>Drools 3.0.x did not had native support for primitive types and
+      consequently, it auto-boxed all primitives in it's respective wrapper
+      classes. That way, any use of a boxed variable binding required a manual
+      unbox. </para>
+
+      <para>Drools 4.0.x has full support for primitive types and does not
+      wrap values anymore. So, all previous unwrap method calls must be
+      removed from the DRL. </para>
+
+      <example>
+        <title>Drools 3.0.x manual unwrap</title>
+
+        <programlisting>rule "Primitive int manual unbox"
+when
+    $c : Cheese( $price : price )
+then
+    $c.setPrice( $price<emphasis role="bold">.intValue()</emphasis> * 2 )
+end
+</programlisting>
+      </example>
+
+      <para>The above rule in 4.0.x would be:</para>
+
+      <example>
+        <title>Drools 4.0.x primitive support</title>
+
+        <programlisting>rule "Primitive support"
+when
+    $c : Cheese( $price : price )
+then
+    $c.setPrice( $price * 2 )
+end
+</programlisting>
+      </example>
+    </section>
+  </section>
+
+  <section>
+    <title>Drools Update Tool</title>
+
+    <para>The Drools Update tools is a simple program to help with the upgrade
+    of DRL files from Drools 3.0.x to Drools 4.0.x.</para>
+
+    <para>At this point, its main objective is to upgrade the memory action
+    calls from 3.0.x to 4.0.x, but expect it to grow over the next few weeks
+    covering additional scenarios. It is important to note that it does not
+    make a dumb text search and replace in rules file, but it actually parses
+    the rules file and try to make sure it is not doing anything unexpected,
+    and as so, it is a safe tool to use for upgrade large sets of rule
+    files.</para>
+
+    <para></para>
+  </section>
+</section>
\ No newline at end of file




More information about the jboss-svn-commits mailing list