for (Class<?> clazz : HOSTOBJECT_CLASSES) {
try {
// register the host object
ScriptableObject.defineClass(rootScope, clazz);
final ScriptableObject host = (ScriptableObject) clazz.newInstance();
if (SlingWrapper.class.isAssignableFrom(clazz)) {
// SlingWrappers can map to several classes if needed
final SlingWrapper hostWrapper = (SlingWrapper) host;
for (Class<?> c : hostWrapper.getWrappedClasses()) {
SlingWrapFactory.INSTANCE.registerWrapper(c,
hostWrapper.getClassName());
}
} else {
// but other ScriptableObjects need to be registered as
// well
SlingWrapFactory.INSTANCE.registerWrapper(
host.getClass(), host.getClassName());
}
} catch (Throwable t) {
log.warn("getRootScope: Cannot prepare host object " + clazz, t);
}
}