I think =?iso-8859-4?Q?Raoul_J=E4rvis?= wrote:
[Charset iso-8859-4 unsupported, filtering to ASCII...]
> Hello,
> 
> I was just wondering what would be the best way to embed JESS into a Java 
> application. The situation is as follows:
> 
> * The Java app has a lot of other logic and comm functionality, therefore Jess 
> library must be used from Java (and not the other way around, i.e. extending Jess 
> functionality with Java)
> * at certain time the Java app will need to invoke Jess's functionality to process a 
> _large_ set of rules and facts
> * after the execution, extract facts' values and do something with them (e.g. store 
> in a database)

No problems; Jess is specifically designed for this kind of usage. The
manual has useful information; you probably also would want a copy of
"Jess in Action", which has some fully-worked examples.

> 
> What would be the fastest way to load the Jess constructs (rules and facts) ? Is it 
> better to write them to a text file and then use executeCommand("(batch 
> thefile.clp)") ? Or is there a faster way (in terms of runtime performance)? 

The two choices are using a batch file, or dumping them using the
(bsave) function and loading at runtime using (bload). These functions
use Java serialization, and last time I checked, this was generally
slower than parsing the constructs as text.

Note that generally, your app will want to load the rules just once,
not every time you want to invoke Jess. Similarly, if most of the
facts are common between runs, you can just load these as well.

> 
> And what would be the fastest way to "transfer" the facts' values (all slots or just 
> some) back into the Java code?
> 

There's a complete Java API for doing this. You can use a defquery to
locate a subset of working memory that's of interest, then loop over
the results -- there's an example of doing this from Java in the
manual. If you want to look at all of working memory, then skip the
defquery and just call Rete.listFacts() to get an iterator.

---------------------------------------------------------
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