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 {
225225 * Note that collection types are not supported here, in contrast to reflective
226226 * injection points. For programmatically retrieving a list of beans matching a
227227 * 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.
229229 * @return a corresponding provider handle
230230 * @since 5.1
231- * @see ObjectProvider#stream()
232231 * @see ObjectProvider#iterator()
233- * @see ObjectProvider#toList()
232+ * @see ObjectProvider#stream()
233+ * @see ObjectProvider#orderedStream()
234234 */
235235 <T > ObjectProvider <T > getBeanProvider (ResolvableType requiredType );
236236
Original file line number Diff line number Diff line change @@ -382,13 +382,13 @@ public T getIfUnique() throws BeansException {
382382 }
383383 @ Override
384384 public Stream <T > stream () {
385- return Arrays .stream (getBeanNamesForType (requiredType ))
385+ return Arrays .stream (getBeanNamesForTypedStream (requiredType ))
386386 .map (name -> (T ) getBean (name ))
387387 .filter (bean -> !(bean instanceof NullBean ));
388388 }
389389 @ Override
390390 public Stream <T > orderedStream () {
391- String [] beanNames = getBeanNamesForType (requiredType );
391+ String [] beanNames = getBeanNamesForTypedStream (requiredType );
392392 Map <String , T > matchingBeans = new LinkedHashMap <>(beanNames .length );
393393 for (String beanName : beanNames ) {
394394 Object beanInstance = getBean (beanName );
@@ -424,6 +424,10 @@ else if (parent != null) {
424424 return null ;
425425 }
426426
427+ private String [] getBeanNamesForTypedStream (ResolvableType requiredType ) {
428+ return BeanFactoryUtils .beanNamesForTypeIncludingAncestors (this , requiredType );
429+ }
430+
427431
428432 //---------------------------------------------------------------------
429433 // Implementation of ListableBeanFactory interface
You can’t perform that action at this time.
0 commit comments