The IDs are just data, not really relevant to the problem, the "list of IDs"
is just a multislot of integers. In my JESS code, I basically have a rule
whose LHS matches a fact. I take that fact on the RHS and I modify the
contents of the multislot of IDs. I then (still in the RHS) send the newly
modified fact to the userfunction in my Java code. When I print out the
values in the userfunction, they are correct. The userfunction then creates
an object with the fact (and some other data), serializes the object and
sends it to the client process. The client deserializes the object, and
when it prints out the values in the multislot of IDs (using null as the
context), the values are incorrect.
Here are some snippets of my code:
JESS:
-----
?a1 <- (alert (name ?name1) (ID ?id1) (requires $?) (provides $? ?pro1 $?)
(globfacts $?) (rollups ?) (timestamp ?t1) (cluster-ids $?cids1) (depth ?d1)
(retirement ?rm1))
=>
(modify ?a2 (globfacts (insert$ $?gf2 1 ?a1)) (depth (+ ?d1 1)))
; create a new cluster
(modify ?a1 (cluster-ids (union$ $?cids1 (create$ ?*globcid*))))
(modify ?a2 (cluster-ids (union$ $?cids2 (create$ ?*globcid*))))
(new-cluster (create$ ?*globcid*) ?a1 ?a2)
Server Side Java:
-----------------
public class NewCluster implements Userfunction {
// params are: cluster-id, fact1, fact2
public String getName() { return ("new-cluster"); }
public Value call (ValueVector vv, Context context) throws
JessException {
ValueVector cid = vv.get(1).listValue(context);
Fact f1 = vv.get(2).factValue(context);
Fact f2 = vv.get(3).factValue(context);
RPData rpd = new RPData (RPData.NEW, cid, f1, f2);
try {
clientout.writeObject (rpd);
} catch (IOException ioe) {System.out.println ("got ioe: " +
ioe);}
return (new Value (true));
}
}
Client Side Java (after deserializing object):
----------------------------------------------
public void new_cluster (ValueVector cids, Fact f1, Fact f2, Vector
tempcids1, Vector tempcids2) throws JessException {
int cid = cids.get(0).intValue(null);
int depth = f1.getSlotValue ("depth").intValue(null) + 1;
String alertid = f2.getSlotValue ("name").stringValue(null);
String category = f2.getSlotValue ("category").stringValue(null);
double av = ((f1.getSlotValue ("av").numericValue(null) >
f2.getSlotValue
("av").numericValue(null)) ?
f1.getSlotValue ("av").numericValue(null) :
f2.getSlotValue
("av").numericValue(null));
boolean hashyp = ((f1.getSlotValue ("ID").intValue(null) < 0 ||
f2.getSlotValue ("ID").intValue(null) < 0) ? true : false);
ValueVector ips1 = f1.getSlotValue ("ips").listValue(null);
ValueVector subnets1 = f1.getSlotValue ("subnets").listValue(null);
ValueVector ips2 = f2.getSlotValue ("ips").listValue(null);
ValueVector subnets2 = f2.getSlotValue ("subnets").listValue(null);
ClusterState cs = new ClusterState (cid, depth, alertid, category, av,
hashyp);
Any ideas?
- Nik.
-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
Behalf Of [EMAIL PROTECTED]
Sent: Friday, December 12, 2003 6:00 AM
To: [EMAIL PROTECTED]
Subject: Re: JESS: problems with serialization
I think Nik Joshi wrote:
> Can anyone shed any light on this, or do I need to give more detail?
I don't know what IDs are in this context, and I don't know if a
"list" is the contents of a multislot or a Java List, so it's hard to
narrow it down. The only thing I can think of is to point out that
when a multislot is modified, it may or may not be that the
ValueVector object in the slot is a different one than before the
modification, so that if you fetch a ValueVector using
fact-slot-value, then modify the fact, the contents of that
ValueVector may, or may not, change.
If this doesn't help, then you probably need to show us some code.
---------------------------------------------------------
Ernest Friedman-Hill
Science and Engineering PSEs Phone: (925) 294-2154
Sandia National Labs FAX: (925) 294-2234
PO Box 969, MS 9012 [EMAIL PROTECTED]
Livermore, CA 94550 http://herzberg.ca.sandia.gov
--------------------------------------------------------------------
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]
--------------------------------------------------------------------
--------------------------------------------------------------------
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]
--------------------------------------------------------------------