On Mon, 2010-02-15 at 13:25 -0800, Kaiser Sose wrote:
> Hi all,
> I need to write an "interface" (not in the oo meaning) that handles many
> threads making some GET/POST on different websites. I used a
> ThreadSafeClientConnManager inside a DefaultHttpClient but I wonder how to
> set different parameters in the GET/POST of each service (I've already set
> those concerning the MAXTOTALCONN/MAXDEFPERROUTE) ... for instance for one
> service (1 url) the TimeOut should be about 5 seconds while for another
> could be 15 ... for one service the port is the 80, for another the port is
> the 8080 ... can I leave just 1 DefaultHttpClient() and set these parameters
> directly in the GET object? 
> 

Yes, you can and you basically should.


> Sorry if its a stupid question but I am new to Java and to those components
> and I am little bit in confusion with all these new classes! Till now I did
> something like that
> 
> 1 - A singleton creates the DefaultHttpClient and Initialize it with some
> parameters taken from a properties file
> 2 - The singleton (manager) has some public MakeGetRequest and
> MakePostRequest (overloaded) who build the Querystring and create the
> GET/POST object
> 3 - I convert the result in a String object and send back to the caller
> 
> Now since services are about 10 and I'd like to keep a Singleton rather than
> 10 objects with 10 connection pool I want make something like this ...
> 
> MakeGetRequest(String uri, Map params, String ServiceName) 
> 
> (for instance ServiceName can be "BANNER")
> 
> Then I analyze the ServiceName and set the correct parameters that I already
> took from another property file ... 
> 
> if ServiceName = Banner
>    Get.Port = 8080
>    Get.TimeOut = 10000
>    execute(Get)
> 
> is it a good way?

Yes, it is. It is the recommended way of using HttpClient

>  do you have any better idea or tip? How do I set the
> parameter in a Get object?
> 

By using HttpRequest#getParams()

Hope this helps

Oleg


> Best Regards
> 
> -- 
> - Carlo -
> 



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to