users@jersey.java.net

Resource Filter Factory injectables

From: John Lister <john.lister_at_kickstone.com>
Date: Sun, 11 Apr 2010 20:32:42 +0100

Hi, I'm trying to create a resource filter by using a factory that
determines which filter is required based on a number of factors but
struggling with one issue.

Because I create the filter objects in the factory class using new, I
cannot use any injectable content within them, to get around this I'm
injecting some things into the factory object and passing them as
parameters to the filter classes. However I'm struggling to find a way
to inject some types of content and wondered if any one can give me any
advice. For example I would like to inject a @SessionScoped (or
RequestScoped) bean and additionally an EntityManager but when I do
using either Inject or Context I get nulls.

To get around this at the minute I have a global resource filter that I
can inject things into with no problems and I'm setting attributes on a
HttpServletRequest object and retrieving them within the factory
generated filters.

Any ideas?

Thanks

John