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

[jsr339-experts] Some comments about Target and Invocation

From: Sergey Beryozkin <sberyozkin_at_talend.com>
Date: Thu, 25 Aug 2011 12:38:42 +0100

Hi

Here are some comments about Target and Invocation [1]

1. Target.getUriBuilder()

what is the idea behind this method ? In other words, what is the
expected outcome of

client.target("http://bar").getUriBuilder().build() ?

I'm presuming getUriBuilder() needs to return a cloned builder. But I'm
still not sure what is next after getUriBuilder() is invoked ?

2. I'm wondering if Target path & query methods accepting Annotations
should also be dropped ? (assuming they were originally added to support
the validation at the low-level api level)

3. Would it make sense to have Target.fragment(String) ?

4. Can we consider adding a back() method ? That would allow Target
glide back to the previous segment after multiple path() invocations...


5. Target.prepare()

I can see that the idea here is to create an invocable entity which can
be used in batched invocations. I think the fact that Target can be used
to perform simple and sophisticated HTTP invocations without relying on
prepare()/request() is very good.

So Target.prepare() kind of does make sense and I think it's clean it's
done - I've set Target as needed, including all the headers, etc and
then I do prepare() and then I finalize it with selecting a verb.

The thing I don't understand why would anyone use Invocation.
If it's a standalone Invocation, a single one, then Target just works
perfectly well on its own, for sync or async support of its own.

There's no need to have Invocation to duplicate what Target can do for
simple single and specific invocations.

So then we'd use Target.prepare() to create many Invocations and submit
them to the queue or batch processor which can happily do invoke() for
every Invocation in the collection.

And I don't know what it means in practice. I think it can only work for
empty post pings or similar...

IMHO, if we can come up with a good practical example of using a
collection of Invocations then Target.prepare() should stay.
If not then Target.prepare() and Invocation should be dropped which
IMHO can only improve API in the positive way

Thanks, Sergey



[1]
http://java.net/projects/jax-rs-spec/sources/git/show/src/jax-rs-api/src/main/java/javax/ws/rs/client/


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