jess

Jess bind this instance of java object


I want to do something like that in Jess:

(bind ?instance (this))

The only way I get it working is by using "new Object" instead of "this".

How can I get it working?


Solution

  • Presumably you are passing some Jess code to the Rete.exec() method, and want a reference to the object that's making the call. You just have to inject it into Jess yourself. Either use Rete.store() to store the object in Jess, then use (fetch) to retrieve it from storage in the Jess code, or use the methods of the global context object -- see Rete.getGlobalContext() -- to set a variable to refer to the Java object, then use the variable in the Jess code.