|
|
|
@ -162,9 +162,8 @@ public abstract class BeanFactoryUtils { |
|
|
|
Assert.notNull(lbf, "ListableBeanFactory must not be null"); |
|
|
|
Assert.notNull(lbf, "ListableBeanFactory must not be null"); |
|
|
|
String[] result = lbf.getBeanNamesForType(type); |
|
|
|
String[] result = lbf.getBeanNamesForType(type); |
|
|
|
if (lbf instanceof HierarchicalBeanFactory hbf) { |
|
|
|
if (lbf instanceof HierarchicalBeanFactory hbf) { |
|
|
|
if (hbf.getParentBeanFactory() instanceof ListableBeanFactory) { |
|
|
|
if (hbf.getParentBeanFactory() instanceof ListableBeanFactory pbf) { |
|
|
|
String[] parentResult = beanNamesForTypeIncludingAncestors( |
|
|
|
String[] parentResult = beanNamesForTypeIncludingAncestors(pbf, type); |
|
|
|
(ListableBeanFactory) hbf.getParentBeanFactory(), type); |
|
|
|
|
|
|
|
result = mergeNamesWithParent(result, parentResult, hbf); |
|
|
|
result = mergeNamesWithParent(result, parentResult, hbf); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
@ -225,9 +224,8 @@ public abstract class BeanFactoryUtils { |
|
|
|
Assert.notNull(lbf, "ListableBeanFactory must not be null"); |
|
|
|
Assert.notNull(lbf, "ListableBeanFactory must not be null"); |
|
|
|
String[] result = lbf.getBeanNamesForType(type); |
|
|
|
String[] result = lbf.getBeanNamesForType(type); |
|
|
|
if (lbf instanceof HierarchicalBeanFactory hbf) { |
|
|
|
if (lbf instanceof HierarchicalBeanFactory hbf) { |
|
|
|
if (hbf.getParentBeanFactory() instanceof ListableBeanFactory) { |
|
|
|
if (hbf.getParentBeanFactory() instanceof ListableBeanFactory pbf) { |
|
|
|
String[] parentResult = beanNamesForTypeIncludingAncestors( |
|
|
|
String[] parentResult = beanNamesForTypeIncludingAncestors(pbf, type); |
|
|
|
(ListableBeanFactory) hbf.getParentBeanFactory(), type); |
|
|
|
|
|
|
|
result = mergeNamesWithParent(result, parentResult, hbf); |
|
|
|
result = mergeNamesWithParent(result, parentResult, hbf); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
@ -371,9 +369,8 @@ public abstract class BeanFactoryUtils { |
|
|
|
Map<String, T> result = new LinkedHashMap<>(4); |
|
|
|
Map<String, T> result = new LinkedHashMap<>(4); |
|
|
|
result.putAll(lbf.getBeansOfType(type, includeNonSingletons, allowEagerInit)); |
|
|
|
result.putAll(lbf.getBeansOfType(type, includeNonSingletons, allowEagerInit)); |
|
|
|
if (lbf instanceof HierarchicalBeanFactory hbf) { |
|
|
|
if (lbf instanceof HierarchicalBeanFactory hbf) { |
|
|
|
if (hbf.getParentBeanFactory() instanceof ListableBeanFactory) { |
|
|
|
if (hbf.getParentBeanFactory() instanceof ListableBeanFactory pbf) { |
|
|
|
Map<String, T> parentResult = beansOfTypeIncludingAncestors( |
|
|
|
Map<String, T> parentResult = beansOfTypeIncludingAncestors(pbf, type, includeNonSingletons, allowEagerInit); |
|
|
|
(ListableBeanFactory) hbf.getParentBeanFactory(), type, includeNonSingletons, allowEagerInit); |
|
|
|
|
|
|
|
parentResult.forEach((beanName, beanInstance) -> { |
|
|
|
parentResult.forEach((beanName, beanInstance) -> { |
|
|
|
if (!result.containsKey(beanName) && !hbf.containsLocalBean(beanName)) { |
|
|
|
if (!result.containsKey(beanName) && !hbf.containsLocalBean(beanName)) { |
|
|
|
result.put(beanName, beanInstance); |
|
|
|
result.put(beanName, beanInstance); |
|
|
|
|