In the Jess 6.0a2 manual, in section 4.6, there is a class showing
several examples of creating and executing jess.Funcall objects from
Java code -- one of them is a definstance function call, which is
what you want to do. Here's the complete example
import java.awt.Button;
import jess.*;
public class ExAButton
{
public static void main(String[] unused) throws JessException
{
Rete r = new Rete();
Context c = r.getGlobalContext();
Value button = new Value("button", RU.ATOM);
Funcall f = new Funcall("batch", r);
f.add(new Value("jess/scriptlib.clp", RU.STRING));
f.execute(c);
f = new Funcall("defclass", r);
f.add(button).add(new Value("java.awt.Button", RU.ATOM));
f.execute(c);
new Funcall("definstance", r).arg(button).arg(new Value(new Button("Press
Me"))).execute(c);
new Funcall("facts", r).execute(c);
}
}
I think Peter Olsen wrote:
> Ladies and Gentlemen,
>
> I'd like to know the best way of inserting an existing Bean into a
> running Rete engine.
>
> I'm working on a Jess-based system to govern access to controlled
> documents. I'll have a large number of users and an immense number of
> documents, so I can't store them all in memory. Furthermore, user
> permissions will be set locally at hosts throughout the network, each
> user's permissions can change frequently, and documents will be
> distributed across many servers.
>
> To address these requirements, I plan to store user permissions and
> document descriptions as beans. When a user requests a document, the
> beans describing the user's permissions and the document's
> descriptions will be serialized and sent to security modules containing
> the Rete engines. I'll assert the facts describing user permissions and
> document requirements, run the appropriate engine (There may be more
> than one.), and return a decision whether or not the specific user may
> hold the specific document. Jess's ability to deal directly with
> beans is a Real Good Thing for this design.
>
> My problem is that I don't know a good way of making the Rete engine
> aware of the beans.
>
> I've seen examples of how to create beans in Jess and how to extract
> bean properties directly from Jess to Java, but I haven't seen any
> examples of how to insert a bean into a running engine. I'm sure it
> can be done with "store" and "fetch", but I'm wondering if there might
> be a more elegant solution.
>
> Please feel free to flame me with "RTFM" as long as you tell me where
> in TFM to R --- and agree to take questions afterwards. I have R'd
> TFM and I haven't found the answer. (But who knows, perhaps my son is
> right and I am senile already.)
>
> Thanks for reading my request.
>
> Peter Olsen
>
> --
> Peter Olsen, PE 703-516-7304
> Principal Member of Technical Staff FAX 703-528-5918
> The Charles Stark Draper Laboratory SWBD 703-243-2600
> 1555 Wilson Boulevard, Suite 501 [EMAIL PROTECTED]
> Arlington VA 22209
>
>
> ---------------------------------------------------------------------
> 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]
---------------------------------------------------------------------