[jax-rs-spec users] Re: Suggestion to refactor rx invoker API

From: Markus KARG <>
Date: Sat, 14 Jan 2017 15:28:58 +0100

Sounds good for me, but actually I think it would be even simpler if we name it "unwrap()", and do not fill in any parameters. As I said, I think applications will typically use only one technology at the time. So "unwrap()" simply can check if there is a @Provider registered having a method with the same parameters as your proposed "conver()", we finally have the requested plugability, no additonal complexity, follow existing JAX-RS patterns, and get rid of repeating lots of "rx(Class)". :-)





From: Ondrej Mihályi []
Sent: Samstag, 14. Januar 2017 12:54
Subject: Suggestion to refactor rx invoker API


I was thinking about an alternative to current rx API, to simplify it in context of supporting extensibility.

My idea is to modify the CompletionStageRxInvoker, so that it returns an extension to CompletionStage, which would contain additional method to convert the interface to any other reactive interface:

public interface RxCompletionStage<T> extends CompletionStage<T> {
    <NEW> NEW convert(Function<CompletionStage<T>, NEW> converter);

With this, we would move all the complexity to this new interface, which still can be used as a usual CompletionStage, but with the additional convert method, it provides an extension point to other interfaces. And it's based on standard CompletionStage, therefore we don't need additional rx invokers.

We could remove RxInvokerProvider, the 2 rx() methods from the Builder, which accept RxInvokerProvider, and even remove the RxInvoker interface, as CompletionStageRxInvoker would be the only required implementation.


Here is an example of what I mean, with RxJava2 as an example:

client.request().rx().get(). // we get the RxCompletionStage here, which extends CompletionStage
    .convert(this::flowableFromStage) // accepts a function that converts the CompletionStage to another interface
    .subscribe(s -> testResult = s, Throwable::printStackTrace);
An example of a working code here <> (although not using JAX-RS, just wrapping a method that returns a CompletionStage).