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

[jsr339-experts] client revisions

From: Bill Burke <bburke_at_redhat.com>
Date: Tue, 05 Jul 2011 11:30:25 -0400

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