I think Chuck Davis wrote:
> The rules engine is being called from a Web session; the code snippet is
> included below. I neglected to mention that an instance of AClass was being
> passed in (see the three commented-out lines in the code snippet).
>
> This seems to be the source of the problem.
>
> With these lines uncommented-out, the output was [one, null, doit] - the
> null indicating that the object created by do-startup was not matching in
> do-stuff. With the lines commented-out, the output was [success, doit],
> which is the expected result.
>
> I'm sorry to say that I don't understand why passing in an instance of
> AClass would make a difference here.
Ah, OK. I tried running it your way, and I see the problem. Your rule
file leaves "stuff" as the current module, so that when the objects
passed to executeRules() are received, Jess ends up defining a
stuff::example.AClass template as well as the existing
MAIN::example.AClass template. The existence of the template subtly
changes the meaning of several rules, with the end result that dostuff
is never activated. A workaround would be to add (set-current-module
MAIN) to the end of your rules file.
Remember that the JSR94 RI isn't a product -- it's more of a
proof-of-concept. A JSR94 implementation that's actually useable will
soon be available as part of the Jess distribution.
>
> Thanks for your help,
> chuck
>
>
>
> ********** Code snippet ************
>
> HttpServletRequest request;
> HttpServletResponse response;
>
> FileReader reader = null;
> StatelessRuleSession ruleSession = null;
> List results = null;
> try {
> Class.forName("org.jcp.jsr94.jess.RuleServiceProviderImpl");
> RuleServiceProvider serviceProvider =
> RuleServiceProviderManager.getRuleServiceProvider(
> "org.jcp.jsr94.jess");
> //
> // Administration
> //
> RuleAdministrator admin = serviceProvider.getRuleAdministrator();
> HashMap vendorProperties = new HashMap();
> LocalRuleExecutionSetProvider lresp =
> admin.getLocalRuleExecutionSetProvider(vendorProperties);
> reader = new FileReader("..the rules file..");
> RuleExecutionSet ruleSet =
> lresp.createRuleExecutionSet(reader, vendorProperties);
> admin.registerRuleExecutionSet("rules", ruleSet, vendorProperties);
>
> //
> // Runtime
> //
> RuleRuntime runtime = serviceProvider.getRuleRuntime();
> ruleSession =
> (StatelessRuleSession)runtime.
> createRuleSession("rules", vendorProperties,
> RuleRuntime.STATELESS_SESSION_TYPE);
> ArrayList inputList = new ArrayList();
> // AClass aC = new AClass(); // removing comments causes the issue
> // aC.setField1("one");
> // inputList.add(aC);
> results = ruleSession.executeRules(inputList);
>
> } catch (Exception e) {
> response.getWriter().write("Error: " + e);
> } finally {
> if (reader != null) reader.close();
> try {
> if (ruleSession != null) ruleSession.release();
> } catch (Exception e2) {
> }
> }
>
> response.getWriter().write("Test results: " + results);
>
>
> *********************
>
>
> -----Original Message-----
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On
> Behalf Of [EMAIL PROTECTED]
> Sent: Friday, July 23, 2004 4:14 PM
> To: [EMAIL PROTECTED]
> Subject: Re: JESS: Definstance matching within a module for JSR94
>
> I think Chuck Davis wrote:
> >
> >
> > executing within a STATELESS_SESSION_TYPE session causes the do-it rule,
> but
> > not the do-stuff rule, to fire. Yet, when run as a JESS batch file, both
> > these rules fire.
> >
>
> > All three rules seem to fire and do what they're supposed to.
>
> > How did you determine that some but not all of the rules had fired?
>
> --------------------------------------------------------------------
> To unsubscribe, send the words 'unsubscribe jess-users [EMAIL PROTECTED]'
> in the BODY of a message to [EMAIL PROTECTED], NOT to the list
> (use your own address!) List problems? Notify [EMAIL PROTECTED]
> --------------------------------------------------------------------
>
---------------------------------------------------------
Ernest Friedman-Hill
Science and Engineering PSEs Phone: (925) 294-2154
Sandia National Labs FAX: (925) 294-2234
PO Box 969, MS 9012 [EMAIL PROTECTED]
Livermore, CA 94550 http://herzberg.ca.sandia.gov
--------------------------------------------------------------------
To unsubscribe, send the words 'unsubscribe jess-users [EMAIL PROTECTED]'
in the BODY of a message to [EMAIL PROTECTED], NOT to the list
(use your own address!) List problems? Notify [EMAIL PROTECTED]
--------------------------------------------------------------------