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

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

From: Bill Burke <bburke_at_redhat.com>
Date: Thu, 07 Jul 2011 11:17:00 -0400

On 7/7/11 11:00 AM, Sergey Beryozkin wrote:
> Sergey Beryozkin wrote:
>> Hi Santiago
>>
>> Santiago Pericas-Geertsen wrote:
>>> Sergey,
>>>
>>> I'm not convinced this is any simpler from the point of the view of
>>> the application developer. If the common case is to configure a Link
>>> with parameters, etc. (see Bill's e-mail) then your API is actually
>>> less friendly.
>>> Consider the following case which works with the current API:
>>>
>>> Link customersUri =
>>> client.link("http://jaxrs.examples.org/jaxrsApplication/customers").path("{id}");
>>>
>>> Customer customer123 = customersUri.get().pathParam("id",
>>> 123).queryParam("country", "US").invoke(Customer.class);
>>> Customer customer321 = customersUri.get().pathParam("id",
>>> 321).invoke(Customer.class);
>>>
>>
>> IMHO
>>
>> customersUri.get().pathParam("id", 321).invoke(Customer.class);
>>
>> needs to be avoided -
>>
>> I'm proposing
>>
>> client.link("http://jaxrs.examples.org/jaxrsApplication/customers/{id}").pathParam("id",
>> 123).get();
>>
>> Works too.
>>
>> Link link =
>> client.link("http://jaxrs.examples.org/jaxrsApplication/customers/{id}");
>>
>> link.pathParam("id", 123).get();
>> link.pathParam("id", 124).get();
>>
>> works as well.
>>
>> If we can converge on Bill's proposal then we will get
>>
>> Invocation inv =
>> client.request("http://jaxrs.examples.org/jaxrsApplication/customers/{id}");
>>
>>
>> inv.pathParam("id", 123).get();
>> inv.pathParam("id", 124).get();
>>
>> etc.
>>
>> Effectively all I want to do is to turn Link into a URI+metadata
>> holder only
>
> And then we will do
>
> Invocation inv = client.getRequest(myLink);
>
> (inv is fully initialized with queries, etc, thus thread-safe)
>
> as opposed to
>
> link.get(), etc
>

I don't get what your proposal buys us over the current/original one.
What is the benefit? I don't see it.

client.request(..).pathParam(...).get();

is the same amount of typing as:

client.link(...).pathParam().get();

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