users@jax-rs-spec.java.net

[jax-rs-spec users] [jsr339-experts] Re: Interceptor Invocation and CDI

From: Jan Algermissen <jan.algermissen_at_nordsc.com>
Date: Wed, 24 Oct 2012 10:11:47 +0200

On Oct 23, 2012, at 9:55 PM, Santiago Pericas-Geertsen <Santiago.PericasGeertsen_at_oracle.com> wrote:

> Jan,
>
> Interesting questions. Here's my take on them:
>
>> For example, if using
>>
>> @Inject Instance<MessageBodyReader> mbrs;
>>
>> for(MessageBodyReader mbr : mbrs) {
>> if(mbr.canRead( ... ) ) {
>> someObject = mbr.readFrom( ... )
>> }
>> }
>>
>> is the expectation that any applicable JAX-RS interceptors are invoked?
>
> I don't think so. JAX-RS entity interceptors are not method interceptors, they are part of the JAX-RS processing pipeline. For method interceptors, use CDI.

Does that apply to injection vie @Context Providers.. , too? Is ist also desired behavior that interceptors are also not called when JAX-RS injection is used?

If so, I wonder what is the reason for having interceptors at all since the same things can be done with filters.

What is it that can be done with interceptors that cannot be done with filters?

Jan






>
>>
>> What about ordering/interference with CDI Interceptors?
>
> For example CDI interceptor(s) for readFrom()? They should be called after the entity interceptors (in the normal processing pipeline), when JAX-RS calls the CDI bean method. Their ordering, if there's more than one, should be defined by the CDI spec (which I believe they are doing now).
>
> -- Santiago
>