<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
</head>
<body text="#000000" bgcolor="#FFFFFF">
Dear Drools Users,<br>
<br>
I am building a network server for drools since the existing
drools-server did not meet my requirements. Since I recently found
a bug and find the people here very helpful I'll try to explain
another issue I encountered in the hope that it improves drools 5.6
and 6.0.<br>
I noticed that declared types and globals don't seem to be found
when you access them from a rule that was written in a different
file. For the declared types I hacked around this issue by
preprocessing the files and placing every declared type at the top
of each file that needs it. For globals this is of course not
possible. <br>
<br>
An example is shown below. File1 is loaded from the moment the agent
starts up, then file2 is loaded.<br>
There is a difference when the knowledgeAgent detects the two files
at once or one by one. In this case the KnowledgeAgent detects one
file and then a few minutes later the other file and compiles them
completely separately.<br>
The idea is to keep how many rules are matched of a certain type in
a global.<br>
<br>
<b><small> FILE1: global_rules_matches.drl<br>
----------------------------------------------<br>
package ellipsoidfacts<br>
<br>
// declare<br>
global Integer RULES_MATCHED;<br>
<br>
// initialize global<br>
rule "initRULESMATCHED"<br>
salience 999<br>
when<br>
<br>
then<br>
RULES_MATCHED = 0;<br>
end</small></b><br>
<br>
<b><small> FILE2: testrule.drl<br>
----------------------------------------------<br>
package ellipsoidfacts<br>
<br>
rule "Gesture_lefthook"<br>
when <br>
<br>
// ... any precedent rules ... <br>
<br>
then<br>
System.out.println("matched gesture: lefthook"+
RULES_MATCHED);<br>
end</small></b><br>
<br>
In this particular case, my rule is not matched. I load these rules
using a changeset xml, my knowledgeagent is set to incremental (but
either doesnt work).<br>
The same happens when I declare types in FILE1 and use them in
FILE2. When I write the type declaration in both files it works
perfectly. <br>
Being the same package I assumed that these two scenarios should
work. Am I doing something wrong or is the agent not supposed to
work like this and should a package be in one file?<br>
<br>
Kind Regards,<br>
De Rooms Brecht<br>
</body>
</html>