users@jersey.java.net

Re: [Jersey] programmatically config jersey filter

From: James Strachan <james.strachan_at_gmail.com>
Date: Tue, 3 Aug 2010 09:35:42 +0100

On 2 August 2010 20:26, Yoryos <valotas_at_gmail.com> 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)


As an aside you can configure Jersey inside your IoC container

e.g. here's how I configure Jersey (and the Scalate servlets) using
guice-servlet...

http://github.com/scalate/scalate/blob/master/scalate-guice/src/main/scala/org/fusesource/scalate/guice/ScalateModule.scala

-- 
James
-------
http://macstrac.blogspot.com/
Open Source Integration
http://fusesource.com/