I think Xavier Noria wrote:

> > (bind ?consumer (new Consumer))
> > (?consumer setIncome 1500)
> > (defclass consumer Consumer)
> 
> I've seen examples like this in the manual, but unless I am wrong a new 
> instance of the class Consumer is being created there, isn't it? The 
> situation would be that objects _created in the Java-side of the 
> application_ would be "used" in the rules, that includes method calls. 
> In my example external objects were consumer and market.


Yes, in the above code (new Consumer) creates a new Consumer
object. You can replace that with any other Jess code to retrieve an
object of interest. The store and fetch functions are one easy way to
do this, but you can do it however you'd like -- e.g., using a static
Java method or member variable to "bootstrap" a tree of objects into
Jess. Once Jess has ahold of one object, you can use its methods and
data to retrieve others.


> 
> Since I don't know whether this is relevant, let's add the complexity 
> that we are iterating over a collection of consumer agents in the Java 
> code and firing that rule in each iteration. Could the corresponding 
> Jess variables be instantiated with each corresponding JavaBean in each 
> iteration?
> 

Yes, although that's really quite not how Jess is meant to be used;
you can add all the Consumer objects at once, and the rule will fire
only for those for which is applies, then extract all the results;
this will be more efficient.



---------------------------------------------------------
Ernest Friedman-Hill  
Distributed Systems Research        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]
--------------------------------------------------------------------

Reply via email to