[jboss-svn-commits] JBL Code SVN: r19795 - labs/jbossrules/branches/irooskov_docs/drools-docs/drools-docs-referenceguide/en/Chapter-JSR94.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Thu May 1 00:45:51 EDT 2008


Author: irooskov at redhat.com
Date: 2008-05-01 00:45:51 -0400 (Thu, 01 May 2008)
New Revision: 19795

Modified:
   labs/jbossrules/branches/irooskov_docs/drools-docs/drools-docs-referenceguide/en/Chapter-JSR94/Section-How_To_Use.xml
Log:
re-wrote How_To_Use for the JRE API for the reference guide


Modified: labs/jbossrules/branches/irooskov_docs/drools-docs/drools-docs-referenceguide/en/Chapter-JSR94/Section-How_To_Use.xml
===================================================================
--- labs/jbossrules/branches/irooskov_docs/drools-docs/drools-docs-referenceguide/en/Chapter-JSR94/Section-How_To_Use.xml	2008-05-01 04:35:19 UTC (rev 19794)
+++ labs/jbossrules/branches/irooskov_docs/drools-docs/drools-docs-referenceguide/en/Chapter-JSR94/Section-How_To_Use.xml	2008-05-01 04:45:51 UTC (rev 19795)
@@ -3,7 +3,7 @@
   <title>How To Use</title>
 
   <para>There are two parts to working with JSR94. The first part is the
-  administrative api that deals with building and register RuleExecutionSets,
+  administrative API that deals with building and register RuleExecutionSets,
   the second part is runtime session execution of those
   RuleExecutionSets.</para>
 
@@ -19,18 +19,19 @@
     <para><example>
         <title>Automatic RuleServiceProvider Registration</title>
 
-        <programlisting>// RuleServiceProviderImpl is registered to "http://drools.org/" via a static initialization block
+<screen>// RuleServiceProviderImpl is registered to "http://drools.org/" via a static initialization block
 Class.forName("org.drools.jsr94.rules.RuleServiceProviderImpl");
 
 // Get the rule service provider from the provider manager.
-RuleServiceProvider ruleServiceProvider = RuleServiceProviderManager.getRuleServiceProvider("http://drools.org/");</programlisting>
+RuleServiceProvider ruleServiceProvider = RuleServiceProviderManager.getRuleServiceProvider("http://drools.org/");
+</screen>
       </example>The RuleServiceProvider provides access to the RuleRuntime and
     RuleAdministration APIs. The RuleAdministration provides an administration
     API for the management of RuleExecutionSets, making it possible to
     register a RuleExecutionSet that can then be retrieved via the
     RuleRuntime.</para>
 
-    <para>First you need to create a RuleExecutionSet before it can be
+    <para>First create a RuleExecutionSet before it can be
     registered; RuleAdministrator provides factory methods to return an empty
     LocalRuleExecutionSetProvider or RuleExecutionSetProvider. The
     LocalRuleExecutionSetProvider should be used to load a RuleExecutionSets
@@ -63,16 +64,16 @@
     the above example takes a null parameter for the properties map; however it
     can actually be used to provide configuration for the incoming source.
     When null is passed the default is used to load the input as a drl.
-    Allowed keys for a map are "source" and "dsl". "source" takes "drl" or
-    "xml" as its value; set "source" to "drl" to load a drl or to "xml" to
-    load an xml source; xml will ignore any "dsl" key/value settings. The
-    "dsl" key can take a Reader or a String (the contents of the dsl) as a
+    Allowed keys for a map are <code>source</code> and <code>dsl</code>. <code>source</code> takes <code>dsl</code> or
+    <code>xml</code> as its value; set <code>source</code> to <code>dsl</code> to load a drl or to <code>xml</code> to
+    load an xml source; xml will ignore any <code>dsl</code> key/value settings. The
+    <code>dsl</code> key can take a Reader or a String (the contents of the dsl) as a
     value.</para>
 
     <example>
       <title>Specifying a DSL when registering a LocalRuleExecutionSet</title>
 
-      <programlisting>// Get the RuleAdministration 
+<screen>// Get the RuleAdministration 
 RuleAdministration ruleAdministrator = ruleServiceProvider.getRuleAdministrator();
 LocalRuleExecutionSetProvider ruleExecutionSetProvider = ruleAdministrator.getLocalRuleExecutionSetProvider( null );
 
@@ -89,19 +90,20 @@
 
 // Create the RuleExecutionSet for the drl and dsl
 RuleExecutionSet ruleExecutionSet = ruleExecutionSetProvider.createRuleExecutionSet( reader, properties );
-</programlisting>
+</screen>
     </example>
 
-    <para>When registering a RuleExecutionSet you must specify the name, to be
+    <para>When registering a RuleExecutionSet the name must be specified, to be
     used for its retrieval. There is also a field to pass properties, this is
     currently unused so just pass null.</para>
 
     <example>
       <title>Register the RuleExecutionSet</title>
 
-      <programlisting>// Register the RuleExecutionSet with the RuleAdministrator
+<screen>// Register the RuleExecutionSet with the RuleAdministrator
 String uri = ruleExectionSet.getName();
-ruleAdministrator.registerRuleExecutionSet(uri, ruleExecutionSet, null);</programlisting>
+ruleAdministrator.registerRuleExecutionSet(uri, ruleExecutionSet, null);
+</screen>
     </example>
   </section>
 
@@ -114,13 +116,14 @@
     <example>
       <title>Getting the RuleRuntime</title>
 
-      <programlisting>RuleRuntime ruleRuntime = ruleServiceProvider.getRuleRuntime();</programlisting>
+<screen>RuleRuntime ruleRuntime = ruleServiceProvider.getRuleRuntime();
+</screen>
     </example>
 
-    <para>To create a rule session you must use one of the two RuleRuntime
-    public constants - "RuleRuntime.STATEFUL_SESSION_TYPE" and
-    "RuleRuntime.STATELESS_SESSION_TYPE" along with the uri to the
-    RuleExecutionSet you wish to instantiate a RuleSession for. The properties
+    <para>To create a rule session one of the two RuleRuntime
+	    public constants must be used; <option>RuleRuntime.STATEFUL_SESSION_TYPE</option> and
+    <option>RuleRuntime.STATELESS_SESSION_TYPE</option> along with the URI to the
+    RuleExecutionSet that a RuleSession is to be instantiated for. The properties
     map can be null, or it can be used to specify globals, as shown in the
     next section. The createRuleSession(....) method returns a RuleSession
     instance which must then be cast to StatefulRuleSession or
@@ -129,28 +132,24 @@
     <example>
       <title>Stateful Rule</title>
 
-      <programlisting>(StatefulRuleSession) session = ruleRuntime.createRuleSession( uri,
-                                                               null,
-                                                               RuleRuntime.STATEFUL_SESSION_TYPE );
+<screen>(StatefulRuleSession) session = ruleRuntime.createRuleSession( uri, null, RuleRuntime.STATEFUL_SESSION_TYPE );
 session.addObject( new PurchaseOrder( "lots of cheese" ) );
-session.executeRules();</programlisting>
+session.executeRules();
+</screen>
     </example>
 
-    <para>The StatelessRuleSession has a very simple API; you can only call
-    executeRules(List list) passing a list of objects, and an optional filter,
-    the resulting objects are then returned.</para>
+    <para>The StatelessRuleSession has a very simple API; <classname>executeRules(List list)</classname> can only be called when passing a list of objects, and an optional filter, the resulting objects are then returned.</para>
 
     <example>
       <title>Stateless</title>
 
-      <programlisting>(StatelessRuleSession) session = ruleRuntime.createRuleSession( uri,
-                                                                null,
-                                                                RuleRuntime.STATELESS_SESSION_TYPE );
+<screen>(StatelessRuleSession) session = ruleRuntime.createRuleSession( uri, null, RuleRuntime.STATELESS_SESSION_TYPE );
 List list = new ArrayList();
 list.add( new PurchaseOrder( "even more cheese" ) );
 
 List results = new ArrayList();
-results = session.executeRules( list );</programlisting>
+results = session.executeRules( list );
+</screen>
     </example>
 
     <section>
@@ -159,12 +158,13 @@
       <para>It is possible to support globals with JSR94, in a non-portable
       manner, by using the properties map passed to the RuleSession factory
       method. Globals must be defined in the drl or xml file first, otherwise
-      an Exception will be thrown. the key represents the identifier declared
-      in the drl or xml and the value is the instance you wish to be used in
+      an Exception will be thrown. The key represents the identifier declared
+      in the drl or xml and the value is the instance to be used in
       the execution. In the following example the results are collected in a
       java.util.List which is used as global:</para>
 
-      <programlisting>java.util.List globalList = new java.util.ArrayList( );
+<screen>
+java.util.List globalList = new java.util.ArrayList( );
 java.util.Map map = new java.util.HashMap( );
 map.put( "list", globalList ); 
 //Open a stateless Session StatelessRuleSession srs = (StatelessRuleSession) runtime.createRuleSession( "SistersRules", map, RuleRuntime.STATELESS_SESSION_TYPE );
@@ -173,11 +173,13 @@
 // call executeRules( ) giving a List of Objects as parameter
 // There are rules which will put Objects in the List
 // fetch the list from the map
-List list = (java.util.List) map.get("list");</programlisting>
+List list = (java.util.List) map.get("list");
+</screen>
 
-      <para>Do not forget to declare the global "list" in your DRL:</para>
+<important>
+<para>Do not forget to declare the global <emphasis>list</emphasis> in your DRL:</para>
 
-      <programlisting>package SistersRules; 
+<screen>package SistersRules; 
 import org.drools.jsr94.rules.Person; 
 global java.util.List list
 rule FindSisters 
@@ -188,7 +190,8 @@
 then 
 list.add($person1.getName() + " and " + $person2.getName() +" are sisters"); 
 assert( $person1.getName() + " and " + $person2.getName() +" are sisters"); 
-end</programlisting>
+end</screen>
+</important>
     </section>
   </section>
 </section>
\ No newline at end of file




More information about the jboss-svn-commits mailing list