jsr339-experts@jax-rs-spec.java.net

[jsr339-experts] Re: client revisions

From: Sergey Beryozkin <sberyozkin_at_talend.com>
Date: Thu, 7 Jul 2011 11:28:57 +0200

I spent some time yesterday analyzing the current API draft on the wiki and Bill's version,

This is actually pretty close, definitely invocation.get() being the last thing to call is good, but Invocation is just a wrong term, and
the current version breaks the idea of Invocation being fully initialized for it to be used by batch processors, i.e, you can't call
Invocation.invoke() without setting the right method name and generic processors have no idea about it.

Besides we still have a duplication between Link & HttpRequest as far as setting pathParams/etc is concerned which is a good sign that Link (which is misnamed IMHO) needs to extend HttpRequest and do what Invocation does now, in Bill's version, with Invocation and AsyncInvocation being already initialized, if used...Summarizing it in the diff email

Cheers, Sergey
________________________________________
From: Bill Burke [bburke_at_redhat.com]
Sent: 05 July 2011 16:30
To: jsr339-experts_at_jax-rs-spec.java.net
Subject: [jsr339-experts] client revisions

I made some changes to client API to simplifiy it a little.

https://github.com/patriot1burke/redhat-jaxrs-2.0-proposals-rev2

* removed queue from Invocation interface
* Added an AsyncInvocation interface
* Added get/post/delete/etc. methods to AsyncInvocation and Invocation
* removed invoke/queue methods from Client as they are redundant and I
don't get why they are there.
* removed HttpRequest.Builder as its not needed anymore
* Link no longer extends HttpRequest.Builder
* added request/async methods to Link
* Gutted and simplified ClientFactory. No need for all those extra
abstractions.

You now are forced to put a get(), Post() or whatever at end of method
call unless you are doing a custom HTTP method like PATCH. It now looks
like:

Client c = ...;

Invocation invocation = c.request();
HttpResponse response = invocation.header("foo", "bar").get();
String str = invocation.header("foo", "bar").get(String.class);

AsyncInvocation async = c.async();
Future<HttpResponse> f = async.header("foo", "bar").get();
Future<String> f = async.header("foo", "bar").get(String.class);

Generic invocations are:

Invocation invocation = c.request();
HttpResponse response = invocation.header("foo",
"bar").method("PATCH").invoke();


Alternatively, you could combine Invocation/AsyncInvocation, but you'd
have to rename get() to getAsync(), etc. I think originally it wasn't
done this way because of the explosion of methods within Invocation.



--
Bill Burke
JBoss, a division of Red Hat
http://bill.burkecentral.com