Skip to content
Browse files

add documentation for the CompositeKBuilder

(cherry picked from commit da6da1c)
  • Loading branch information...
1 parent 648d482 commit 8d647dc6a54c84d85f561a8ec258b537cc89d1df @mariofusco mariofusco committed May 3, 2012
View
34 ...ls-docs/drools-expert-docs/src/main/docbook/en-US/Chapter-User_Guide/Section-Building.xml
@@ -187,6 +187,40 @@ if( kbuilder.hasErrors() ) {
Collection<KnowledgePackage> kpkgs = kbuilder.getKnowledgePackages();
</programlisting>
</example>
+
+ <para>The KnowledgeBuilder also has a batch mode, with a fluent interface, that
+ allows to build multiple DRLs at once as in the following example:</para>
+
+ <example>
+ <title>Using KnowledgeBuilder in batch mode</title>
+
+ <programlisting language="java">KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
+kbuilder.batch()
+ .add( ResourceFactory.newFileResource( "/project/myrules1.drl" ), ResourceType.DRL )
+ .add( ResourceFactory.newFileResource( "/project/myrules2.drl" ), ResourceType.DRL )
+ .add( ResourceFactory.newFileResource( "/project/mytypes1.drl" ), ResourceType.DRL )
+ .build();
+ </programlisting>
+ </example>
+
+ <para>In this way it is no longer necessary to build the DRLs files in the right order (e.g. first the DRLs
+ containing the type declarations and then the ones with the rules using them) and it will also be possible to have
+ circular references among them.</para>
+
+ <para>In the end the KnowledgeBuilder (regardless if you are using the batch mode or not) also allows to discard
+ what has been added with the last DRL(s) building. This can be useful to recover from having added a wrong DRL to
+ the KnowledgeBuilder as it follows:</para>
+
+ <example>
+ <title>Discard the building of the last added DRL</title>
+
+ <programlisting language="java">kbuilder.add( ResourceFactory.newFileResource( "/project/wrong.drl" ), ResourceType.DRL );
+if ( kbuilder.hasErrors() ) {
+ kbuilder.undo();
+}
+ </programlisting>
+ </example>
+
</section>
<section>

0 comments on commit 8d647dc

Please sign in to comment.
Something went wrong with that request. Please try again.