jsr339-experts@jax-rs-spec.java.net

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

From: Santiago Pericas-Geertsen <Santiago.PericasGeertsen_at_oracle.com>
Date: Wed, 24 Oct 2012 14:57:25 -0400

Jan,

 If you haven't, please refer to the alias archive for the original discussions, I'm sure there are more examples there.

>> Here are some of the differences:
>>
>> (i) Clearly they are in different extension points in the pipeline
>
> Yes, however the respective extension points are adjacent and there is really nothing I can do in an interceptor I could not do at the filter extension point directly before the interceptor extension point.

 They are not always adjacent, consider the following:

 Response r = client.target(...).request().get(); // Filters called here
 callLongRunningMethod();
 Foo f = r.getEntity(Foo.class); // Interceptors called here

>
>> (ii) Interceptors are wrapping and can access the entity in marshalled and unmarshalled forms
>
> Filters can do that, too.

 That's not true. For example, a ContainerRequestFilter only has access to the unmarshalled form since it is executed before MBRs, which in turn, are executed only if needed.

>
>> (iii) ReaderInterceptors, just like MBRs, are called only if needed (based on application logic, for example, when Response.getEntity() is called on the client)
>
> This I do not understand. Can you explain further.

 See example above, and add a conditional around r.getEntity(Foo.class).

-- Santiago