I have been experiencing difficulty using the JSR-94 API with Jess. Specifically, when I attempt to make the following API call:
session.addObject("A string");
where session is an instance of StatefulRuleSession, I do not see "A string" available anywhere within the Jess session. Specifically, I do not see a fact of the form (java.lang.String "A string" nil), which the documentation on Jess's implementation of JSR-94 seems to imply will be added to the factbase. Such a fact does not appear to be visible when I execute the Jess function
(facts)
and rules that are dependent on the existence of this fact are not activated. I did not see any documentation that indicated any other way in which an object added to the session via the "addObject" method would be visible to Jess rules. Is there any way that this difficulty can be circumvented? Is there some other mechanism by which objects added to the rule session can be accessed? Any assistance you can provide in this matter would be greatly appreciated.
P.S. The code to execute the rule session looks something like the following:
String implName = "org.jcp.jsr94.jess";
Class.forName("org.jcp.jsr94.jess.RuleServiceProviderImpl");
RuleServiceProvider serviceProvider =
RuleServiceProviderManager.getRuleServiceProvider(implName);
RuleAdministrator admin = serviceProvider.getRuleAdministrator();
HashMap properties = new HashMap();
properties.put("name", "test rule set");
properties.put("description", "some rules");
FileReader reader = new FileReader("C:\\WSADWorkspace\\JESSPrototype\\frb\\tl\\tender\\bidValidation_ruleset.xml");
RuleExecutionSet ruleSet = null;
try {
LocalRuleExecutionSetProvider lresp =
admin.getLocalRuleExecutionSetProvider(properties);
ruleSet = lresp.createRuleExecutionSet(reader, properties);
} finally {
reader.close();
}
admin.registerRuleExecutionSet("rules", ruleSet, properties);
RuleRuntime runtime = serviceProvider.getRuleRuntime();
StatefulRuleSession session = (StatefulRuleSession)
runtime.createRuleSession("rules",
properties,
RuleRuntime.STATEFUL_SESSION_TYPE);
session.addObject("A string");
session.executeRules();
List results = session.getObjects();
session.release();
And my XML file appears as follows:
<?xml version="1.0" encoding="UTF-8"?>
<rule-execution-set>
<name>test rule set</name>
<description>some rules</description>
<code>
(printout t "Hello, world! from TenderValidation ruleset..." crlf)
(facts)
(watch all)
(reset)
(import frb.tl.tender.*)
(import frb.tl.tender.comp.*)
(defrule define-tender-info
?notInitialized <- (TenderInfoNotInitialized)
(frb.tl.tender.comp.CompTenderInfo (OBJECT ?tenderInfo))
=>
(printout t "Found comp tender info fact" crlf)
(bind ?*compTenderInfo* ?tenderInfo)
(retract ?notInitialized)
(assert (TenderNotInitialized))
)
(assert (TenderInfoNotInitialized))
(facts)
</code>
</rule-execution-set>
- Re: JESS: Problems with JSR-94 Benjamin . Poserow
- Re: JESS: Problems with JSR-94 ejfried
- Re: JESS: Problems with JSR-94 Benjamin Tomasini
