On 08/05/2013 09:04 AM, Wolfgang Laun wrote:
Fine. Although occasionally useful, "from
<expression>" is often used
as a cover-up for inadequate design of fact types. (from
collect/accumulate is a different matter.)
That was exactly the case before we
found out how to make fact types
"more rule friendly". Luckily we are generating the fact classes from a
model, so we could implement some "rule helper functionality" quite
easily. For example, we generate all fact classes in 2 incarnations:
once as fully featured implementation classes with Hibernate, JAXB and
god-knows-what dependencies for the runtime system, and once as "almost
pure Java beans" for using them as models in Guvnor.
Hmm, there isn't much. Perhaps I should consider writing another
white
paper on monitoring.
That would be an excellent idea, me thinks ! I think with the
Annotations coming in Drools 6 one could put together a really useful
set of monitoring annotations (I have some experience doing this for
Java/Spring, but not for Drools, obviously. But I could be a good tester :-)
Activations are created whenever WM changes (or rule base changes)
make LHSs true for some fact set. At first, an activation is added to
the agenda. Firing removes an activation, but so does any change to
the set of facts in the WM. For instance:
rule AB when
A( $aid: id )
not B( id == $aid )
then ... end
Inserting 100k As and *then* 100k matching Bs before calling
fireAllRules creates and deletes 100k activations; with Bs before As
nothing is wasted.
Aha! That could be my problem, I'm doing exactly that in one
case.
Wasn't really aware the the sequence of fact insertion can have such a
great impact...
Activations can be destroyed by calling clear() on the Agenda, and
they can "evaporate" by being filtered away by an AgendaFilter that's
passed to the fireXY method.
I can see use cases for using an AgendaFilter (like "eliminating"
certain rules without changing the rule set and without clobbering the
LHS with guard facts.
But what would be a good example where I would use clear() on the Agenda
? Can't really think of one, but maybe I still did not understand the
concept fully...
--
CU, Joe