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

[jsr339-experts] Re: client revisions

From: Guilherme Silveira <guilherme.silveira_at_caelum.com.br>
Date: Wed, 6 Jul 2011 13:00:47 -0300

btw: removing the Builder is a nice idea
Guilherme Silveira
Caelum | Ensino e Inovação
http://www.caelum.com.br/



On Tue, Jul 5, 2011 at 12:30 PM, Bill Burke <bburke_at_redhat.com> wrote:
> 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
>