[jboss-svn-commits] JBL Code SVN: r34400 - in labs/jbossrules/trunk/drools-docs: drools-docs-expert/src/main/docbook/en-US/Chapter-User_Guide and 5 other directories.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Fri Jul 30 02:49:01 EDT 2010
Author: mark.proctor at jboss.com
Date: 2010-07-30 02:49:01 -0400 (Fri, 30 Jul 2010)
New Revision: 34400
Added:
labs/jbossrules/trunk/drools-docs/drools-docs-expert/src/main/docbook/en-US/images/Chapter-Quick_Start/InferIsAdult.png
labs/jbossrules/trunk/drools-docs/drools-docs-expert/src/main/docbook/en-US/images/Chapter-Quick_Start/IssueIdCard.png
labs/jbossrules/trunk/drools-docs/drools-docs-expert/src/main/docbook/en-US/images/Chapter-Quick_Start/monolithic.png
labs/jbossrules/trunk/drools-docs/drools-docs-expert/src/main/docbook/en-US/images/Chapter-User_Guide/Activation.png
labs/jbossrules/trunk/drools-docs/drools-docs-expert/src/main/docbook/en-US/images/Chapter-User_Guide/ChangeSet.png
labs/jbossrules/trunk/drools-docs/drools-docs-expert/src/main/docbook/en-US/images/Chapter-User_Guide/KnowledgeAgent.ResourceStatus.png
labs/jbossrules/trunk/drools-docs/drools-docs-expert/src/main/docbook/en-US/images/Chapter-User_Guide/KnowledgeAgentConfiguration.png
labs/jbossrules/trunk/drools-docs/drools-docs-expert/src/main/docbook/en-US/images/Chapter-User_Guide/KnowledgeBaseConfiguration.png
labs/jbossrules/trunk/drools-docs/drools-docs-expert/src/main/docbook/en-US/images/Chapter-User_Guide/KnowledgeSessionConfiguration.png
labs/jbossrules/trunk/drools-docs/drools-docs-expert/src/main/docbook/en-US/images/Chapter-User_Guide/ObjectFilter.png
labs/jbossrules/trunk/drools-docs/drools-docs-expert/src/main/docbook/en-US/images/Chapter-User_Guide/StatelessKnowledgeSessionResults.png
labs/jbossrules/trunk/drools-docs/drools-docs-expert/src/main/docbook/en-US/images/Chapter-User_Guide/ViewChangedEventListener.png
labs/jbossrules/trunk/drools-docs/drools-docs-expert/src/main/docbook/en-US/images/Chapter-User_Guide/clips-shell.png
Modified:
labs/jbossrules/trunk/drools-docs/drools-docs-expert/src/main/docbook/en-US/Chapter-Quick_Start/Section-A_Little_More_Theory.xml
labs/jbossrules/trunk/drools-docs/drools-docs-expert/src/main/docbook/en-US/Chapter-User_Guide/Section-Running.xml
labs/jbossrules/trunk/drools-docs/drools-docs-expert/src/main/docbook/en-US/images/Chapter-User_Guide/AgendaGroup.png
labs/jbossrules/trunk/drools-docs/drools-docs-expert/src/main/docbook/en-US/images/Chapter-User_Guide/CommandExecutor.png
labs/jbossrules/trunk/drools-docs/drools-docs-expert/src/main/docbook/en-US/images/Chapter-User_Guide/ExecutionResults.png
labs/jbossrules/trunk/drools-docs/drools-docs-expert/src/main/docbook/en-US/images/Chapter-User_Guide/KnowledgeAgent.png
labs/jbossrules/trunk/drools-docs/drools-docs-expert/src/main/docbook/en-US/images/Chapter-User_Guide/KnowledgeAgentFactory.png
labs/jbossrules/trunk/drools-docs/drools-docs-expert/src/main/docbook/en-US/images/Chapter-User_Guide/KnowledgeBase.png
labs/jbossrules/trunk/drools-docs/drools-docs-expert/src/main/docbook/en-US/images/Chapter-User_Guide/KnowledgeBaseFactory.png
labs/jbossrules/trunk/drools-docs/drools-docs-expert/src/main/docbook/en-US/images/Chapter-User_Guide/KnowledgeRuntime.png
labs/jbossrules/trunk/drools-docs/drools-docs-expert/src/main/docbook/en-US/images/Chapter-User_Guide/WorkingMemory.png
labs/jbossrules/trunk/drools-docs/drools-docs-expert/src/main/docbook/en-US/images/Chapter-User_Guide/WorkingMemoryEntryPoint.png
labs/jbossrules/trunk/drools-docs/drools-docs-integration/src/main/docbook/en-US/Chapter-Camel/Chapter-Camel.xml
labs/jbossrules/trunk/drools-docs/drools-docs-integration/src/main/docbook/en-US/Chapter-Camel/Section-Introduction/Section-Introduction.xml
labs/jbossrules/trunk/drools-docs/drools-docs-integration/src/main/docbook/en-US/Chapter-Commands/Section-API/Section-API.xml
Log:
-doc tweaking
Modified: labs/jbossrules/trunk/drools-docs/drools-docs-expert/src/main/docbook/en-US/Chapter-Quick_Start/Section-A_Little_More_Theory.xml
===================================================================
--- labs/jbossrules/trunk/drools-docs/drools-docs-expert/src/main/docbook/en-US/Chapter-Quick_Start/Section-A_Little_More_Theory.xml 2010-07-30 05:25:59 UTC (rev 34399)
+++ labs/jbossrules/trunk/drools-docs/drools-docs-expert/src/main/docbook/en-US/Chapter-Quick_Start/Section-A_Little_More_Theory.xml 2010-07-30 06:49:01 UTC (rev 34400)
@@ -1,77 +1,79 @@
<?xml version="1.0" encoding="UTF-8"?>
<section version="5.0"
xsi:schemaLocation="http://docbook.org/ns/docbook http://www.docbook.org/xml/5.0/xsd/docbook.xsd http://www.w3.org/1999/xlink http://www.docbook.org/xml/5.0/xsd/xlink.xsd"
- xml:base="../" xmlns="http://docbook.org/ns/docbook" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xlink="http://www.w3.org/1999/xlink"
- xmlns:xi="http://www.w3.org/2001/XInclude" xmlns:ns="http://docbook.org/ns/docbook">
+ xml:base="../" xmlns="http://docbook.org/ns/docbook"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:xs="http://www.w3.org/2001/XMLSchema"
+ xmlns:xlink="http://www.w3.org/1999/xlink"
+ xmlns:xi="http://www.w3.org/2001/XInclude"
+ xmlns:ns="http://docbook.org/ns/docbook">
+ <title>A Little Theory</title>
- <title>A Little Theory</title>
+ <section>
+ <title>Methods versus Rules</title>
- <section>
- <title>Methods versus Rules</title>
+ <para>People often confuse methods and rules, and new rule users regular
+ ask, "How do I call a rule?" After the last section, you are now feeling
+ like a rule expert and the answer to that is obvious, but let's summarize
+ the differences nonetheless.</para>
- <para>People often confuse methods and rules, and new rule users regular
- ask, "How do I call a rule?" After the last section, you are now
- feeling like a rule expert and the answer to that is obvious, but let's
- summarize the differences nonetheless.</para>
-
- <programlisting role="JAVA">public void helloWorld(Person person) {
+ <programlisting role="JAVA">public void helloWorld(Person person) {
if ( person.getName().equals( "Chuck" ) ) {
System.out.println( "Hello Chuck" );
}
}</programlisting>
- <itemizedlist>
- <listitem>
- <para>Methods are called directly.</para>
- </listitem>
+ <itemizedlist>
+ <listitem>
+ <para>Methods are called directly.</para>
+ </listitem>
- <listitem>
- <para>Specific instances are passed.</para>
- </listitem>
+ <listitem>
+ <para>Specific instances are passed.</para>
+ </listitem>
- <listitem>
- <para>One call results in a single execution.</para>
- </listitem>
- </itemizedlist>
+ <listitem>
+ <para>One call results in a single execution.</para>
+ </listitem>
+ </itemizedlist>
- <programlisting>rule "Hello World"
+ <programlisting>rule "Hello World"
when
Person( name == "Chuck" )
then
System.out.println( "Hello Chuck" );
end</programlisting>
- <itemizedlist>
- <listitem>
- <para>Rules execute by matching against any data as long it is
- inserted into the engine.</para>
- </listitem>
+ <itemizedlist>
+ <listitem>
+ <para>Rules execute by matching against any data as long it is
+ inserted into the engine.</para>
+ </listitem>
- <listitem>
- <para>Rules can never be called directly.</para>
- </listitem>
+ <listitem>
+ <para>Rules can never be called directly.</para>
+ </listitem>
- <listitem>
- <para>Specific instances cannot be passed to a rule.</para>
- </listitem>
+ <listitem>
+ <para>Specific instances cannot be passed to a rule.</para>
+ </listitem>
- <listitem>
- <para>Depending on the matches, a rule may fire once or several
- times, or not at all.</para>
- </listitem>
- </itemizedlist>
- </section>
+ <listitem>
+ <para>Depending on the matches, a rule may fire once or several times,
+ or not at all.</para>
+ </listitem>
+ </itemizedlist>
+ </section>
- <section>
- <title>Cross Products</title>
+ <section>
+ <title>Cross Products</title>
- <para>Earlier the term "cross product" was mentioned, which is the
- result of a join. Imagine for a moment that the data from the
- fire alarm example were used in combination with the following
- rule where there ar no field constraints:</para>
+ <para>Earlier the term "cross product" was mentioned, which is the result
+ of a join. Imagine for a moment that the data from the fire alarm example
+ were used in combination with the following rule where there ar no field
+ constraints:</para>
- <programlisting>rule
+ <programlisting>rule
when
$room : Room()
$sprinkler : Sprinkler()
@@ -80,11 +82,11 @@
" sprinkler:" + $sprinkler.getRoom().getName() );
end</programlisting>
- <para>In SQL terms this would be like doing <code>select * from Room,
- Sprinkler</code> and every row in the Room table would be joined with every
- row in the Sprinkler table resulting in the following output:</para>
+ <para>In SQL terms this would be like doing <code>select * from Room,
+ Sprinkler</code> and every row in the Room table would be joined with
+ every row in the Sprinkler table resulting in the following output:</para>
- <programlisting>room:office sprinker:office
+ <programlisting>room:office sprinker:office
room:office sprinkler:kitchen
room:office sprinkler:livingroom
room:office sprinkler:bedroom
@@ -101,13 +103,13 @@
room:bedroom sprinkler:livingroom
room:bedroom sprinkler:bedroom</programlisting>
- <para>These cross products can obviously become huge, and they may
- very well contain spurious data. The size of cross products is
- often the source of performance problems for new rule authors.
- From this it can be seen that it's always desirable to constrain
- the cross products, which is done with the variable constraint.</para>
+ <para>These cross products can obviously become huge, and they may very
+ well contain spurious data. The size of cross products is often the source
+ of performance problems for new rule authors. From this it can be seen
+ that it's always desirable to constrain the cross products, which is done
+ with the variable constraint.</para>
- <programlisting>rule
+ <programlisting>rule
when
$room : Room()
$sprinkler : Sprinkler( room == $room )
@@ -116,27 +118,28 @@
" sprinkler:" + $sprinkler.getRoom().getName() );
end</programlisting>
- <para>This results in just four rows of data, with the correct Sprinkler
- for each Room. In SQL (actually HQL) the corresponding query would be
- <code>select * from Room, Sprinkler where Room == Sprinkler.room</code>.</para>
+ <para>This results in just four rows of data, with the correct Sprinkler
+ for each Room. In SQL (actually HQL) the corresponding query would be
+ <code>select * from Room, Sprinkler where Room ==
+ Sprinkler.room</code>.</para>
- <programlisting>room:office sprinkler:office
+ <programlisting>room:office sprinkler:office
room:kitchen sprinkler:kitchen
room:livingroom sprinkler:livingroom
room:bedroom sprinkler:bedroom</programlisting>
- </section>
+ </section>
- <section>
- <title>Activations, Agenda and Conflict Sets.</title>
+ <section>
+ <title>Activations, Agenda and Conflict Sets.</title>
- <para>So far the data and the matching process has been simple and small. To
- mix things up a bit a new example will be explored that handles cashflow
- calculations over date periods. The state of the engine will be
- illustratively shown at key stages to help get a better understanding
- of what is actually going on under the hood. Three classes will be used,
- as shown below.</para>
+ <para>So far the data and the matching process has been simple and small.
+ To mix things up a bit a new example will be explored that handles
+ cashflow calculations over date periods. The state of the engine will be
+ illustratively shown at key stages to help get a better understanding of
+ what is actually going on under the hood. Three classes will be used, as
+ shown below.</para>
- <programlisting role="JAVA">public class CashFlow {
+ <programlisting role="JAVA">public class CashFlow {
private Date date;
private double amount;
private int type;
@@ -156,36 +159,34 @@
// getter and setter methods here
}</programlisting>
- <para>By now you already know how to create Knowledge Bases and how to
- instantiate facts to populate the <code>StatefulKnowledgeSession</code>, so tables
- will be used to show the state of the inserted data, as it makes things
- clearer for illustration purposes. The tables below show that a single fact
- was inserted for the <code>Account</code>. Also inserted are a series of debits
- and credits as <code>CashFlow</code> objects for that account, extending over two
- quarters.</para>
+ <para>By now you already know how to create Knowledge Bases and how to
+ instantiate facts to populate the <code>StatefulKnowledgeSession</code>,
+ so tables will be used to show the state of the inserted data, as it makes
+ things clearer for illustration purposes. The tables below show that a
+ single fact was inserted for the <code>Account</code>. Also inserted are a
+ series of debits and credits as <code>CashFlow</code> objects for that
+ account, extending over two quarters.</para>
- <figure>
- <title>CashFlows and Account</title>
+ <figure>
+ <title>CashFlows and Account</title>
- <mediaobject>
- <imageobject>
- <imagedata width="100%"
- fileref="images/Chapter-Quick_Start/tables1.png" />
- </imageobject>
- </mediaobject>
- </figure>
+ <mediaobject>
+ <imageobject>
+ <imagedata fileref="images/Chapter-Quick_Start/tables1.png"
+ width="100%"></imagedata>
+ </imageobject>
+ </mediaobject>
+ </figure>
- <para>Two rules can be used to determine the debit and credit for that
- quarter and update the Account balance. The two rules below constrain
- the cashflows for an account for a given time period. Notice the
- "&&" which use short cut syntax to avoid repeating the field
- name twice.</para>
+ <para>Two rules can be used to determine the debit and credit for that
+ quarter and update the Account balance. The two rules below constrain the
+ cashflows for an account for a given time period. Notice the "&&"
+ which use short cut syntax to avoid repeating the field name twice.</para>
- <informaltable frame="void">
- <tbody>
- <tr>
- <td align="left" valign="top">
- <programlisting>rule "increase balance for credits"
+ <informaltable frame="void">
+ <tbody>
+ <tr>
+ <td align="left" valign="top"><programlisting>rule "increase balance for credits"
when
ap : AccountPeriod()
acc : Account( $accountNo : accountNo )
@@ -195,11 +196,9 @@
$amount : amount )
then
acc.balance += $amount;
-end</programlisting>
- </td>
+end</programlisting></td>
- <td align="left" valign="top">
- <programlisting>rule "decrease balance for debits"
+ <td align="left" valign="top"><programlisting>rule "decrease balance for debits"
when
ap : AccountPeriod()
acc : Account( $accountNo : accountNo )
@@ -209,103 +208,100 @@
$amount : amount )
then
acc.balance -= $amount;
-end</programlisting>
- </td>
- </tr>
- </tbody>
- </informaltable>
+end</programlisting></td>
+ </tr>
+ </tbody>
+ </informaltable>
- <para>If the <code>AccountPeriod</code> is set to the first quarter we constrain the
- rule "increase balance for credits" to fire on two rows of data and
- "decrease balance for debits" to act on one row of data.</para>
+ <para>If the <code>AccountPeriod</code> is set to the first quarter we
+ constrain the rule "increase balance for credits" to fire on two rows of
+ data and "decrease balance for debits" to act on one row of data.</para>
- <figure>
- <title>AccountingPeriod, CashFlows and Account</title>
+ <figure>
+ <title>AccountingPeriod, CashFlows and Account</title>
- <mediaobject>
- <imageobject>
- <imagedata fileref="images/Chapter-Quick_Start/tables2.png" />
- </imageobject>
- </mediaobject>
- </figure>
+ <mediaobject>
+ <imageobject>
+ <imagedata fileref="images/Chapter-Quick_Start/tables2.png"></imagedata>
+ </imageobject>
+ </mediaobject>
+ </figure>
- <para>The two cashflow tables above represent the matched data for the
- two rules. The data is matched during the insertion stage and, as you
- discovered in the previous chapter, does not fire straight away, but only
- after <code>fireAllRules()</code> is called. Meanwhile, the rule plus its
- matched data is
- placed on the Agenda and referred to as an Activation. The Agenda is a
- table of Activations that are able to fire and have their consequences
- executed, as soon as fireAllRules() is called. Activations on the
- Agenda are executed in turn. Notice that the order of execution
- so far is considered arbitrary.</para>
+ <para>The two cashflow tables above represent the matched data for the two
+ rules. The data is matched during the insertion stage and, as you
+ discovered in the previous chapter, does not fire straight away, but only
+ after <code>fireAllRules()</code> is called. Meanwhile, the rule plus its
+ matched data is placed on the Agenda and referred to as an Activation. The
+ Agenda is a table of Activations that are able to fire and have their
+ consequences executed, as soon as fireAllRules() is called. Activations on
+ the Agenda are executed in turn. Notice that the order of execution so far
+ is considered arbitrary.</para>
- <figure>
- <title>CashFlows and Account</title>
+ <figure>
+ <title>CashFlows and Account</title>
- <mediaobject>
- <imageobject>
- <imagedata fileref="images/Chapter-Quick_Start/tables7.png" />
- </imageobject>
- </mediaobject>
- </figure>
+ <mediaobject>
+ <imageobject>
+ <imagedata fileref="images/Chapter-Quick_Start/tables7.png"></imagedata>
+ </imageobject>
+ </mediaobject>
+ </figure>
- <para>After all of the above activations are fired, the account has a
- balance of -25.</para>
+ <para>After all of the above activations are fired, the account has a
+ balance of -25.</para>
- <figure>
- <title>CashFlows and Account</title>
+ <figure>
+ <title>CashFlows and Account</title>
- <mediaobject>
- <imageobject>
- <imagedata fileref="images/Chapter-Quick_Start/tables3.png" />
- </imageobject>
- </mediaobject>
- </figure>
+ <mediaobject>
+ <imageobject>
+ <imagedata fileref="images/Chapter-Quick_Start/tables3.png"></imagedata>
+ </imageobject>
+ </mediaobject>
+ </figure>
- <para>If the <code>AccountPeriod</code> is updated to the second quarter, we have just
- a single matched row of data, and thus just a single Activation on the
- Agenda.</para>
+ <para>If the <code>AccountPeriod</code> is updated to the second quarter,
+ we have just a single matched row of data, and thus just a single
+ Activation on the Agenda.</para>
- <figure>
- <title>CashFlows and Account</title>
+ <figure>
+ <title>CashFlows and Account</title>
- <mediaobject>
- <imageobject>
- <imagedata fileref="images/Chapter-Quick_Start/tables4.png" />
- </imageobject>
- </mediaobject>
- </figure>
+ <mediaobject>
+ <imageobject>
+ <imagedata fileref="images/Chapter-Quick_Start/tables4.png"></imagedata>
+ </imageobject>
+ </mediaobject>
+ </figure>
- <para>The firing of that Activation results in a balance of 25.</para>
+ <para>The firing of that Activation results in a balance of 25.</para>
- <figure>
- <title>CashFlows and Account</title>
+ <figure>
+ <title>CashFlows and Account</title>
- <mediaobject>
- <imageobject>
- <imagedata fileref="images/Chapter-Quick_Start/tables5.png" />
- </imageobject>
- </mediaobject>
- </figure>
+ <mediaobject>
+ <imageobject>
+ <imagedata fileref="images/Chapter-Quick_Start/tables5.png"></imagedata>
+ </imageobject>
+ </mediaobject>
+ </figure>
- <para>What if you don't want the order of Activation
- execution to be arbitrary? When there is one or more Activations on the
- Agenda they are said to be in conflict, and a conflict resolver strategy
- is used to determine the order of execution. At the simplest level the
- default strategy uses salience to determine rule priority. Each rule has
- a default value of 0, the higher the value the higher the priority. To
- illustrate this we add a rule to print the account balance, where we
- want this rule to be executed after all the debits and credits have
- been applied for all accounts. We achieve this by assigning a negative
- salience to this rule so that it fires after all rules with the default
- salience 0.</para>
+ <para>What if you don't want the order of Activation execution to be
+ arbitrary? When there is one or more Activations on the Agenda they are
+ said to be in conflict, and a conflict resolver strategy is used to
+ determine the order of execution. At the simplest level the default
+ strategy uses salience to determine rule priority. Each rule has a default
+ value of 0, the higher the value the higher the priority. To illustrate
+ this we add a rule to print the account balance, where we want this rule
+ to be executed after all the debits and credits have been applied for all
+ accounts. We achieve this by assigning a negative salience to this rule so
+ that it fires after all rules with the default salience 0.</para>
- <table border="0">
- <tbody>
- <tr>
- <td>
- <programlisting>rule "Print balance for AccountPeriod"
+ <table border="0">
+ <tbody>
+ <tr>
+ <td>
+ <programlisting>rule "Print balance for AccountPeriod"
salience -50
when
ap : AccountPeriod()
@@ -313,86 +309,86 @@
then
System.out.println( acc.accountNo + " : " + acc.balance );
end</programlisting>
- </td>
- </tr>
- </tbody>
- </table>
+ </td>
+ </tr>
+ </tbody>
+ </table>
- <para>The table below depicts the resulting Agenda. The three debit and credit
- rules are shown to be in arbitrary order, while the print rule is ranked
- last, to execute afterwards.</para>
+ <para>The table below depicts the resulting Agenda. The three debit and
+ credit rules are shown to be in arbitrary order, while the print rule is
+ ranked last, to execute afterwards.</para>
- <figure>
- <title>CashFlows and Account</title>
+ <figure>
+ <title>CashFlows and Account</title>
- <mediaobject>
- <imageobject>
- <imagedata fileref="images/Chapter-Quick_Start/tables6.png" />
- </imageobject>
- </mediaobject>
- </figure>
+ <mediaobject>
+ <imageobject>
+ <imagedata fileref="images/Chapter-Quick_Start/tables6.png"></imagedata>
+ </imageobject>
+ </mediaobject>
+ </figure>
- <para>Earlier we showed how rules would equate to SQL, which can often
- help people with an SQL background to understand rules.
- The two rules above can be represented with two views and a trigger for
- each view, as below:</para>
+ <para>Earlier we showed how rules would equate to SQL, which can often
+ help people with an SQL background to understand rules. The two rules
+ above can be represented with two views and a trigger for each view, as
+ below:</para>
- <table border="0">
- <tbody>
- <tr>
- <td align="left" valign="top">
- <programlisting>select * from Account acc,
+ <table border="0">
+ <tbody>
+ <tr>
+ <td align="left" valign="top">
+ <programlisting>select * from Account acc,
Cashflow cf,
AccountPeriod ap
where acc.accountNo == cf.accountNo and
cf.type == CREDIT and
cf.date >= ap.start and
cf.date <= ap.end</programlisting>
- </td>
+ </td>
- <td align="left" valign="top">
- <programlisting>select * from Account acc,
+ <td align="left" valign="top">
+ <programlisting>select * from Account acc,
Cashflow cf,
AccountPeriod ap
where acc.accountNo == cf.accountNo and
cf.type == DEBIT and
cf.date >= ap.start and
cf.date <= ap.end</programlisting>
- </td>
- </tr>
+ </td>
+ </tr>
- <tr>
- <td align="left" valign="top">
- <programlisting>trigger : acc.balance += cf.amount</programlisting>
- </td>
+ <tr>
+ <td align="left" valign="top">
+ <programlisting>trigger : acc.balance += cf.amount</programlisting>
+ </td>
- <td align="left" valign="top">
- <programlisting>trigger : acc.balance -= cf.amount</programlisting>
- </td>
- </tr>
- </tbody>
- </table>
+ <td align="left" valign="top">
+ <programlisting>trigger : acc.balance -= cf.amount</programlisting>
+ </td>
+ </tr>
+ </tbody>
+ </table>
- <para>Drools also features ruleflow-group attributes which allows
- workflow diagrams to declaratively specify when rules are allowed to
- fire. The screenshot below is taken from Eclipse using the Drools
- plugin. It has two ruleflow-group nodes which ensures that the calculation
- rules are executed before the reporting rules.</para>
+ <para>Drools also features ruleflow-group attributes which allows workflow
+ diagrams to declaratively specify when rules are allowed to fire. The
+ screenshot below is taken from Eclipse using the Drools plugin. It has two
+ ruleflow-group nodes which ensures that the calculation rules are executed
+ before the reporting rules.</para>
- <mediaobject>
- <imageobject>
- <imagedata fileref="images/Chapter-Quick_Start/ruleflow.png" />
- </imageobject>
- </mediaobject>
+ <mediaobject>
+ <imageobject>
+ <imagedata fileref="images/Chapter-Quick_Start/ruleflow.png"></imagedata>
+ </imageobject>
+ </mediaobject>
- <para>The use of the ruleflow-group attribute in a rule is shown
- below.</para>
+ <para>The use of the ruleflow-group attribute in a rule is shown
+ below.</para>
- <table border="0">
- <tbody>
- <tr>
- <td align="left" valign="top">
- <programlisting>rule "increase balance for credits"
+ <table border="0">
+ <tbody>
+ <tr>
+ <td align="left" valign="top">
+ <programlisting>rule "increase balance for credits"
ruleflow-group "calculation"
when
ap : AccountPeriod()
@@ -404,10 +400,10 @@
then
acc.balance += $amount;
end</programlisting>
- </td>
+ </td>
- <td align="left" valign="top">
- <programlisting>rule "Print balance for AccountPeriod"
+ <td align="left" valign="top">
+ <programlisting>rule "Print balance for AccountPeriod"
ruleflow-group "report"
when
ap : AccountPeriod()
@@ -416,12 +412,226 @@
System.out.println( acc.accountNo +
" : " + acc.balance );
end</programlisting>
- </td>
- </tr>
- </tbody>
- </table>
- </section>
+ </td>
+ </tr>
+ </tbody>
+ </table>
+ </section>
+ <section>
+ <title>Inference</title>
+
+ <para>Inference has a bad names these days, as something not relevant to
+ business use cases and just too complicated to be useful. It is true that
+ contrived and complicated examples occur with inference, but that should
+ not detract from the fact that simple and useful ones exist too. But more
+ than this, correct use of inference can crate more agile and less error
+ prone businesses with easier to maintain software.</para>
+
+ <para> So what is inference? Something is inferred when we gain knowledge
+ of something from using previous knowledge. For example given a Person
+ fact with an age field and a rule that provides age policy control, we can
+ infer whether a Person is an adult or a child and act on this.</para>
+
+ <programlisting>rule "Infer Adult"
+when
+ $p : Person( age >= 18 )
+then
+ insert( new IsAdult( $p ) )
+end</programlisting>
+
+ <para>So in the above every Person who is 18 or over will have an instance
+ of IsAdult inserted for them. This fact is special in that it is known as
+ a relation. We can use this inferred relation in any rule:</para>
+
+ <programlisting>$p : Person()
+IsAdult( person == $p )</programlisting>
+
+ <para>So now we know what inference is, and have a basic example, how does
+ this facilitate good rule design and maintenance?</para>
+
+ <para>Let's take a government department that are responsible for issuing
+ ID cards when children become adults, hence forth referred to as ID
+ department. They might have a decision table that includes logic like
+ this, which says when an adult living in london is 18 or over, issue the
+ card:</para>
+
+ <mediaobject>
+ <imageobject>
+ <imagedata fileref="images/Chapter-Quick_Start/monolithic.png"></imagedata>
+ </imageobject>
+ </mediaobject>
+
+ <para>However the ID department does not set the policy on who an adult
+ is. That's done at a central government level. If the central government
+ where to change that age to 21 there is a change management process.
+ Someone has to liaise with the ID department and make sure their systems
+ are updated, in time for the law going live.</para>
+
+ <para>This change management process and communication between departments
+ is not ideal for an agile environment and change become costly and error
+ prone. Also the card department is managing more information than it needs
+ to be aware of with its "monolothic" approach to rules management which is
+ "leaking" information better placed else where. By this I mean that it
+ doesn't care what explicit "age >= 18" information determines whether
+ someone is an adult, only that they are an adult.</para>
+
+ <para>Instead what if we were to split (de-couple) the authoring
+ responsibility, so the central government maintains its rules and the ID
+ department maintains its.</para>
+
+ <para>So its the central governments job to determine who is an adult and
+ if they change the law they just update their central repository with the
+ new rules, which others use:</para>
+
+ <mediaobject>
+ <imageobject>
+ <imagedata fileref="images/Chapter-Quick_Start/InferIsAdult.png"></imagedata>
+ </imageobject>
+ </mediaobject>
+
+ <para>The IsAdult fact, as discussed previously, is inferred from the
+ policy rules. It encapsulates the seemingly arbitrary piece of logic "age
+ >= 18" and provides semantic abstractions for it's meaning. Now if
+ anyone uses the above rules, they no longer need to be aware of explicit
+ information that determines whether someone is an adult or not. They can
+ just use the inferred fact:</para>
+
+ <mediaobject>
+ <imageobject>
+ <imagedata fileref="images/Chapter-Quick_Start/IssueIdCard.png"></imagedata>
+ </imageobject>
+ </mediaobject>
+
+ <para>While the example is very minimal and trivial it illustrates some
+ important points. We started with a monolithic and leaky approach to our
+ knowledge engineering. We create a single decision table that had all
+ possible information in it that leaks information from central government
+ that the ID department did not care about and did not want to
+ manage.</para>
+
+ <para>We first de-coupled the knowledge process so each department was
+ responsible for only what it needed to know. We then encapsulated this
+ leaky knowledge using an inferred fact IsAdult. The use of the term
+ IsAdult also gave a semantic abstraction to the previously arbitrary logic
+ "age >= 18".</para>
+
+ <para> So a general rule or thumb when doing your knowledge engineering
+ is:</para>
+
+ <para></para>
+
+ <itemizedlist>
+ <listitem>
+ <para><emphasis role="bold">Bad</emphasis></para>
+
+ <itemizedlist>
+ <listitem>
+ <para>Monolithic</para>
+ </listitem>
+
+ <listitem>
+ <para>Leaky</para>
+ </listitem>
+ </itemizedlist>
+ </listitem>
+
+ <listitem>
+ <para><emphasis role="bold">Good</emphasis></para>
+
+ <itemizedlist>
+ <listitem>
+ <para>De-couple knowledge responsibilities</para>
+ </listitem>
+
+ <listitem>
+ <para>Encapsulate knowledge</para>
+ </listitem>
+
+ <listitem>
+ <para>Provide semantic abstractions for those
+ encapsulations</para>
+ </listitem>
+ </itemizedlist>
+ </listitem>
+ </itemizedlist>
+ </section>
+
+ <section>
+ <title>Inference and TruthMaintenance</title>
+
+ <para>The previous example was issuing ID cards to over 18s, in this
+ example we now issue bus passes, either a child or adult pass.</para>
+
+ <programlisting>rule "Issue Child Bus Pass" when
+ $p : Person( age < 16 )
+then
+ insert(new ChildBusPass( $p ) );
+end
+rule "Issue Adult Bus Pass" when
+ $p : Person( age >= 16 )
+then
+ insert(new AdultBusPass( $p ) );
+end</programlisting>
+ <para>As before the above example is considered monolithic, leaky and
+ providing poor separation of concerns.</para>
+
+ <para>As before we can provide a more robust application with a separation
+ of concerns using inference. Notice this time we don't just insert the
+ inferred object, we use "logicalInsert":</para>
+
+ <programlisting>rule "Infer Child" when
+ $p : Person( age < 16 )
+then
+ logicalInsert( new IsChild( $p ) )
+end
+rule "Infer Adult" when
+ $p : Person( age >= 16 )
+then
+ logicalInsert( new IsAdult( $p ) )
+end</programlisting>
+
+ <para>A "logicalInsert" is part of the Drools Truth Maintenance System
+ (TMS). Here the fact is logically inserted, this fact is dependant on the
+ truth of the "when" clause. It means that when the rule becomes false the
+ fact is automatically retracted. This works particularly well as the two
+ rules are mutually exclusive. So in the above rules if the person is under
+ 16 it inserts an IsChild fact, once the person is 16 or over the IsChild
+ fact is automatically retracted and the IsAdult fact inserted.</para>
+
+ <para> We can now bring back in the code to issue the passes, these two
+ can also be logically inserted, as the TMS supports chaining of logical
+ insertions for a cascading set of retracts.</para>
+
+ <programlisting>rule "Issue Child Bus Pass" when
+ $p : Person( )
+ IsChild( person =$p )
+then
+ logicalInsert(new ChildBusPass( $p ) );
+end
+
+rule "Issue Adult Bus Pass" when
+ $p : Person( age >= 16 )
+ IsAdult( person =$p )
+then
+ logicalInsert(new AdultBusPass( $p ) );
+end</programlisting>
+
+ <para>Now when the person changes from being 15 to 16, not only is the
+ IsChild fact automatically retracted, so is the person's ChildBusPass
+ fact. For bonus points we can combine this with the 'not' conditional
+ element to handle notifications, in this situation a request for the
+ returning of the pass. So when the TMS automatically retracts the
+ ChildBusPass object, this rule triggers and sends a request to the
+ person:</para>
+
+ <programlisting>rule "Return ChildBusPass Request "when
+ $p : Person( )
+ not( ChildBusPass( person == $p ) )
+then
+ requestChildBusPass( $p );
+end</programlisting>
+ </section>
</section>
Modified: labs/jbossrules/trunk/drools-docs/drools-docs-expert/src/main/docbook/en-US/Chapter-User_Guide/Section-Running.xml
===================================================================
--- labs/jbossrules/trunk/drools-docs/drools-docs-expert/src/main/docbook/en-US/Chapter-User_Guide/Section-Running.xml 2010-07-30 05:25:59 UTC (rev 34399)
+++ labs/jbossrules/trunk/drools-docs/drools-docs-expert/src/main/docbook/en-US/Chapter-User_Guide/Section-Running.xml 2010-07-30 06:49:01 UTC (rev 34400)
@@ -1645,4 +1645,49 @@
</programlisting>
</example>
</section>
+
+ <section>
+ <title>Drools Clips</title>
+
+ <para>Drools Clips is an alpha level research project to provide a Clips
+ like front end ot Drools.</para>
+
+ <para>Deftemplates are working, the knowledge base handles multiple name
+ spaces and you can attach the knoweldge base to the session for interative
+ building, to provide a more "shell" like environment suitable for Clips.
+ </para>
+
+ <itemizedlist>
+ <listitem>
+ <para>deftemplate</para>
+ </listitem>
+
+ <listitem>
+ <para>defrule</para>
+ </listitem>
+
+ <listitem>
+ <para>deffunction</para>
+ </listitem>
+
+ <listitem>
+ <para>and/or/not/exists/test conditional elements</para>
+ </listitem>
+
+ <listitem>
+ <para>Literal, Variable, Return Value and Predicate field
+ constarints</para>
+ </listitem>
+ </itemizedlist>
+
+ <mediaobject>
+ <imageobject>
+ <imagedata fileref="images/Chapter-User_Guide/clips-shell.png"></imagedata>
+ </imageobject>
+ </mediaobject>
+
+ <para>This project is very early stages and in need of love. If you want
+ to help, open up eclipse import api, core, compiler and clips and you
+ should be good to go. The unit tests should be self explanatory.</para>
+ </section>
</section>
Added: labs/jbossrules/trunk/drools-docs/drools-docs-expert/src/main/docbook/en-US/images/Chapter-Quick_Start/InferIsAdult.png
===================================================================
(Binary files differ)
Property changes on: labs/jbossrules/trunk/drools-docs/drools-docs-expert/src/main/docbook/en-US/images/Chapter-Quick_Start/InferIsAdult.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: labs/jbossrules/trunk/drools-docs/drools-docs-expert/src/main/docbook/en-US/images/Chapter-Quick_Start/IssueIdCard.png
===================================================================
(Binary files differ)
Property changes on: labs/jbossrules/trunk/drools-docs/drools-docs-expert/src/main/docbook/en-US/images/Chapter-Quick_Start/IssueIdCard.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: labs/jbossrules/trunk/drools-docs/drools-docs-expert/src/main/docbook/en-US/images/Chapter-Quick_Start/monolithic.png
===================================================================
(Binary files differ)
Property changes on: labs/jbossrules/trunk/drools-docs/drools-docs-expert/src/main/docbook/en-US/images/Chapter-Quick_Start/monolithic.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: labs/jbossrules/trunk/drools-docs/drools-docs-expert/src/main/docbook/en-US/images/Chapter-User_Guide/Activation.png
===================================================================
(Binary files differ)
Property changes on: labs/jbossrules/trunk/drools-docs/drools-docs-expert/src/main/docbook/en-US/images/Chapter-User_Guide/Activation.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Modified: labs/jbossrules/trunk/drools-docs/drools-docs-expert/src/main/docbook/en-US/images/Chapter-User_Guide/AgendaGroup.png
===================================================================
(Binary files differ)
Added: labs/jbossrules/trunk/drools-docs/drools-docs-expert/src/main/docbook/en-US/images/Chapter-User_Guide/ChangeSet.png
===================================================================
(Binary files differ)
Property changes on: labs/jbossrules/trunk/drools-docs/drools-docs-expert/src/main/docbook/en-US/images/Chapter-User_Guide/ChangeSet.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Modified: labs/jbossrules/trunk/drools-docs/drools-docs-expert/src/main/docbook/en-US/images/Chapter-User_Guide/CommandExecutor.png
===================================================================
(Binary files differ)
Modified: labs/jbossrules/trunk/drools-docs/drools-docs-expert/src/main/docbook/en-US/images/Chapter-User_Guide/ExecutionResults.png
===================================================================
(Binary files differ)
Added: labs/jbossrules/trunk/drools-docs/drools-docs-expert/src/main/docbook/en-US/images/Chapter-User_Guide/KnowledgeAgent.ResourceStatus.png
===================================================================
(Binary files differ)
Property changes on: labs/jbossrules/trunk/drools-docs/drools-docs-expert/src/main/docbook/en-US/images/Chapter-User_Guide/KnowledgeAgent.ResourceStatus.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Modified: labs/jbossrules/trunk/drools-docs/drools-docs-expert/src/main/docbook/en-US/images/Chapter-User_Guide/KnowledgeAgent.png
===================================================================
(Binary files differ)
Added: labs/jbossrules/trunk/drools-docs/drools-docs-expert/src/main/docbook/en-US/images/Chapter-User_Guide/KnowledgeAgentConfiguration.png
===================================================================
(Binary files differ)
Property changes on: labs/jbossrules/trunk/drools-docs/drools-docs-expert/src/main/docbook/en-US/images/Chapter-User_Guide/KnowledgeAgentConfiguration.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Modified: labs/jbossrules/trunk/drools-docs/drools-docs-expert/src/main/docbook/en-US/images/Chapter-User_Guide/KnowledgeAgentFactory.png
===================================================================
(Binary files differ)
Modified: labs/jbossrules/trunk/drools-docs/drools-docs-expert/src/main/docbook/en-US/images/Chapter-User_Guide/KnowledgeBase.png
===================================================================
(Binary files differ)
Added: labs/jbossrules/trunk/drools-docs/drools-docs-expert/src/main/docbook/en-US/images/Chapter-User_Guide/KnowledgeBaseConfiguration.png
===================================================================
(Binary files differ)
Property changes on: labs/jbossrules/trunk/drools-docs/drools-docs-expert/src/main/docbook/en-US/images/Chapter-User_Guide/KnowledgeBaseConfiguration.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Modified: labs/jbossrules/trunk/drools-docs/drools-docs-expert/src/main/docbook/en-US/images/Chapter-User_Guide/KnowledgeBaseFactory.png
===================================================================
(Binary files differ)
Modified: labs/jbossrules/trunk/drools-docs/drools-docs-expert/src/main/docbook/en-US/images/Chapter-User_Guide/KnowledgeRuntime.png
===================================================================
(Binary files differ)
Added: labs/jbossrules/trunk/drools-docs/drools-docs-expert/src/main/docbook/en-US/images/Chapter-User_Guide/KnowledgeSessionConfiguration.png
===================================================================
(Binary files differ)
Property changes on: labs/jbossrules/trunk/drools-docs/drools-docs-expert/src/main/docbook/en-US/images/Chapter-User_Guide/KnowledgeSessionConfiguration.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: labs/jbossrules/trunk/drools-docs/drools-docs-expert/src/main/docbook/en-US/images/Chapter-User_Guide/ObjectFilter.png
===================================================================
(Binary files differ)
Property changes on: labs/jbossrules/trunk/drools-docs/drools-docs-expert/src/main/docbook/en-US/images/Chapter-User_Guide/ObjectFilter.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: labs/jbossrules/trunk/drools-docs/drools-docs-expert/src/main/docbook/en-US/images/Chapter-User_Guide/StatelessKnowledgeSessionResults.png
===================================================================
(Binary files differ)
Property changes on: labs/jbossrules/trunk/drools-docs/drools-docs-expert/src/main/docbook/en-US/images/Chapter-User_Guide/StatelessKnowledgeSessionResults.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: labs/jbossrules/trunk/drools-docs/drools-docs-expert/src/main/docbook/en-US/images/Chapter-User_Guide/ViewChangedEventListener.png
===================================================================
(Binary files differ)
Property changes on: labs/jbossrules/trunk/drools-docs/drools-docs-expert/src/main/docbook/en-US/images/Chapter-User_Guide/ViewChangedEventListener.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Modified: labs/jbossrules/trunk/drools-docs/drools-docs-expert/src/main/docbook/en-US/images/Chapter-User_Guide/WorkingMemory.png
===================================================================
(Binary files differ)
Modified: labs/jbossrules/trunk/drools-docs/drools-docs-expert/src/main/docbook/en-US/images/Chapter-User_Guide/WorkingMemoryEntryPoint.png
===================================================================
(Binary files differ)
Added: labs/jbossrules/trunk/drools-docs/drools-docs-expert/src/main/docbook/en-US/images/Chapter-User_Guide/clips-shell.png
===================================================================
(Binary files differ)
Property changes on: labs/jbossrules/trunk/drools-docs/drools-docs-expert/src/main/docbook/en-US/images/Chapter-User_Guide/clips-shell.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Modified: labs/jbossrules/trunk/drools-docs/drools-docs-integration/src/main/docbook/en-US/Chapter-Camel/Chapter-Camel.xml
===================================================================
--- labs/jbossrules/trunk/drools-docs/drools-docs-integration/src/main/docbook/en-US/Chapter-Camel/Chapter-Camel.xml 2010-07-30 05:25:59 UTC (rev 34399)
+++ labs/jbossrules/trunk/drools-docs/drools-docs-integration/src/main/docbook/en-US/Chapter-Camel/Chapter-Camel.xml 2010-07-30 06:49:01 UTC (rev 34400)
@@ -7,10 +7,10 @@
<title>Apache Camel Integration</title>
<xi:include href="Section-Introduction/Section-Introduction.xml" />
- <xi:include href="Section-API/Section-CreatingOurCamelContext.xml" />
+ <!--xi:include href="Section-API/Section-CreatingOurCamelContext.xml" />
<xi:include href="Section-API/Section-RegisteringKnowledgeSession.xml" />
<xi:include href="Section-API/Section-CamelRoutesCreation.xml" />
<xi:include href="Section-API/Section-CreatingDroolsCommands.xml" />
- <xi:include href="Section-API/Section-SendingMessagesExchanges.xml" />
+ <xi:include href="Section-API/Section-SendingMessagesExchanges.xml" /-->
</chapter>
Modified: labs/jbossrules/trunk/drools-docs/drools-docs-integration/src/main/docbook/en-US/Chapter-Camel/Section-Introduction/Section-Introduction.xml
===================================================================
--- labs/jbossrules/trunk/drools-docs/drools-docs-integration/src/main/docbook/en-US/Chapter-Camel/Section-Introduction/Section-Introduction.xml 2010-07-30 05:25:59 UTC (rev 34399)
+++ labs/jbossrules/trunk/drools-docs/drools-docs-integration/src/main/docbook/en-US/Chapter-Camel/Section-Introduction/Section-Introduction.xml 2010-07-30 06:49:01 UTC (rev 34400)
@@ -7,75 +7,114 @@
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns:xi="http://www.w3.org/2001/XInclude"
xmlns:ns="http://docbook.org/ns/docbook">
- <title>Introduction</title>
+ <title>Camel</title>
- <para>The Apache Camel integration allows us to interact with a Drools
- Stateless or Stateful session through a pipeline. It simply works by
- transforming XML commands into executable commands and executing them. The
- advantage of this integration is that Apache Camel makes possible the
- implemention of more advanced enterprise integration patterns, which is an
- improvement of drools pipeline.</para>
+ <para>Camel provides a light weight bus framework for geting information
+ into and out of Drools.</para>
- <para></para>
+ <para>Drools introduces two elements to make easy integration.</para>
- <para>This integration with Drools allows us to add any of the current Camel
- components. Using the <link
- xlink:href="http://camel.apache.org/components.html">Apache
- Components</link> you can, receive commands from several entry points and
- send the execution result to another entry point. To name a few, JMS
- queue/Atom Feed/Mina connection/a Mail/etc. As you can see, this brings a
- more powerful interoperability mechanism to integrate your application with
- Drools.</para>
+ <itemizedlist>
+ <listitem>
+ <para>Drools Policy</para>
- <para>Actually Drools is using Camel 2.4.0 that allows a more strong
- internal integration between them.</para>
+ <para>Augments any JAXB or XStream data loaders. For JAXB it adds drools
+ related paths ot the contextpath, for XStream it adds custom converters
+ and aliases for Drools classes. It also handles setting the ClassLoader
+ to the targetted ksession.</para>
+ </listitem>
- <section>
- <title>Architecture</title>
+ <listitem>
+ <para>Drools Endpoint</para>
- <para><insert architecture graphic here></para>
+ <para>Executes the payload against the specified drools session</para>
+ </listitem>
+ </itemizedlist>
- <para></para>
- </section>
+ <para>Drools can be configured like any norma camel component, but notice
+ the policy that wraps the drools related segments. This will route all
+ payloads to ksession1</para>
- <section>
- <title>Introduction to drools-grid</title>
+ <example>
+ <title>Drools EndPoint configured with the CXFRS producer</title>
- <para>Introduction to drools-grid Camel integration is coupled with
- another drools module called: drools-grid. This module allow us to
- interact with Drools sessions independent of the JVM location. At the
- moment we can use two implementations:</para>
+ <programlisting><bean id="droolsPolicy" class="org.drools.camel.component.DroolsPolicy" />
- <table>
- <title>drools-grid implementations</title>
+<camelContext id="camel" xmlns="http://camel.apache.org/schema/spring">
+ <route>
+ <from uri="cxfrs://bean://rsServer"/>
+ <policy ref="droolsPolicy">
+ <unmarshal ref="xstream" />
+ <to uri="drools:node1/ksession1" />
+ <marshal ref="xstream" />
+ </policy>
+ </route></programlisting>
+ </example>
- <tgroup cols="2">
- <tbody>
- <row>
- <entry>Local</entry>
+ <para>It is possible to not specify the session in the drools endpoint uri,
+ and instead "multiplex" based on an attribute or header. In this example the
+ policy will check either the header field "DroolsLookup" for the named
+ session to execute and if that isn't specified it'll check the "lookup"
+ attribute on the incoming payload. It then attempts to "lookup" the session
+ fron the execution-node context and execute against it.</para>
- <entry>Used when the drools sessions and clients are in the same
- JVM</entry>
- </row>
+ <example>
+ <title>Drools EndPoint configured with the CXFRS producer</title>
- <row>
- <entry>Remote</entry>
+ <programlisting><bean id="droolsPolicy" class="org.drools.camel.component.DroolsPolicy" />
- <entry>Used when you have drools sessions on a remote JVM.
- Currently, the only implementation is based on Apache Mina.
- HornetQ support will be added in the next release</entry>
- </row>
- </tbody>
- </tgroup>
- </table>
+<camelContext id="camel" xmlns="http://camel.apache.org/schema/spring">
+ <route>
+ <from uri="cxfrs://bean://rsServer"/>
+ <policy ref="droolsPolicy">
+ <unmarshal ref="xstream" />
+ <to uri="drools:node1" />
+ <marshal ref="xstream" />
+ </policy>
+ </route></programlisting>
+ </example>
- <para></para>
+ <example>
+ <title>Java Code to execute against Route from a Spring and Camel
+ Context</title>
- <para>Drools Grid is embedded inside the Drools Camel component, so don't
- worry about further implementation information because this is hidden by
- Drools. With this information we can start to configure our Camel
- Context.</para>
+ <programlisting>public class MyTest extends CamelSpringTestSupport {
+
+ @Override
+ protected AbstractXmlApplicationContext createApplicationContext() {
+ return new ClassPathXmlApplicationContext("org/drools/camel/component/CxfRsSpring.xml");
+ }
- <para></para>
- </section>
+ public void test1() throws Exception {
+ String cmd = "";
+ cmd += "<batch-execution lookup=\"ksession1\">\n";
+ cmd += " <insert out-identifier=\"salaboy\">\n";
+ cmd += " <org.drools.pipeline.camel.Person>\n";
+ cmd += " <name>salaboy</name>\n";
+ cmd += " </org.drools.pipeline.camel.Person>\n";
+ cmd += " </insert>\n";
+ cmd += " <fire-all-rules/>\n";
+ cmd += "</batch-execution>\n";
+
+ Object object = this.context.createProducerTemplate().requestBody("direct://client", cmd);
+ System.out.println( object );
+ } </programlisting>
+ </example>
+
+ <para>The following urls show sample script examples for jaxb, xstream and
+ json marshalling using:</para>
+
+ <itemizedlist>
+ <listitem>
+ <para>http://fisheye.jboss.org/browse/JBossRules/trunk/drools-camel/src/test/resources/org/drools/camel/component/jaxb.mvt?r=HEAD</para>
+ </listitem>
+
+ <listitem>
+ <para>http://fisheye.jboss.org/browse/JBossRules/trunk/drools-camel/src/test/resources/org/drools/camel/component/jaxb.mvt?r=HEAD</para>
+ </listitem>
+
+ <listitem>
+ <para>http://fisheye.jboss.org/browse/JBossRules/trunk/drools-camel/src/test/resources/org/drools/camel/component/xstream.mvt?r=HEAD</para>
+ </listitem>
+ </itemizedlist>
</section>
Modified: labs/jbossrules/trunk/drools-docs/drools-docs-integration/src/main/docbook/en-US/Chapter-Commands/Section-API/Section-API.xml
===================================================================
--- labs/jbossrules/trunk/drools-docs/drools-docs-integration/src/main/docbook/en-US/Chapter-Commands/Section-API/Section-API.xml 2010-07-30 05:25:59 UTC (rev 34399)
+++ labs/jbossrules/trunk/drools-docs/drools-docs-integration/src/main/docbook/en-US/Chapter-Commands/Section-API/Section-API.xml 2010-07-30 06:49:01 UTC (rev 34400)
@@ -1,15 +1,37 @@
<?xml version="1.0" encoding="UTF-8"?>
<section version="5.0"
xsi:schemaLocation="http://docbook.org/ns/docbook http://www.docbook.org/xml/5.0/xsd/docbook.xsd http://www.w3.org/1999/xlink http://www.docbook.org/xml/5.0/xsd/xlink.xsd"
- xml:base="../../" xmlns="http://docbook.org/ns/docbook" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xlink="http://www.w3.org/1999/xlink"
- xmlns:xi="http://www.w3.org/2001/XInclude" xmlns:ns="http://docbook.org/ns/docbook">
+ xml:base="../../" xmlns="http://docbook.org/ns/docbook"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:xs="http://www.w3.org/2001/XMLSchema"
+ xmlns:xlink="http://www.w3.org/1999/xlink"
+ xmlns:xi="http://www.w3.org/2001/XInclude"
+ xmlns:ns="http://docbook.org/ns/docbook">
<title>API</title>
<para>XML marshalling/unmarshalling of the Drools Commands requires the use
of special classes, which are going to be described in the following
sections.</para>
+ <para>The following urls show sample script examples for jaxb, xstream and
+ json marshalling using:</para>
+
+ <itemizedlist>
+ <listitem>
+ <para>http://fisheye.jboss.org/browse/JBossRules/trunk/drools-camel/src/test/resources/org/drools/camel/component/jaxb.mvt?r=HEAD</para>
+ </listitem>
+
+ <listitem>
+ <para>http://fisheye.jboss.org/browse/JBossRules/trunk/drools-camel/src/test/resources/org/drools/camel/component/jaxb.mvt?r=HEAD</para>
+ </listitem>
+
+ <listitem>
+ <para>http://fisheye.jboss.org/browse/JBossRules/trunk/drools-camel/src/test/resources/org/drools/camel/component/xstream.mvt?r=HEAD</para>
+ </listitem>
+ </itemizedlist>
+
+ <para></para>
+
<section>
<title>XStream</title>
More information about the jboss-svn-commits
mailing list