users@jersey.java.net

Re: [Jersey] programmatically config jersey filter

From: Paul Sandoz <Paul.Sandoz_at_oracle.com>
Date: Tue, 3 Aug 2010 10:14:04 +0200

Hi Yoryos,

Try:

   rc.getFeatures().put(DefaultResourceConfig.FEATURE_REDIRECT, true);

When defined as servlet/flter init params jersey will add all params
as properties and also go through all the params whose values are true/
false and add them as features.

I agree this is confusing. What we should do is convert all properties
to features at the resource config level. Can you log an issue?

Thanks,
Paul.


On Aug 2, 2010, at 9:26 PM, Yoryos wrote:

> Hi all,
> is there a way to pragmatically config jersey filter? As I've seen
> on the docs overriding the ServletContainer#initiate method should
> do the trick but as I've seen I can not put there any king of
> properties. I've overridden it to something like that:
>
> @Override
> protected void initiate(ResourceConfig rc, WebApplication wa) {
> rc.getProperties().put(DefaultResourceConfig.FEATURE_REDIRECT,
> "true");
> String[] filters = new String[]
> {ResourceDebuggingFilterFactory.class.getName()};
> rc
> .getProperties
> ().put(DefaultResourceConfig.PROPERTY_RESOURCE_FILTER_FACTORIES,
> filters);
> System.out.println(rc.getProperties());
> super.initiate(rc, wa);
> }
>
> From the method above, the filter factories seems to work just fine
> but the redirect future not. If I comment out the redirect feature
> and put it as a filter's init-param it will work just fine. In both
> cases I see all the properties defined just fine (from the
> System.out.println)
>
>