dain 2005/02/25 18:06:15
Modified: modules/core/src/java/org/openejb/transaction
BeanPolicy.java ContainerPolicy.java
Log:
Added support for in-tx cacheing back in
This unturned a load of places that were not handling transaction contexts
properly and bugs in the context itself
Changed instance contexts so they track entrancy and can be killed as
required by the spec
Made all instance context fields final
Revision Changes Path
1.9 +4 -7
openejb/modules/core/src/java/org/openejb/transaction/BeanPolicy.java
Index: BeanPolicy.java
===================================================================
RCS file:
/home/projects/openejb/scm/openejb/modules/core/src/java/org/openejb/transaction/BeanPolicy.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- BeanPolicy.java 16 Feb 2005 00:09:23 -0000 1.8
+++ BeanPolicy.java 25 Feb 2005 23:06:13 -0000 1.9
@@ -76,7 +76,6 @@
if (beanContext != transactionContextManager.getContext()) {
throw new UncommittedTransactionException();
}
- beanContext.commit();
return result;
} catch (Throwable t) {
try {
@@ -86,12 +85,10 @@
} catch (Exception e) {
log.warn("Unable to roll back", e);
}
- try {
- beanContext.rollback();
- } catch (Exception e) {
- log.warn("Unable to roll back", e);
- }
+ beanContext.setRollbackOnly();
throw t;
+ } finally {
+ beanContext.commit();
}
} finally {
ejbInvocation.setTransactionContext(clientContext);
1.9 +19 -32
openejb/modules/core/src/java/org/openejb/transaction/ContainerPolicy.java
Index: ContainerPolicy.java
===================================================================
RCS file:
/home/projects/openejb/scm/openejb/modules/core/src/java/org/openejb/transaction/ContainerPolicy.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- ContainerPolicy.java 16 Feb 2005 00:09:23 -0000 1.8
+++ ContainerPolicy.java 25 Feb 2005 23:06:15 -0000 1.9
@@ -90,17 +90,12 @@
ejbInvocation.setTransactionContext(beanContext);
try {
InvocationResult result =
interceptor.invoke(ejbInvocation);
- beanContext.commit();
return result;
- } catch (RollbackException re) {
- throw re;
} catch (Throwable t) {
- try {
- beanContext.rollback();
- } catch (Exception e) {
- log.warn("Unable to roll back", e);
- }
+ beanContext.setRollbackOnly();
throw t;
+ } finally {
+ beanContext.commit();
}
} finally {
ejbInvocation.setTransactionContext(null);
@@ -126,7 +121,7 @@
ejbInvocation.setTransactionContext(callerContext);
return interceptor.invoke(ejbInvocation);
} catch (Throwable t){
- ((InheritableTransactionContext)
callerContext).setRollbackOnly();
+ callerContext.setRollbackOnly();
if (ejbInvocation.getType().isLocal()) {
throw new
TransactionRolledbackLocalException().initCause(t);
} else {
@@ -146,17 +141,18 @@
ejbInvocation.setTransactionContext(beanContext);
try {
InvocationResult result =
interceptor.invoke(ejbInvocation);
- beanContext.commit();
return result;
} catch (RollbackException re) {
throw re;
} catch (Throwable t) {
try {
- beanContext.rollback();
+ beanContext.setRollbackOnly();
} catch (Exception e) {
log.warn("Unable to roll back", e);
}
throw t;
+ } finally {
+ beanContext.commit();
}
} finally {
ejbInvocation.setTransactionContext(null);
@@ -183,7 +179,7 @@
ejbInvocation.setTransactionContext(callerContext);
return interceptor.invoke(ejbInvocation);
} catch (Throwable t){
- ((InheritableTransactionContext)
callerContext).setRollbackOnly();
+ callerContext.setRollbackOnly();
if (ejbInvocation.getType().isLocal()) {
throw new
TransactionRolledbackLocalException().initCause(t);
} else {
@@ -203,17 +199,12 @@
ejbInvocation.setTransactionContext(beanContext);
try {
InvocationResult result =
interceptor.invoke(ejbInvocation);
- beanContext.commit();
return result;
- } catch (RollbackException re) {
- throw re;
} catch (Throwable t) {
- try {
- beanContext.rollback();
- } catch (Exception e) {
- log.warn("Unable to roll back", e);
- }
+ beanContext.setRollbackOnly();
throw t;
+ } finally {
+ beanContext.commit();
}
} finally {
ejbInvocation.setTransactionContext(null);
@@ -244,17 +235,18 @@
ejbInvocation.setTransactionContext(beanContext);
try {
InvocationResult result =
interceptor.invoke(ejbInvocation);
- beanContext.commit();
return result;
} catch (RollbackException re) {
throw re;
} catch (Throwable t) {
try {
- beanContext.rollback();
+ beanContext.setRollbackOnly();
} catch (Exception e) {
log.warn("Unable to roll back", e);
}
throw t;
+ } finally {
+ beanContext.commit();
}
} finally {
ejbInvocation.setTransactionContext(null);
@@ -290,7 +282,7 @@
ejbInvocation.setTransactionContext(callerContext);
return interceptor.invoke(ejbInvocation);
} catch (Throwable t) {
- ((InheritableTransactionContext)
callerContext).setRollbackOnly();
+ callerContext.setRollbackOnly();
if (ejbInvocation.getType().isLocal()) {
throw new
TransactionRolledbackLocalException().initCause(t);
} else {
@@ -331,17 +323,12 @@
ejbInvocation.setTransactionContext(beanContext);
try {
InvocationResult result =
interceptor.invoke(ejbInvocation);
- beanContext.commit();
return result;
- } catch (RollbackException re) {
- throw re;
} catch (Throwable t) {
- try {
- beanContext.rollback();
- } catch (Exception e) {
- log.warn("Unable to roll back", e);
- }
+ beanContext.setRollbackOnly();
throw t;
+ } finally {
+ beanContext.commit();
}
} finally {
ejbInvocation.setTransactionContext(null);