return modelClass.cast(resolved);
} else if (unresolved instanceof ClassReference) {
// Load a class on demand
ClassReference classReference = (ClassReference)unresolved;
Class clazz = null;
for (Bundle bundle : bundles.values()) {
try {
clazz = bundle.loadClass(classReference.getClassName());
} catch (ClassNotFoundException e) {
continue;
}
break;
}
if (clazz == null) {
// Return the unresolved object
return unresolved;
}
// Store a new ClassReference wrapping the loaded class
resolved = new ClassReference(clazz);
map.put(resolved, resolved);
// Return the resolved ClassReference
return modelClass.cast(resolved);