RuleRuntime ruleRuntime = serviceProvider.getRuleRuntime();
System.out.println( "Acquired RuleRuntime: " + ruleRuntime );
// create a StatefulRuleSession
StatefulRuleSession statefulRuleSession =
(StatefulRuleSession) ruleRuntime.createRuleSession( uri,
new HashMap(),
RuleRuntime.STATEFUL_SESSION_TYPE );
System.out.println( "Got Stateful Rule Session: " + statefulRuleSession );
// Add some clauses...
ArrayList input = new ArrayList();
input.add(new Clause("Socrate","is human"));
// add an Object to the statefulRuleSession
statefulRuleSession.addObjects( input );
System.out.println( "Called addObject on Stateful Rule Session: "
+ statefulRuleSession );
statefulRuleSession.executeRules();
System.out.println( "Called executeRules" );
// extract the Objects from the statefulRuleSession
List results = statefulRuleSession.getObjects();
System.out.println( "Result of calling getObjects: " +
results.size() + " results." );
// Loop over the results.
Hashtable wm = ((StatefulRuleSessionImpl)statefulRuleSession).getWorkingMemory();
Enumeration en = wm.keys();
while(en.hasMoreElements()) {
Object obj = en.nextElement();
System.out.println("Clause Found: "+obj+" "+wm.get(obj));
}
// release the statefulRuleSession
statefulRuleSession.release();
System.out.println( "Released Stateful Rule Session." );
System.out.println();
}
catch (NoClassDefFoundError e) {