I use ektorp to connect to CouchDB.
The way to build an ektorp HttpClient instance is to use builder pattern:
HttpClient httpClient = n
You may try to implement FactoryBean interface:
public class HttpFactoryBean implements FactoryBean{
private String host;
private int port;
public HttpClient getObject() throws Exception {
return new StdHttpClient.Builder()
.host(host)
.port(port)
.build();
}
public Class extends HttpClient> getObjectType() {
return StdHttpClient.class;
}
public boolean isSingleton() {
return true;
}
public void setHost(String host) {
this.host = host;
}
public void setPort(int port) {
this.port = port;
}}
And add to config following bean definition:
Then you can inject this bean to another beans, it will be resolved as StdHttpClient instance.