Skip to content

Commit a4a71a8

Browse files
committed
Polishing
1 parent e23ac03 commit a4a71a8

File tree

2 files changed

+13
-10
lines changed

2 files changed

+13
-10
lines changed

spring-beans/src/main/java/org/springframework/beans/factory/config/AutowireCapableBeanFactory.java

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -318,8 +318,8 @@ Object applyBeanPostProcessorsAfterInitialization(Object existingBean, String be
318318
* @param requiredType type the bean must match; can be an interface or superclass.
319319
* {@code null} is disallowed.
320320
* @return the bean name plus bean instance
321-
* @throws NoSuchBeanDefinitionException if no bean of the given type was found
322-
* @throws NoUniqueBeanDefinitionException if more than one bean of the given type was found
321+
* @throws NoSuchBeanDefinitionException if no matching bean was found
322+
* @throws NoUniqueBeanDefinitionException if more than one matching bean was found
323323
* @throws BeansException if the bean could not be created
324324
* @since 4.3.3
325325
* @see #getBean(Class)
@@ -328,30 +328,30 @@ Object applyBeanPostProcessorsAfterInitialization(Object existingBean, String be
328328

329329
/**
330330
* Resolve the specified dependency against the beans defined in this factory.
331-
* @param descriptor the descriptor for the dependency
332-
* @param requestingBeanName the name of the bean which declares the present dependency
331+
* @param descriptor the descriptor for the dependency (field/method/constructor)
332+
* @param requestingBeanName the name of the bean which declares the given dependency
333333
* @return the resolved object, or {@code null} if none found
334334
* @throws NoSuchBeanDefinitionException if no matching bean was found
335335
* @throws NoUniqueBeanDefinitionException if more than one matching bean was found
336336
* @throws BeansException if dependency resolution failed for any other reason
337-
* @see #resolveDependency(DependencyDescriptor, String, Set, TypeConverter)
338337
* @since 2.5
338+
* @see #resolveDependency(DependencyDescriptor, String, Set, TypeConverter)
339339
*/
340340
Object resolveDependency(DependencyDescriptor descriptor, String requestingBeanName) throws BeansException;
341341

342342
/**
343343
* Resolve the specified dependency against the beans defined in this factory.
344-
* @param descriptor the descriptor for the dependency
345-
* @param requestingBeanName the name of the bean which declares the present dependency
346-
* @param autowiredBeanNames a Set that all names of autowired beans (used for resolving
347-
* the present dependency) are supposed to be added to
344+
* @param descriptor the descriptor for the dependency (field/method/constructor)
345+
* @param requestingBeanName the name of the bean which declares the given dependency
346+
* @param autowiredBeanNames a Set that all names of autowired beans (used for
347+
* resolving the given dependency) are supposed to be added to
348348
* @param typeConverter the TypeConverter to use for populating arrays and collections
349349
* @return the resolved object, or {@code null} if none found
350350
* @throws NoSuchBeanDefinitionException if no matching bean was found
351351
* @throws NoUniqueBeanDefinitionException if more than one matching bean was found
352352
* @throws BeansException if dependency resolution failed for any other reason
353-
* @see DependencyDescriptor
354353
* @since 2.5
354+
* @see DependencyDescriptor
355355
*/
356356
Object resolveDependency(DependencyDescriptor descriptor, String requestingBeanName,
357357
Set<String> autowiredBeanNames, TypeConverter typeConverter) throws BeansException;

spring-beans/src/main/java/org/springframework/beans/factory/support/DefaultListableBeanFactory.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -989,6 +989,7 @@ public <T> NamedBeanHolder<T> resolveNamedBean(Class<T> requiredType) throws Bea
989989
private <T> NamedBeanHolder<T> resolveNamedBean(Class<T> requiredType, Object... args) throws BeansException {
990990
Assert.notNull(requiredType, "Required type must not be null");
991991
String[] beanNames = getBeanNamesForType(requiredType);
992+
992993
if (beanNames.length > 1) {
993994
ArrayList<String> autowireCandidates = new ArrayList<String>();
994995
for (String beanName : beanNames) {
@@ -1000,6 +1001,7 @@ private <T> NamedBeanHolder<T> resolveNamedBean(Class<T> requiredType, Object...
10001001
beanNames = autowireCandidates.toArray(new String[autowireCandidates.size()]);
10011002
}
10021003
}
1004+
10031005
if (beanNames.length == 1) {
10041006
String beanName = beanNames[0];
10051007
return new NamedBeanHolder<T>(beanName, getBean(beanName, requiredType, args));
@@ -1019,6 +1021,7 @@ else if (beanNames.length > 1) {
10191021
}
10201022
throw new NoUniqueBeanDefinitionException(requiredType, candidates.keySet());
10211023
}
1024+
10221025
return null;
10231026
}
10241027

0 commit comments

Comments
 (0)