DSLs are non trivial and we still have yet to determine best practices when building one. Michael Neale has ideas around a template based system, similar to his work on Excel Integration. Until we have a clear way forward we are avoiding promoting this area too much.

Mark
Dave B wrote:
Hi David,

I'm just exploring Drools for the first time, and I've never looked at a
rules engine before.

I'm also investigating Drools for a project we're about to embark on,
and have just implemented a DSL in the last couple of days.

I don't quite understand the semantics
of this, especially the actions.

Does this emit the "room" element in some output, or what exactly
happens?

A ConditionFactory and ConsequenceFactory are used to create Condition
and Consequence objects.  These objects have access to the
Configuration object, which is in concept an XML wrapper.  So the XML
you see inside the <house:actions> tag is essentially the
configuration for the action.

Your custom Consquence object can inspect the Configuration (i.e. the
content of the action elements) and perform any arbitrary process on
it.  In the house example, there is code that interprets that XML, and
programmatically sets the heating to be off in the room object
representing the lounge.  How you do this is up to you, but the
natural implementation would be a Map of Room objects with a Heating
property.  The Consequence does the programmatic work to translate the
XML to the object model.

Condition objects operate in the same way.

So the DSL is not necessarily the text of the elements but encompasses
the whole XML structure.  There needn't be any element text at all if
you wish, the elements and their attributes themselves could provide
everything you need to perform rule processing.

Obviously then, there is a certain amount of work in implementing a
DSL.  And creating a DSL is not very well documented (I might add some
of my experiences now that I've actually created a non-trivial DSL). But the benefit once the Condition, Consequence, and Factory objects
have been coded is that a relatively complex process can be translated
to rules using a rule structure of your choosing.

Happy to answer any more questions.

Cheers,
Dave



Reply via email to