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

[jsr339-experts] Re: interceptors

From: Roberto Chinnici <roberto.chinnici_at_oracle.com>
Date: Mon, 07 Mar 2011 14:49:27 -0800

  OK, this is sufficiently different from filters that it deserves its
own issue, so I created JAX_RS_SPEC-57 [1].

[1] http://java.net/jira/browse/JAX_RS_SPEC-57

On 3/4/11 6:37 AM, Bill Burke wrote:
> In resteasy, we found that Filters and CDI were not good enough for
> our needs of interception. We wanted to be able to trigger
> interceptions of the HTTP request at different points depending on
> what annotations were applied to a JAX-RS method.
>
> * We couldn't use Filter in many situations because there's no way to
> trigger/bind a Filter based on an annotation specified on a JAX-RS
> method.
>
> * I don't know if Servlet 3.0 fixed this, but originally, Filters
> didn't work with Async HTTP. Resteasy has Async HTTP integration of
> its own that we hope to standardize.
>
> * We couldn't use CDI because we needed different types of
> interception points were needed: Before the method was called or even
> matched (security). Or specific to (un)marshalling (wrapping
> MessageBodyReader/Writer invocations).
>
> * We wanted something that could be re-used on the client side.
>
> So, we defined 4 interception points:
>
> - Pre-process before matching
> - Around MessageBodyReader
> - Around MessageBodyWriter
> - After method was called before marshalling (not sure if we ever had
> a usecase for this)
>
> MessageBodyReader/Writer interception was used for things like: gzip
> encoding, digital signatures, caching. Many of these worked on both
> the client and server side.
>
> pre-process interception was used for: caching, security plugins.
>
>