Experiment with "when rule becomes true execute a callback" feature in Drools
Expert, benchmarked by Drools Planner
-------------------------------------------------------------------------------------------------------------------
Key: JBRULES-3144
URL:
https://issues.jboss.org/browse/JBRULES-3144
Project: Drools
Issue Type: Task
Security Level: Public (Everyone can see)
Components: drools-core (expert), drools-planner
Reporter: Geoffrey De Smet
Assignee: Geoffrey De Smet
<_conan_> ge0ffrey: can do unfalse situation
<ge0ffrey> conan: is there a way to get a "when the rule no longer applies,
execture this code"?
<_conan_> ge0ffrey: i.e. when a ruel becomes untrue execute a callback
<ge0ffrey> conan: yes!
<_conan_> yes
<_conan_> it's trivial to do actually
<ge0ffrey> conan: what's the code name for that feature?
<_conan_> not related to TMS
<ge0ffrey> yep
<_conan_> you can potentially hack one for yourself
<_conan_> in about 10 minutes
<ge0ffrey> I 'd also need to have a value which was caclulated in hte the
orginal RHS
<_conan_> but the feature over all will take a lot of thought, due to language
design
<_conan_> but for your use case
<_conan_> it's trivial to do
<_conan_> in the rule you have the Activation
<_conan_> the impl is the AgendaItem
<ge0ffrey> conan: would love to do this (espeically if I get some appointed time for
it :)
<_conan_> you can do kcontext.getActivation
<_conan_> it'll take you 15 minutes to do it
<_conan_> change AgendaItem to have new field reference Callable or what ever you
want to use.
<ge0ffrey> k
<_conan_> in the consequnce just do agendaItem.addCallable( new Callable()
{............ } );
<_conan_> i.e. use an anonymous class
<_conan_> the only thing you need to do now
<_conan_> is in RuleTerminalNode in retractLeftTuple is
agendaItem.executeCallables()
<_conan_> that's it
<_conan_> it's that trivial
<ge0ffrey> (copy pasting htis in an issue to look at later, as my workspace is open
on my fork today)
<_conan_> I just don't want to expose that as a generic feature
<_conan_> because the issue needs more thought
<ge0ffrey> of course
<_conan_> with regards to language design
<_conan_> but for your use case
<_conan_> and as you are an expert
<_conan_> it's fine
<_conan_> I'd suggest you just maintain a "patched" version of drools
for that feature
<ge0ffrey> but if the exeperiment works well, we can look at language design
<_conan_> yes
<_conan_> I need this anyway
<_conan_> becausae rule engines need to tell peopl when things stop being true
<ge0ffrey> conan: not going to start using for released planner until it's in
drools expert for real
--
This message is automatically generated by JIRA.
For more information on JIRA, see:
http://www.atlassian.com/software/jira