Skip to content

Commit cd66467

Browse files
committed
Clarify FactoryBean initialization effect in getBeanNamesForAnnotation
Issue: SPR-17392 (cherry picked from commit da23505)
1 parent a3bdeb2 commit cd66467

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

spring-beans/src/main/java/org/springframework/beans/factory/ListableBeanFactory.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2016 the original author or authors.
2+
* Copyright 2002-2018 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -243,7 +243,9 @@ <T> Map<String, T> getBeansOfType(Class<T> type, boolean includeNonSingletons, b
243243

244244
/**
245245
* Find all names of beans whose {@code Class} has the supplied {@link Annotation}
246-
* type, without creating any bean instances yet.
246+
* type, without creating corresponding bean instances yet.
247+
* <p>Note that this method considers objects created by FactoryBeans, which means
248+
* that FactoryBeans will get initialized in order to determine their object type.
247249
* @param annotationType the type of annotation to look for
248250
* @return the names of all matching beans
249251
* @since 4.0
@@ -253,6 +255,8 @@ <T> Map<String, T> getBeansOfType(Class<T> type, boolean includeNonSingletons, b
253255
/**
254256
* Find all beans whose {@code Class} has the supplied {@link Annotation} type,
255257
* returning a Map of bean names with corresponding bean instances.
258+
* <p>Note that this method considers objects created by FactoryBeans, which means
259+
* that FactoryBeans will get initialized in order to determine their object type.
256260
* @param annotationType the type of annotation to look for
257261
* @return a Map with the matching beans, containing the bean names as
258262
* keys and the corresponding bean instances as values
@@ -267,7 +271,7 @@ <T> Map<String, T> getBeansOfType(Class<T> type, boolean includeNonSingletons, b
267271
* found on the given class itself.
268272
* @param beanName the name of the bean to look for annotations on
269273
* @param annotationType the annotation class to look for
270-
* @return the annotation of the given type if found, or {@code null}
274+
* @return the annotation of the given type if found, or {@code null} otherwise
271275
* @throws NoSuchBeanDefinitionException if there is no bean with the given name
272276
* @since 3.0
273277
*/

0 commit comments

Comments
 (0)