users@jersey.java.net

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

From: <agksmehx_at_gmail.com>
Date: Thu, 5 Jan 2012 23:13:22 +0000 (GMT)

Thank you Marshall and Tatu for your excellent responses! :-)

I had an additional idea last night, which seems to have the benefit of
being JAX-RS standard:

The constructor for a Resource is ordinarily invoked on a per-request
basis prior to any method that handles a request for it, yielding way
to hook in-bound filter logic at a coarser granularity than a method
(but finer than a urlPatterns specification).

When a Resource constructor is not invoked on a per-request basis, it
is because a method of another Resource is responsible for its
lifecycle, and the constructor for that Resource is invoked on a
per-request basis. Also, in this case the method itself which is
managing the lifecycle for the Resource is itself another hook for
filter logic (both in-bound and out-bound) at a granularity coarser
than a method but finer than a urlPatterns specification.

Any opinion on this approach?