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.
This commit is contained in:
hns 2001-11-26 17:58:00 +00:00
parent c4fb354f92
commit e32c31e1b1
2 changed files with 28 additions and 51 deletions

View file

@ -29,7 +29,7 @@ public class ESNode extends ObjectPrototype {
// store temporary stuff. // store temporary stuff.
INode cache; INode cache;
// the ecmascript wrapper for the 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. // The handle of the wrapped Node. Makes ESNodes comparable without accessing the wrapped node.
NodeHandle handle; 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. // persistent or persistent capable nodes have a cache property that's a transient node.
// it it hasn't requested before, initialize it now // it it hasn't requested before, initialize it now
if ("cache".equalsIgnoreCase (propertyName) && node instanceof Node) { if ("cache".equalsIgnoreCase (propertyName) && node instanceof Node) {
if (cacheWrapper == null) {
cache = node.getCacheNode (); cache = node.getCacheNode ();
if (cacheWrapper == null)
cacheWrapper = new ESNode (cache, eval); cacheWrapper = new ESNode (cache, eval);
} else
cacheWrapper.node = cache;
return cacheWrapper; return cacheWrapper;
} }
if ("subnodeRelation".equalsIgnoreCase (propertyName)) { if ("subnodeRelation".equalsIgnoreCase (propertyName)) {
@ -413,6 +414,12 @@ public class ESNode extends ObjectPrototype {
return ESNull.theNull; return ESNull.theNull;
} }
public boolean clearCache () {
checkNode ();
node.clearCacheNode ();
return true;
}
public Enumeration getAllProperties () { public Enumeration getAllProperties () {
return getProperties (); return getProperties ();
} }

View file

@ -54,8 +54,14 @@ public class ESUser extends ESNode {
else else
return new ESString (user.getSessionID ()); 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 cacheWrapper;
}
return super.getProperty (propname, hash); return super.getProperty (propname, hash);
} }
@ -99,53 +105,17 @@ public class ESUser extends ESNode {
} }
public boolean clearCache () {
if (user != null)
user.clearCache ();
else
super.clearCache ();
return true;
}
public String toString () { public String toString () {
return ("UserObject "+node.getName ()); return ("UserObject "+node.getName ());
} }
} }