Considering that googling on "rule latch" will return this thread on gmane as the 2nd link, you might find research difficult. :) I think Tom coined that term in this context, but it fits. The basic idea is that you use an object as an indicator of what processing has happened, and whether or not rules should fire. class RuleLatch { public final String name; public final DataObject dataObject; public RuleLatch(String name, DataObject dataObject) { this.name = name; this.dataObject = dataObject; } } when data: DataObject(...selection conditions for data...) level1Latch: RuleLatch(name == "level1Foo", dataObejct == data) level2Latch: RuleLatch(name == "level2Bar", dataObject == data) then ...if this rule wants to cancel all subsequent "level1Foo" it retracts level1Latch... ...if this rule wants to cancel all subsequent "level2Bar" it retractslevel2Latch... end An alternative, more efficient, but not as OO happy way, is to put the control information into the DataObject itself. Drools does a lot of optimization on the == tests with hashing, but if speed is a priority it might not be enough. So... class DataObject { public boolean level1Foo = true; public boolean level2Bar = true; } when data: DataObject(level1Foo == true, level2Bar == true, ...selection conditions for data... ) then ...if this rule wants to cancel all subsequent "level1Foo" it updates level1Foo = false... ...if this rule wants to cancel all subsequent "level2Bar" it updates level2Bar = false... end --- On Thu, 7/22/10, tom ska <tiberium.linux@gmail.com> wrote:
|