Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [ecf-dev] rest API work

Hi Andre,

I need to clarify my last post. This should be the code snippet (the comment in my previoius post about creating a new HttpClient for every request was incorrect):

protected HttpClient getHttpClientForCall(HttpMethod httpMethod, IRemoteCall call, IRestCallable callable) {
     return httpClient;


Scott Lewis wrote:
protected HttpClient getHttpClientForCall(HttpMethod httpMethod, IRemoteCall call, IRestCallable callable) { // By default, create a new HttpClient instance for every request. return httpClient;

The intention is that subclasses can override this behavior if they wish...e.g. to reuse an HttpClient for all calls. This change is now committed to HEAD.

Now the question is: what should the default behavior be in RestClientService? (i.e. a separate HttpClient for each call, or one that is shared for all calls)? My initial inclination was that the default should be a new HttpClient for each call (i.e. creating/returning a new one each time getHttpClientForCall is called), but I think upon reflection that having an HttpClient that is reused for each call is probably a better default...and so I've changed the default implementation in RestClientService to reuse the httpClient (created upon construction) for each call. Subclasses may override this behavior simply by implementing getHttpClientForCall in a different manner (i.e. returning a new HttpClient for each instance).

- - I need to be able to elaborate on the specific HTTP error.In some
cases my REST service answers 404 to signal me that there's no
information present. I'll have to react by not showing any information
for this call. On the other hand I'd have to popup an error for any
other error that may occur (authentication, transport etc.). I'd suggest
to pass an IStatus to the ECFException instead of a plain string. I'll
then be able to fetch it's code.
The newly revised RestClientContainer and RestClientService classes
can/would/do allow subclassing to implement alternative strategies for
particular rest APIs...e.g. for handling http responses in custom ways
for a particular rest api. That is, it's intended that for *some* rest
clients, subclasses of RestClientContainer and RestClientService might
be created to customize the runtime behavior (since rest is more a
family of protocols than it is a single protocol).
In addition, it's possible that we could introduce some more flexibility
into these classes....e.g. RestClientService...through some
generalization of the protected and public methods...or by introducing
interfaces for delegation.

sound good! I'll catch up with the latest incarnation and try to
subclass to get what I need.
On the other hand, I wonder here too, if there's any good reason to
deliberately loose the error code. What do I miss?

I've introduced an new class: RestException that provides access to the error code. This is/also been committed to HEAD. It allows receivers/handlers of the RestException to get at the error code if they wish.

Hi Scott, Hi Holger

sorry, for being too quick with my posts. I guess your API suggests to
subclass IRestCallable and augment it to have request entities.
Am I right?

Well, unfortunately I don't think subclassing RestCallable will properly do the trick WRT request we probably need to figure out how to allow people to specify a RequestEntity for post parameter in some way that is not yet in the API. I removed it from the old API for simplicity...but I think I forgot to put it back in.

I agree that there should be some way of specifying that a RequestEntity is to be used for post requests, but I'm not clear on the 'best' or 'clearest' way to represent it in the API. Any thoughts/comments would be appreciated...and we will get it back in there.


Thanks + Cheers!

- --
André Dietisheim
Head of Eclipse Development

Puzzle ITC GmbH

Telefon +41 31 370 22 00
Fax     +41 31 370 22 01
Mobile  +41 76 423 03 02

Abonnieren Sie unsere News:

Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla -

ecf-dev mailing list

ecf-dev mailing list

Back to the top