while (classUrls.hasMoreElements()) {
URL url = classUrls.nextElement();
String className = toClassName(url);
try {
Class<?> implType = bundle.loadClass(className);
Model annotation = implType.getAnnotation(Model.class);
if (annotation != null) {
// get list of adapters from annotation - if not given use annotated class itself
Class<?>[] adapterTypes = annotation.adapters();
if (adapterTypes.length == 0) {
adapterTypes = new Class<?>[] { implType };
}
// register adapter only if given adapters are valid
if (validateAdapterClasses(implType, adapterTypes)) {
for (Class<?> adapterType : adapterTypes) {
if (adapterType != implType) {
adapterImplementations.add(adapterType, implType);
}
}
ServiceRegistration reg = registerAdapterFactory(adapterTypes, annotation.adaptables(), implType, annotation.condition());
regs.add(reg);
}
}
} catch (ClassNotFoundException e) {
log.warn("Unable to load class", e);