Fix object precedence in parent prototype registration: If an object
is already registered with a parent prototype's name, leave it as it is and don't overwrite it since it has higher precedence than we have.
This commit is contained in:
parent
144dee55cd
commit
026d6e1429
1 changed files with 9 additions and 2 deletions
|
@ -176,14 +176,21 @@ public final class Prototype {
|
|||
}
|
||||
|
||||
/**
|
||||
* Register an object as handler for all our parent prototypes.
|
||||
* Register an object as handler for all our parent prototypes, but only if
|
||||
* a handler by that prototype name isn't registered yet. This is used to
|
||||
* implement direct over indirect prototype precedence and child over parent
|
||||
* precedence.
|
||||
*/
|
||||
public final void registerParents(Map handlers, Object obj) {
|
||||
|
||||
Prototype p = parent;
|
||||
|
||||
while ((p != null) && !"hopobject".equalsIgnoreCase(p.getName())) {
|
||||
handlers.put(p.name, obj);
|
||||
Object old = handlers.put(p.name, obj);
|
||||
// if an object was already registered by this name, put it back in again.
|
||||
if (old != null) {
|
||||
handlers.put(p.name, old);
|
||||
}
|
||||
|
||||
p = p.parent;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue