users@jax-rs-spec.java.net

[jax-rs-spec users] [jsr339-experts] Re: Interceptors vs composite MBR and MBW

From: Marek Potociar <marek.potociar_at_oracle.com>
Date: Tue, 15 May 2012 10:50:10 +0200

On May 14, 2012, at 10:39 PM, Sergey Beryozkin wrote:

> Hi
>
> Composite Message Body Readers and Writers are the ones that can use an injected Providers interface to delegate to the 'real' readers or writers.
>
> I can see that reader and writer interceptors can be useful additions.
> However, IMHO, there needs to be a clear recommendation on when the interceptors should be preferred to the composite MBR/MBW or vice versa

I can see that some use cases of composite entity providers could be solved by interceptors.

> .
>
> At the moment I see the only limitation of composite MBRs & MBWs compared to reader/writer interceptors is that the former has no a standard mechanism for exchanging the properties with filters.
>
> Is it what others see too ? Anything else that I've missed ?

I think that another significant difference is that in a composite entity provider you need to manually select the proper (leaf) entity provider to which you eventually delegate the (de)serialization work. In interceptors this selection is done "for free" by the JAX-RS runtime.

Also, implementing a generic composite entity provider in a way that it is always guaranteed to kick in when necessary, but at the same time does not interfere with other providers if not needed is quite tough due to the JAX-RS entity provider selection algorithm.

Marek

>
> Thanks, Sergey