users@jersey.java.net

Filter configuration feature

From: Craig Iverson <civy4fun_at_gmail.com>
Date: Tue, 21 Oct 2008 11:12:15 -0700

Paul,

That would work for me I believe. I wonder how the filters that are
annotated would work with the list described in the web.xml. Could
the ones in the web.xml be the default and only used if no filters
are annotated? Could you also support an empty list (@RequestFilters
({})) which would not apply any filters, not even the ones in the
web.xml. This would basically allow the exclude functionality I
would like.

I've seen lots of feedback on this issue so I'm not sure where your
opinions lie at this point. If you want I can open up a bug/feature
for this.

Craig

Date: Fri, 17 Oct 2008 09:44:42 +0200
From: Paul Sandoz <Paul.Sandoz_at_Sun.COM>
Content-type: text/plain; delsp=yes; format=flowed; charset=US-ASCII
Subject: [Jersey] Filter configuration feature


On Oct 16, 2008, at 6:50 PM, Craig Iverson wrote:

> First let me thank you for all the good work you guys are doing with
> jersey and jsr-311. It's been a pleasure to develop against.

Thanks!


>
> I have a feature request that I can add to the issue tracker if you
> agree.

Please. No need to ask permission to log issues :-)


> I think it would be great to be able to configure a filter per
> resource(s). In my case its even more than that, it would be more
> beneficial to also support an exclude list. I have a case where I
> only want certain filters applied to certain resources. I really
> want a couple of filters to always be applied except for on a couple
> of resources. The reason for the exclude list would allow other
> team members to add resources without worrying about configuring the
> filter for the new resource. Your thoughts?

Currently request and response filters are called before resource
matching is performed. Having filters apply to specific root resource
classes could also make sense, but i wonder if the exclude list
complicates matters, especially if there is more then one filter
present in the filter chain, rather than being explicit and describing
the list of resources with the list of filters e.g.

Map<List<Class<??>, List<ContainerRequestFilter>>

I am wondering if it is appropriate to have filters associated with
resources and resource methods configured from the resources
themselves. How about allowing the following:

@RequestFilters({A.class, B.class})
@Path("resource")
public class Resource {

@RequestFilters({C.class, D.class})
@GET
public String get() { ... }

@RequestFilters({E.class, F.class})
@Path("sub-resource")
public Object getSubResource() { ... }
}

Paul.

>
> Craig
>