Call hasFunction() on the prototype rather than on HopObjects themselves to avoid fetching

references or child objects from database.
This commit is contained in:
hns 2003-09-15 14:41:08 +00:00
parent fad97efc60
commit 512cea20ac

View file

@ -337,7 +337,13 @@ public class RhinoEngine implements ScriptingEngine {
* is a java object) with that name. * is a java object) with that name.
*/ */
public boolean hasFunction(Object obj, String fname) { public boolean hasFunction(Object obj, String fname) {
// System.err.println ("HAS_FUNC: "+obj+"."+fname); // Treat HopObjects separately - otherwise we risk to fetch database
// references/child objects just to check for function properties.
if (obj instanceof INode) {
String protoname = ((INode) obj).getPrototype();
return core.hasFunction(protoname, fname.replace('.', '_'));
}
Scriptable op = obj == null ? global : Context.toObject(obj, global); Scriptable op = obj == null ? global : Context.toObject(obj, global);
Object func = ScriptableObject.getProperty(op, fname.replace('.', '_')); Object func = ScriptableObject.getProperty(op, fname.replace('.', '_'));