6. Embedding Jess in a Java Application
6.1. Using the class jess.Main
The class jess.Main provides not only the Jess command-line
interface, but also the backbone of the example graphical interfaces
(jess.Console and jess.ConsoleApplet) as well. You
can reuse jess.Main from your own applications, or you can
simply use it as an example of what an application embedding Jess
can look like.
jess.Main does a number of things that a reasonable Jess
application might do:
- It reads the script library jess/scriptlib.clp and
installs an event-handler so that the file will be re-read
clear() is called.
- It (optionally) reads an entire file of Jess code directly, using
the jess.Jesp parser class.
- It reads and executes user input in a loop.
- It provides special handling for the bload and
bsave commands, which disrupt the normal flow of execution.
6.2. Manipulating Jess in other ways
Note that each individual jess.Rete object represents an
independent reasoning engine. A single program can then include
several indepenent engines.
Jess can be used in a multithreaded environment. The
jess.Rete class internally synchronizes itself using several
synchronization locks. The most important lock is a global lock on all
rule LHSs: only one assert or retract may be processing int a given
jess.Rete object at a time. This restriction is likely to be
relaxed in the future.
Back to index