Type: New Feature
Affects Version/s: None
Fix Version/s: 2.0
(Email from Bill Burke, http://java.net/projects/jax-rs-spec/lists/jsr339-experts/archive/2011-03/message/9)
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.