Sorry - this ought to be in the documentation. Call getEngine() on the
Context object to get a reference to the Rete object the function was
called in. The Jess source code itself is a pretty good place to turn
for examples, since all of the Jess language functions are themselves
simply Userfunctions. There are lots of examples of getEngine() calls
-- here's one particularly simple one:
class Build implements Userfunction, Serializable
{
private String m_name;
Build(String name) { m_name = name; }
public String getName() { return m_name;}
public Value call(ValueVector vv, Context context) throws JessException
{
String argument = vv.get(1).stringValue(context);
return context.getEngine().executeCommand(argument);
}
}
What you're doing ought to work fine, btw. I'm doing something quite
similar.
I think Katherine Baker wrote:
>
> Hi,
> I am in the midst of implementing a CORBA server object within a JESS agent.
> I am doing this by calling a UserFunction called DeviceCORBAServerObject,
> whose "call" function initializes the CORBA server object. I don't know if
> it will work or not, but we'll see.
>
> While implementing the CORBA methods, I came across a situation where I'd
> like to be able to execute commands in the JESS engine from within a
> Userfunction method. I was thinking it might be possible to pass in a
> reference to the JESS engine in the "call" function, and then have the CORBA
> methods call the executeCommand function. Is this possible? If so, how would
> I go about doing passing in a Jess engine reference i.e. how would a Jess
> engine refer to itself - I have a feeling it has something to do with the
> Context variable passed in the call function but I haven't found much in the
> way of documentation or previous examples on this.
>
> If you could direct me towards some documentation, or provide any additional
> information, it would be much appreciated.
>
> Thanks,
> Katherine Baker
>
> P.S. The code for function looks something like this:
>
> public class DeviceCORBAServerObject extends extends _DeviceImplBase
> implements Userfunction
> {
>
> private JESSSystem m_jessSystem;
>
> /* constructor */
> public DeviceCORBAServerObject(String sObject, JESSSystem system)
> {
> super(sObject);
> m_jessSystem = system;
> }
>
> /* Userfunction methods */
> public String getName() { return "DeviceCORBAServer";}
>
> public Value call(ValueVector vv, Context context) throws ReteException
>
>
> try
> {
> org.omg.CORBA.ORB orb = org.omg.CORBA.ORB.init();
> org.omg.CORBA.BOA boa = orb.BOA_init();
>
> String sUser = vv.get(1).stringValue();
>
> DeviceConfigCORBAServer dccs = new
> eviceConfigCORBAServer( sUser, WHAT HERE? );
>
> boa.obj_is_ready( dccs );
> boa.impl_is_ready();
> }
> catch(org.omg.CORBA.SystemException e)
> {
> return new Value(RU.putAtom("FALSE"), RU.ATOM);;
> }
> return new Value(RU.putAtom("TRUE"), RU.ATOM);
> }
>
>
> /* CORBA Method */
> public void updateDevices()
> {
> m_jessSystem.executeCommand(" updateDevices () ");
> }
>
> }
>
>
>
>
>
>
> ---------------------------------------------------------------------
> 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]
---------------------------------------------------------------------