You are viewing a plain text version of this content. The canonical link for it is here.
Posted to httpclient-users@hc.apache.org by Oleg Kalnichevski <ol...@apache.org> on 2006/11/01 11:40:57 UTC
Re: HttpClient Static instance
On Fri, 2006-10-20 at 11:16 -0500, vjayakumar@mmm.com wrote:
> What is issue that might arise by keeping the HttpClient instance static in
> a Utility class.
>
Vasanth,
I apologize for such a latest response. Users are very much encouraged
to re-use HttpClient instance(s), so I see nothing wrong in keeping a
static instance in a utility class.
Oleg
> Before I use the static instance of the httpClient I make the check and
> initialize it.
>
> Please let me know if there is a better way to implement this?
>
>
> //Initialize the HttpClient & enable Concurrent execution of
> HTTPmethods
> if(httpClient==null) {
> MultiThreadedHttpConnectionManager connectionManager =
> new MultiThreadedHttpConnectionManager();
> httpClient = new HttpClient(connectionManager);
>
> /*Set the proxy*/
> if (proxy != null) {
> httpClient.getHostConfiguration().setProxy(proxy,
> proxyPort);
> }
> }
>
> Thanks & Regards,
> Vasanth.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: httpclient-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: httpclient-user-help@jakarta.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: httpclient-user-help@jakarta.apache.org