There is no such thing as the "point in flow of control where a rule's
'when' is executed". It is the foremost purpose of the Rete algorithm to
avoid these straightforward evaluations of the LHS conditions as rule
programmers see them in the rule text. Instead, LHSides are taken apart (by
the rule compiler), rearranging the Conditional Elements (patterns & frieds)
into the most efficient evaluation order, and producing what is known as the
"Rete Network". This rearrangement includes the detection of shared CE
nodes. (This is similar to what a classic compiler would do after it
identifies code sections common to several branches of a conditional
statement.)
Having said that, it should be clear that setting a breakpoint on a 'when'
is neither possible (even with the Eclipse IDE) nor would it be meaningful,
and not even helpful.
There are, of course, situations where some information about what's going
on during CE evaluation is indeed useful, e.g., when evaluating one of the
complex CEs. Consider:
# Check for a point being within a simple (concave or convex) polygon
#
rule "point in polygon"
when
$polygon : Polygon( $name : name, $edge : edge )
Point( $pn : name, $x : x, $y : y )
Boolean( booleanValue == true )
from accumulate( Edge( polygon == $polygon, $p1 : p1, $p2 : p2 )
init( int count = 0; )
action( if( cut( $p1.getX(), $p1.getY(), $p2.getX(), $p2.getY(),
$x, $y ) ){
count++;
} )
result( count % 2 != 0 ) )
then
System.out.println( "polygon " + $name + " contains " + $pn
);
end
Here, the function cut is called, and lots of things could have been
botched. You may set a breakpoint on the function and check the values. If
the breakpoint is not reached, then some preceding CE has stopped the
progress through the Rete network, at least for what is currently in WM.
-W
On Mon, May 4, 2009 at 10:16 AM, lightbulb432 <veerukrishnan(a)hotmail.com>wrote:
(I can't use Eclipse's debug as "Drools Application" feature because
the
Drools application I'm using is embedded within a larger deployed web
application, so I must use breakpoints.)
Where can I set breakpoints in my IDE to know exactly when the when/then
sides of a rule are evaluated? I know that the "then" side of a rule is
executed when DefaultAgenda.fireActivation(Activation) method is run, so
every time that breakpoint is hit I know that a rule's "then" side is
about
to be fired.
However, I don't know where to set the breakpoint for the "when" side of
the
rule - where is this?
Assuming I have 10 rules in total but in a particular scenario only 1 of
those is actually fired successfully after executing the "when" tests, what
I'd like to see is 10 "when" breakpoints being hit and only 1
"then"
breakpoint being hit.
--
View this message in context:
http://www.nabble.com/Debugging-Drools-when-then-using-breakpoints-tp2336...
Sent from the drools - user mailing list archive at
Nabble.com.
_______________________________________________
rules-users mailing list
rules-users(a)lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users