users@jersey.java.net

Filters

From: Fabio Mancinelli <fabio.mancinelli_at_gmail.com>
Date: Fri, 6 Feb 2009 18:47:59 +0100

Dear all,

I am stuck with the following problem: I would like to implement a
"setup/cleanup" filter that, before calling any resource, must do the
following

1) Perform some initializations
2) Make some environment objects available to the resource that will
be called after.
3) Cleanup after the request has been served (no matter what, even if
exceptions are thrown, a bit like a finally)

I looked at the examples and there is an AuthFilter that performs
authentication and it stores the authenticated user in a public static
variable of a base class for all the resources. As the comment says
"This is a pretty smelly way to transfer information from an
authentication filter to the corresponding request"

So I was wondering if there was some other ways for doing this kind of things.

Thanks for your help,
Fabio