Filter and interceptors

JAX-RS 2.0 added ContainerRequestFilter and ContainerResponseFilter to modify the request context. It is executed around the method invocation but has already passed the method resolution. On a high level, it can be seen as a CDI interceptor but only at the HTTP layer. These filters do not impact significantly the performance until they do a lot of logic, and there are a few cases where it is a good place to put some logic. One very common example is to validate a security token or log in a user based on the HTTP headers. Don't be surprised to see this kind of component while investigating what your application is doing.

In the same spirit, ReaderInterceptor and WriterInterceptor intercept MessageBodyReader or MessageBodyWriter ...

Get Java EE 8 High Performance now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.