So let's dive directly into the new bean.xml:
<bean id="sm1" class="org.drools.vsm.local.ServiceManagerLocalClient" />
<drools:kbase id="kbase1" serviceManager="sm1">
<drools:resource type="DRL" source="classpath:org/drools/container/spring/testSpring.drl"/>
<drools:resource source="classpath:org/drools/container/spring/IntegrationExampleTest.xls" type="DTABLE">
<drools:decisiontable-conf input-type="XLS" worksheet-name="Tables_2" />
</drools:resource>
</drools:kbase>
<drools:ksession id="ksession1" type="stateless" name="stateless1" kbase="kbase1" serviceManager="sm1"/>
<drools:ksession id="ksession2" type="stateful" kbase="kbase1" serviceManager="sm1"/>
As we can see the first change is that instead of registering sessions inside an SM, the SM is injected into kbases and ksessions.
in the case of defining a kbase you need to provide an SM from which it will be created. But now we've made serviceManager optional, when an SM isn't provided it'll create a ServiceManagerLocalClient internally.
Another change we've made is that ksessions are auto-registered into the SM when one is provided. You also have the option of providing a name if you don't want to use the bean id when registering it to an SM. As such the above example can be rewritten as:
<drools:kbase id="kbase1">
<drools:resource type="DRL" source="classpath:org/drools/container/spring/testSpring.drl"/>
<drools:resource source="classpath:org/drools/container/spring/IntegrationExampleTest.xls" type="DTABLE">
<drools:decisiontable-conf input-type="XLS" worksheet-name="Tables_2" />
</drools:resource>
</drools:kbase>
<drools:ksession id="ksession1" type="stateless" kbase="kbase1"/>
<drools:ksession id="ksession2" type="stateful" kbase="kbase1"/>
As a working demonstration we updated the camel pipeline example to make use of the changes we've made.
Enjoy!
Download the updated example project: Drools Camel Spring

Great work guys,
ReplyDeleteWe have been evaluating a rules driven workflow engine to integrate with our spring stack and really like what you have done here.
Thanks,
-Abbas.
Is there any official release about this?
ReplyDelete