introduced "matchesName" method on BeanDefinitionHolder

This commit is contained in:
Juergen Hoeller 2009-03-27 17:40:25 +00:00
parent 565c1c1320
commit fbfbb88032
2 changed files with 11 additions and 3 deletions

View File

@ -209,8 +209,7 @@ public class QualifierAnnotationAutowireCandidateResolver implements AutowireCan
actualValue = bd.getAttribute(attributeName);
}
if (actualValue == null && attributeName.equals(AutowireCandidateQualifier.VALUE_KEY) &&
(expectedValue.equals(bdHolder.getBeanName()) ||
ObjectUtils.containsElement(bdHolder.getAliases(), expectedValue))) {
expectedValue instanceof String && bdHolder.matchesName((String) expectedValue)) {
// fall back on bean name (or alias) match
continue;
}

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2008 the original author or authors.
* Copyright 2002-2009 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -112,6 +112,15 @@ public class BeanDefinitionHolder implements BeanMetadataElement {
return this.beanDefinition.getSource();
}
/**
* Determine whether the given candidate name matches the bean name
* or the aliases stored in this bean definition.
*/
public boolean matchesName(String candidateName) {
return (candidateName != null &&
(candidateName.equals(this.beanName) || ObjectUtils.containsElement(this.aliases, candidateName)));
}
/**
* Return a friendly, short description for the bean, stating name and aliases.