On Jun 11, 2009, at 12:58 PM, Martin Probst wrote:
>> By the component that performs the commit or rollback, that same
>> component
>> that checks for the response state. Then you can check if the
>> exception was
>> mapped and if so what the type of the exception was.
>
> Could you sketch some sample code? Will this be a JerseyFilter or
> something similar? Or are you thinking of a ContainerResponseFilter?
> But that won't work as it is now, because of course the response
> filters happen before the response is written.
A Jersey container or resource filter is not appropriate because an
exception thrown by a response filter will break the response filter
chain. I designed the filters so that are not stack based.
I was thinking of the Closeable instance registered when the session
is created.
public class SessionCloseable implements Closeable() {
HttpContext hc;
Session s;
SessionCloseable(HttpContext hc, Session s) {
this.hc = hc;
this.s = s;
}
public void close() {
ResponseState rs = hc.getResponse.getState();
Object o = hc.getProperties.get("mapped.exception);
// Check rs and o to work out whether to commit or roll back.
}
}
Paul.