users@jersey.java.net

[Jersey] Re: Equivalent of a Servlet Filter for Jersey / JAX-RS / REST resources?

From: Tatu Saloranta <tsaloranta_at_gmail.com>
Date: Thu, 5 Jan 2012 10:32:15 -0800

On Wed, Jan 4, 2012 at 10:11 PM, <agksmehx_at_gmail.com> wrote:
> In a regular Web Application, I can assign a chain of Filters to
> various paths for aspects such as Authentication, Authorization,
> Errors, Logging and more.
>
> The advantage is that I write servlets to focus on core functionality
> without worrying about infrastructure aspects. I can write orthogonal,
> cross-cutting Filters to authenticate, authorize, etc. Then I can weave
> them in web.xml. Looking at web.xml is enough to assure me that there
> are no holes in my application.
>
> Is this possible in JAX-RS or Jersey? If not, what is my best bet?

Aside from JAX-RS hooks, perhaps you should do this at "plain old
Servlet" level -- JAX-RS is hooked via Servlet API, and many of
cross-cutting concerns may be easier to tackle at that level.

-+ Tatu +-