* Simplify static HopObject constructor getter code.

* Set node reference to an empty transient node in checkNode()
   for deleted/invalid HopObjects.
This commit is contained in:
hns 2005-11-17 14:22:11 +00:00
parent ed6712719c
commit 527a1bc846

View file

@ -37,14 +37,11 @@ public class HopObject extends ScriptableObject implements Wrapper, PropertyReco
static Method hopObjCtor; static Method hopObjCtor;
static { static {
Method[] methods = HopObject.class.getMethods(); try {
hopObjCtor = HopObject.class.getMethod("jsConstructor", new Class[] {
for (int i = 0; i < methods.length; i++) { Context.class, Object[].class, Function.class, Boolean.TYPE });
if ("jsConstructor".equals(methods[i].getName())) { } catch (NoSuchMethodException e) {
hopObjCtor = methods[i]; throw new RuntimeException("Error getting HopObject.jsConstructor()");
break;
}
} }
} }
@ -221,6 +218,12 @@ public class HopObject extends ScriptableObject implements Wrapper, PropertyReco
if (node instanceof helma.objectmodel.db.Node) { if (node instanceof helma.objectmodel.db.Node) {
NodeHandle handle = ((helma.objectmodel.db.Node) node).getHandle(); NodeHandle handle = ((helma.objectmodel.db.Node) node).getHandle();
node = handle.getNode(core.app.getWrappedNodeManager()); node = handle.getNode(core.app.getWrappedNodeManager());
if (node == null) {
// we probably have a deleted node. Replace with empty transient node
// to avoid throwing an exception.
node = new helma.objectmodel.TransientNode();
// throw new RuntimeException("Tried to access invalid/removed node " + handle + ".");
}
} }
} }
} }