[jboss-svn-commits] JBL Code SVN: r33446 - labs/jbossrules/trunk/drools-docs/drools-docs-expert/src/main/docbook/en-US/Chapter-Quick_Start.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Thu Jun 10 15:57:46 EDT 2010


Author: eaa
Date: 2010-06-10 15:57:45 -0400 (Thu, 10 Jun 2010)
New Revision: 33446

Modified:
   labs/jbossrules/trunk/drools-docs/drools-docs-expert/src/main/docbook/en-US/Chapter-Quick_Start/Section-More_On_Building_And_Deploying.xml
Log:
JBRULES-2541: KnowledgeAgent: Add the possibility to add custom KnowledgeBuilderConfiguration
	- Updated documentation

Modified: labs/jbossrules/trunk/drools-docs/drools-docs-expert/src/main/docbook/en-US/Chapter-Quick_Start/Section-More_On_Building_And_Deploying.xml
===================================================================
--- labs/jbossrules/trunk/drools-docs/drools-docs-expert/src/main/docbook/en-US/Chapter-Quick_Start/Section-More_On_Building_And_Deploying.xml	2010-06-10 19:44:52 UTC (rev 33445)
+++ labs/jbossrules/trunk/drools-docs/drools-docs-expert/src/main/docbook/en-US/Chapter-Quick_Start/Section-More_On_Building_And_Deploying.xml	2010-06-10 19:57:45 UTC (rev 33446)
@@ -110,6 +110,49 @@
     </para>
 
     <section>
+      <title>Knowledge Agent and Custom ClassLoaders</title>
+      <para>Because Knowledge Agent could scan and process remote resources, it
+      could ends up failing when compiling or executing rules, queries, functions,
+      etc. that use classes outside the agent's classloader.
+      If this is your case, you could take 2 approach: use a custom classloader
+      for agent's kbuilder or force the agent to use the same classloader that
+      its kbase has.</para>
+      <section>
+      <title>Custom ClassLoaders for KnowledgeBuilder</title>
+        <para>Knowledge Agent uses KnowledgeBuilder internally in order to
+        compile managed resources. If you need to pass custom configuration to
+        these compilers you could pass a KnowledgeBuilderConfiguration object
+        to KnowledgeAgentFactory.newKnowledgeAgent(). This object will be used
+        in every builder the agent creates. Using a KnowledgeBuilderConfiguration
+        you can specify a custom classloader.</para>
+      </section>
+      <section>
+      <title>Reuse KnowledgeBase ClassLoader</title>
+        <para>Most of the times, the classloader you wan't to use in the
+        compilation process of remote resources is the same needed in the
+        agent's kbase, so the rules could be executed. If you want to use this
+        approach, you will need to setup the desired ClassLoader to the
+        agen't kbase and use the "drools.agent.useKBaseClassLoaderForCompiling"
+        property of KnowledgeAgentConfiguration object.</para>
+        <para>This approach lets you modify agent's kbuilder classloader in
+        runtime by modifying the classloader the agent's kbase uses. Of course
+        you will need to use incremental change set processing (see the section
+        bellow). Otherwise the kbase will be recreated every time a change set
+        is processed and the custom classloader will be missed.</para>
+<programlisting>KnowledgeBaseConfiguration kbaseConfig =
+    KnowledgeBaseFactory.newKnowledgeBaseConfiguration(null, customClassLoader);
+KnowledgeBase kbase =
+    KnowledgeBaseFactory.newKnowledgeBase(kbaseConfig); //kbase with custom classloader
+KnowledgeAgentConfiguration aconf =
+    KnowledgeAgentFactory.newKnowledgeAgentConfiguration();
+aconf.setProperty("drools.agent.newInstance", "false"); //incremental change set processing enabled
+aconf.setProperty("drools.agent.useKBaseClassLoaderForCompiling", "true");
+KnowledgeAgent kagent = KnowledgeAgentFactory.newKnowledgeAgent(
+                "test agent", kbase, aconf);</programlisting>
+      </section>
+    </section>
+
+    <section>
       <title>Incremental Change Set Processing</title>
         <para>
             Knowledge Agent can process change sets in two different ways:



More information about the jboss-svn-commits mailing list