* Consider superclasses and interfaces when resolving class to prototype mapping.
This commit is contained in:
parent
cf1d403ab3
commit
ab378b0806
1 changed files with 27 additions and 2 deletions
|
@ -1281,8 +1281,33 @@ public final class Application implements IPathElement, Runnable {
|
||||||
// e implements the getPrototype() method
|
// e implements the getPrototype() method
|
||||||
return ((IPathElement) obj).getPrototype();
|
return ((IPathElement) obj).getPrototype();
|
||||||
} else {
|
} else {
|
||||||
// use java class name as prototype name
|
// look up prototype name by java class name
|
||||||
return classMapping.getProperty(obj.getClass().getName());
|
Class clazz = obj.getClass();
|
||||||
|
String protoname = classMapping.getProperty(clazz.getName());
|
||||||
|
if (protoname != null) {
|
||||||
|
return protoname;
|
||||||
|
}
|
||||||
|
// walk down superclass path
|
||||||
|
while ((clazz = clazz.getSuperclass()) != null) {
|
||||||
|
protoname = classMapping.getProperty(clazz.getName());
|
||||||
|
if (protoname != null) {
|
||||||
|
// cache the class name for the object so we run faster next time
|
||||||
|
classMapping.setProperty(obj.getClass().getName(), protoname);
|
||||||
|
return protoname;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// check interfaces, too
|
||||||
|
Class[] classes = obj.getClass().getInterfaces();
|
||||||
|
for (int i = 0; i < classes.length && protoname == null; i++) {
|
||||||
|
protoname = classMapping.getProperty(classes[i].getName());
|
||||||
|
if (protoname != null) {
|
||||||
|
// cache the class name for the object so we run faster next time
|
||||||
|
classMapping.setProperty(obj.getClass().getName(), protoname);
|
||||||
|
return protoname;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// nada
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue