On Mar 23, 2009, at 8:05 PM, Erdinc Yilmazel wrote:
> Hi,
>
> Is there a way of registering a ResourceFilterFactory class using
> Jersey API instead of declaring an init param in web.xml?
Yes.
You can set the list of filters using the ResourceConfig properties,
see:
https://jersey.dev.java.net/source/browse/*checkout*/jersey/tags/jersey-1.0.2/api/jersey/com/sun/jersey/api/core/ResourceConfig.html
#PROPERTY_RESOURCE_FILTER_FACTORIES
The only thing you should be careful of is when you want to add
filters programatically *and* declaratively in the web.xml as the
property will already be set to a String value.
We probably need some normalizing functionality of ResourceConfig to
normalize such properties into canonical form e.g. List<?> before
configuration of the Servlet.
BTW it is not necessary to override Servlet to obtain this
functionality. You can override say PackagesResourceConfig for
registration purposes.
Paul.
> I am using a
> custom servlet filter which extends ServletContainer. I am overriding
> some of ServletContainer's methods. I am trying to register a
> ResourceFilterFactory class in configure(FilterConfig fc,
> ResourceConfig rc, WebApplication wa) method. Neither WebApplication
> interface nor ResourceConfig class allow me to add a
> ResourceFilterFactory class. And the FilterFactory class is declared
> final.
>