Thursday, December 20, 2007

Modify Block for Java Dialect

In one more post in the series: "What are you guys doing right now?", :) we just added support to modify block in Java dialect consequences.

This is a feature that was already supported by MVEL and we decided to port it to Java so that it would benefit everyone, independently of the chosen dialect.

Basically, a modify block is a block of code that allow attributes of a given fact to be changed in the consequence of your rules, even with shadow facts turned off. In other words, if you don't want to pay for the shadow fact performance and memory cost, you can disabled them as long as you only change fact attributes inside modify blocks.

Example:

rule "Eat Cheese"
when
$p: Person( status == "hungry" )
$c: Cheese( )
then
retract( $c );
modify( $p ) {
setStatus( "full" ),
setAge( $p.getAge() + 1 )
}
end

So, inside of the modify block, you may write a comma separated list of Java expressions (set attribute values, call methods, etc) that are applied to the object scoped to that modify call. All of them are executed in sequence and inside a single fact update scope.

The grammar pseudo BNF looks like this:

modify ::= 'modify' '(' <expression> ')' '{' [ <expression> [ ',' <expression> ]* ] '}'

This feature was added both to trunk and 4.0.x branches and will be released in Drools 4.0.4 and Drools 4.1.0.

Happy drooling,
Edson
Share/Bookmark

19 comments:

  1. If a fact did not have property change support listener support, normally I would call update() on it after modifying it. Is that explicit call still necessary when using the modify block, or is it implied?

    ReplyDelete
  2. I admire this article for the well-researched content and excellent wording. I got so involved in this material that I couldn’t stop reading. I am impressed with your work and skill. Thank you so much.
    WordPress development company in Chennai

    ReplyDelete
  3. This is a very amazing post for cheap web hosting services. in this post, you have provided all the basic information regarding.
    website builder for reseller

    ReplyDelete
  4. Comfortabl y, the post is really the freshest on that deserving topic. I harmonise with your conclusions and definitely will thirstily look forward to your next updates.

    private label website builder

    ReplyDelete
  5. Thank you for the link building list.I am going jot down this because it will help me a lot.Great blog! Please keep on posting such blog.

    white label website builder

    ReplyDelete
  6. It has been simply incredibly generous with you to provide openly what exactly many individuals wouldíve marketed for an eBook to end up making some cash for their end, primarily given that you could have tried it in the event you wanted.
    Java Training | best java training institute in chennai | java j2ee training in chennai |
    java training chennai | java classes in chennai | java course in chennai | java training with placement in chennai| best java training center in chennai |
    java coaching classes in chennai

    ReplyDelete
  7. Great article Lot's of information to Read...Great Man Keep Posting and update to People..Thanks Kopar at Newton at Newton Hawker Centre

    ReplyDelete
  8. If you are viewing come up with alter in most of the living, starting point generally L . a . Weight reduction cutting down on calories platform are a wide stair as part of your attaining that most agenda. weight loss desktop mockup

    ReplyDelete
  9. your blog is very good. It was very well authored and easy to understand. Unlike additional blogs I have read which are really not good. I also found your posts very interesting desktop mockup

    ReplyDelete
  10. Pretty section of content. I just stumbled upon your weblog and in accession capital to assert that I get actually enjoyed account your blog posts. Any way I will be subscribing to your augment and even I achievement you access consistently quickly. imac mockups

    ReplyDelete
  11. I wanted to say Appreciate providing these details, youre doing a great job with the site... top app development companies

    ReplyDelete
  12. Highest quality fella toasts, or toasts. will most certainly be given birth to product or service ? from the party therefore supposed to become surprising, humorous coupled with enlightening likewise. best man speaches web design

    ReplyDelete
  13. Hello there, just became alert to your blog through Google, and found that it’s truly informative. I’m gonna watch out for brussels. I will appreciate if you continue this in future. A lot of people will be benefited from your writing. Cheers! ui ux design

    ReplyDelete
  14. Your way to enlighten everything on web design companies this blog is actually pleasant, everyone manage to efficiently be familiar with it, Thanks a great deal.

    ReplyDelete
  15. Expressive syntax includes: how easy it is to express an idea and how concisely can you do it. Python training allows you to write complex codes within few lines, still keeping its readability intact. unindent does not match any outer indentation level python

    ReplyDelete
  16. I'd be trampled if all sites gave articles like these awesome articles.
    UI design company

    ReplyDelete
  17. Great Article android based projects

    Java Training in Chennai

    Project Center in Chennai

    Java Training in Chennai

    projects for cse

    The Angular Training covers a wide range of topics including Components, Angular Directives, Angular Services, Pipes, security fundamentals, Routing, and Angular programmability. The new Angular TRaining will lay the foundation you need to specialise in Single Page Application developer. Angular Training

    ReplyDelete
  18. Hey, this day is too much good for me, since this time I am reading this enormous informative article here at my home. Thanks a lot for massive hard work. targonca szállítás Debrecen Europa-Road Kft.

    ReplyDelete