FooConfig, Foo, Bar, and BarFactory are now public static classes in order to avoid a bug with JDT/Spring IDE where the classes cannot be found in the XML application context.
git-svn-id: https://src.springframework.org/svn/spring-framework/trunk@3117 50f2f4bb-b051-0410-bef5-90022cba6387
This commit is contained in:
parent
3478dec5f0
commit
677a3d2615
|
|
@ -1,12 +1,11 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
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">
|
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
|
||||||
|
|
||||||
<bean id="foo" class="org.springframework.context.annotation.Foo">
|
<bean id="foo" class="org.springframework.context.annotation.Spr6602Tests$Foo">
|
||||||
<constructor-arg ref="barFactory"/>
|
<constructor-arg ref="barFactory" />
|
||||||
</bean>
|
</bean>
|
||||||
|
|
||||||
<bean id="barFactory" class="org.springframework.context.annotation.BarFactory"/>
|
<bean id="barFactory" class="org.springframework.context.annotation.Spr6602Tests$BarFactory" />
|
||||||
|
|
||||||
</beans>
|
</beans>
|
||||||
|
|
|
||||||
|
|
@ -59,24 +59,31 @@ public class Spr6602Tests {
|
||||||
assertThat(bar3, is(not(bar4)));
|
assertThat(bar3, is(not(bar4)));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
@Configuration
|
||||||
|
public static class FooConfig {
|
||||||
|
@Bean
|
||||||
@Configuration
|
public Foo foo() throws Exception {
|
||||||
class FooConfig {
|
|
||||||
public @Bean Foo foo() throws Exception {
|
|
||||||
return new Foo(barFactory().getObject());
|
return new Foo(barFactory().getObject());
|
||||||
}
|
}
|
||||||
|
|
||||||
public @Bean BarFactory barFactory() {
|
@Bean
|
||||||
|
public BarFactory barFactory() {
|
||||||
return new BarFactory();
|
return new BarFactory();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class Foo { final Bar bar; public Foo(Bar bar) { this.bar = bar; } }
|
public static class Foo {
|
||||||
class Bar { }
|
final Bar bar;
|
||||||
|
|
||||||
class BarFactory implements FactoryBean<Bar> {
|
public Foo(Bar bar) {
|
||||||
|
this.bar = bar;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class Bar {
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class BarFactory implements FactoryBean<Bar> {
|
||||||
|
|
||||||
public Bar getObject() throws Exception {
|
public Bar getObject() throws Exception {
|
||||||
return new Bar();
|
return new Bar();
|
||||||
|
|
@ -90,4 +97,6 @@ class BarFactory implements FactoryBean<Bar> {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
Loading…
Reference in New Issue