Monday, March 9, 2009

Drools Adds"Command Design Pattern" Calls to Version 5

Greetings:

Well, version 5 isn't even out the door good before Mark begins adding things.  Check out http://rafb.net/p/DTK56i23.html for his latest example code.  What he's is doing is trying to have the same code for statefull or stateless session for system calls to Java.  Also see  http://en.wikipedia.org/wiki/Command_pattern for more info.  Checking out the lines with Mark:

l. 61: This if for doing an insert.  It marshals the XML into a Batch Execution Command.  

l. 88:  This means that it will return the BatchExecutionResults which supports full marshalling back to XML of the results.

l. 519:  Shows how a pipeline works.  it is a Unit Test and the String makes it more readable.  I prefer StringBuffer but Mark says that I'm old and should be using StringBuilder now.  Oh, well.

l. 113 shows how you would insert a set of elements.

l. 293 is what Mark calls "the money part" of the dual state machine

l. 307 is where they created a batch command to insert the four kinds of cheese.  Also, notice that they specify two queries which are viewable on lines 297 and 301.

So, what does that mean for ordinary Joe the plumber?  Well, the queries have an identifier where they can have their results added to the BatchExecutionResults.  Also, when executing a batch (shell script to us Unix geeks) you can get back specific facts or globals via an 'out" attribute.  Also, you can execute queries and have the results as part of the same BatchExecutionResults.  

With a stateless session (because the session is tossed after the execution) you now get a single shot execute that will work with statefull or stateless.

Anyway, most of this is Mark's words via iChat late last night so I hope it's all correct.  But, you might want to check it out anyway.

The link above will probably disappear shortly but here are some more along the same lines that should be more permanent:

https://hudson.jboss.org/hudson/job/drools/lastSuccessfulBuild/artifact/trunk/target/javadocs/stable/drools-api/org/drools/runtime/help/BatchExecutionHelper.html

https://hudson.jboss.org/hudson/job/drools/lastSuccessfulBuild/artifact/trunk/target/javadocs/stable/drools-api/org/drools/runtime/pipeline/PipelineFactory.html

https://hudson.jboss.org/hudson/job/drools/lastSuccessfulBuild/artifact/trunk/target/javadocs/stable/drools-api/org/drools/command/CommandFactory.html

SDG
jco

No comments: