Browse files

Demonstrate @Qualifier usage for SPR-8582

  • Loading branch information...
1 parent 048aed1 commit 09dd8abf2c28eb7d2b7bd4abaa67bffdbe4776b9 @cbeams cbeams committed Aug 8, 2011
View
4 SPR-8582/src/test/java/Config.java
@@ -1,3 +1,4 @@
+import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.MessageSource;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@@ -19,7 +20,8 @@ public MessageSource messageSource() {
}
@Bean
- public TheBeanThatUsesTheBeanWithMessageSource theOtherBean(TheBeanWithMessageSource theBeanWithMessageSource) {
+ public TheBeanThatUsesTheBeanWithMessageSource theOtherBean(
+ @Qualifier("theBean1") TheBeanWithMessageSource theBeanWithMessageSource) {
TheBeanThatUsesTheBeanWithMessageSource theOtherBean =
new TheBeanThatUsesTheBeanWithMessageSource();
theOtherBean.setBean(theBeanWithMessageSource);
View
2 SPR-8582/src/test/resources/applicationcontext.xml
@@ -7,7 +7,7 @@
<bean id="messageSource" class="org.springframework.context.support.ResourceBundleMessageSource" />
<bean id="theOtherBean" class="TheBeanThatUsesTheBeanWithMessageSource">
- <property name="bean" ref="theBean" />
+ <property name="bean" ref="theBean1" />
</bean>
</beans>
View
5 SPR-8582/src/test/resources/inherited.xml
@@ -2,8 +2,11 @@
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
- <bean name="theBean" class="TheBeanWithMessageSource">
+ <bean name="theBean1" class="TheBeanWithMessageSource">
<property name="messageSource" ref="messageSource" />
</bean>
+ <bean name="theBean2" class="TheBeanWithMessageSource">
+ <property name="messageSource" ref="messageSource" />
+ </bean>
</beans>

0 comments on commit 09dd8ab

Please sign in to comment.