r9994 - in helma/helma/trunk/src/helma: objectmodel/db scripting/rhino
[email protected] Wed, 25 Nov 2009 10:33:28 +0100 (CET)
| Newsgroups | gmane.comp.java.helma.cvs |
|---|---|
| Message-ID | <20091125093328.4E7C53D0E2@mia> |
Author: hannes
Date: 2009-11-25 10:33:28 +0100 (Wed, 25 Nov 2009)
New Revision: 9994
Modified:
helma/helma/trunk/src/helma/objectmodel/db/Node.java
helma/helma/trunk/src/helma/scripting/rhino/HopObject.java
Log:
Revert back to using TransientNode as HopObject cache node and as placeholder for invalidated/deleted nodes. Some cleanup and modifier tweaking in HopObject.
Details at http://dev.helma.org/trac/helma/changeset/9994
Modified: helma/helma/trunk/src/helma/objectmodel/db/Node.java
===================================================================
--- helma/helma/trunk/src/helma/objectmodel/db/Node.java 2009-11-24 15:06:07 UTC (rev 9993)
+++ helma/helma/trunk/src/helma/objectmodel/db/Node.java 2009-11-25 09:33:28 UTC (rev 9994)
@@ -22,6 +22,7 @@
import helma.objectmodel.ConcurrencyException;
import helma.objectmodel.INode;
import helma.objectmodel.IProperty;
+import helma.objectmodel.TransientNode;
import helma.util.EmptyEnumeration;
import java.util.*;
@@ -2476,7 +2477,7 @@
*/
public synchronized INode getCacheNode() {
if (cacheNode == null) {
- cacheNode = new Node("cache", null, nmgr);
+ cacheNode = new TransientNode();
}
return cacheNode;
Modified: helma/helma/trunk/src/helma/scripting/rhino/HopObject.java
===================================================================
--- helma/helma/trunk/src/helma/scripting/rhino/HopObject.java 2009-11-24 15:06:07 UTC (rev 9993)
+++ helma/helma/trunk/src/helma/scripting/rhino/HopObject.java 2009-11-25 09:33:28 UTC (rev 9994)
@@ -35,7 +35,7 @@
String className;
final NodeProxy proxy;
- RhinoCore core;
+ final RhinoCore core;
// fields to implement PropertyRecorder
private boolean isRecording = false;
@@ -124,9 +124,9 @@
}
/**
+ * Get the class/prototype name for this HopObject
*
- *
- * @return ...
+ * @return The object's class or prototype name
*/
public String getClassName() {
return className;
@@ -136,8 +136,8 @@
* Overwritten to not define constructor property as constant -
* we need to have the constructor property resettable in Helma.
* @param propertyName the property name
- * @param value the proeprty value
- * @param attributes the property attributs
+ * @param value the property value
+ * @param attributes the property attributes
*/
public void defineProperty(String propertyName, Object value,
int attributes)
@@ -1046,8 +1046,9 @@
if (value == this) {
return Boolean.TRUE;
}
- if (value instanceof HopObject && proxy != null) {
- return proxy.equivalentValues(((HopObject) value).proxy);
+ if (value instanceof HopObject && proxy != null
+ && proxy.equivalentValues(((HopObject) value).proxy)) {
+ return Boolean.TRUE;
}
return Scriptable.NOT_FOUND;
}
@@ -1096,48 +1097,9 @@
changedProperties = null;
}
- /**
- * This method represents the Java-Script-exposed function for updating Subnode-Collections.
- * The following conditions must be met to make a subnodecollection updateable.
- * .) the collection must be specified with collection.updateable=true
- * .) the id's of this collection must be in ascending order, meaning, that new records
- * do have a higher id than the last record loaded by this collection
- */
- /* public int jsFunction_update() {
- if (!(node instanceof Node))
- throw new RuntimeException ("update only callabel on persistent HopObjects");
- checkNode();
- Node n = (Node) node;
- return n.updateSubnodes();
- } */
-
- /**
- * Retrieve a view having a different order from this Node's subnodelist.
- * The underlying OrderedSubnodeList will keep those views and updates them
- * if the original collection has been updated.
- * @param expr the order (like sql-order using the properties instead)
- * @return ListViewWrapper holding the information of the ordered view
- */
- /* public Object jsFunction_getOrderedView(String expr) {
- if (!(node instanceof Node)) {
- throw new RuntimeException (
- "getOrderedView only callable on persistent HopObjects");
- }
- Node n = (Node) node;
- n.loadNodes();
- SubnodeList subnodes = n.getSubnodeList();
- if (subnodes == null) {
- throw new RuntimeException (
- "getOrderedView only callable on already existing subnode-collections");
- }
- Node subnode = new Node("OrderedView", "HopObject", core.app.getWrappedNodeManager());
- subnode.setSubnodes(subnodes.getOrderedView(expr));
- return new HopObject("HopObject", core, subnode, core.getPrototype("HopObject"));
- } */
-
class NodeProxy {
- INode node;
- NodeHandle handle;
+ private INode node;
+ private NodeHandle handle;
NodeProxy(INode node) {
this.node = node;
@@ -1150,7 +1112,7 @@
this.handle = handle;
}
- INode getNode() {
+ synchronized INode getNode() {
if (node == null || node.getState() == Node.INVALID) {
if (handle != null) {
node = handle.getNode(core.app.getWrappedNodeManager());
@@ -1171,19 +1133,17 @@
if (node == null || node.getState() == Node.INVALID) {
// We probably have a deleted node.
// Replace with empty transient node to avoid throwing an exception.
- node = new Node("DeletedNode", null, core.app.getWrappedNodeManager());
+ node = new TransientNode();
}
}
return node;
}
- public Boolean equivalentValues(NodeProxy other) {
+ public boolean equivalentValues(NodeProxy other) {
if (handle == null) {
- return other.node == this.node ?
- Boolean.TRUE : Boolean.FALSE;
+ return other.node == this.node;
} else {
- return handle.equals(other.handle) ?
- Boolean.TRUE : Boolean.FALSE;
+ return handle == other.handle || handle.equals(other.handle);
}
}
}