Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [jaxrs-dev] JAX-RS Client Question

Hi John, Santiago,

In the MicroProfile Rest Client project, I have proposed an SPI (though really it could be an API instead) that allows components to get first access to a RestClientBuilder (MP's version of JAX-RS's ClientBuilder) before the user does.  One of the main use cases was for other technologies to automatically plug in their providers as "out-of-the-box" for all users of the builder APIs.  

Here is a concrete use case:
* An organization wants all outbound REST invocations to be logged into OpenTracing or some similar framework.  The simplest approach would be to add a ClientRequestFilter that does the logging, adds a trace headers, etc.
* That organization may not have complete control over the code that goes into their application server (i.e. many different developers, using third-party libraries, etc.), so they may not be able to add the filter to all clients.

Given that scenario (and we ran into this already in MP), I proposed adding a notification mechanism that would allow components to be notified when new builders were created.  That way, they could pre-configure the builder before the user got access to the builder (that way, the user could always undo something they didn't like if necessary).  So, if an organization wanted to use OpenTracing on all REST client requests, they could add their ClientRequestFilter to the builder, and the user code would not need to do anything in order to take advantage of this feature.

It works using the ServiceLoader pattern - the OpenTracing component would have a META-INF/services/org.eclipse.microprofile.rest.client.spi.ProviderRegistrar (I'm starting to think this should be renamed to something like NewClientNotification) file that points to a class that implements an interface that looks like this:

public interface ProviderRegistrar {

   void onNewBuilder(RestClientBuilder builder);
}

Then, the OpenTracing implementation of that interface could register providers, set properties, etc.  When all implementations of the ProviderRegistrar interface have been invoked, then the RestClientBuilder would return to the user for them to build with.

It would be fairly simple to add to JAX-RS if we wanted to.  Just let me know, and I can spin up a PR to resolve John's issue #596.

Thanks,

Andy

On Mon, Mar 5, 2018 at 9:01 AM, Santiago Pericas-Geertsen <santiago.pericasgeertsen@xxxxxxxxxx> wrote:
John,

 If the product that you’re using supports these technologies, the JAX-RS implementation must support those entity providers (as discussed in this thread). The term “support” really implies out of the box, without any manual registration steps.

— Santiago 


On Mar 4, 2018, at 9:44 PM, John D. Ament <john.d.ament@xxxxxxxxx> wrote:

Andy

So I think that partially answers what I'm looking for, though I'm thinking something in section 5 should call out whether or not these MBR's/MBW's are registered automatically or not (w/r/t to 11.2.6-7).

As I know you've noticed, there's no portable way to be made aware when a new client is created.  So as a result, the integration of such a component is non-portable, and thus makes the two not work well together.

You may want to pitch that other client feature you're working on over here.

John

On Sun, Mar 4, 2018 at 9:22 PM Andy McCright <j.andrew.mccright@xxxxxxxxx> wrote:
Hi John,

Section 4.2.4 lists the types that all JAX-RS implementations must handle out of the box. It also points to section 11.2.6-7 referring to JSON-P and JSON-B, but that section does seem to imply that these providers are only required if the implementation provides those APIs.  

So my opinion would be that all JAX-RS client implementations must handle the basic set of return types / media types, but the JSON support is optional - and thus non-portable.  That said, I think most of the major vendors support JSON-P/B, so the portability shouldn’t be too much of an issue.

Hope this helps,

Andy

On Sun, Mar 4, 2018 at 5:28 PM John D. Ament <john.d.ament@xxxxxxxxx> wrote:
Hi All,

I'm wondering, if anyone can give me some opinions.

When using JAX-RS Client API, there is no requirement for any providers to be registered by default when you invoke ClientBuilder.newClient() right?  e.g. its non-portable, platform specific if a JSON-B, JSON-P provider is registered right?

John
_______________________________________________
jaxrs-dev mailing list
jaxrs-dev@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/jaxrs-dev
_______________________________________________
jaxrs-dev mailing list
jaxrs-dev@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/jaxrs-dev
_______________________________________________
jaxrs-dev mailing list
jaxrs-dev@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/jaxrs-dev


_______________________________________________
jaxrs-dev mailing list
jaxrs-dev@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/jaxrs-dev



Back to the top