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

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

From: Markus KARG <markus_at_headcrashing.eu>
Date: Tue, 23 Oct 2012 23:34:42 +0200

I have to object due "to formal reasons", since this restriction is not told
in the current spec draft. I literally says:

"Entity interceptors wrap calls to the methods readFrom in classes
implementing MessageBodyReader and writeTo in classes implementing
MessageBodyWriter."

There is nothing told that this is true only for particular uses of the MBRs
and MBWs.

So a reader of the specification will assume that actually all entity
interceptors of that code example are really invoked! If that is not wanted
(what I think would be a pity since it reduces the usability of entity
interceptors) then the specification must clearly say that.

Jan, what I actually expect from you now is the question that you asked me
yesterday... ;-) (damned, this could be interpreted as humor which i
wanted to abstain, sorry for that)

Regards
Markus

> -----Original Message-----
> From: Santiago Pericas-Geertsen
> [mailto:Santiago.PericasGeertsen_at_oracle.com]
> Sent: Dienstag, 23. Oktober 2012 21:55
> To: jsr339-experts_at_jax-rs-spec.java.net
> Subject: [jsr339-experts] Re: [jax-rs-spec users] Interceptor
> Invocation and CDI
>
> 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.
>
> >
> > 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