From e32c31e1b1de1adc545b1e3e9816508e68cc1d75 Mon Sep 17 00:00:00 2001 From: hns Date: Mon, 26 Nov 2001 17:58:00 +0000 Subject: [PATCH] Cache nodes are checked each time they are retrieved because the clearCache() function may have been called on the object since last accessing the cache node. implemented clearCache() method to reset the cache in the wrapped object. --- src/helma/scripting/fesi/ESNode.java | 17 +++++--- src/helma/scripting/fesi/ESUser.java | 62 +++++++--------------------- 2 files changed, 28 insertions(+), 51 deletions(-) diff --git a/src/helma/scripting/fesi/ESNode.java b/src/helma/scripting/fesi/ESNode.java index b08e0ab5..790fad6e 100644 --- a/src/helma/scripting/fesi/ESNode.java +++ b/src/helma/scripting/fesi/ESNode.java @@ -29,7 +29,7 @@ public class ESNode extends ObjectPrototype { // store temporary stuff. INode cache; // the ecmascript wrapper for the cache. - ESObject cacheWrapper; + ESNode cacheWrapper; // The handle of the wrapped Node. Makes ESNodes comparable without accessing the wrapped node. NodeHandle handle; @@ -310,10 +310,11 @@ public class ESNode extends ObjectPrototype { // persistent or persistent capable nodes have a cache property that's a transient node. // it it hasn't requested before, initialize it now if ("cache".equalsIgnoreCase (propertyName) && node instanceof Node) { - if (cacheWrapper == null) { - cache = node.getCacheNode (); + cache = node.getCacheNode (); + if (cacheWrapper == null) cacheWrapper = new ESNode (cache, eval); - } + else + cacheWrapper.node = cache; return cacheWrapper; } if ("subnodeRelation".equalsIgnoreCase (propertyName)) { @@ -413,12 +414,18 @@ public class ESNode extends ObjectPrototype { return ESNull.theNull; } + public boolean clearCache () { + checkNode (); + node.clearCacheNode (); + return true; + } + public Enumeration getAllProperties () { return getProperties (); } public Enumeration getProperties () { - checkNode (); + checkNode (); return node.properties (); } diff --git a/src/helma/scripting/fesi/ESUser.java b/src/helma/scripting/fesi/ESUser.java index 32798caa..0c97e1eb 100644 --- a/src/helma/scripting/fesi/ESUser.java +++ b/src/helma/scripting/fesi/ESUser.java @@ -54,8 +54,14 @@ public class ESUser extends ESNode { else return new ESString (user.getSessionID ()); } - if ("cache".equals (propname) && user != null) + // if this represents an active user object, we override + // the cache property to come from the user session object + // instead of the Node object. + if ("cache".equals (propname) && user != null) { + cache = user.getCache (); + cacheWrapper.node = cache; return cacheWrapper; + } return super.getProperty (propname, hash); } @@ -97,7 +103,15 @@ public class ESUser extends ESNode { else handle = null; - } + } + + public boolean clearCache () { + if (user != null) + user.clearCache (); + else + super.clearCache (); + return true; + } public String toString () { return ("UserObject "+node.getName ()); @@ -105,47 +119,3 @@ public class ESUser extends ESNode { } - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -