Davide Sottara wrote
Could you please provide a more detailed example?
The usecase you propose is really interesting and the optimization of
something very similar is on the todo-list (@salaboy: "request-when" rings
a bell?)
Now, depending on your exact requirements, there could be various options,
more or less "clean" ;)
First of all, we should determine whether a) you need a new rule or b) you
can just use a parametric rule and carry the parameters in a fact, e.g.:
when
ParamHolder( $x : threshold, $bid : beanId )
Bean( id == $bid, value > $x )
then
...
end
If you do need new rules, generating the drl on the fly is feasible but
the parsing and compilation is a bit expensive, so maybe one should try to
build the internal representation, to save at least the parsing process
and "jump" to the RETE construction. Btw, you mentioned that you'd have to
generate a rule for each transaction: would that rule "lifecycle" be
limited to the transaction too? i.e. would it be possible/necessary to
remove the rule once it has been used?
Davide
Both of you are correct. This is not the typical use case Drools is designed
for.
Here are more details about the the context and use case.
Most of these rules will be used for filtering facts.
For example,
MyBean
{
var 1;
var 2;
var n;
}
We want to give the user the ability to define rules that can then be used
to filter a collection of face (Collection<MyBean>) at runtime. So you can
see how this can change with every request. In one case, the user may only
want to see a subset that satisfies the condition
var 1 > 2 and var 2.equals("something")
and the same user may may want to use a rule
var 3 > 10 and var 2.equals("something else").
I hope you get the idea. So, even if my business model is fixed the rules
are not. Although the rules are not very complicated, you can imagine that
the user can defined pretty much anything at runtime.
Can I use a "parameteric" rule for each of fact type in my business model?
--
View this message in context:
http://drools.46999.n3.nabble.com/Is-there-a-faster-way-of-doing-this-in-...
Sent from the Drools: User forum mailing list archive at
Nabble.com.