OpenSessionInView Interceptor Best Practice?
SchottenHammel <[email protected]> Sat, 23 Dec 2006 05:41:18 CST
| Newsgroups | gmane.comp.java.open-symphony.webwork |
|---|---|
| Message-ID | <2442388.1166874108332.JavaMail.os-j2ee@opensymphony01.managed.contegix.com> |
Hi there,
I just wrote my own OpenSessionInView Interceptor, that starts JTA Usertransactions (before) and commits them (after). I was just wondering if it is the right way to write it, especially in regards to exception handling or if there's a better way?
public String intercept(ActionInvocation invocation) throws Exception {
String result = null;
try {
jotm.begin();
result = invocation.invoke();
jotm.commit();
}
catch (RuntimeException ex) {
try {
jotm.rollback();
}
catch (Exception rbEx) {
System.err.println("Could not rollback transaction after exception! - " + rbEx);
}
throw ex;
}
return result;
---------------------------------------------------------------------
Posted via Jive Forums
http://forums.opensymphony.com/thread.jspa?threadID=55000&messageID=109890#109890