Hi Jack,
Well, you can't pluck one out of thin air, since createMyFact could
theoretically be called from within any one of a dozen Rete objects in
an app. The easiest thing to do here would be to give createMyFact a
Rete argument, then call it as
(call ?SomeClassInstance createMyFact (engine))
or alternatively give ?SomeClassInstance's class a constructor that
takes a Rete as a constructor argument.
I think Jack Kerkhof wrote:
> Hello again,
>
> Today I thought I'd play around with trying to make some Jess calls in
> java, but have run into what seems like a trivial problem that I just
> can't figure out:
>
> I am calling a java method from a jess script, and creating a Fact in
> that method.
> The problem is how to get the current Rete instance?
>
> I.e. In the .clp file:
> ...
> (call ?SomeClassInstance createMyFact)
> ...
>
> In the java code
> ...
> public void createMyFact() {
> Fact f = new Fact("MyTemplate", reteInstance);
> f.setSlotValue("A", new Value(1, RU.INTEGER));
> reteInstance.assert(f);
> }
> ...
>
> Where do I get "reteInstance" from? Most examples simply create one in
> Java, but alas I'm starting from an existing engine. I have a feeling
> from section 4.3 that Context.getEngine() is involved, but I'm afraid I
> have not located an example in the doc.
>
> thank you in advance,
>
> Jack
>
>
>
> ---------------------------------------------------------------------
> 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]
> ---------------------------------------------------------------------
>
---------------------------------------------------------
Ernest Friedman-Hill
Distributed Systems Research Phone: (925) 294-2154
Sandia National Labs FAX: (925) 294-2234
Org. 8920, MS 9012 [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 (use your own address!) List problems? Notify [EMAIL PROTECTED]
---------------------------------------------------------------------