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

[jsr339-experts] interceptors

From: Bill Burke <bburke_at_redhat.com>
Date: Fri, 04 Mar 2011 09:37:29 -0500

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.


-- 
Bill Burke
JBoss, a division of Red Hat
http://bill.burkecentral.com