public Collection getBeansOfType()

in components/camel-cxf/camel-cxf-blueprint/src/main/java/org/apache/camel/component/cxf/blueprint/bus/BlueprintBeanLocator.java [114:141]


    public <T> Collection<? extends T> getBeansOfType(Class<T> type) {
        List<T> list = new ArrayList<>();

        for (String s : container.getComponentIds()) {
            ComponentMetadata cmd = container.getComponentMetadata(s);
            Class<?> cls = getClassForMetaData(cmd);
            if (cls != null && type.isAssignableFrom(cls)) {
                list.add(type.cast(container.getComponentInstance(s)));
            }
        }
        if (list.isEmpty() && context != null) {
            try {
                ServiceReference<?>[] refs = context.getServiceReferences(type.getName(), null);
                if (refs != null) {
                    for (ServiceReference<?> r : refs) {
                        list.add(type.cast(context.getService(r)));
                    }
                }
            } 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);
            }
        }
        list.addAll(orig.getBeansOfType(type));

        return list;
    }