The idea of recycling methods is good, but at the moment, its not very useful. Consider the following use case:

1) User needs to make a bunch of GETs as efficiently as possible
2) All the resources that they want to get are full string urls
3) In a loop, iterate over the list of resources and do the GET

In code, I'm thinking of somthing like this:

client = new HttpClient()
method = new GetMethod()
for (int i=0; i< resources.length; i++) {
method.setUri(resources[i])
client.executeMethod(method)
body = method.getResponseAsStream()
//do somthing with body
method.recycle()
}

Two issues with this:

1) There needs to be some way to set the entire uri from a method call. Right now we can use a full uri in the constructor, but after its constructed, we're stuck having to try and peice it together with calls to setPath(), setQuery() and such.

Perhaps we should add setUri(String) to HttpMethod. I think its best to have a string, as opposed to a URL or a URI object because its most portable, and we have a bunch of parsing code for it already. The constructor that takes a uri can call the setUri method to do its work, for code reuse. This is not hard to do but will break any clients that implement the HttpMethod interface.

2) From a connection standpoint, if the new url is to the same protocol://host:port then I would expect that the connection be reused for performance purposes. If not, then a new connection has to be established and the old one should probablly be closed. But the call to recycle() will release the connection so it won't be re-used. The point of calling recycle is for efficiency but if we are always releasing the connection, then all we are saving is object construction time which is tiny compared to the time to establish a connection.

We could have a use case where all the GETs are to the same protocol://host:port, (there is code in Slide like this) but this just a special case that is covered by arbitrairy urls.

Comments? Anyone want to work on this?

Jandalf.



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to