in components/camel-cxf/camel-cxf-blueprint/src/main/java/org/apache/camel/component/cxf/blueprint/bus/BlueprintBeanLocator.java [144:190]
public <T> boolean loadBeansOfType(Class<T> type, BeanLoaderListener<T> listener) {
List<String> names = new ArrayList<>();
boolean loaded = false;
for (String s : container.getComponentIds()) {
ComponentMetadata cmd = container.getComponentMetadata(s);
Class<?> cls = getClassForMetaData(cmd);
if (cls != null && type.isAssignableFrom(cls)) {
names.add(s);
}
}
Collections.reverse(names);
for (String s : names) {
ComponentMetadata cmd = container.getComponentMetadata(s);
Class<?> beanType = getClassForMetaData(cmd);
Class<? extends T> t = beanType.asSubclass(type);
if (listener.loadBean(s, t)) {
Object o = container.getComponentInstance(s);
if (listener.beanLoaded(s, type.cast(o))) {
return true;
}
loaded = true;
}
}
try {
if (context != null) {
ServiceReference<?>[] refs = context.getServiceReferences(type.getName(), null);
if (refs != null) {
for (ServiceReference<?> r : refs) {
Object o2 = context.getService(r);
Class<? extends T> t = o2.getClass().asSubclass(type);
if (listener.loadBean(t.getName(), t)) {
if (listener.beanLoaded(t.getName(), type.cast(o2))) {
return true;
}
loaded = true;
}
}
}
}
} catch (Exception ex) {
//ignore, just don't support the OSGi services
LOG.info("Try to find the Bean with type:" + type
+ " from OSGi services and get error: " + ex);
}
return orig.loadBeansOfType(type, listener) || loaded;
}