Download User Manual

Transcript
OpenRules® User Manual
OpenRules, Inc.
If a business rule is changed, OpenRulesEngine automatically reloads the rule
when necessary. Before any engine's run, OpenRulesEngine checks to determine
if the main Excel file associated with this instance of the engine has been
changed. Actually, OpenRulesEngine looks at the latest modification dates of
the file xlsMainFileName.
If it has been modified, OpenRulesEngine re-
initializes itself and reloads all related Excel files. You can shut down this
feature by executing the following method:
engine.setCheckRuleUpdates(false);
Decision API
Decision Example
OpenRules® provides a special API for decision execution using the Java class
“Decision”. The following example from the standard project “Decision1040EZ”
demonstrates the use of this API.
public class Main {
public static void main(String[] args) {
String fileName = "file:rules/main/Decision.xls";
OpenRulesEngine engine =
new OpenRulesEngine(fileName);
Decision decision =
new Decision("Apply1040EZ",engine);
DynamicObject taxReturn =
(DynamicObject) engine.run("getTaxReturn");
engine.log("=== INPUT:\n" + taxReturn);
decision.put("taxReturn",taxReturn);
decision.execute();
engine.log("=== OUTPUT:\n" + taxReturn);
}
}
Here we first created an instance engine of the class OpenRulesEngine and used
it to create an instance decision of the class Decision. We used the engine to get
an example of the object taxReturn that was described in Excel data tables:
DynamicObject taxReturn =
(DynamicObject) engine.run("getTaxReturn");
93