users@jax-rs-spec.java.net

[jax-rs-spec users] Re: [PLEASE REVIEW] JAX-RS Client Reactive API -- updated

From: Sergey Beryozkin <sberyozkin_at_talend.com>
Date: Fri, 20 Jan 2017 17:45:30 +0000

Hi Markus

For RxJava it would be more like ObservableRxInvokerProvider, or may be for RxJava2 - Flowable, etc, though not quite sure, it will depend on the provider implementers

Sergey
On 20/01/17 17:36, Markus KARG wrote:
Yes, Java8 clearly is not a good name. My intention about a different name was that it clearly names the framework, not the full technical solution. For "RxJava" it is simple: RxJava". An analogy would be "JavaSE" (in the sense of "JavaSE implements RxFramework" where "RxFramework" is a user-friendly name for RxInvokerProvider). Or we could go with "CompletionStageProvider". Actually I don't know really good names also, but maybe one of the lots of other highly appreciated EG members might want to chime in with an idea…? ;-)
Markus

From: Pavel Bucek [mailto:pavel.bucek_at_oracle.com]
Sent: Freitag, 20. Januar 2017 18:18
To: jsr370-experts_at_jax-rs-spec.java.net<mailto:jsr370-experts_at_jax-rs-spec.java.net>
Subject: Re: [PLEASE REVIEW] JAX-RS Client Reactive API -- updated


Hi Sergey,



thanks for chiming in.



You are spot on - CompletionStageRxInvoker will be almost completely hidden from the users. It is not for them to implement. There is only single point where a user can get a reference to this class (the rx() method):



CompletionStageRxInvoker rx = client.target("remote/forecast/{destination}")

                                    .request()

                                    .rx();



CompletionStage<List<String>> cs =

        rx.get(new GenericType<List<String>>() { });



cs.thenAccept(System.out::println);



I don't believe this will be very common case (and you can alreagy get various "strange" ifaces when you are constructing the request). But I do see that this is the one with the longest name :).



(the code sample should also answer Sergeys question - yes, we still do have rx() method.)



Marcus: Java8 doesn't seem to be a good name for (any) class. What would you expect when Java8.get() is invoked? javax.ws.rs.Response? I don't think so. Anyway, if you have other suggestions related to the name, we'll definitely think about them.



ad review: just to not hide anything - there is one method, which was added to be able to do a RxInvocationProvider lookup:



public interface RxInvokerProvider<T extends RxInvoker> {



    /**

     * Find out whether current instance provides given {_at_link RxInvoker} subclass.

     *

     * @param clazz {_at_code RxInvoker} subclass.

     * @return {_at_code true} when this provider provides given {_at_code RxInvoker} subclass, {_at_code false} otherwise.

     */

    public boolean provides(Class<?> clazz);



    //...

    public T getRxInvoker(SyncInvoker syncInvoker, ExecutorService executorService);



}



I don't particularly like that name, if anyone has better idea, please share it as well.



Thanks!
Pavel



On 20/01/2017 18:00, Sergey Beryozkin wrote:
We still have rx() for those who would like to get a default, they do not have to even use this provider.
'Java8' actually looks strange to me, the argument about the 'beginners' does not work IMHO, we are talking about the sophisticated developers here knowing what they do, what Rx is, etc...

Pavel is it right, we still have rx() ?
I.e. CompletionStageRxInvokerProvider does have to be effectively pre-registered

Sergey
On 20/01/17 16:49, Markus KARG wrote:
Pavel,

thank you for considering the critics and proposals discussed this week! It is great that you picked up the ideas.

As ugly as the API finally looks, I do not see an way to make it even better. :-( So for me, this new proposal is acceptable, given the fact that the majority in this EG apparently wants to support multiple RX implementations.

But there is only one thing I would really ask for: Can we rename "CompletionStageRxInvokerProvider" to e. g. "Java8" or something nice like that (so it could be similar to other providers named like "RxJava")? I mean, that name is certainly technically correct, but totally ugly to write and understand for beginners! :-)

Thanks
-Markus


From: Pavel Bucek [<mailto:pavel.bucek_at_oracle.com>mailto:pavel.bucek_at_oracle.com]
Sent: Freitag, 20. Januar 2017 15:12
To: jsr370-experts_at_jax-rs-spec.java.net<mailto:jsr370-experts_at_jax-rs-spec.java.net>
Subject: [PLEASE REVIEW] JAX-RS Client Reactive API -- updated

Dear experts,

thanks for your feedback!

Last suggestion by Santiago (doing lookup by the RxInvoker subclass) is implementable and I believe it is the best one we do have.

Code example (extensibility support):

Client rxClient = client.register(CompletionStageRxInvokerProvider.class, RxInvokerProvider.class);



CompletionStage<List<String>> cs =

        rxClient.target("remote/forecast/{destination}")

                .resolveTemplate("destination", "mars")

                .request()

                .header("Rx-User", "Java8")

                .rx(CompletionStageRxInvoker.class)

                .get(new GenericType<List<String>>() {

                });



cs.thenAccept(System.out::println);
Corresponding pull request: https://github.com/jax-rs/api/pull/3
Please review the pull request and provide your comments and suggestions.

Thanks and have a nice weekend,
Pavel

On 19/01/2017 16:54, Santiago Pericasgeertsen wrote:
Hi Pavel,

 Just catching up with this issue. I guess the two levels of indirection has led us into a generic wall :)


Client rxClient = client.register(CompletionStageRxInvokerProvider.class);

CompletionStage<UserPojo> cs =

        rxClient.target("http://foo.bar"<http://foo.bar/>)

                .request()

                .rx(CompletionStage.class)

                .get(UserPojo.class);
 So what if we reduce indirection and write:

   .rx(CompletionStageRxInvoker.class)

 as before, still keeping the provider for it? Less ideal of course.

— Santiago