On Wed, 2009-06-17 at 09:36 -0700, Malay Shah wrote:
Hi,
I am looking to create the drools Rule objects programatically, and I
believe there is API to do that in 4.0.7. But, the API looks complex and the
documentation is not sufficient. Could anyone please point me to some
examples of doing this? I basically don't want to write rules in .drl files,
but have a database store the rules and make them strongly typed (by
generating Rule Objects directly from DB). Any help is much appreciated.
We're doing this by converting (XML) configuration files into rules
directly. Our reason was to avoid the serialization requirements, as
most of our objects used in facts are not serializable at all.
There is indeed not much documentation, and our approach was to build
simple rules first as DRL in a unit test, and then follow their way
through
the *Descr parts mentioned in another post, and observe how drools uses
them to build the RuleConditionElements using a debugger.
We have our built own abstraction on top then that hides the drools
"magic" behind documented classes, so that we can adjust our
implementation easily when drools changes.
The unit tests inside drools can help a long way here as well, but be
aware that this is quite some work and most of that follows a
trial-and-error approach :)
FWIW, we're using drools 5.0.1.FINAL, and haven't tested whether the
same approach works for 4.0.7.
HTH,
--
Andreas
--
Never attribute to malice that which can be adequately explained by
stupidity. -- Hanlon's Razor