cxf-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Eirik Bjørsnøs <eir...@gmail.com>
Subject Re: Using Interceptors on JAX-RS 2.0 Client
Date Wed, 23 Mar 2016 16:40:47 GMT
Sergey,

Our observation (with 3.0.3 I think) was that the feature was not ignored,
but instead initialized once per request. Which added new interceptors to
the WebClient on every request. Not sure I understand the intention behind
this design.

I think I just assumed that I could use Interceptors for JAX-RS clients
just like JAX-WS.

We could and probably will rewrite these to JAX-RS filters, but it would of
course be even sweeter if we could simply reuse the logging interceptors we
currently use for our SOAP services.

Cheers,
Eirik.
On Mar 22, 2016 10:08 AM, "Sergey Beryozkin" <sberyozkin@gmail.com> wrote:

> Hi
>
> It is not possible to register CXF specific Feature or Interceptor
> with JAX-RS 2.0 Client API.
>
> When you do "client.register(new MyLoggingFeature())", assuming it is CXF
> Feature, then it will be currently ignored.
>
> I wonder if it might make sense to create some JAX-RS 2.0 FeatureWrapper
> which can wrap an arbitrary CXF Feature...I'll try to experiment with it...
>
> Sergey
>
>
>
> On 22/03/16 01:56, Eirik Bjørsnøs wrote:
>
>> Hello,
>>
>> Is the CXF implementation of the JAX-RS 2.0 client API designed to allow
>> Interceptors to be configured on Clients? If so, how should this be done?
>>
>> Say we have a Client built like this:
>>
>>     Client client = ClientBuilder.newClient();
>>
>> and we want to configure Logging[In/Out]Interceptors of this client. (Just
>> as an example).
>>
>> First I tried in various ways to get an Endpoint out of the client, but
>> failed at that.
>>
>> Then, after looking through the implementation classes of
>> Client/WebTarget,
>> I discovered that you can register CXF Features on a Client using
>> something
>> like
>>
>>      client.register(new MyLoggingFeature());
>>
>> However, with this setup MyLoggingFeature.initialize(InterceptorProvider
>> ip, Bus bus) is called _once per request_.
>>
>> Not exactly what I wanted since it lead to the interceptor chains being
>> filled up with duplicate LoggingInterceptors.
>>
>> I might perhaps have misunderstood the lifecycle of Clients and/or
>> WebTargets. Should be ok to reuse a JAX-RS 2.0 Client, right?
>>
>> Can someone please enlighten me? Did I perhaps miss some relevant
>> documentation?
>>
>> Cheers,
>> Eirik.
>>
>>
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message