I think Juan Luis Mulas Platero wrote:
>
> Hello everybody again.
> If I a create a object from Java outside Jess, and then I put it into Jess
> using a definstance or bind with a defglobal (all from Java), is it
> possible to access from Jess to the changes makes on that object (created
> in Java)?
Of course!
> Could someone explain me, in detail, how I can create a object outside
> JESS, put it into JESS and use the firePropertyChange method (from JAVA)
> so that it fires a rule in JESS with a pattern=the object put into JESS
> (having used the definstance contruct).
>
Here is a complete example using the Pumps and Tanks classes, but driving
things from Java instead of from Jess. Before running this, edit the
jess/examples/pumps/pumps.clp file by commenting out the 'startup' rule
and the (reset) and (run) commands.
; ----------------------------------------------------------------------
import jess.*;
public class FromJava
{
public static void main(String[] argv) throws ReteException
{
// Initial setup.
Rete rete = new Rete(new NullDisplay());
rete.addUserpackage(new MiscFunctions()); // For 'batch'
rete.addUserpackage(new jess.reflect.ReflectFunctions());
// IMPORTANT: Edit this file - remove the 'startup' rule and the
// (reset) and (run) commands!
rete.executeCommand("(batch jess/examples/pumps/pumps.clp)");
rete.executeCommand("(reset)");
// Create some Java Beans ...
jess.examples.pumps.Tank t = new
jess.examples.pumps.Tank("MAIN");
jess.examples.pumps.Pump p = new
jess.examples.pumps.Pump("MAIN", t);
// Install these objects into Jess ...
Funcall f = new Funcall("definstance", rete);
f.add(new Value(RU.putAtom("pump"), RU.ATOM));
f.add(new Value(p, RU.EXTERNAL_ADDRESS));
f.simpleExecute(f, rete.globalContext());
f = new Funcall("definstance", rete);
f.add(new Value(RU.putAtom("tank"), RU.ATOM));
f.add(new Value(t, RU.EXTERNAL_ADDRESS));
f.simpleExecute(f, rete.globalContext());
// and start the engine...
rete.executeCommand("(run)");
}
}
; ----------------------------------------------------------------------
---------------------------------------------------------
Ernest Friedman-Hill
Distributed Systems Research Phone: (510) 294-2154
Sandia National Labs FAX: (510) 294-2234
Org. 8920, MS 9214 [EMAIL PROTECTED]
PO Box 969 http://herzberg.ca.sandia.gov
Livermore, CA 94550
---------------------------------------------------------------------
To unsubscribe, send the words 'unsubscribe jess-users [EMAIL PROTECTED]'
in the BODY of a message to [EMAIL PROTECTED], NOT to the
list. List problems? Notify [EMAIL PROTECTED]
---------------------------------------------------------------------