[rules-users] Creating objects in WHEN clause

David Boaz davidb at dbmotion.com
Wed Feb 25 12:35:24 EST 2009


In my application, we often compare the fact's field values against a known
object. For example:
WHEN Person(height> new Quantity(2, "m")) // the height is greater than 2
meters.
will DROOLS create a "singleton" Quantity object, or will it create one
object for each fact evaluation?

We consider using anoter approach, using GLOBALS. Then, the Quantity object
will be created applicatively, and passed by the API to the engine.
something like:
GLOBAL Quantity 2meters
WHEN Person(height > 2meters)
But this approach is combersom, because the rule author has to define part
of the information in the calling application, and part in the rule.

A similar issue is when creating Duration objects. for example: Job(
endTime-startTime < new Duration(3, "week"))
Do you have a good practice how to handle these situations?

Thanks, David
-- 
View this message in context: http://www.nabble.com/Creating-objects-in-WHEN-clause-tp22207616p22207616.html
Sent from the drools - user mailing list archive at Nabble.com.




More information about the rules-users mailing list