27
27
import org .springframework .context .annotation .ComponentScan ;
28
28
import org .springframework .context .annotation .Configuration ;
29
29
import org .springframework .context .annotation .Lazy ;
30
+ import org .springframework .core .env .Environment ;
30
31
import org .springframework .remoting .support .RemoteInvocation ;
31
32
import org .springframework .remoting .support .RemoteInvocationResult ;
32
33
import org .springframework .scheduling .annotation .Async ;
@@ -60,6 +61,17 @@ public void testNonLoadedConfigClass() {
60
61
myBean .myService .handleAsync ();
61
62
}
62
63
64
+ @ Test
65
+ public void withConfigurationClassWithPlainFactoryBean () {
66
+ AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext ();
67
+ context .register (ConfigWithPlainFactoryBean .class );
68
+ context .refresh ();
69
+ MyBean myBean = context .getBean ("myBean" , MyBean .class );
70
+ assertSame (context .getBean ("myService" ), myBean .myService );
71
+ myBean .myService .handle ();
72
+ myBean .myService .handleAsync ();
73
+ }
74
+
63
75
64
76
public interface MyService {
65
77
@@ -93,7 +105,6 @@ public HttpInvokerProxyFactoryBean myService() {
93
105
HttpInvokerProxyFactoryBean factory = new HttpInvokerProxyFactoryBean ();
94
106
factory .setServiceUrl ("/svc/dummy" );
95
107
factory .setServiceInterface (MyService .class );
96
- Thread thread = Thread .currentThread ();
97
108
factory .setHttpInvokerRequestExecutor (new HttpInvokerRequestExecutor () {
98
109
@ Override
99
110
public RemoteInvocationResult executeRequest (HttpInvokerClientConfiguration config , RemoteInvocation invocation ) {
@@ -109,4 +120,32 @@ public FactoryBean<String> myOtherService() {
109
120
}
110
121
}
111
122
123
+
124
+ @ Configuration
125
+ static class ConfigWithPlainFactoryBean {
126
+
127
+ @ Autowired
128
+ Environment env ;
129
+
130
+ @ Bean
131
+ public MyBean myBean () {
132
+ return new MyBean ();
133
+ }
134
+
135
+ @ Bean
136
+ public FactoryBean myService () {
137
+ String name = env .getProperty ("testbean.name" );
138
+ HttpInvokerProxyFactoryBean factory = new HttpInvokerProxyFactoryBean ();
139
+ factory .setServiceUrl ("/svc/" + name );
140
+ factory .setServiceInterface (MyService .class );
141
+ factory .setHttpInvokerRequestExecutor (new HttpInvokerRequestExecutor () {
142
+ @ Override
143
+ public RemoteInvocationResult executeRequest (HttpInvokerClientConfiguration config , RemoteInvocation invocation ) {
144
+ return new RemoteInvocationResult (null );
145
+ }
146
+ });
147
+ return factory ;
148
+ }
149
+ }
150
+
112
151
}
0 commit comments