Browse Source

introduced "matchesName" method on BeanDefinitionHolder

git-svn-id: https://src.springframework.org/svn/spring-framework/trunk@855 50f2f4bb-b051-0410-bef5-90022cba6387
pull/1/head
Juergen Hoeller 17 years ago
parent
commit
3cae153148
  1. 3
      org.springframework.beans/src/main/java/org/springframework/beans/factory/annotation/QualifierAnnotationAutowireCandidateResolver.java
  2. 11
      org.springframework.beans/src/main/java/org/springframework/beans/factory/config/BeanDefinitionHolder.java

3
org.springframework.beans/src/main/java/org/springframework/beans/factory/annotation/QualifierAnnotationAutowireCandidateResolver.java

@ -209,8 +209,7 @@ public class QualifierAnnotationAutowireCandidateResolver implements AutowireCan @@ -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;
}

11
org.springframework.beans/src/main/java/org/springframework/beans/factory/config/BeanDefinitionHolder.java

@ -1,5 +1,5 @@ @@ -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 { @@ -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.

Loading…
Cancel
Save