Revert back to using TransientNode as HopObject cache node and as placeholder for invalidated/deleted nodes. Some cleanup and modifier tweaking in HopObject.
This commit is contained in:
		
							parent
							
								
									62db24a43c
								
							
						
					
					
						commit
						16ead75851
					
				
					 2 changed files with 17 additions and 56 deletions
				
			
		|  | @ -22,6 +22,7 @@ import helma.framework.core.Application; | ||||||
| import helma.objectmodel.ConcurrencyException; | import helma.objectmodel.ConcurrencyException; | ||||||
| import helma.objectmodel.INode; | import helma.objectmodel.INode; | ||||||
| import helma.objectmodel.IProperty; | import helma.objectmodel.IProperty; | ||||||
|  | import helma.objectmodel.TransientNode; | ||||||
| import helma.util.EmptyEnumeration; | import helma.util.EmptyEnumeration; | ||||||
| 
 | 
 | ||||||
| import java.util.*; | import java.util.*; | ||||||
|  | @ -2476,7 +2477,7 @@ public final class Node implements INode { | ||||||
|      */ |      */ | ||||||
|     public synchronized INode getCacheNode() { |     public synchronized INode getCacheNode() { | ||||||
|         if (cacheNode == null) { |         if (cacheNode == null) { | ||||||
|             cacheNode = new Node("cache", null, nmgr); |             cacheNode = new TransientNode(); | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         return cacheNode; |         return cacheNode; | ||||||
|  |  | ||||||
|  | @ -35,7 +35,7 @@ public class HopObject extends ScriptableObject implements Wrapper, PropertyReco | ||||||
| 
 | 
 | ||||||
|     String className; |     String className; | ||||||
|     final NodeProxy proxy; |     final NodeProxy proxy; | ||||||
|     RhinoCore core; |     final RhinoCore core; | ||||||
| 
 | 
 | ||||||
|     // fields to implement PropertyRecorder |     // fields to implement PropertyRecorder | ||||||
|     private boolean isRecording = false; |     private boolean isRecording = false; | ||||||
|  | @ -124,9 +124,9 @@ public class HopObject extends ScriptableObject implements Wrapper, PropertyReco | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     /** |     /** | ||||||
|  |      * Get the class/prototype name for this HopObject | ||||||
|      * |      * | ||||||
|      * |      * @return The object's class or prototype name | ||||||
|      * @return ... |  | ||||||
|      */ |      */ | ||||||
|     public String getClassName() { |     public String getClassName() { | ||||||
|         return className; |         return className; | ||||||
|  | @ -136,8 +136,8 @@ public class HopObject extends ScriptableObject implements Wrapper, PropertyReco | ||||||
|      * Overwritten to not define constructor property as constant - |      * Overwritten to not define constructor property as constant - | ||||||
|      * we need to have the constructor property resettable in Helma. |      * we need to have the constructor property resettable in Helma. | ||||||
|      * @param propertyName the property name |      * @param propertyName the property name | ||||||
|      * @param value the proeprty value |      * @param value the property value | ||||||
|      * @param attributes the property attributs |      * @param attributes the property attributes | ||||||
|      */ |      */ | ||||||
|     public void defineProperty(String propertyName, Object value, |     public void defineProperty(String propertyName, Object value, | ||||||
|                                int attributes) |                                int attributes) | ||||||
|  | @ -1046,8 +1046,9 @@ public class HopObject extends ScriptableObject implements Wrapper, PropertyReco | ||||||
|         if (value == this) { |         if (value == this) { | ||||||
|             return Boolean.TRUE; |             return Boolean.TRUE; | ||||||
|         } |         } | ||||||
|         if (value instanceof HopObject && proxy != null) { |         if (value instanceof HopObject && proxy != null | ||||||
|             return proxy.equivalentValues(((HopObject) value).proxy); |                 && proxy.equivalentValues(((HopObject) value).proxy)) { | ||||||
|  |             return Boolean.TRUE; | ||||||
|         } |         } | ||||||
|         return Scriptable.NOT_FOUND; |         return Scriptable.NOT_FOUND; | ||||||
|     } |     } | ||||||
|  | @ -1096,48 +1097,9 @@ public class HopObject extends ScriptableObject implements Wrapper, PropertyReco | ||||||
|         changedProperties = null; |         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 { |     class NodeProxy { | ||||||
|         INode node; |         private INode node; | ||||||
|         NodeHandle handle; |         private NodeHandle handle; | ||||||
| 
 | 
 | ||||||
|         NodeProxy(INode node) { |         NodeProxy(INode node) { | ||||||
|             this.node = node; |             this.node = node; | ||||||
|  | @ -1150,7 +1112,7 @@ public class HopObject extends ScriptableObject implements Wrapper, PropertyReco | ||||||
|             this.handle = handle; |             this.handle = handle; | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         INode getNode() { |         synchronized INode getNode() { | ||||||
|             if (node == null || node.getState() == Node.INVALID) { |             if (node == null || node.getState() == Node.INVALID) { | ||||||
|                 if (handle != null) { |                 if (handle != null) { | ||||||
|                     node = handle.getNode(core.app.getWrappedNodeManager()); |                     node = handle.getNode(core.app.getWrappedNodeManager()); | ||||||
|  | @ -1171,19 +1133,17 @@ public class HopObject extends ScriptableObject implements Wrapper, PropertyReco | ||||||
|                 if (node == null || node.getState() == Node.INVALID) { |                 if (node == null || node.getState() == Node.INVALID) { | ||||||
|                     // We probably have a deleted node. |                     // We probably have a deleted node. | ||||||
|                     // Replace with empty transient node to avoid throwing an exception. |                     // Replace with empty transient node to avoid throwing an exception. | ||||||
|                     node = new Node("DeletedNode", null, core.app.getWrappedNodeManager()); |                     node = new TransientNode(); | ||||||
|                 } |                 } | ||||||
|             } |             } | ||||||
|             return node; |             return node; | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         public Boolean equivalentValues(NodeProxy other) { |         public boolean equivalentValues(NodeProxy other) { | ||||||
|             if (handle == null) { |             if (handle == null) { | ||||||
|                 return other.node == this.node ? |                 return other.node == this.node; | ||||||
|                         Boolean.TRUE : Boolean.FALSE; |  | ||||||
|             } else { |             } else { | ||||||
|                 return handle.equals(other.handle) ? |                 return handle == other.handle || handle.equals(other.handle); | ||||||
|                         Boolean.TRUE : Boolean.FALSE; |  | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue