Well, actually KnowledgeAgent can&#39;t modify the rules. It can modify its internal kbase using the change-sets shown by jervis, but the rule sources are never modified by the agent.  <div>Basically you can start an agent with some initial change-set and all the rules present in the change-set resources are added to the agent&#39;s kbase. Once the agent is running you can add more resources using similar change-sets. You can even modify (remove, update) the rules inside the agent&#39;s kbase using change-sets too. Using ResourceScanner and Notifier, the agent is able to automatically detect changes on monitored resources and reflect the changes in its internal kbase. But as I said, the resources are never modified by the agent.</div>

<div><br></div><div>Hope I was clear.</div><div><br></div><div>Best,  <br><br><div class="gmail_quote">On Thu, May 20, 2010 at 3:43 AM, Jervisliu <span dir="ltr">&lt;<a href="mailto:jliu@redhat.com">jliu@redhat.com</a>&gt;</span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">With the new KnowledgeAgent API, you can not only connect to Guvnor<br>
server remotely to store and retrieve rules, but also to add or update<br>
rules. It also has basic authentication supported. Take a look at the<br>
unit test:<br>
<a href="http://anonsvn.jboss.org/repos/labs/labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/agent/KnowledgeAgentTest.java" target="_blank">http://anonsvn.jboss.org/repos/labs/labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/agent/KnowledgeAgentTest.java</a><br>


<br>
Below is a very simple test case that connects to Guvnor to retrieve a<br>
rule package, build a KnowledgeSession, then fire rules:<br>
<br>
    public void testBasicAuthentication() throws Exception {<br>
        String xml = &quot;&quot;;<br>
        xml += &quot;&lt;change-set<br>
xmlns=&#39;<a href="http://drools.org/drools-5.0/change-set" target="_blank">http://drools.org/drools-5.0/change-set</a>&#39;&quot;;<br>
        xml += &quot;    xmlns:xs=&#39;<a href="http://www.w3.org/2001/XMLSchema-instance" target="_blank">http://www.w3.org/2001/XMLSchema-instance</a>&#39;&quot;;<br>
        xml += &quot;<br>
xs:schemaLocation=&#39;<a href="http://drools.org/drools-5.0/change-set" target="_blank">http://drools.org/drools-5.0/change-set</a><br>
drools-change-set-5.0.xsd&#39; &gt;&quot;;<br>
        xml += &quot;    &lt;add&gt; &quot;;<br>
        xml += &quot;        &lt;resource<br>
source=&#39;<a href="http://localhost:8081/drools-guvnor/org.drools.guvnor.Guvnor/package/mortgages/LATEST" target="_blank">http://localhost:8081/drools-guvnor/org.drools.guvnor.Guvnor/package/mortgages/LATEST</a>&#39;<br>


type=&#39;PKG&#39;  basicAuthentication=&#39;enabled&#39; username=&#39;admin&#39;<br>
password=&#39;admin&#39;/&gt;&quot;;<br>
        xml += &quot;    &lt;/add&gt; &quot;;<br>
        xml += &quot;&lt;/change-set&gt;&quot;;<br>
        File fxml = fileManager.newFile(&quot;changeset.xml&quot;);<br>
        Writer output = new BufferedWriter(new FileWriter(fxml));<br>
        output.write(xml);<br>
        output.close();<br>
<br>
        KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase();<br>
<br>
        ResourceChangeScannerConfiguration sconf = ResourceFactory<br>
                .getResourceChangeScannerService()<br>
                .newResourceChangeScannerConfiguration();<br>
        sconf.setProperty(&quot;drools.resource.scanner.interval&quot;, &quot;2&quot;);<br>
        ResourceFactory.getResourceChangeScannerService().configure(sconf);<br>
<br>
        KnowledgeAgentConfiguration aconf = KnowledgeAgentFactory<br>
                .newKnowledgeAgentConfiguration();<br>
        aconf.setProperty(&quot;drools.agent.scanDirectories&quot;, &quot;true&quot;);<br>
        aconf.setProperty(&quot;drools.agent.scanResources&quot;, &quot;true&quot;);<br>
        aconf.setProperty(&quot;drools.agent.newInstance&quot;, &quot;true&quot;);<br>
        KnowledgeAgent kagent = KnowledgeAgentFactory.newKnowledgeAgent(<br>
                &quot;test agent&quot;, kbase, aconf);<br>
<br>
        kagent.applyChangeSet(ResourceFactory.newUrlResource(fxml.toURI()<br>
                .toURL()));<br>
<br>
        StatefulKnowledgeSession ksession = kagent.getKnowledgeBase()<br>
                .newStatefulKnowledgeSession();<br>
        List&lt;String&gt; list = new ArrayList&lt;String&gt;();<br>
        ksession.setGlobal(&quot;list&quot;, list);<br>
        ksession.fireAllRules();<br>
        ksession.dispose();<br>
<br>
        assertEquals(2, list.size());<br>
        assertTrue(list.contains(&quot;rule1&quot;));<br>
        assertTrue(list.contains(&quot;rule2&quot;));<br>
    }<br>
<br>
Hope this helps,<br>
<br>
Jervis<br>
<div><div></div><div class="h5"><br>
Michael Rhoden wrote:<br>
&gt; Yes and no. Guvnor uses a JCR repository (the default is<br>
&gt; <a href="http://jackrabbit.apache.org/" target="_blank">http://jackrabbit.apache.org/</a>) which can not be accessed using<br>
&gt; hibernate directly. We ran into this issue, and the only way to use<br>
&gt; guvnor as of 6 months ago was to have a user go into guvnor and create<br>
&gt; a DRL file by clicking a few buttons. Not a big deal, but it isn&#39;t<br>
&gt; automated. You can then use that DRL as a resource in your<br>
&gt; application. I know there was some working being done to be able to<br>
&gt; pull out DRLs from Guvnor using xml calls, but don&#39;t know if that was<br>
&gt; ever completed.<br>
&gt;<br>
&gt; Michael Rhoden<br>
&gt;<br>
&gt;<br>
&gt; ----- Original Message -----<br>
&gt; From: &quot;bbarani&quot; &lt;<a href="mailto:bbarani@gmail.com">bbarani@gmail.com</a>&gt;<br>
&gt; To: <a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>
&gt; Sent: Wednesday, May 19, 2010 5:12:57 PM<br>
&gt; Subject: [rules-users] Drools with Guvnor<br>
&gt;<br>
&gt;<br>
&gt; Hi,<br>
&gt;<br>
&gt; I am very new to Drools and very very new to Guvnor.<br>
&gt;<br>
&gt; I am in the process of creating a rule engine which will fetch the<br>
&gt; data from<br>
&gt; a source (I am using Hibernate framework to fetch the data) and<br>
&gt; evaluate the<br>
&gt; data using Drools rule engine. The rules supplied to the Drools rule<br>
&gt; engine<br>
&gt; are stored in a Rules table in a database.<br>
&gt;<br>
&gt; Now my question is that can I use Guvnor to store the rules (instead of me<br>
&gt; creating a rule data model) and use Guvnor to supply rules to my Drools<br>
&gt; engine?<br>
&gt;<br>
&gt; I am trying to find out the best possible way to create / manage a rule<br>
&gt; database (which stores all the rules).<br>
&gt;<br>
&gt; Thanks,<br>
&gt; BB<br>
&gt; --<br>
&gt; View this message in context:<br>
&gt; <a href="http://drools-java-rules-engine.46999.n3.nabble.com/Drools-with-Guvnor-tp830453p830453.html" target="_blank">http://drools-java-rules-engine.46999.n3.nabble.com/Drools-with-Guvnor-tp830453p830453.html</a><br>


&gt; Sent from the Drools - User mailing list archive at Nabble.com.<br>
&gt; _______________________________________________<br>
&gt; rules-users mailing list<br>
&gt; <a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>
&gt; <a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
</div></div>&gt; ------------------------------------------------------------------------<br>
<div><div></div><div class="h5">&gt;<br>
&gt; _______________________________________________<br>
&gt; rules-users mailing list<br>
&gt; <a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>
&gt; <a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
&gt;<br>
<br>
_______________________________________________<br>
rules-users mailing list<br>
<a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
</div></div></blockquote></div><br><br clear="all"><br>-- <br>XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX<br><br>Esteban Aliverti<br>
</div>