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

[jsr339-experts] Re: [Client API] Refactoring Link and Invocation

From: Sergey Beryozkin <sberyozkin_at_talend.com>
Date: Thu, 07 Jul 2011 16:36:06 +0100

Bill Burke wrote:
>
> On 7/7/11 11:15 AM, Sergey Beryozkin wrote:
>>>> Link link =
>>>> client.link("http://jaxrs.examples.org/jaxrsApplication/customers/{id}");
>>>>
>>>>
>>>> link.pathParam("id", 123).get();
>>>> link.pathParam("id", 124).get();
>>> This is not the same example, you forgot the query param which is used
>>> in the first and _not_ the second invocation. This is why the
>>> separation between Link and Invocation make sense. See other examples
>>> in Bill's message.
>> Are you saying that in the current API you have to create a new
>> Invocation instance per every query ? Does it really make sense ?
>>
>
> Yes, just as in your example, you'd have to create a link per query.
>
>
>
>> >> link.pathParam("id", 123).query("bar", "foo").get();
>> link.query("bar", null);
>> >> link.pathParam("id", 124).get();
>>
>
> I guess this works if link.pathParam()/queryParam()/header/etc. returns
> a *different* Link instance.

One does not have to follow a pattern where the same link instance is
reused to do get/post. Your proposal (re Invocation being HttpRequest
but with final get() etc) is exactly the same - one can use
client.request() multiple times to do gets()/etc or the same invocation
request to do multiple gets, clearing out queries.etc in between -
depending on the case

>
> But, IMO, you're muddling static vs. dynamic stuff into one object.
> Link is both a request and a resource. I still think the current model
> is better. It separates concerns, fits perfectly in the interceptor
> model, and isn't any less typing.
>

And me thinks you are just not reading what I'm trying to say :-)
Having duplication between Link and HttpResource is bad, I don't
understand why we'd need to protect it.
Forget about my proposal, lets use your proposal, but avoid
client-link-invocation chain, lets do

client.request(Link)
client.request(URI)
etc

nothing will be lost, no compromises will have to be done, and
the only thing we will get is that Client will use Links when needed and
Links will become Links

Sergey

-- 
Sergey Beryozkin
http://sberyozkin.blogspot.com
Talend - http://www.talend.com