Interface IRuleEngine
-
public interface IRuleEngine
Rule Engine is an engine to execute rules. A rule is composed of two parts, a condition and an action: When the condition is met, the action is executed.
From this interface you can create
RuleBase
. The RuleBase is a repository for all rule resources. Then the RuleBase has to create a new rule session to execute the rules.- Rule resource is a resource that defines rules. It can be a native rule language (*.drl) file, decision table.
- Rule session is a session that interacts with the engine.
Example: execute rules on an object
Example: execute rules on a collection of objects// This example will calculate tax for an employee Employee employee = new Employee("John Snow", 4000); IRuleBase rulebase = Rules.engine().createRuleBase(); // namespace.of.rules is the folder hierarchy (namespace\of\rules) that contains rule resources // and inside the root rules folder in the Ivy project rulebase.loadRulesFromNamespace("namespace.of.rules"); IStatelessRuleSession session = rulebase.createSession(); session.execute(employee);
// This example will calculate tax for list of employees IRuleBase rulebase = Rules.engine().createRuleBase(); rulebase.loadRulesFromNamespace("namespace.of.rules"); IStatelessRuleSession session = rulebase.createSession(); session.execute(employees);
- API:
- This is a public API.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description IRuleBase
createRuleBase()
Create a rule base to store the rule resources.
-
-
-
Method Detail
-
createRuleBase
IRuleBase createRuleBase()
Create a rule base to store the rule resources.- Returns:
- The newly created rule base.
- API:
- This public API is available in IvyScript and Java. It has the visibility NOVICE.
-
-