users@jax-rs-spec.java.net

[jax-rs-spec users] [jsr339-experts] Re: Re: Fwd: [Resteasy-users] PostProcessInterceptors not invoked for responses created by ExceptionMappers

From: Bill Burke <bburke_at_redhat.com>
Date: Wed, 22 Aug 2012 11:59:05 -0400

On 8/15/2012 5:26 AM, Marek Potociar wrote:
> I checked the spec text and I think we should clarify this. But first we
> should agree on the general processing flow. Here's the my original idea
> about how it should work in various scenarios:
>
> *Definitions:*
>
> * pre-matching request filters
> o request filters annotated with @PreMatching, container-only
> * post-matching/bound request filters
> o global request filters (unbound) as well as any req. filters
> bound to the matched method, container-only
> * pre-matching response filters
> o response filters annotated with @PreMatching, container-only
> * post-matching/bound response filters
> o global response filters (unbound) as well as any response
> filters bound to the matched method, container-only
>

"global" and "resource method bound" response filters should be combined
and sorted based on BindingPriority. A Pre matching designation makes
sense for request filters as they may change the request before it
matches a method. For response filters it doesn't make sense and is
even error prone as you may have ordering issues.

So, if there was a match, generate a list of respponse filters and
writer interceptors based on the resource method match and sort them all
based on BindingPriority. If there is an abort/exceptiono in PreMatch
request filter, then response filter/writer interceptor lists are
generated based on no resource-method match.

>
> *Scenarios:*
>

Do we need a way to tell a filter that an error happened? Maybe
different callbacks?

ContainerResponseFilter {

    filter(...); // if resource method didn't throw exception
    applicationException(...);
    filterException(...);
    writerException(...);
}

Right now we don't have anything like that. We only run response
filters if there was a successful method invocation. Nor do we run
filters after Exceptionapper.

In all your examples, what I worry about is you have too many scenarios
a filter/interceptor developer has to code for.


Maybe this might simplify things?

If exception thrown from resource method
- ExceptioMapper
- response filters and interception if there is an entity.

If an exception thrown in response filter (or WriterInterceptor)
- ExceptionMapper
- no additional filtering or interception.

-- 
Bill Burke
JBoss, a division of Red Hat
http://bill.burkecentral.com