PDA

View Full Version : Spring HttpInvoker: how to replace serviceUrl at runtime?



michaelf
Apr 16th, 2012, 04:57 PM
The issue is discussed couple of times, but I was not able to find a solution that solves our problem.
We have the following HttpInvoker service that takes the remote URL from Database:


@Service("exampleService")
public class ExampleHttpInvoker extends HttpInvokerProxyFactoryBean {

@Resource
private DBService service;

@PostConstruct
public void init() throws ConfigurationException {

String url = service.getURL();
this.setServiceUrl(url);
this.setServiceInterface(RemoteInterface.class);
this.setHttpInvokerRequestExecutor(new CommonsHttpInvokerRequestExecutor());
afterPropertiesSet();

}

}


The URL can be changed between remote calls.
How to replace serviceUrl at runtime?
We can not use Session or Request scope since the service is not Web aware.
Any help will be appreciated.

michaelf
Apr 17th, 2012, 02:02 AM
My clarification: I would be able to solve my problem if I would able to create the ExampleHttpInvoker before each remote call or upon DB modification. In Spring is possible to use @Scope(“request”) or @Scope(“session”), but these options are valid only in the context of a web-aware Spring ApplicationContext. I am looking for a way to recreate my ExampleHttpInvoker singleton.
Any help will be appreciated.