hc-httpclient-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Roland Weber <ROLWE...@de.ibm.com>
Subject Re: HTTPClient Singleton why ?
Date Wed, 01 Dec 2004 08:57:40 GMT
Hi Santosh,

> In previous posts it has been suggested to make HTTPClient singleton. 
> But why ? If HTTPClient gets connection from 
> MultiThreadedHttpConnectionManager connection pool and gives connection 
> back to pool why will connection be gc'ed? what is benefit of  saving 
> HTTPClient object?

The HttpClient object also holds preferences, and a default state.
Indeed we usually recommend a single HttpClient object primarily
because of the connection manager, but there are lots of other
objects which get uselessly re-created over and over again if you
create a new HttpClient object for each request.
So if you have a singleton connection manager anyway, why not
make the HttpClient object a singleton as well?

cheers,
  Roland

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message