|
|
|
|
@ -51,6 +51,7 @@ public class BeanMethodQualificationTests {
@@ -51,6 +51,7 @@ public class BeanMethodQualificationTests {
|
|
|
|
|
assertFalse(ctx.getBeanFactory().containsSingleton("testBean1")); |
|
|
|
|
StandardPojo pojo = ctx.getBean(StandardPojo.class); |
|
|
|
|
assertThat(pojo.testBean.getName(), equalTo("interesting")); |
|
|
|
|
assertThat(pojo.testBean2.getName(), equalTo("boring")); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
@ -60,6 +61,7 @@ public class BeanMethodQualificationTests {
@@ -60,6 +61,7 @@ public class BeanMethodQualificationTests {
|
|
|
|
|
assertFalse(ctx.getBeanFactory().containsSingleton("testBean1")); |
|
|
|
|
StandardPojo pojo = ctx.getBean(StandardPojo.class); |
|
|
|
|
assertThat(pojo.testBean.getName(), equalTo("interesting")); |
|
|
|
|
assertThat(pojo.testBean2.getName(), equalTo("boring")); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
@ -69,6 +71,7 @@ public class BeanMethodQualificationTests {
@@ -69,6 +71,7 @@ public class BeanMethodQualificationTests {
|
|
|
|
|
assertTrue(ctx.getBeanFactory().containsSingleton("testBean1")); // a shared scoped proxy
|
|
|
|
|
StandardPojo pojo = ctx.getBean(StandardPojo.class); |
|
|
|
|
assertThat(pojo.testBean.getName(), equalTo("interesting")); |
|
|
|
|
assertThat(pojo.testBean2.getName(), equalTo("boring")); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
@ -89,7 +92,7 @@ public class BeanMethodQualificationTests {
@@ -89,7 +92,7 @@ public class BeanMethodQualificationTests {
|
|
|
|
|
return new TestBean("interesting"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Bean @Qualifier("boring") |
|
|
|
|
@Bean @Boring |
|
|
|
|
public TestBean testBean2() { |
|
|
|
|
return new TestBean("boring"); |
|
|
|
|
} |
|
|
|
|
@ -103,7 +106,7 @@ public class BeanMethodQualificationTests {
@@ -103,7 +106,7 @@ public class BeanMethodQualificationTests {
|
|
|
|
|
return new TestBean("interesting"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Bean @Qualifier("boring") @Scope("prototype") |
|
|
|
|
@Bean @Boring @Scope("prototype") |
|
|
|
|
public TestBean testBean2() { |
|
|
|
|
return new TestBean("boring"); |
|
|
|
|
} |
|
|
|
|
@ -117,7 +120,7 @@ public class BeanMethodQualificationTests {
@@ -117,7 +120,7 @@ public class BeanMethodQualificationTests {
|
|
|
|
|
return new TestBean("interesting"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Bean @Qualifier("boring") @Scope(value="prototype", proxyMode=ScopedProxyMode.TARGET_CLASS) |
|
|
|
|
@Bean @Boring @Scope(value="prototype", proxyMode=ScopedProxyMode.TARGET_CLASS) |
|
|
|
|
public TestBean testBean2() { |
|
|
|
|
return new TestBean("boring"); |
|
|
|
|
} |
|
|
|
|
@ -127,6 +130,13 @@ public class BeanMethodQualificationTests {
@@ -127,6 +130,13 @@ public class BeanMethodQualificationTests {
|
|
|
|
|
static class StandardPojo { |
|
|
|
|
|
|
|
|
|
@Autowired @Qualifier("interesting") TestBean testBean; |
|
|
|
|
|
|
|
|
|
@Autowired @Boring TestBean testBean2; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Qualifier |
|
|
|
|
@Retention(RetentionPolicy.RUNTIME) |
|
|
|
|
public @interface Boring { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Configuration |
|
|
|
|
|