users@jersey.java.net

Re: [Jersey] programmatically config jersey filter

From: Yoryos <valotas_at_gmail.com>
Date: Tue, 3 Aug 2010 12:08:33 +0300

Hi Paul,
thank you for your quick response. I've logged an issue (
https://jersey.dev.java.net/issues/show_bug.cgi?id=565). I don not know if
implementing a "central configuration map" could be avoided by a better
documentation on how to use the ResourceConfig.

By the way is there a place to have jersey's all configuration parameters
available? For example I see that some configurations attributes are defined
within the ServletContainer class and some others in ResourceConfig.

On Tue, Aug 3, 2010 at 11:14, Paul Sandoz <Paul.Sandoz_at_oracle.com> wrote:

> 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)
>>
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>
>