[rules-users] Is "modify" available from the Java API?

Thomas Grayson tgrayson at bluemetal.com
Tue Jun 18 16:22:39 EDT 2013


In the RHS of a rule one can use either an "update" or "modify" block to notify Drools that a fact has changed.  In the Java API for 5.5.0 Final, I can call StatefulKnowledgeSession.update(factHandle, object) to update a fact handle with an object.  However, there's no complementary StatefulKnowledgeSession.modify method.  Is there a way to get modify's property-reactive functionality through the API?  That is, can Java code update fact objects and then inform Drools that only certain properties have been changed?  This capability would allow just the rules that reference those properties to be reevaluated, unlike update, which causes all the rules that reference the Java class to be reevaluated.

There is a CommandFactory.newModify method, but the JavaDoc<http://docs.jboss.org/drools/release/5.5.0.Final/knowledge-api-javadoc/org/drools/command/CommandFactory.html#newModify(org.drools.runtime.rule.FactHandle,%20java.util.List)> has no explanatory text.  I explored the source to understand how this is used, and it appears that it is meant to be passed a list of Setter objects that contain literal bean property names and string values which are then dynamically interpreted by MVEL.  It might be possible to use this in a pinch, but it seems a rather roundabout way to update an object that the code can access directly.

Thanks,
Tom

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20130618/ca1d1c7e/attachment.html 


More information about the rules-users mailing list