users@jersey.java.net

more about resource filters

From: Brian Moseley <bcm_at_maz.org>
Date: Thu, 29 Jul 2010 14:02:25 -0400

a few more questions about resource filters:

when a filter is applied to a resource class via @ResourceFilters, is
the filter instance obtained from the IoC container, or is it
instantiated directly? signs point to the latter - I'm using Spring,
and my filter class has a field annotated with @Autowired. at runtime
that field is null, ie the dependency was not injected.

by snooping around in the code of various filters included in Jersey,
it looks like @Context is supported for filter factories at least.
presuming that is also true for filters themselves, then I could
inject the servlet context, use it to find the Spring application
context, and look up the bean myself, but obviously I'd prefer not to
have to do that.

also, I find that @ResourceFilters isn't recognized by the runtime if
I apply it to a trait and mix that trait into my resource class. the
annotation is only recognized when I apply it directly to the resource
class. is this by design or have I uncovered a bug?

I've searched a lot and haven't found many resources describing how
resource filters work other than the javadoc for the
com.sun.jersey.api.container.filter package and a few messages on this
list. has more been written about them elsewhere?

thanks!