dain 2005/03/01 18:34:35
Modified: modules/core/src/java/org/openejb/transaction
BeanPolicy.java ContainerPolicy.java
Log:
Changed to use new TransactionManagerContext methods managing bean
transactions
Fixed improper handling of bean transactions in StatefulInstanceInterceptor
Removed excessive handling of bean transactions in the SFSB and SLSB vops
Revision Changes Path
1.10 +11 -9
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.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- BeanPolicy.java 25 Feb 2005 23:06:13 -0000 1.9
+++ BeanPolicy.java 1 Mar 2005 23:34:34 -0000 1.10
@@ -53,7 +53,6 @@
import org.apache.geronimo.core.service.InvocationResult;
import org.apache.geronimo.transaction.context.TransactionContext;
import org.apache.geronimo.transaction.context.TransactionContextManager;
-import org.apache.geronimo.transaction.context.UnspecifiedTransactionContext;
import org.openejb.EJBInvocation;
/**
@@ -69,7 +68,7 @@
clientContext.suspend();
}
try {
- UnspecifiedTransactionContext beanContext =
transactionContextManager.newUnspecifiedTransactionContext();
+ TransactionContext beanContext =
transactionContextManager.newUnspecifiedTransactionContext();
ejbInvocation.setTransactionContext(beanContext);
try {
InvocationResult result = interceptor.invoke(ejbInvocation);
@@ -78,12 +77,15 @@
}
return result;
} catch (Throwable t) {
- try {
- if (beanContext !=
transactionContextManager.getContext()) {
- transactionContextManager.getContext().rollback();
+ TransactionContext currentContext =
transactionContextManager.getContext();
+ if (currentContext.isActive()) {
+ try {
+ if (beanContext != currentContext) {
+ currentContext.rollback();
+ }
+ } catch (Exception e) {
+ log.warn("Unable to roll back", e);
}
- } catch (Exception e) {
- log.warn("Unable to roll back", e);
}
beanContext.setRollbackOnly();
throw t;
@@ -93,7 +95,7 @@
} finally {
ejbInvocation.setTransactionContext(clientContext);
transactionContextManager.setContext(clientContext);
- if (clientContext != null) {
+ if (clientContext != null) {
clientContext.resume();
}
}
1.10 +10 -13
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.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- ContainerPolicy.java 25 Feb 2005 23:06:15 -0000 1.9
+++ ContainerPolicy.java 1 Mar 2005 23:34:35 -0000 1.10
@@ -57,11 +57,8 @@
import org.apache.commons.logging.LogFactory;
import org.apache.geronimo.core.service.Interceptor;
import org.apache.geronimo.core.service.InvocationResult;
-import org.apache.geronimo.transaction.context.InheritableTransactionContext;
import org.apache.geronimo.transaction.context.TransactionContext;
import org.apache.geronimo.transaction.context.TransactionContextManager;
-import org.apache.geronimo.transaction.context.ContainerTransactionContext;
-import org.apache.geronimo.transaction.context.UnspecifiedTransactionContext;
import org.openejb.EJBInvocation;
/**
@@ -86,7 +83,7 @@
callerContext.suspend();
}
try {
- UnspecifiedTransactionContext beanContext =
transactionContextManager.newUnspecifiedTransactionContext();
+ TransactionContext beanContext =
transactionContextManager.newUnspecifiedTransactionContext();
ejbInvocation.setTransactionContext(beanContext);
try {
InvocationResult result =
interceptor.invoke(ejbInvocation);
@@ -116,7 +113,7 @@
private static final class TxRequired implements TransactionPolicy {
public InvocationResult invoke(Interceptor interceptor,
EJBInvocation ejbInvocation, TransactionContextManager
transactionContextManager) throws Throwable {
TransactionContext callerContext =
transactionContextManager.getContext();
- if (callerContext instanceof InheritableTransactionContext) {
+ if (callerContext != null && callerContext.isInheritable()) {
try {
ejbInvocation.setTransactionContext(callerContext);
return interceptor.invoke(ejbInvocation);
@@ -137,7 +134,7 @@
callerContext.suspend();
}
try {
- ContainerTransactionContext beanContext =
transactionContextManager.newContainerTransactionContext();
+ TransactionContext beanContext =
transactionContextManager.newContainerTransactionContext();
ejbInvocation.setTransactionContext(beanContext);
try {
InvocationResult result =
interceptor.invoke(ejbInvocation);
@@ -174,7 +171,7 @@
private static final class TxSupports implements TransactionPolicy {
public InvocationResult invoke(Interceptor interceptor,
EJBInvocation ejbInvocation, TransactionContextManager
transactionContextManager) throws Throwable {
TransactionContext callerContext =
transactionContextManager.getContext();
- if (callerContext instanceof InheritableTransactionContext) {
+ if (callerContext != null && callerContext.isInheritable()) {
try {
ejbInvocation.setTransactionContext(callerContext);
return interceptor.invoke(ejbInvocation);
@@ -195,7 +192,7 @@
callerContext.suspend();
}
try {
- UnspecifiedTransactionContext beanContext =
transactionContextManager.newUnspecifiedTransactionContext();
+ TransactionContext beanContext =
transactionContextManager.newUnspecifiedTransactionContext();
ejbInvocation.setTransactionContext(beanContext);
try {
InvocationResult result =
interceptor.invoke(ejbInvocation);
@@ -231,7 +228,7 @@
callerContext.suspend();
}
try {
- ContainerTransactionContext beanContext =
transactionContextManager.newContainerTransactionContext();
+ TransactionContext beanContext =
transactionContextManager.newContainerTransactionContext();
ejbInvocation.setTransactionContext(beanContext);
try {
InvocationResult result =
interceptor.invoke(ejbInvocation);
@@ -270,7 +267,7 @@
TransactionContext callerContext =
transactionContextManager.getContext();
// If we don't have a transaction, throw an exception
- if (!(callerContext instanceof InheritableTransactionContext)) {
+ if (callerContext == null || !callerContext.isInheritable()) {
if (ejbInvocation.getType().isLocal()) {
throw new TransactionRequiredLocalException();
} else {
@@ -307,7 +304,7 @@
TransactionContext callerContext =
transactionContextManager.getContext();
// If we have a transaction, throw an exception
- if (callerContext instanceof InheritableTransactionContext) {
+ if (callerContext != null && callerContext.isInheritable()) {
if (ejbInvocation.getType().isLocal()) {
throw new TransactionNotSupportedLocalException();
} else {
@@ -319,7 +316,7 @@
callerContext.suspend();
}
try {
- UnspecifiedTransactionContext beanContext =
transactionContextManager.newUnspecifiedTransactionContext();
+ TransactionContext beanContext =
transactionContextManager.newUnspecifiedTransactionContext();
ejbInvocation.setTransactionContext(beanContext);
try {
InvocationResult result =
interceptor.invoke(ejbInvocation);