Polishing
This commit is contained in:
@@ -318,8 +318,8 @@ public interface AutowireCapableBeanFactory extends BeanFactory {
|
|||||||
* @param requiredType type the bean must match; can be an interface or superclass.
|
* @param requiredType type the bean must match; can be an interface or superclass.
|
||||||
* {@code null} is disallowed.
|
* {@code null} is disallowed.
|
||||||
* @return the bean name plus bean instance
|
* @return the bean name plus bean instance
|
||||||
* @throws NoSuchBeanDefinitionException if no bean of the given type was found
|
* @throws NoSuchBeanDefinitionException if no matching bean was found
|
||||||
* @throws NoUniqueBeanDefinitionException if more than one bean of the given type was found
|
* @throws NoUniqueBeanDefinitionException if more than one matching bean was found
|
||||||
* @throws BeansException if the bean could not be created
|
* @throws BeansException if the bean could not be created
|
||||||
* @since 4.3.3
|
* @since 4.3.3
|
||||||
* @see #getBean(Class)
|
* @see #getBean(Class)
|
||||||
@@ -328,30 +328,30 @@ public interface AutowireCapableBeanFactory extends BeanFactory {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Resolve the specified dependency against the beans defined in this factory.
|
* Resolve the specified dependency against the beans defined in this factory.
|
||||||
* @param descriptor the descriptor for the dependency
|
* @param descriptor the descriptor for the dependency (field/method/constructor)
|
||||||
* @param requestingBeanName the name of the bean which declares the present dependency
|
* @param requestingBeanName the name of the bean which declares the given dependency
|
||||||
* @return the resolved object, or {@code null} if none found
|
* @return the resolved object, or {@code null} if none found
|
||||||
* @throws NoSuchBeanDefinitionException if no matching bean was found
|
* @throws NoSuchBeanDefinitionException if no matching bean was found
|
||||||
* @throws NoUniqueBeanDefinitionException if more than one matching bean was found
|
* @throws NoUniqueBeanDefinitionException if more than one matching bean was found
|
||||||
* @throws BeansException if dependency resolution failed for any other reason
|
* @throws BeansException if dependency resolution failed for any other reason
|
||||||
* @see #resolveDependency(DependencyDescriptor, String, Set, TypeConverter)
|
|
||||||
* @since 2.5
|
* @since 2.5
|
||||||
|
* @see #resolveDependency(DependencyDescriptor, String, Set, TypeConverter)
|
||||||
*/
|
*/
|
||||||
Object resolveDependency(DependencyDescriptor descriptor, String requestingBeanName) throws BeansException;
|
Object resolveDependency(DependencyDescriptor descriptor, String requestingBeanName) throws BeansException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Resolve the specified dependency against the beans defined in this factory.
|
* Resolve the specified dependency against the beans defined in this factory.
|
||||||
* @param descriptor the descriptor for the dependency
|
* @param descriptor the descriptor for the dependency (field/method/constructor)
|
||||||
* @param requestingBeanName the name of the bean which declares the present dependency
|
* @param requestingBeanName the name of the bean which declares the given dependency
|
||||||
* @param autowiredBeanNames a Set that all names of autowired beans (used for resolving
|
* @param autowiredBeanNames a Set that all names of autowired beans (used for
|
||||||
* the present dependency) are supposed to be added to
|
* resolving the given dependency) are supposed to be added to
|
||||||
* @param typeConverter the TypeConverter to use for populating arrays and collections
|
* @param typeConverter the TypeConverter to use for populating arrays and collections
|
||||||
* @return the resolved object, or {@code null} if none found
|
* @return the resolved object, or {@code null} if none found
|
||||||
* @throws NoSuchBeanDefinitionException if no matching bean was found
|
* @throws NoSuchBeanDefinitionException if no matching bean was found
|
||||||
* @throws NoUniqueBeanDefinitionException if more than one matching bean was found
|
* @throws NoUniqueBeanDefinitionException if more than one matching bean was found
|
||||||
* @throws BeansException if dependency resolution failed for any other reason
|
* @throws BeansException if dependency resolution failed for any other reason
|
||||||
* @see DependencyDescriptor
|
|
||||||
* @since 2.5
|
* @since 2.5
|
||||||
|
* @see DependencyDescriptor
|
||||||
*/
|
*/
|
||||||
Object resolveDependency(DependencyDescriptor descriptor, String requestingBeanName,
|
Object resolveDependency(DependencyDescriptor descriptor, String requestingBeanName,
|
||||||
Set<String> autowiredBeanNames, TypeConverter typeConverter) throws BeansException;
|
Set<String> autowiredBeanNames, TypeConverter typeConverter) throws BeansException;
|
||||||
|
|||||||
@@ -989,6 +989,7 @@ public class DefaultListableBeanFactory extends AbstractAutowireCapableBeanFacto
|
|||||||
private <T> NamedBeanHolder<T> resolveNamedBean(Class<T> requiredType, Object... args) throws BeansException {
|
private <T> NamedBeanHolder<T> resolveNamedBean(Class<T> requiredType, Object... args) throws BeansException {
|
||||||
Assert.notNull(requiredType, "Required type must not be null");
|
Assert.notNull(requiredType, "Required type must not be null");
|
||||||
String[] beanNames = getBeanNamesForType(requiredType);
|
String[] beanNames = getBeanNamesForType(requiredType);
|
||||||
|
|
||||||
if (beanNames.length > 1) {
|
if (beanNames.length > 1) {
|
||||||
ArrayList<String> autowireCandidates = new ArrayList<String>();
|
ArrayList<String> autowireCandidates = new ArrayList<String>();
|
||||||
for (String beanName : beanNames) {
|
for (String beanName : beanNames) {
|
||||||
@@ -1000,6 +1001,7 @@ public class DefaultListableBeanFactory extends AbstractAutowireCapableBeanFacto
|
|||||||
beanNames = autowireCandidates.toArray(new String[autowireCandidates.size()]);
|
beanNames = autowireCandidates.toArray(new String[autowireCandidates.size()]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (beanNames.length == 1) {
|
if (beanNames.length == 1) {
|
||||||
String beanName = beanNames[0];
|
String beanName = beanNames[0];
|
||||||
return new NamedBeanHolder<T>(beanName, getBean(beanName, requiredType, args));
|
return new NamedBeanHolder<T>(beanName, getBean(beanName, requiredType, args));
|
||||||
@@ -1019,6 +1021,7 @@ public class DefaultListableBeanFactory extends AbstractAutowireCapableBeanFacto
|
|||||||
}
|
}
|
||||||
throw new NoUniqueBeanDefinitionException(requiredType, candidates.keySet());
|
throw new NoUniqueBeanDefinitionException(requiredType, candidates.keySet());
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user