Title: [2580] trunk/openejb3/container/openejb-core/src/main/java/org/openejb/core/stateful: Port context usage from 1.x branch.
- Revision
- 2580
- Author
- dblevins
- Date
- 2006-03-23 21:08:41 -0500 (Thu, 23 Mar 2006)
Log Message
Port context usage from 1.x branch. Allows for wrapped containers.
Modified Paths
Diff
Modified: trunk/openejb3/container/openejb-core/src/main/java/org/openejb/core/stateful/StatefulBeanManagedTxPolicy.java (2579 => 2580)
--- trunk/openejb3/container/openejb-core/src/main/java/org/openejb/core/stateful/StatefulBeanManagedTxPolicy.java 2006-03-24 02:07:44 UTC (rev 2579)
+++ trunk/openejb3/container/openejb-core/src/main/java/org/openejb/core/stateful/StatefulBeanManagedTxPolicy.java 2006-03-24 02:08:41 UTC (rev 2580)
@@ -14,8 +14,6 @@
public class StatefulBeanManagedTxPolicy extends TransactionPolicy {
- protected StatefulContainer statefulContainer;
-
public StatefulBeanManagedTxPolicy(TransactionContainer container) {
this();
if (container instanceof org.openejb.Container &&
@@ -23,8 +21,6 @@
throw new IllegalArgumentException();
}
this.container = container;
- this.statefulContainer = (StatefulContainer) container;
-
}
public StatefulBeanManagedTxPolicy() {
@@ -38,10 +34,13 @@
public void beforeInvoke(EnterpriseBean instance, TransactionContext context) throws org.openejb.SystemException, org.openejb.ApplicationException {
try {
+ StatefulInstanceManager instanceManager = (StatefulInstanceManager) context.context.get(StatefulInstanceManager.class);
+ // if no transaction ---> suspend returns null
context.clientTx = suspendTransaction(context);
+ // Get any previously started transaction
Object primaryKey = context.callContext.getPrimaryKey();
- Object possibleBeanTx = statefulContainer.getInstanceManager().getAncillaryState(primaryKey);
+ Object possibleBeanTx = instanceManager.getAncillaryState( primaryKey );
if (possibleBeanTx instanceof Transaction) {
context.currentTx = (Transaction) possibleBeanTx;
resumeTransaction(context, context.currentTx);
@@ -67,7 +66,8 @@
}
Object primaryKey = context.callContext.getPrimaryKey();
- statefulContainer.getInstanceManager().setAncillaryState(primaryKey, context.currentTx);
+ StatefulInstanceManager instanceManager = (StatefulInstanceManager) context.context.get(StatefulInstanceManager.class);
+ instanceManager.setAncillaryState( primaryKey, context.currentTx );
} catch (org.openejb.OpenEJBException e) {
handleSystemException(e.getRootCause(), instance, context);
Modified: trunk/openejb3/container/openejb-core/src/main/java/org/openejb/core/stateful/StatefulContainer.java (2579 => 2580)
--- trunk/openejb3/container/openejb-core/src/main/java/org/openejb/core/stateful/StatefulContainer.java 2006-03-24 02:07:44 UTC (rev 2579)
+++ trunk/openejb3/container/openejb-core/src/main/java/org/openejb/core/stateful/StatefulContainer.java 2006-03-24 02:08:41 UTC (rev 2580)
@@ -151,7 +151,7 @@
TransactionPolicy txPolicy = callContext.getDeploymentInfo().getTransactionPolicy(callMethod);
TransactionContext txContext = new TransactionContext(callContext, getTransactionManager());
-
+ txContext.context.put(StatefulInstanceManager.class, instanceManager);
try {
txPolicy.beforeInvoke(bean, txContext);
} catch (org.openejb.ApplicationException e) {
Modified: trunk/openejb3/container/openejb-core/src/main/java/org/openejb/core/transaction/TransactionContext.java (2579 => 2580)
--- trunk/openejb3/container/openejb-core/src/main/java/org/openejb/core/transaction/TransactionContext.java 2006-03-24 02:07:44 UTC (rev 2579)
+++ trunk/openejb3/container/openejb-core/src/main/java/org/openejb/core/transaction/TransactionContext.java 2006-03-24 02:08:41 UTC (rev 2580)
@@ -5,11 +5,15 @@
import org.openejb.core.ThreadContext;
+import java.util.Map;
+import java.util.HashMap;
+
public class TransactionContext {
public Transaction clientTx;
public Transaction currentTx;
public ThreadContext callContext;
+ public final Map context = new HashMap();
private final TransactionManager transactionManager;