Michał Jaśtak opened SPR-12141 and commented
Suppose that I have class annotated with @Configuration, in which I want to use Environment, injected by Spring Framework, something like this:
@Configuration
public class MyConfig {
@Inject
private Environment env;
...
}
When I declare bean using HttpInvokerProxyFactoryBean, and try to access injected environment to use one or the properties as for ex. service URL
@Bean
public FactoryBean someService() {
final HttpInvokerProxyFactoryBean factory = new HttpInvokerProxyFactoryBean();
factory.setServiceInterface(SomeService.class);
factory.setServiceUrl(env.getRequiredProperty("service.uri"));
return factory;
}
I get NPEx because Spring Framework is trying to instantiate the factory before Environment is injected.
The problem doesn't exist, if I declare returned type as FactoryBean<SomeService>, but because of current signature of HttpInvokerProxyFactoryBean, I'm unable to use it directly (it implements FactoryBean<Object>).
Affects: 3.2.10, 4.0.6, 4.1 RC2
Issue Links:
Referenced from: commits 4432c41, f4f7f40, 5da8a16, bff2bf2
Backported to: 4.0.7, 3.2.11
Michał Jaśtak opened SPR-12141 and commented
Suppose that I have class annotated with
@Configuration, in which I want to use Environment, injected by Spring Framework, something like this:When I declare bean using HttpInvokerProxyFactoryBean, and try to access injected environment to use one or the properties as for ex. service URL
I get NPEx because Spring Framework is trying to instantiate the factory before Environment is injected.
The problem doesn't exist, if I declare returned type as FactoryBean<SomeService>, but because of current signature of HttpInvokerProxyFactoryBean, I'm unable to use it directly (it implements FactoryBean<Object>).
Affects: 3.2.10, 4.0.6, 4.1 RC2
Issue Links:
@BeanReferenced from: commits 4432c41, f4f7f40, 5da8a16, bff2bf2
Backported to: 4.0.7, 3.2.11