/** * @param bean * @param probe * @return the set of dependents */ static Set<Dependency> getDependents(Bean<?> bean, Probe probe) { Set<Dependency> dependents = new HashSet<Dependency>(); for (Bean<?> candidate : probe.getBeans()) { 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) { // At this point unsatisfied or ambiguous dependency should not exits Bean<?> candidateDependency = beanManager.resolve( beanManager.getBeans( injectionPoint.getType(), injectionPoint .getQualifiers() .toArray(new Annotation[injectionPoint.getQualifiers().size()]))); 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)); } } } } return dependents; }
/** * @param bean * @param beanManager * @param probe * @return the set of dependencies */ static Set<Dependency> getDependencies(Bean<?> bean, BeanManager beanManager, Probe probe) { Set<Dependency> dependencies = new HashSet<Dependency>(); Set<InjectionPoint> injectionPoints = bean.getInjectionPoints(); if (injectionPoints != null && !injectionPoints.isEmpty()) { for (InjectionPoint injectionPoint : injectionPoints) { // At this point unsatisfied or ambiguous dependency should not exits Bean<?> dependency = beanManager.resolve( beanManager.getBeans( injectionPoint.getType(), injectionPoint .getQualifiers() .toArray(new Annotation[injectionPoint.getQualifiers().size()]))); if (isBuiltinBeanButNotExtension(dependency)) { dependency = probe.getBean(Components.getBuiltinBeanId((AbstractBuiltInBean<?>) dependency)); } dependencies.add(new Dependency(dependency, injectionPoint)); } } return dependencies; }