I would like to configure a HttpParams using spring setter injection but HttpParams has a two argument setter ( setParameter(String name, Object object) ). Is anyone aware of a way to configure this in spring?
The closest I can think of is like you would do a List, Set, or Property configuration:
http://www.mkyong.com/spring/spring-collections-list-set-map-and-properties-example/
Thanks!
I believe HttpConnectionParamBean and HttpProtocolParamBean were created for precisely this purpose. Documentation Example
Strictly speaking: A setter with two parameters is not a setter. It violates the JavaBeans convention, on which Spring builds. There is no simple way to solve that.
As an alternative, here's a Helper class you can use to configure your HttpParams object with Spring:
Wire it like this:
Are you using Apache HttpClient? If so, the HttpClientParams implementation of HttpParams has real getters and setters that you can use.
Otherwise, I'd suggest writing a simple HttpParamsFactory that you could pass a map that contains the parameters you need and construct an appropriate instance of HttpParams.