overwrite hashCode to depend on prototype
make prototype switchable for prototypes with same storage
This commit is contained in:
parent
9d1b1d4d6f
commit
20af506b75
1 changed files with 29 additions and 0 deletions
|
@ -1418,6 +1418,23 @@ public final class Node implements INode, Serializable {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// check if the property we're setting specifies the prototype of this object.
|
||||||
|
if (dbmap != null && dbmap.getPrototypeField () != null) {
|
||||||
|
String pn = dbmap.columnNameToProperty (dbmap.getPrototypeField ());
|
||||||
|
if (propname.equals (pn)) {
|
||||||
|
DbMapping newmap = nmgr.getDbMapping (value);
|
||||||
|
if (newmap != null) {
|
||||||
|
// see if old and new prototypes have same storage - otherwise type change is ignored
|
||||||
|
String oldStorage = dbmap.getStorageTypeName ();
|
||||||
|
String newStorage = newmap.getStorageTypeName ();
|
||||||
|
if ((oldStorage == null && newStorage == null) ||
|
||||||
|
(oldStorage != null && oldStorage.equals (newStorage))) {
|
||||||
|
this.dbmap = newmap;
|
||||||
|
this.prototype = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Server.throwNodeEvent (new NodeEvent (this, NodeEvent.PROPERTIES_CHANGED));
|
// Server.throwNodeEvent (new NodeEvent (this, NodeEvent.PROPERTIES_CHANGED));
|
||||||
lastmodified = System.currentTimeMillis ();
|
lastmodified = System.currentTimeMillis ();
|
||||||
|
@ -1786,6 +1803,18 @@ public final class Node implements INode, Serializable {
|
||||||
return nmgr == null;
|
return nmgr == null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* We overwrite hashCode to make it dependant from the prototype. That way, when the prototype
|
||||||
|
* changes, the node will automatically get a new ESNode wrapper, since they're cached in a hashtable.
|
||||||
|
* You gotta love these hash code tricks ;-)
|
||||||
|
*/
|
||||||
|
public int hashCode () {
|
||||||
|
if (prototype == null)
|
||||||
|
return super.hashCode ();
|
||||||
|
else
|
||||||
|
return super.hashCode () + prototype.hashCode ();
|
||||||
|
}
|
||||||
|
|
||||||
public void dump () {
|
public void dump () {
|
||||||
System.err.println ("subnodes: "+subnodes);
|
System.err.println ("subnodes: "+subnodes);
|
||||||
System.err.println ("properties: "+propMap);
|
System.err.println ("properties: "+propMap);
|
||||||
|
|
Loading…
Add table
Reference in a new issue