This is the mail archive of the
kawa@sources.redhat.com
mailing list for the Kawa project.
RE: Java rule engine with rules expressed in Scheme
- From: "Bhinderwala, Shoeb" <SBhinderwala at wellington dot com>
- To: 'Chris Dean' <Chris dot Dean at sokitomi dot com>
- Cc: "'kawa at sources dot redhat dot com'" <kawa at sources dot redhat dot com>
- Date: Tue, 22 Jul 2003 11:44:33 -0400
- Subject: RE: Java rule engine with rules expressed in Scheme
Chris,
Thanks for the reply. I looked at the thread but could not find
all the steps. Could you send me a more detailed example.
Specifically, lets say I have a scheme script called test.scm.
How do I load this script from Java. After loading it, I want
to create my Java business object Security assigned to variable
mySecurity. Then I want to invoke a procedure in test.scm.
How do I access the business object I created (in Java code) inside
the procedure in test.scm?
-Shoeb
-----Original Message-----
From: Chris Dean [mailto:Chris.Dean@sokitomi.com]
Sent: Monday, July 21, 2003 6:46 PM
To: Bhinderwala, Shoeb
Cc: 'kawa@sources.redhat.com'
Subject: Re: Java rule engine with rules expressed in Scheme
> I am trying to write a Java rule engine application where the rules can be
> expressed in scheme.
This is easy, I do it all the time. See the short thread on:
http://sources.redhat.com/ml/kawa/2003-q1/msg00119.html
Write back if you would like a more detailed example.
Hmm. Mailing lists boxes seem down, so I'll repeat some info here. You
can see:
http://216.239.57.104/search?q=cache:tIRxOJpslfEJ:sources.redhat.com/ml/kawa
/2003-q1/msg00123.html
and Per's reply
| Slightly better/cleaner might be to use Procedure:
|
| Procedure test = (Procedure) env.get( "test", null );
| test.apply0();
|
| Though I think it unlikely that user-defined functions
| will no longer be ModuleMethod, it is even less likely
| that they will cease being Procecedures. In any case,
| using Procedure also works for builtin or halt-written
| procedures.
|
| You might also consider using 'eval' instead of 'get':
|
| Scheme scm = Scheme.getInstance();
| // or scm = new Scheme();
| Procedure test = (Procedure) scm.eval("test");
|
| This is slower than using get (though it doesn't matter
| unless its in an inner loop), but you don't have to
| explicitly work with environments.
|
Regards,
Chris Dean