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

Re: Global post match ContainerRequestFilter and subresources

From: Sergey Beryozkin <sberyozkin_at_talend.com>
Date: Wed, 25 Mar 2015 13:06:58 +0000

The user has reported that his experiments with Jersey have shown that
in the below case Jersey invokes a global post-match
ContainerRequestFilter once but ContainerResponseFilter twice.

For the record, CXF invokes ContainerRequestFilter twice and
ContainerResponseFilter once.

I guess invoking a global ContainerResponseFilter twice in a case below
is consistent with my reasoning that such a filter has a wild-card
name-binding.

Should it be (as far as global request response filters are concerned in
the below example):

ContainerRequestFilter: twice
ContainerResponseFilter: twice

?

Cheers, Sergey

On 25/03/15 12:35, Sergey Beryozkin wrote:
> Hi All
>
> I've had a user query and I'm reviewing the documentation at [1] and I'm
> actually not sure if I understand it completely.
>
> Right now, CXF will run the same global post-match
> ContainerRequestFilter twice with the following service class:
>
> @Path("rs")
> public RSService {
> @Path("sub")
> public RSService sub() {
> return this;
> }
> @Path("resource")
> @GET
> public Response get() {
> //
> }
>
> }
>
> and
>
> GET /rs/sub/resource
>
> once for the sub() method, and once for the get() method.
>
> I vaguely suspect it might be wrong, but the docs at [1] mention that
> both resource and subresource methods can be invoked when Name Bindings
> are used and in case of a global filter it is effective a wildcard name
> binding.
>
> Marek, Santiago, can you please be nice (as you always are :-)) and
> clarify: how many times a global filter is expected to be called in the
> above case, 1 or 2 ?
>
> Thanks, Sergey
>
> [1]
> https://jax-rs-spec.java.net/nonav/2.0-rev-a/apidocs/javax/ws/rs/container/ContainerRequestFilter.html
>
>
>