jsr339-experts@jax-rs-spec.java.net

[jsr339-experts] Are name-bound container filters executed twice ?

From: Sergey Beryozkin <sberyozkin_at_talend.com>
Date: Thu, 6 Sep 2012 10:45:16 +0100

Hi,

Here is the ContainerRequestFilter documentation fragment:

"By default, i.e. if no name binding is applied to the filter
implementation class, the filter instance is applied globally, however
only after the incoming request has been matched to a particular
resource by JAX-RS runtime. If there is a @NameBinding annotation
applied to the filter, the filter will *also* be executed at the
post-match request extension point, but only in case the matched
resource or sub-resource method is bound to the same name-binding
annotation. "

Note I highlighted 'also'.

That means to me that if we have @Logged attached to a given
ContainerRequestFilter and also to some request method, then we get this
request filter executed twice, once after a root resource has been
selected, and once - after the matching request method has been selected.

Is it really what we want ?

I think that if we have a name-bound filter then it should only be
executed whenever a selected resource method has the same name binding.

Thanks, Sergey