Drools Component Integration

Page added by Van Halbert


Drools Component Integration

The Drools component integration is an example of integrating business rules with your data. This example will demonstrate how a business rule can be triggered via a User Defined Function (UDF).

The UDF (RulesUDF.java) is written to load one or more drools .drl file(s) that is defined as a system property. An example is:

  • <property name="org.teiid.drools.UDF" value="org.jboss.teiid.quickstart.data.MarketData:MyBusinessRules.drl"/>

where: - value format is: POJO className:.drl file[,POJO className:.drl,…]

The format maps the POJO to the rule that will process it.

The caller to the UDF will call the following function method:
<code>
public static Object performRuleOnData(final String className, final String returnMethodName, final Object returnIfNull, final Object... arguments)

Unknown macro: { .. }

</code>

where:

  • className: class name of the POJO to be instantiated and passed to the rules
  • returnMethodName: name of the method to call on the POJO to get the return value (if one)
  • returnIfNull: if returnMethodName returns a null value, then default to returnIfNull value
  • arguments: is a variable number of objects, that must match to the constructor of the POJO.
    So all the arguments will be passed in when the "className" is instantiated.

One of the goals of this example was to demonstrate that a UDF could be written generically to integrate with drools.

Stop watching space | Change email notification preferences
View Online | Add Comment