use of org.jboss.weld.bean.builtin.AbstractBuiltInBean in project core by weld.
the class Components method getDependents.
/**
* @param bean
* @param beans
* @param probe
* @param firstMatch
* @return the set of dependents
*/
static Set<Dependency> getDependents(Bean<?> bean, Collection<Bean<?>> beans, Probe probe, boolean firstMatch) {
Set<Dependency> dependents = new HashSet<Dependency>();
for (Bean<?> candidate : beans) {
if (candidate.equals(bean)) {
continue;
}
BeanManager beanManager = probe.getBeanManager(candidate);
if (beanManager == null) {
// Don't process built-in beans
continue;
}
Set<InjectionPoint> injectionPoints = candidate.getInjectionPoints();
if (injectionPoints != null && !injectionPoints.isEmpty()) {
for (InjectionPoint injectionPoint : injectionPoints) {
if (injectionPoint.isDelegate()) {
// Do not include delegate injection points
continue;
}
Set<Bean<?>> foundBeans = beanManager.getBeans(injectionPoint.getType(), injectionPoint.getQualifiers().toArray(new Annotation[injectionPoint.getQualifiers().size()]));
if (foundBeans.isEmpty()) {
continue;
}
Bean<?> candidateDependency;
try {
candidateDependency = beanManager.resolve(foundBeans);
} catch (AmbiguousResolutionException e) {
continue;
}
if (candidateDependency.getBeanClass().equals(InstanceImpl.class)) {
Bean<?> lazilyFetched = getInstanceResolvedBean(beanManager, injectionPoint);
if (lazilyFetched != null && lazilyFetched.equals(bean)) {
dependents.add(Dependency.createPotential(candidate, injectionPoint, INFO_FETCHING_LAZILY));
if (firstMatch) {
break;
} else {
continue;
}
}
}
boolean satisfies = false;
if (isBuiltinBeanButNotExtension(candidateDependency)) {
satisfies = bean.equals(probe.getBean(Components.getBuiltinBeanId((AbstractBuiltInBean<?>) candidateDependency)));
} else {
satisfies = bean.equals(candidateDependency);
}
if (satisfies) {
dependents.add(new Dependency(candidate, injectionPoint));
if (firstMatch) {
break;
} else {
continue;
}
}
}
}
}
return dependents;
}
Aggregations