Hi,
I was using bsave() and bload() with an engine that includes
Java-implemented user-functions. Since these are not serializable, I was
using removeUserfunction() to all Java-implemented functions before
bsave()ing. The user functions would be re-defined after bload()ing.
This approach got be to the bug reported at "Bug Hunt".
Now, in the meantime I tried just defining my functions as being
Serializable. Something like:
public class MyFunction implements Userfunction, Serializable { ... }
Just stating the class to be Serializable made it work, that is, bsave()
does not complain anymore and after bload()ing the functions work as
expected.
I then tried with a simpler example, which got me the
NotSerializableException again. In this case, my function was very simple:
public class MyUserfunction implements Userfunction, Serializable {
// The name method returns the name by which the function
appears in Jess
public String getName() {
return ("my-user-function");
}
// Called when (my-user-function ...) is encountered
public Value call(ValueVector vv, Context context) throws
JessException {
// JESS calls (my-user-function ?s)
// get the ?s (first argument) as a String
String s = vv.get(1).symbolValue(context);
System.out.println("*" + s + "*");
return Funcall.TRUE;
}
} // end MyUserfunction class
My question is: why does this approach work only sometimes? Is this
approach recommendable, or should I use my initial approach that removes
Java-implemented user-functions before bsave()ing and adds those
functions after bload()ing? Of course it will only work if the bug is
corrected.
Henrique
--------------------------------------------------------------------
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]
--------------------------------------------------------------------