in src/main/java/org/apache/sling/models/impl/AdapterImplementations.java [121:151]
boolean addAll(Class<?> implType, Class<?>... adapterTypes) {
ModelClass<?> modelClass = null;
try {
modelClass = new ModelClass(implType, sortedStaticInjectAnnotationProcessorFactories);
} catch (Exception e) {
log.warn("Unable to reflect on " + implType.getName(), e);
return false;
} catch (NoClassDefFoundError e) {
log.warn("Unable to reflect on " + implType.getName(), e);
return false;
}
for (Class<?> adapterType : adapterTypes) {
String key = adapterType.getName();
if (adapterType == implType) {
modelClasses.put(key, modelClass);
} else {
// although we already use a ConcurrentMap synchronize explicitly because we apply non-atomic operations on it
synchronized (adapterImplementations) {
ConcurrentNavigableMap<String, ModelClass<?>> implementations = adapterImplementations.get(key);
if (implementations == null) {
// to have a consistent ordering independent of bundle loading use a ConcurrentSkipListMap that sorts by class name
implementations = new ConcurrentSkipListMap<>();
adapterImplementations.put(key, implementations);
}
implementations.put(implType.getName(), modelClass);
}
}
}
return true;
}