users@jersey.java.net

Inject CDI/Web Bean into filter

From: John Lister <john.lister_at_kickstone.com>
Date: Thu, 08 Apr 2010 20:55:30 +0100

Hi, is it possible to inject a CDI/Web bean into a resource filter, the
reason I ask is that I am using a @SessionScoped bean to store data
across requests and would like to access this in a filter.

Originally I was injecting a HttpServletRequest into the constructor of
a filter factory and passing this reference to the filters as I created
them, which worked well. But I'd like to wrap the session stuff up using
CDI which seems much neater and I'm struggling. Injecting the bean into
the factory doesn't seem to work and as I create the filter I can't use
injection there...

Is this possible or am I going about it the wrong way? Suggestions


Thanks

John