Don't do deep serialization of HopObjects. Instead, for

HopObject properties a proxy object is created for
serialization. It is a Hashtable with two entries: id and prototype,
containing the the id and prototype name of the referenced
HopObject as string values.
This commit is contained in:
hns 2001-12-07 16:18:38 +00:00
parent 7ee29bfdc3
commit d306e6fa18

View file

@ -5,6 +5,8 @@ package helma.xmlrpc.fesi;
import helma.xmlrpc.*;
import helma.scripting.fesi.ESNode;
import helma.objectmodel.INode;
import FESI.Exceptions.*;
import FESI.Data.*;
@ -14,7 +16,9 @@ import java.util.*;
public class FesiRpcUtil {
// convert a generic Java object to a JavaScript Object.
/**
* convert a generic Java object to a JavaScript Object.
*/
public static ESValue convertJ2E (Object what, Evaluator evaluator) throws Exception {
if (what == null)
return ESNull.theNull;
@ -47,7 +51,9 @@ public class FesiRpcUtil {
}
// convert a JavaScript Object object to a generic Java.
/**
* convert a JavaScript Object object to a generic Java.
*/
public static Object convertE2J (ESValue what) throws EcmaScriptException {
if (XmlRpc.debug)
System.out.println ("converting e-2-j: "+what.getClass ());
@ -69,7 +75,23 @@ public class FesiRpcUtil {
for (Enumeration e=o.getProperties (); e.hasMoreElements (); ) {
String next = (String) e.nextElement ();
if (XmlRpc.debug) System.out.println ("converting object member "+next);
Object nj = convertE2J (o.getProperty (next, next.hashCode ()));
// We don't do deep serialization of HopObjects to avoid
// that the whole web site structure is sucked out with one
// object. Instead we return some kind of "proxy" objects
// that only contain the prototype and id of the HopObject property.
Object nj = null;
ESValue esv = o.getProperty (next, next.hashCode ());
if (esv instanceof ESNode) {
INode node = ((ESNode) esv).getNode ();
if (node != null) {
Hashtable nt = new Hashtable ();
nt.put ("id", node.getID());
if (node.getPrototype() != null)
nt.put ("prototype", node.getPrototype ());
nj = nt;
}
} else
nj = convertE2J (esv);
if (nj != null) // can't put null as value in hashtable
t.put (next, nj);
}