Client API

A RuleBase may be obtained a variety of ways. The I/O subsystem is a popular method for loading a RuleBase. Other methods might include looking up a RuleBase in a JNDI store or simply deserializing a structure from disk.

The most useful method on RuleBase is a factory for constructing WorkingMemory sessions.

RuleBase ruleBase = obtainRuleBase();

WorkingMemory workingMemory = ruleBase.newWorkingMemory();

The WorkingMemory represents an isolated knowledge session against the RuleBase that created it. Changes may accumulate over time within a WorkingMemory through the use of the assertObject(...) modifyObject(...) retractObject(...) methods. Rules can be evaluated against the accumulated changes through the use of the fireAllRules() method.

WorkingMemory workingMemory = ruleBase.newWorkingMemory();  

Person person = new Person();

FactHandle handle = workingMemory.assertObject( person );

person.setAge( 52 );

workingMemory.modifyObject( handle, 
                            person );

workingMemory.fireAllRules();

workingMemory.retractObject( handle );

workingMemory.fireAllRules();