File tree Expand file tree Collapse file tree 2 files changed +9
-5
lines changed
spring-beans/src/main/java/org/springframework/beans/factory Expand file tree Collapse file tree 2 files changed +9
-5
lines changed Original file line number Diff line number Diff line change @@ -225,12 +225,12 @@ public interface BeanFactory {
225
225
* Note that collection types are not supported here, in contrast to reflective
226
226
* injection points. For programmatically retrieving a list of beans matching a
227
227
* specific type, specify the actual bean type as an argument here and subsequently
228
- * use {@link ObjectProvider#toList ()} or its lazy streaming/iteration options.
228
+ * use {@link ObjectProvider#orderedStream ()} or its lazy streaming/iteration options.
229
229
* @return a corresponding provider handle
230
230
* @since 5.1
231
- * @see ObjectProvider#stream()
232
231
* @see ObjectProvider#iterator()
233
- * @see ObjectProvider#toList()
232
+ * @see ObjectProvider#stream()
233
+ * @see ObjectProvider#orderedStream()
234
234
*/
235
235
<T > ObjectProvider <T > getBeanProvider (ResolvableType requiredType );
236
236
Original file line number Diff line number Diff line change @@ -382,13 +382,13 @@ public T getIfUnique() throws BeansException {
382
382
}
383
383
@ Override
384
384
public Stream <T > stream () {
385
- return Arrays .stream (getBeanNamesForType (requiredType ))
385
+ return Arrays .stream (getBeanNamesForTypedStream (requiredType ))
386
386
.map (name -> (T ) getBean (name ))
387
387
.filter (bean -> !(bean instanceof NullBean ));
388
388
}
389
389
@ Override
390
390
public Stream <T > orderedStream () {
391
- String [] beanNames = getBeanNamesForType (requiredType );
391
+ String [] beanNames = getBeanNamesForTypedStream (requiredType );
392
392
Map <String , T > matchingBeans = new LinkedHashMap <>(beanNames .length );
393
393
for (String beanName : beanNames ) {
394
394
Object beanInstance = getBean (beanName );
@@ -424,6 +424,10 @@ else if (parent != null) {
424
424
return null ;
425
425
}
426
426
427
+ private String [] getBeanNamesForTypedStream (ResolvableType requiredType ) {
428
+ return BeanFactoryUtils .beanNamesForTypeIncludingAncestors (this , requiredType );
429
+ }
430
+
427
431
428
432
//---------------------------------------------------------------------
429
433
// Implementation of ListableBeanFactory interface
You can’t perform that action at this time.
0 commit comments