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:
parent
c4fb354f92
commit
e32c31e1b1
2 changed files with 28 additions and 51 deletions
|
@ -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 ();
|
||||
}
|
||||
|
||||
|
|
|
@ -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 {
|
|||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue