开发者

Transaction-per-request and Jersey

I'd like to implement transaction-per-request in conjunction with Jersey resources. By that, I just mean I want开发者_如何学编程 a single place to manage transactions, something like:

try {
  chain.doFilter(request, response);
  commitSession();
} finally {
  rollbackSession(); // no-op if already committed
  closeSession();
}      

In the past, I've done similar things with Servlet Filters, but that won't work in Jersey. In Jersey , the exception is intercepted and converted into a 500 long before web container Filters regain control. I suppose I could stick w/ the Filter approach, and check response codes, but that's not very appealing. I've seen a couple conversations about this, but I've been unable to come up with a solid approach using ResourceFilter, CloseableService, or ServletContainer, etc. My terrible solution so far has been to do implement a custom ExceptionMapper and perform a rollback there. Has anyone solved this cleanly?

Disclaimer - this project currently doesn't use Spring, so I'd rather avoid it for this small use case.


No Jersey love, eh?

http://markmail.org/thread/orcctyu7hczx3d5w

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜