
Handy for being notified of changes... the icon is the feed icon on list screens (paste that URL into a feed reader). It is an authenticated feed of course....

All things Artificial Intelligence related: Rules, Processes, Events, Agents, Planning, Ontologies and more :)
Monitoring for changes in repository
San Francisco Boot Camp for June filling up fast
The BPM Technology Convergence
Not one but two Drools books
Drools Boot Camp - Ales Justin to do Micro Container Talk
JBoss Drools Business Rules (Paperback) now on Amazon
Drools Boot Camp (SF 2009) are filling up fast
// Create a simple POJO objectAnd here's what that 'marshalled' variable contains
Person p = new Person("Mike", 30, new String[] { "Dorkus", "Jerkhead"});
p.setActive(true);
// Create another...
Person mother = new Person("Sarah", 50, new String[] { "Mommy", "Mom"});
mother.setActive(false);
// And another
Person father = new Person("John", 55, new String[] { "Dad", "Daddy"});
mother.setActive(false);
// Stick them together to make a somewhat complex graph
p.setMother(mother);
p.setFather(father);
// Create an MVBus encoding bus
MVBus bus = MVBus.createBus();
// Encode it!
String marshalled = bus.encode(p);
org.mvbus.decode.MVBUSDecoder.instantiate(org.mvbus.tests.resources.Person).{name="Mike",age=30,nicknames=new java.lang.String[] {"Dorkus","Jerkhead"},mother=org.mvbus.decode.MVBUSDecoder.instantiate(org.mvbus.tests.resources.Person).{name="Sarah",age=50,nicknames=new java.lang.String[] {"Mommy","Mom"},active=false},father=org.mvbus.decode.MVBUSDecoder.instantiate(org.mvbus.tests.resources.Person).{name="John",age=55,nicknames=new java.lang.String[] {"Dad","Daddy"},active=false},active=true}This is completely native MVEL code that can be turned back into an Object simply by passing it to MVEL.eval(). And it's very fast. However, if this isn't pretty enough for you, the encoder has a nice pretty printer that can be turned on like so:
MVBus bus = MVBus.createBus(PrintStyle.PRETTY);Which produces
String marshalled = bus.encode(p);
org.mvbus.decode.MVBUSDecoder.instantiate(org.mvbus.tests.resources.Person).{... in all it's MVEL-ly glory.
name = "Mike",
age = 30,
nicknames = new java.lang.String[] {
"Dorkus","Jerkhead"
},
mother = org.mvbus.decode.MVBUSDecoder.instantiate(org.mvbus.tests.resources.Person).{
name = "Sarah",
age = 50,
nicknames = new java.lang.String[] {
"Mommy","Mom"
},
active = false
},
father = org.mvbus.decode.MVBUSDecoder.instantiate(org.mvbus.tests.resources.Person).{
name = "John",
age = 55,
nicknames = new java.lang.String[] {
"Dad","Daddy"
},
active = false
},
active = true
}
High performance human readable marshalling with MVEL
public interface BatchExecutor {Both the StatelessKnowledgeSession and StatefulKnowledgeSession implement this interface, creating consistency. The CommandFactory allows for commands to be executed on those sessions, only only difference being the StatelessKnowledgeSession executes fireAllRules() at the end before disposing the session. The current supported commands are:
BatchExecutionResults execute(Command cmd);
}
public interface BatchExecutionResults {
CollectiongetIdentifiers();
Object getValue(String identifier);
}
StatelessKnowledgeSession ksession = kbase.newStatelessKnowledgeSession();
Listcmds = new ArrayList ();
cmds.add( CommandFactory.newInsertObject( new Cheese( "stilton", 1), "stilton") );
cmds.add( CommandFactory.newStartProcess( "process cheeses" ) );
cmds.add( CommandFactory.newQuery( "cheeses" ) );
BatchExecutionResults bresults = ksession.execute( CommandFactory.newBatchExecution( cmds ) );
QueryResults qresults = ( QueryResults ) bresults.getValue( "cheeses" );
Cheese stilton = ( Cheese ) bresults.getValue( "silton" );
Action executeResultHandler = PipelineFactory.newExecuteResultHandler();
Action assignResult = PipelineFactory.newAssignObjectAsResult();
assignResult.setReceiver( executeResultHandler );
Transformer outTransformer = PipelineFactory.newXStreamToXmlTransformer( BatchExecutionHelper.newXStreamMarshaller() );
outTransformer.setReceiver( assignResult );
KnowledgeRuntimeCommand batchExecution = PipelineFactory.newBatchExecutor();
batchExecution.setReceiver( outTransformer );
Transformer inTransformer = PipelineFactory.newXStreamFromXmlTransformer( BatchExecutionHelper.newXStreamMarshaller() );
inTransformer.setReceiver( batchExecution );
Pipeline pipeline = PipelineFactory.newStatelessKnowledgeSessionPipeline( ksession );
pipeline.setReceiver( inTransformer );
<batch-execution>Executing is as simple as inserting the XML into the pipeline:
<insert out-identifier="stilton">
<org.drools.Cheese>
<type>stilton</type>
<price>1</price>
</org.drools.Cheese>
</insert>
<query out-identifier='cheeses2' name='cheesesWithParams'>
<string>stilton</string>
<string>cheddar</string>
</query>
</batch-execution>
insert( inXml, resultHandler );
String outXml = (String) resultHandler.getObject();With the XML results looking something like:
<batch-execution-results>
<result identifier="stilton">
<org.drools.Cheese>
<type>stilton</type>
<price>2</price>
</org.drools.Cheese>
</result>
<result identifier='cheeses'>
<query-results>
<identifiers>
<identifier>stilton</identifier>
<identifier>cheddar</identifier>
</identifiers>
<row>
<org.drools.Cheese>
<type>cheddar</type>
<price>2</price>
<oldPrice>0</oldPrice>
</org.drools.Cheese>
</row>
<row>
<org.drools.Cheese>
<type>cheddar</type>
<price>1</price>
<oldPrice>0</oldPrice>
</org.drools.Cheese>
</row>
</query-results>
</result>
</batch-execution-results>
BatchExecutor
"Using Drools for Tracking and Situational Awareness" Added as a Lightning talk to the Drools Boot Camp
Drools Boot Camp Registration Page Now Open : San Francisco 1-7 June 2009
Drools Boot Camp introduces Lightning Talks (San Francisco June 2009)