Thursday, June 11, 2009

Seam-Drools integration

Our friend Tihomir Surdilovic just published a few new features in the Drools and Seam integration. I will reproduce his post for those that missed.

Good job Tihomir!

We added a couple of new features to the seam-drools integration:

1. Support for Decision Tables (JBSEAM-4188):

<drools:rule-base name="ruleBase" rule-files="myDecisionTable.xls"/>

You can now compile rules from your Decision Table (xls) when using the drools:rule-base component in components.xml

2. Support for Drools Custom Consequence Exception Handlers (JBSEAM-4049):

<drools:rule-base name="ruleBase" rule-files="myDecisionTable.xls" consequence-exception-handler="#{myConsequenceExceptionHandler}"/>

You can use the new consequence-exception-handler attribute to add a new exception handler. This exception handler can be a Seam component and can look like:

public class MyConsequenceExceptionHandler implements ConsequenceExceptionHandler, Externalizable {

public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {

public void writeExternal(ObjectOutput out) throws IOException {

public void handleException(Activation activation,
WorkingMemory workingMemory,
Exception exception) {
throw new ConsequenceException( exception,
activation.getRule() );


3. Support for Drools Event Listeners (JBSEAM-4225):

<drools:managed-working-memory name="workingMemory" rule-base="#{ruleBase}">

This allows you to be notified of rule engine events, including rules firing, objects being asserted, etc by simply adding the drools:event-listeners element to your managed-working-memory component in components.xml as shown in the example

These updates will be available in Seam 2.2.0.CR1. We are also working on adding RuleFlow support in the near future.