You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tomee.apache.org by da...@apache.org on 2008/08/25 04:39:08 UTC
svn commit: r688602 [2/5] - in /openejb/trunk/openejb3:
assembly/openejb-tomcat/openejb-tomcat-webapp/src/main/resources/META-INF/org.apache.openejb.tomcat/
container/openejb-core/src/main/java/org/apache/openejb/
container/openejb-core/src/main/java/o...
Modified: openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/entity/EntityContainer.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/entity/EntityContainer.java?rev=688602&r1=688601&r2=688602&view=diff
==============================================================================
--- openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/entity/EntityContainer.java (original)
+++ openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/entity/EntityContainer.java Sun Aug 24 19:39:06 2008
@@ -17,6 +17,7 @@
package org.apache.openejb.core.entity;
import java.lang.reflect.Method;
+import java.lang.reflect.InvocationTargetException;
import java.rmi.NoSuchObjectException;
import java.util.Collection;
import java.util.Enumeration;
@@ -24,7 +25,6 @@
import java.util.Iterator;
import java.util.Map;
import java.util.Vector;
-
import javax.ejb.EJBAccessException;
import javax.ejb.EJBHome;
import javax.ejb.EJBLocalHome;
@@ -33,8 +33,6 @@
import javax.ejb.EntityBean;
import javax.ejb.NoSuchEntityException;
import javax.ejb.Timer;
-import javax.transaction.Transaction;
-import javax.transaction.TransactionManager;
import javax.transaction.TransactionSynchronizationRegistry;
import org.apache.openejb.ApplicationException;
@@ -43,18 +41,21 @@
import org.apache.openejb.OpenEJBException;
import org.apache.openejb.ProxyInfo;
import org.apache.openejb.SystemException;
-import org.apache.openejb.loader.SystemInstance;
+import org.apache.openejb.RpcContainer;
import org.apache.openejb.core.BaseContext;
import org.apache.openejb.core.CoreDeploymentInfo;
+import org.apache.openejb.core.ExceptionType;
import org.apache.openejb.core.Operation;
import org.apache.openejb.core.ThreadContext;
-import org.apache.openejb.core.ExceptionType;
-import org.apache.openejb.core.ThreadContextListener;
import org.apache.openejb.core.timer.EjbTimerService;
import org.apache.openejb.core.timer.EjbTimerServiceImpl;
-import org.apache.openejb.core.transaction.TransactionContainer;
-import org.apache.openejb.core.transaction.TransactionContext;
+import static org.apache.openejb.core.transaction.EjbTransactionUtil.handleApplicationException;
+import static org.apache.openejb.core.transaction.EjbTransactionUtil.handleSystemException;
+import static org.apache.openejb.core.transaction.EjbTransactionUtil.afterInvoke;
+import static org.apache.openejb.core.transaction.EjbTransactionUtil.createTransactionPolicy;
import org.apache.openejb.core.transaction.TransactionPolicy;
+import org.apache.openejb.core.transaction.TransactionType;
+import org.apache.openejb.loader.SystemInstance;
import org.apache.openejb.spi.SecurityService;
import org.apache.openejb.util.LogCategory;
import org.apache.openejb.util.Logger;
@@ -62,7 +63,7 @@
/**
* @org.apache.xbean.XBean element="bmpContainer"
*/
-public class EntityContainer implements org.apache.openejb.RpcContainer, TransactionContainer {
+public class EntityContainer implements RpcContainer {
private EntityInstanceManager instanceManager;
@@ -71,7 +72,6 @@
private Object containerID = null;
public static Logger logger = Logger.getInstance(LogCategory.OPENEJB, "org.apache.openejb.util.resources");
- private TransactionManager transactionManager;
private SecurityService securityService;
/**
@@ -79,13 +79,12 @@
*/
protected EntrancyTracker entrancyTracker;
- public EntityContainer(Object id, TransactionManager transactionManager, SecurityService securityService, int poolSize) throws OpenEJBException {
+ public EntityContainer(Object id, SecurityService securityService, int poolSize) throws OpenEJBException {
this.containerID = id;
- this.transactionManager = transactionManager;
this.securityService = securityService;
entrancyTracker = new EntrancyTracker(SystemInstance.get().getComponent(TransactionSynchronizationRegistry.class));
- instanceManager = new EntityInstanceManager(this, transactionManager, securityService, poolSize);
+ instanceManager = new EntityInstanceManager(this, securityService, poolSize);
}
public synchronized DeploymentInfo [] deployments() {
@@ -141,7 +140,7 @@
return invoke(deployID, callMethod.getDeclaringClass(), callMethod, args, primKey);
}
- public Object invoke(Object deployID, Class callInterface, Method callMethod, Object [] args, Object primKey) throws org.apache.openejb.OpenEJBException {
+ public Object invoke(Object deployID, Class callInterface, Method callMethod, Object [] args, Object primKey) throws OpenEJBException {
CoreDeploymentInfo deployInfo = (CoreDeploymentInfo) this.getDeploymentInfo(deployID);
if (deployInfo == null) throw new OpenEJBException("Deployment does not exist in this container. Deployment(id='"+deployID+"'), Container(id='"+containerID+"')");
@@ -200,15 +199,11 @@
return instanceManager;
}
- protected Object invoke(Method callMethod, Method runMethod, Object [] args, ThreadContext callContext)
- throws org.apache.openejb.OpenEJBException {
-
- TransactionPolicy txPolicy = callContext.getDeploymentInfo().getTransactionPolicy(callMethod);
- TransactionContext txContext = new TransactionContext(callContext, transactionManager);
- txContext.callContext = callContext;
+ protected Object invoke(Method callMethod, Method runMethod, Object [] args, ThreadContext callContext) throws OpenEJBException {
+ CoreDeploymentInfo deploymentInfo = callContext.getDeploymentInfo();
+ TransactionPolicy txPolicy = createTransactionPolicy(deploymentInfo.getTransactionType(callMethod), callContext);
EntityBean bean = null;
- txPolicy.beforeInvoke(bean, txContext);
Object returnValue = null;
entrancyTracker.enter(callContext.getDeploymentInfo(), callContext.getPrimaryKey());
@@ -219,34 +214,11 @@
returnValue = runMethod.invoke(bean, args);
ejbStore_If_No_Transaction(callContext, bean);
instanceManager.poolInstance(callContext, bean, callContext.getPrimaryKey());
- } catch (java.lang.reflect.InvocationTargetException ite) {// handle enterprise bean exceptions
- ExceptionType type = callContext.getDeploymentInfo().getExceptionType(ite.getTargetException());
- if (type == ExceptionType.SYSTEM) {
- /* System Exception ****************************/
-
- txPolicy.handleSystemException(ite.getTargetException(), bean, txContext);
- } else {
- /* Application Exception ***********************/
- instanceManager.poolInstance(callContext, bean, callContext.getPrimaryKey());
- txPolicy.handleApplicationException(ite.getTargetException(), type == ExceptionType.APPLICATION_ROLLBACK, txContext);
- }
- } catch (org.apache.openejb.ApplicationException e) {
- txPolicy.handleApplicationException(e.getRootCause(), false, txContext);
- } catch (org.apache.openejb.SystemException se) {
- txPolicy.handleSystemException(se.getRootCause(), bean, txContext);
- } catch (Throwable iae) {// handle reflection exception
- /*
- Any exception thrown by reflection; not by the enterprise bean. Possible
- Exceptions are:
- IllegalAccessException - if the underlying method is inaccessible.
- IllegalArgumentException - if the number of actual and formal parameters differ, or if an unwrapping conversion fails.
- NullPointerException - if the specified object is null and the method is an instance method.
- ExceptionInInitializerError - if the initialization provoked by this method fails.
- */
- txPolicy.handleSystemException(iae, bean, txContext);
+ } catch (Throwable e) {
+ handleException(txPolicy, e, callContext, bean);
} finally {
entrancyTracker.exit(callContext.getDeploymentInfo(), callContext.getPrimaryKey());
- txPolicy.afterInvoke(bean, txContext);
+ afterInvoke(txPolicy, callContext);
}
return returnValue;
@@ -257,69 +229,66 @@
BaseContext.State[] originalAllowedStates = callContext.getCurrentAllowedStates();
if (orginalOperation == Operation.BUSINESS || orginalOperation == Operation.REMOVE) {
- Transaction currentTx = null;
- try {
- currentTx = getTransactionManager().getTransaction();
- } catch (javax.transaction.SystemException se) {
- throw new org.apache.openejb.SystemException("Transaction Manager failure", se);
+ TransactionPolicy callerTxPolicy = callContext.getTransactionPolicy();
+ if (callerTxPolicy != null && callerTxPolicy.isTransactionActive()) {
+ return;
}
- if (currentTx == null) {
- callContext.setCurrentOperation(Operation.LOAD);
- callContext.setCurrentAllowedStates(EntityContext.getStates());
- try {
+ CoreDeploymentInfo deploymentInfo = callContext.getDeploymentInfo();
+ TransactionPolicy txPolicy = deploymentInfo.getTransactionPolicyFactory().createTransactionPolicy(TransactionType.Supports);
+ try {
+ // double check we don't have an active transaction
+ if (!txPolicy.isTransactionActive()) {
+ callContext.setCurrentOperation(Operation.LOAD);
+ callContext.setCurrentAllowedStates(EntityContext.getStates());
bean.ejbLoad();
- } catch (NoSuchEntityException e) {
- instanceManager.discardInstance(callContext, bean);
- throw new ApplicationException(new NoSuchObjectException("Entity not found: " + callContext.getPrimaryKey())/*.initCause(e)*/);
- } catch (Exception e) {
- instanceManager.discardInstance(callContext, bean);
- throw e;
- } finally {
- callContext.setCurrentOperation(orginalOperation);
- callContext.setCurrentAllowedStates(originalAllowedStates);
}
+ } catch (NoSuchEntityException e) {
+ instanceManager.discardInstance(callContext, bean);
+ throw new ApplicationException(new NoSuchObjectException("Entity not found: " + callContext.getPrimaryKey())/*.initCause(e)*/);
+ } catch (Exception e) {
+ instanceManager.discardInstance(callContext, bean);
+ throw e;
+ } finally {
+ callContext.setCurrentOperation(orginalOperation);
+ callContext.setCurrentAllowedStates(originalAllowedStates);
+ txPolicy.commit();
}
}
}
- private TransactionManager getTransactionManager() {
- return transactionManager;
- }
-
- public void ejbStore_If_No_Transaction(ThreadContext callContext, EntityBean bean)
- throws Exception {
-
+ public void ejbStore_If_No_Transaction(ThreadContext callContext, EntityBean bean) throws Exception {
Operation currentOp = callContext.getCurrentOperation();
BaseContext.State[] originalAllowedStates = callContext.getCurrentAllowedStates();
if (currentOp == Operation.BUSINESS) {
- Transaction currentTx = null;
- try {
- currentTx = getTransactionManager().getTransaction();
- } catch (javax.transaction.SystemException se) {
- throw new org.apache.openejb.SystemException("Transaction Manager failure", se);
+ TransactionPolicy callerTxPolicy = callContext.getTransactionPolicy();
+ if (callerTxPolicy != null && callerTxPolicy.isTransactionActive()) {
+ return;
}
- if (currentTx == null) {
- callContext.setCurrentOperation(Operation.STORE);
- callContext.setCurrentAllowedStates(EntityContext.getStates());
- try {
+ CoreDeploymentInfo deploymentInfo = callContext.getDeploymentInfo();
+ TransactionPolicy txPolicy = deploymentInfo.getTransactionPolicyFactory().createTransactionPolicy(TransactionType.Supports);
+ try {
+ // double check we don't have an active transaction
+ if (!txPolicy.isTransactionActive()) {
+ callContext.setCurrentOperation(Operation.STORE);
+ callContext.setCurrentAllowedStates(EntityContext.getStates());
bean.ejbStore();
- } catch (Exception e) {
-
- instanceManager.discardInstance(callContext, bean);
- throw e;
- } finally {
- callContext.setCurrentOperation(currentOp);
- callContext.setCurrentAllowedStates(originalAllowedStates);
}
+ } catch (Exception e) {
+ instanceManager.discardInstance(callContext, bean);
+ throw e;
+ } finally {
+ callContext.setCurrentOperation(currentOp);
+ callContext.setCurrentAllowedStates(originalAllowedStates);
+ txPolicy.commit();
}
}
}
- protected void didCreateBean(ThreadContext callContext, EntityBean bean) throws org.apache.openejb.OpenEJBException {
+ protected void didCreateBean(ThreadContext callContext, EntityBean bean) throws OpenEJBException {
}
protected ProxyInfo createEJBObject(Method callMethod, Object [] args, ThreadContext callContext) throws OpenEJBException {
@@ -328,10 +297,6 @@
callContext.setCurrentOperation(Operation.CREATE);
callContext.setCurrentAllowedStates(EntityContext.getStates());
- TransactionPolicy txPolicy = callContext.getDeploymentInfo().getTransactionPolicy(callMethod);
- TransactionContext txContext = new TransactionContext(callContext, transactionManager);
- txContext.callContext = callContext;
-
/*
* According to section 9.1.5.1 of the EJB 1.1 specification, the "ejbPostCreate(...)
* method executes in the same transaction context as the previous ejbCreate(...) method."
@@ -346,7 +311,7 @@
* super classes afterInvoke( ) method will be executed committing the transaction if its a CMT.
*/
- txPolicy.beforeInvoke(null, txContext);
+ TransactionPolicy txPolicy = createTransactionPolicy(deploymentInfo.getTransactionType(callMethod), callContext);
EntityBean bean = null;
Object primaryKey = null;
@@ -387,30 +352,10 @@
// update pool
instanceManager.poolInstance(callContext, bean, primaryKey);
- } catch (java.lang.reflect.InvocationTargetException ite) {// handle enterprise bean exceptions
- ExceptionType type = callContext.getDeploymentInfo().getExceptionType(ite.getTargetException());
- if (type == ExceptionType.SYSTEM) {
- /* System Exception ****************************/
- txPolicy.handleSystemException(ite.getTargetException(), bean, txContext);
- } else {
- /* Application Exception ***********************/
- instanceManager.poolInstance(callContext, bean, callContext.getPrimaryKey());
- txPolicy.handleApplicationException(ite.getTargetException(), type == ExceptionType.APPLICATION_ROLLBACK, txContext);
- }
- } catch (OpenEJBException e) {
- txPolicy.handleSystemException(e.getRootCause(), bean, txContext);
- } catch (Throwable e) {// handle reflection exception
- /*
- Any exception thrown by reflection; not by the enterprise bean. Possible
- Exceptions are:
- IllegalAccessException - if the underlying method is inaccessible.
- IllegalArgumentException - if the number of actual and formal parameters differ, or if an unwrapping conversion fails.
- NullPointerException - if the specified object is null and the method is an instance method.
- ExceptionInInitializerError - if the initialization provoked by this method fails.
- */
- txPolicy.handleSystemException(e, bean, txContext);
+ } catch (Throwable e) {
+ handleException(txPolicy, e, callContext, bean);
} finally {
- txPolicy.afterInvoke(bean, txContext);
+ afterInvoke(txPolicy, callContext);
}
return new ProxyInfo(deploymentInfo, primaryKey);
@@ -477,18 +422,14 @@
}
}
- protected void removeEJBObject(Method callMethod, Object [] args, ThreadContext callContext)
- throws org.apache.openejb.OpenEJBException {
+ protected void removeEJBObject(Method callMethod, Object [] args, ThreadContext callContext) throws OpenEJBException {
callContext.setCurrentOperation(Operation.REMOVE);
callContext.setCurrentAllowedStates(EntityContext.getStates());
- TransactionPolicy txPolicy = callContext.getDeploymentInfo().getTransactionPolicy(callMethod);
- TransactionContext txContext = new TransactionContext(callContext, transactionManager);
- txContext.callContext = callContext;
+ CoreDeploymentInfo deploymentInfo = callContext.getDeploymentInfo();
+ TransactionPolicy txPolicy = createTransactionPolicy(deploymentInfo.getTransactionType(callMethod), callContext);
EntityBean bean = null;
- txPolicy.beforeInvoke(bean, txContext);
-
try {
bean = instanceManager.obtainInstance(callContext);
@@ -497,32 +438,42 @@
bean.ejbRemove();
didRemove(bean, callContext);
instanceManager.poolInstance(callContext, bean, callContext.getPrimaryKey());
- } catch (org.apache.openejb.ApplicationException e) {
- txPolicy.handleApplicationException(e.getRootCause(), false, txContext);
- } catch (org.apache.openejb.SystemException se) {
- txPolicy.handleSystemException(se.getRootCause(), bean, txContext);
- } catch (Exception e) {// handle reflection exception
- ExceptionType type = callContext.getDeploymentInfo().getExceptionType(e);
- if (type == ExceptionType.SYSTEM) {
- /* System Exception ****************************/
- txPolicy.handleSystemException(e, bean, txContext);
- } else {
- /* Application Exception ***********************/
- instanceManager.poolInstance(callContext, bean, callContext.getPrimaryKey());
- txPolicy.handleApplicationException(e, type == ExceptionType.APPLICATION_ROLLBACK, txContext);
- }
+ } catch (Throwable e) {
+ handleException(txPolicy, e, callContext, bean);
} finally {
- txPolicy.afterInvoke(bean, txContext);
+ afterInvoke(txPolicy, callContext);
}
}
- public void discardInstance(Object bean, ThreadContext threadContext) {
- if (bean != null) {
- try {
- instanceManager.discardInstance(threadContext, (EntityBean) bean);
- } catch (SystemException e) {
- logger.error("The instance manager encountered an unkown system exception while trying to discard the entity instance with primary key " + threadContext.getPrimaryKey());
+ private void handleException(TransactionPolicy txPolicy, Throwable e, ThreadContext callContext, EntityBean bean) throws OpenEJBException {
+ ExceptionType type;
+ if (e instanceof InvocationTargetException) {
+ e = ((InvocationTargetException) e).getTargetException();
+ type = callContext.getDeploymentInfo().getExceptionType(e);
+ } else if (e instanceof ApplicationException) {
+ e = ((ApplicationException) e).getRootCause();
+ type = ExceptionType.APPLICATION;
+ } else if (e instanceof SystemException) {
+ e = ((SystemException) e).getRootCause();
+ type = ExceptionType.SYSTEM;
+ } else {
+ type = ExceptionType.SYSTEM;
+ }
+
+ if (type == ExceptionType.SYSTEM) {
+ // System Exception
+ if (bean != null) {
+ try {
+ instanceManager.discardInstance(callContext, bean);
+ } catch (SystemException e1) {
+ logger.error("The instance manager encountered an unkown system exception while trying to discard the entity instance with primary key " + callContext.getPrimaryKey());
+ }
}
+ handleSystemException(txPolicy, e, callContext);
+ } else {
+ // Application Exception
+ instanceManager.poolInstance(callContext, bean, callContext.getPrimaryKey());
+ handleApplicationException(txPolicy, e, type == ExceptionType.APPLICATION_ROLLBACK);
}
}
}
Modified: openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/entity/EntityContext.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/entity/EntityContext.java?rev=688602&r1=688601&r2=688602&view=diff
==============================================================================
--- openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/entity/EntityContext.java (original)
+++ openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/entity/EntityContext.java Sun Aug 24 19:39:06 2008
@@ -21,13 +21,11 @@
import javax.ejb.EJBLocalObject;
import javax.ejb.EJBObject;
import javax.ejb.TimerService;
-import javax.transaction.TransactionManager;
import javax.transaction.UserTransaction;
import org.apache.openejb.DeploymentInfo;
import org.apache.openejb.InterfaceType;
import org.apache.openejb.InternalErrorException;
-import org.apache.openejb.RpcContainer;
import org.apache.openejb.core.BaseContext;
import org.apache.openejb.core.Operation;
import org.apache.openejb.core.ThreadContext;
@@ -36,24 +34,18 @@
import org.apache.openejb.spi.SecurityService;
import org.apache.openejb.util.proxy.ProxyManager;
-
/**
* @version $Rev$ $Date$
*/
public class EntityContext extends BaseContext implements javax.ejb.EntityContext {
-
protected final static State[] states = new State[Operation.values().length];
public static State[] getStates() {
return states;
}
- public EntityContext(TransactionManager transactionManager, SecurityService securityService) {
- super(transactionManager, securityService);
- }
-
- protected EntityContext(TransactionManager transactionManager, SecurityService securityService, UserTransaction userTransaction) {
- super(transactionManager, securityService, userTransaction);
+ public EntityContext(SecurityService securityService) {
+ super(securityService);
}
protected State getState() {
@@ -105,7 +97,7 @@
throw new IllegalStateException("EJB " + di.getDeploymentID() + " does not have a remote interface");
}
- EjbObjectProxyHandler handler = new EntityEjbObjectHandler(((RpcContainer) di.getContainer()).getDeploymentInfo(di.getDeploymentID()), threadContext.getPrimaryKey(), InterfaceType.EJB_OBJECT, new ArrayList<Class>());
+ EjbObjectProxyHandler handler = new EntityEjbObjectHandler(di.getContainer().getDeploymentInfo(di.getDeploymentID()), threadContext.getPrimaryKey(), InterfaceType.EJB_OBJECT, new ArrayList<Class>());
try {
Class[] interfaces = new Class[]{di.getRemoteInterface(), IntraVmProxy.class};
return (EJBObject) ProxyManager.newProxyInstance(interfaces, handler);
@@ -150,11 +142,11 @@
throw new IllegalStateException();
}
- public void setRollbackOnly(TransactionManager transactionManager) throws IllegalStateException {
+ public void setRollbackOnly() throws IllegalStateException {
throw new IllegalStateException();
}
- public boolean getRollbackOnly(TransactionManager transactionManager) throws IllegalStateException {
+ public boolean getRollbackOnly() throws IllegalStateException {
throw new IllegalStateException();
}
@@ -313,11 +305,11 @@
throw new IllegalStateException();
}
- public void setRollbackOnly(TransactionManager transactionManager) throws IllegalStateException {
+ public void setRollbackOnly() throws IllegalStateException {
throw new IllegalStateException();
}
- public boolean getRollbackOnly(TransactionManager transactionManager) throws IllegalStateException {
+ public boolean getRollbackOnly() throws IllegalStateException {
throw new IllegalStateException();
}
Modified: openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/entity/EntityInstanceManager.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/entity/EntityInstanceManager.java?rev=688602&r1=688601&r2=688602&view=diff
==============================================================================
--- openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/entity/EntityInstanceManager.java (original)
+++ openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/entity/EntityInstanceManager.java Sun Aug 24 19:39:06 2008
@@ -28,58 +28,42 @@
import org.apache.openejb.core.ThreadContext;
import org.apache.openejb.core.NoSuchObjectException;
import org.apache.openejb.core.transaction.TransactionRolledbackException;
+import org.apache.openejb.core.transaction.TransactionPolicy;
+import org.apache.openejb.core.transaction.TransactionPolicy.TransactionSynchronization;
import org.apache.openejb.util.LinkedListStack;
import org.apache.openejb.util.LogCategory;
import org.apache.openejb.util.Logger;
-import org.apache.openejb.util.SafeToolkit;
import org.apache.openejb.util.Stack;
import javax.ejb.EntityBean;
import javax.ejb.NoSuchEntityException;
-import javax.transaction.Transaction;
-import javax.transaction.TransactionManager;
-import javax.transaction.Synchronization;
-import javax.transaction.RollbackException;
import java.util.HashMap;
-import java.util.Hashtable;
import java.util.Map;
import java.rmi.RemoteException;
public class EntityInstanceManager {
+ private static final Logger logger = Logger.getInstance(LogCategory.OPENEJB, "org.apache.openejb.util.resources");
- /* The default size of the bean pools. Every bean class gets its own pool of this size */
- protected int poolsize = 0;
- /* The container that owns this InstanceManager. Its needed to use the invoke() method
- in the obtainInstance( ), which is needed for transactionally safe invokation.
- */
- protected EntityContainer container;
- /*
- * Every entity that is registered with a transaciton is kept in this pool until the tx
- * completes. The pool contains SyncronizationWrappers (each holding a reference) keyed
- * by using an instance of the inner Key class. The Key class is a compound key composed
- * of the tx, deployment, and primary key identifiers.
- */
- protected Hashtable<Object, SynchronizationWrapper> txReadyPool = new Hashtable<Object, SynchronizationWrapper>();
- /*
- * contains a collection of LinkListStacks indexed by deployment id. Each indexed stack
- * represents the method ready pool of for that class.
- */
- protected Map<Object,LinkedListStack> poolMap = null;
+ /**
+ * The default size of the bean pools. Every bean class gets its own pool of this size
+ */
+ private int poolsize = 0;
+
+ /**
+ * contains a collection of LinkListStacks indexed by deployment id. Each indexed stack
+ * represents the method ready pool of for that class.
+ */
+ private Map<Object,LinkedListStack> poolMap = null;
- public Logger logger = Logger.getInstance(LogCategory.OPENEJB, "org.apache.openejb.util.resources");
- protected SafeToolkit toolkit = SafeToolkit.getToolkit("EntityInstanceManager");
- private TransactionManager transactionManager;
private SecurityService securityService;
- public EntityInstanceManager(EntityContainer container, TransactionManager transactionManager, SecurityService securityService, int poolSize) {
- this.transactionManager = transactionManager;
+ public EntityInstanceManager(EntityContainer container, SecurityService securityService, int poolSize) {
this.securityService = securityService;
this.poolsize = poolSize;
- this.container = container;
poolMap = new HashMap<Object,LinkedListStack>();// put size in later
- DeploymentInfo[] deploymentInfos = this.container.deployments();
+ DeploymentInfo[] deploymentInfos = container.deployments();
for (DeploymentInfo deploymentInfo : deploymentInfos) {
deploy(deploymentInfo);
}
@@ -94,19 +78,13 @@
}
public EntityBean obtainInstance(ThreadContext callContext) throws OpenEJBException {
- Transaction currentTx;
- try {
- currentTx = getTransactionManager().getTransaction();
- } catch (javax.transaction.SystemException se) {
- logger.error("Transaction Manager getTransaction() failed.", se);
- throw new SystemException("TransactionManager failure", se);
- }
+ // primary key is null if its a servicing a home methods (create, find, ejbHome)
+ Object primaryKey = callContext.getPrimaryKey();
+ TransactionPolicy txPolicy = callContext.getTransactionPolicy();
+ if (callContext.getPrimaryKey() != null && txPolicy != null && txPolicy.isTransactionActive()) {
- Object primaryKey = callContext.getPrimaryKey();// null if its a servicing a home methods (create, find, ejbHome)
- if (currentTx != null && primaryKey != null) {// primkey is null if create operation is called
- CoreDeploymentInfo deploymentInfo = callContext.getDeploymentInfo();
- Key key = new Key(currentTx, deploymentInfo.getDeploymentID(), primaryKey);
- SynchronizationWrapper wrapper = txReadyPool.get(key);
+ Key key = new Key(callContext.getDeploymentInfo().getDeploymentID(), primaryKey);
+ SynchronizationWrapper wrapper = (SynchronizationWrapper) txPolicy.getResource(key);
if (wrapper != null) {// if true, the requested bean instance is already enrolled in a transaction
@@ -152,7 +130,7 @@
* so it needs to be enrolled in the transaction.
*/
EntityBean bean = getPooledInstance(callContext);
- wrapper = new SynchronizationWrapper(callContext.getDeploymentInfo(), primaryKey, bean, false, key);
+ wrapper = new SynchronizationWrapper(callContext.getDeploymentInfo(), primaryKey, bean, false, key, txPolicy);
if (callContext.getCurrentOperation() == Operation.REMOVE) {
/*
@@ -166,14 +144,8 @@
wrapper.disassociate();
}
- try {
- currentTx.registerSynchronization(wrapper);
- } catch (javax.transaction.SystemException e) {
- logger.error("Transaction Manager registerSynchronization() failed.", e);
- throw new SystemException(e);
- } catch (RollbackException e) {
- throw new ApplicationException(new TransactionRolledbackException(e));
- }
+ txPolicy.registerSynchronization(wrapper);
+
loadingBean(bean, callContext);
Operation orginalOperation = callContext.getCurrentOperation();
callContext.setCurrentOperation(Operation.LOAD);
@@ -191,7 +163,7 @@
callContext.setCurrentOperation(orginalOperation);
callContext.setCurrentAllowedStates(EntityContext.getStates());
}
- txReadyPool.put(key, wrapper);
+ txPolicy.putResource(key, wrapper);
return bean;
}
@@ -280,15 +252,10 @@
bean.ejbActivate();
} catch (Throwable e) {
logger.error("Encountered exception during call to ejbActivate()", e);
- try {
- Transaction tx = getTransactionManager().getTransaction();
- if (tx != null) {
- tx.setRollbackOnly();
- throw new ApplicationException(new TransactionRolledbackException("Reflection exception thrown while attempting to call ejbActivate() on the instance", e));
- }
- } catch (javax.transaction.SystemException se) {
- logger.error("Transaction Manager getTransaction() failed.", se);
- throw new SystemException(se);
+ TransactionPolicy txPolicy = callContext.getTransactionPolicy();
+ if (txPolicy != null && txPolicy.isTransactionActive()) {
+ txPolicy.setRollbackOnly();
+ throw new ApplicationException(new TransactionRolledbackException("Reflection exception thrown while attempting to call ejbActivate() on the instance", e));
}
throw new ApplicationException(new RemoteException("Exception thrown while attempting to call ejbActivate() on the instance. Exception message = " + e.getMessage(), e));
} finally {
@@ -301,23 +268,21 @@
}
private EntityContext createEntityContext() {
- return new EntityContext(transactionManager, securityService);
+ return new EntityContext(securityService);
}
public void poolInstance(ThreadContext callContext, EntityBean bean, Object primaryKey) throws OpenEJBException {
if (bean == null) {
return;
}
- Transaction currentTx;
- try {
- currentTx = getTransactionManager().getTransaction();
- } catch (javax.transaction.SystemException se) {
- logger.error("Transaction Manager getTransaction() failed.", se);
- throw new SystemException("TransactionManager failure", se);
- }
- if (currentTx != null && primaryKey != null) {// primary key is null for find and home methods
- Key key = new Key(currentTx, callContext.getDeploymentInfo().getDeploymentID(), primaryKey);
- SynchronizationWrapper wrapper = txReadyPool.get(key);
+
+ // primary key is null if its a servicing a home methods (create, find, ejbHome)
+ TransactionPolicy txPolicy = callContext.getTransactionPolicy();
+ if (callContext.getPrimaryKey() != null && txPolicy != null && txPolicy.isTransactionActive()) {
+
+ Key key = new Key(callContext.getDeploymentInfo().getDeploymentID(), primaryKey);
+ SynchronizationWrapper wrapper = (SynchronizationWrapper) txPolicy.getResource(key);
+
if (wrapper != null) {
if (callContext.getCurrentOperation() == Operation.REMOVE) {
/*
@@ -348,18 +313,11 @@
tx ready pool
*/
- wrapper = new SynchronizationWrapper(callContext.getDeploymentInfo(), primaryKey, bean, true, key);
+ wrapper = new SynchronizationWrapper(callContext.getDeploymentInfo(), primaryKey, bean, true, key, txPolicy);
- try {
- currentTx.registerSynchronization(wrapper);
- } catch (javax.transaction.SystemException se) {
- logger.error("Transaction Manager registerSynchronization() failed.", se);
- throw new SystemException(se);
- } catch (RollbackException re) {
- throw new ApplicationException(new TransactionRolledbackException(re));
- }
+ txPolicy.registerSynchronization(wrapper);
- txReadyPool.put(key, wrapper);
+ txPolicy.putResource(key, wrapper);
}
} else {
/*
@@ -388,15 +346,9 @@
*/
bean.ejbPassivate();
} catch (Throwable e) {
- try {
- Transaction tx = getTransactionManager().getTransaction();
- if (tx != null) {
- tx.setRollbackOnly();
- throw new ApplicationException(new TransactionRolledbackException("Reflection exception thrown while attempting to call ejbPassivate() on the instance", e));
- }
- } catch (javax.transaction.SystemException se) {
- logger.error("Transaction Manager getTransaction() failed.", se);
- throw new SystemException(se);
+ if (txPolicy.isTransactionActive()) {
+ txPolicy.setRollbackOnly();
+ throw new ApplicationException(new TransactionRolledbackException("Reflection exception thrown while attempting to call ejbPassivate() on the instance", e));
}
throw new ApplicationException(new RemoteException("Reflection exception thrown while attempting to call ejbPassivate() on the instance. Exception message = " + e.getMessage(), e));
} finally {
@@ -452,83 +404,66 @@
}
public void discardInstance(ThreadContext callContext, EntityBean bean) throws SystemException {
- Transaction currentTx = null;
- try {
- currentTx = getTransactionManager().getTransaction();
- } catch (javax.transaction.SystemException se) {
- logger.error("Transaction Manager getTransaction() failed.", se);
- throw new SystemException("TransactionManager failure", se);
- }
- if (currentTx != null) {
- if (callContext.getPrimaryKey() == null)
- return;
-
- Key key = new Key(currentTx, callContext.getDeploymentInfo().getDeploymentID(), callContext.getPrimaryKey());
+ Object primaryKey = callContext.getPrimaryKey();
+ TransactionPolicy txPolicy = callContext.getTransactionPolicy();
+ if (primaryKey == null || txPolicy == null || !txPolicy.isTransactionActive()) {
+ return;
+ }
+ // The wrapper is removed (if pooled) so that it can not be accessed again. This is
+ // especially important in the obtainInstance( ) method where a disassociated wrapper
+ // in the txReadyPool is indicative of an entity bean that has been removed via
+ // ejbRemove() rather than freed because of an error condition as is the case here.
+ Key key = new Key(callContext.getDeploymentInfo().getDeploymentID(), primaryKey);
+ SynchronizationWrapper wrapper = (SynchronizationWrapper) txPolicy.getResource(key);
+ if (wrapper != null) {
/*
- The wrapper is removed (if pooled) so that it can not be accessed again. This is
- especially important in the obtainInstance( ) method where a disassociated wrapper
- in the txReadyPool is indicative of an entity bean that has been removed via
- ejbRemove() rather than freed because of an error condition as is the case here.
- */
- SynchronizationWrapper wrapper = txReadyPool.remove(key);
-
- if (wrapper != null) {
- /*
- It's not possible to deregister a wrapper with the transaction,
- but it can be removed from the tx pool and made inoperative by
- calling its disassociate method. The wrapper will be returned to the
- wrapper pool after the transaction completes
- (see SynchronizationWrapper.afterCompletion( ) method). The wrapper must
- be returned after the transaction completes so that it is not in the service
- of another bean when the TransactionManager calls its Synchronization methods.
+ It's not possible to deregister a wrapper with the transaction,
+ but it can be removed from the tx pool and made inoperative by
+ calling its disassociate method. The wrapper will be returned to the
+ wrapper pool after the transaction completes
+ (see SynchronizationWrapper.afterCompletion( ) method). The wrapper must
+ be returned after the transaction completes so that it is not in the service
+ of another bean when the TransactionManager calls its Synchronization methods.
- In addition, the bean instance is dereferenced so it can be garbage
- collected.
- */
- wrapper.disassociate();
- }
+ In addition, the bean instance is dereferenced so it can be garbage
+ collected.
+ */
+ wrapper.disassociate();
}
}
- private TransactionManager getTransactionManager() {
- return transactionManager;
- }
-
/*
* Instances of this class are used as keys for storing bean instances in the tx method
* ready pool. A compound key composed of the transaction, primary key, and deployment id
* identifiers is required to uniquely identify a bean in the tx method ready pool.
*/
- public static class Key {
- private final Object deploymentID;
+ private static class Key {
+ private final Object deploymentId;
private final Object primaryKey;
- private final Transaction transaction;
- public Key(Transaction tx, Object depID, Object prKey) {
- if (tx == null || depID == null || prKey == null) {
- throw new IllegalArgumentException();
- }
- transaction = tx;
- deploymentID = depID;
- primaryKey = prKey;
- }
+ public Key(Object deploymentId, Object primaryKey) {
+ if (deploymentId == null) throw new NullPointerException("deploymentId is null");
+ if (primaryKey == null) throw new NullPointerException("primaryKey is null");
- public Object getPK() {
- return primaryKey;
+ this.deploymentId = deploymentId;
+ this.primaryKey = primaryKey;
}
- public int hashCode() {
- return transaction.hashCode() ^ deploymentID.hashCode() ^ primaryKey.hashCode();
+ public boolean equals(Object o) {
+ if (this == o) return true;
+ if (o == null || getClass() != o.getClass()) return false;
+
+ Key key = (Key) o;
+
+ return deploymentId.equals(key.deploymentId) && primaryKey.equals(key.primaryKey);
}
- public boolean equals(Object other) {
- if (other != null && other.getClass() == EntityInstanceManager.Key.class) {
- Key otherKey = (Key) other;
- if (otherKey.transaction.equals(transaction) && otherKey.deploymentID.equals(deploymentID) && otherKey.primaryKey.equals(primaryKey))
- return true;
- }
- return false;
+ public int hashCode() {
+ int result;
+ result = deploymentId.hashCode();
+ result = 31 * result + primaryKey.hashCode();
+ return result;
}
}
@@ -539,7 +474,7 @@
* to the method ready pool. Instances of this class are not recycled anymore, because modern VMs
* (JDK1.3 and above) perform better for objects that are short lived.
*/
- protected class SynchronizationWrapper implements Synchronization {
+ protected class SynchronizationWrapper implements TransactionSynchronization {
private EntityBean bean;
/*
* <tt>isAvailable<tt> determines if the wrapper is still associated with a bean. If the bean identity is removed (ejbRemove)
@@ -548,21 +483,24 @@
*/
private boolean available;
private boolean associated;
- private final Key readyPoolIndex;
+ private final Key readyPoolKey;
private final CoreDeploymentInfo deploymentInfo;
private final Object primaryKey;
+ private final TransactionPolicy txPolicy;
- public SynchronizationWrapper(CoreDeploymentInfo deploymentInfo, Object primaryKey, EntityBean bean, boolean available, Key readyPoolIndex) {
+ public SynchronizationWrapper(CoreDeploymentInfo deploymentInfo, Object primaryKey, EntityBean bean, boolean available, Key readyPoolKey, TransactionPolicy txPolicy) {
if (bean == null) throw new IllegalArgumentException("bean is null");
- if (readyPoolIndex == null) throw new IllegalArgumentException("key is null");
+ if (readyPoolKey == null) throw new IllegalArgumentException("key is null");
if (deploymentInfo == null) throw new IllegalArgumentException("deploymentInfo is null");
if (primaryKey == null) throw new IllegalArgumentException("primaryKey is null");
+ if (txPolicy == null) throw new IllegalArgumentException("txEnv is null");
this.deploymentInfo = deploymentInfo;
this.bean = bean;
this.primaryKey = primaryKey;
this.available = available;
- this.readyPoolIndex = readyPoolIndex;
+ this.readyPoolKey = readyPoolKey;
+ this.txPolicy = txPolicy;
associated = true;
}
@@ -609,21 +547,15 @@
bean.ejbStore();
} catch (Exception re) {
logger.error("Exception occured during ejbStore()", re);
- TransactionManager transactionManager = getTransactionManager();
- try {
- transactionManager.setRollbackOnly();
- } catch (javax.transaction.SystemException se) {
- logger.error("Transaction manager reported error during setRollbackOnly()", se);
- }
-
+ txPolicy.setRollbackOnly();
} finally {
ThreadContext.exit(oldCallContext);
}
}
}
- public void afterCompletion(int status) {
- txReadyPool.remove(readyPoolIndex);
+ public void afterCompletion(Status status) {
+ txPolicy.removeResource(readyPoolKey);
}
}
}
Modified: openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/mdb/EndpointFactory.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/mdb/EndpointFactory.java?rev=688602&r1=688601&r2=688602&view=diff
==============================================================================
--- openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/mdb/EndpointFactory.java (original)
+++ openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/mdb/EndpointFactory.java Sun Aug 24 19:39:06 2008
@@ -17,10 +17,9 @@
*/
package org.apache.openejb.core.mdb;
-import org.apache.openejb.DeploymentInfo;
import org.apache.openejb.resource.XAResourceWrapper;
import org.apache.openejb.core.CoreDeploymentInfo;
-import org.apache.geronimo.transaction.manager.WrapperNamedXAResource;
+import org.apache.openejb.core.transaction.TransactionType;
import javax.resource.spi.UnavailableException;
import javax.resource.spi.ActivationSpec;
@@ -67,7 +66,7 @@
}
public boolean isDeliveryTransacted(Method method) throws NoSuchMethodException {
- byte transactionAttribute = deploymentInfo.getTransactionAttribute(method);
- return DeploymentInfo.TX_REQUIRED == transactionAttribute;
+ TransactionType transactionType = deploymentInfo.getTransactionType(method);
+ return TransactionType.Required == transactionType;
}
}
Modified: openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/mdb/MdbContainer.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/mdb/MdbContainer.java?rev=688602&r1=688601&r2=688602&view=diff
==============================================================================
--- openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/mdb/MdbContainer.java (original)
+++ openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/mdb/MdbContainer.java Sun Aug 24 19:39:06 2008
@@ -29,12 +29,15 @@
import org.apache.openejb.core.CoreDeploymentInfo;
import org.apache.openejb.core.Operation;
import org.apache.openejb.core.ThreadContext;
+import org.apache.openejb.core.ExceptionType;
import org.apache.openejb.core.timer.EjbTimerService;
import org.apache.openejb.core.interceptor.InterceptorData;
import org.apache.openejb.core.interceptor.InterceptorStack;
-import org.apache.openejb.core.transaction.TransactionContainer;
-import org.apache.openejb.core.transaction.TransactionContext;
import org.apache.openejb.core.transaction.TransactionPolicy;
+import static org.apache.openejb.core.transaction.EjbTransactionUtil.handleApplicationException;
+import static org.apache.openejb.core.transaction.EjbTransactionUtil.handleSystemException;
+import static org.apache.openejb.core.transaction.EjbTransactionUtil.afterInvoke;
+import static org.apache.openejb.core.transaction.EjbTransactionUtil.createTransactionPolicy;
import org.apache.openejb.spi.SecurityService;
import org.apache.openejb.util.LogCategory;
import org.apache.openejb.util.Logger;
@@ -42,14 +45,13 @@
import org.apache.xbean.recipe.ObjectRecipe;
import org.apache.xbean.recipe.Option;
-import javax.transaction.TransactionManager;
-import javax.transaction.Transaction;
import javax.transaction.xa.XAResource;
import javax.resource.spi.ResourceAdapter;
import javax.resource.spi.ActivationSpec;
import javax.resource.spi.UnavailableException;
import javax.resource.ResourceException;
import java.lang.reflect.Method;
+import java.lang.reflect.InvocationTargetException;
import java.util.List;
import java.util.Map;
import java.util.Arrays;
@@ -58,12 +60,11 @@
import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.ConcurrentHashMap;
-public class MdbContainer implements RpcContainer, TransactionContainer {
+public class MdbContainer implements RpcContainer {
private static final Logger logger = Logger.getInstance(LogCategory.OPENEJB, "org.apache.openejb.util.resources");
private static final Object[] NO_ARGS = new Object[0];
private final Object containerID;
- private final TransactionManager transactionManager;
private final SecurityService securityService;
private final ResourceAdapter resourceAdapter;
private final Class messageListenerInterface;
@@ -73,9 +74,8 @@
private final ConcurrentMap<Object, CoreDeploymentInfo> deployments = new ConcurrentHashMap<Object, CoreDeploymentInfo>();
private final XAResourceWrapper xaResourceWrapper;
- public MdbContainer(Object containerID, TransactionManager transactionManager, SecurityService securityService, ResourceAdapter resourceAdapter, Class messageListenerInterface, Class activationSpecClass, int instanceLimit) {
+ public MdbContainer(Object containerID, SecurityService securityService, ResourceAdapter resourceAdapter, Class messageListenerInterface, Class activationSpecClass, int instanceLimit) {
this.containerID = containerID;
- this.transactionManager = transactionManager;
this.securityService = securityService;
this.resourceAdapter = resourceAdapter;
this.messageListenerInterface = messageListenerInterface;
@@ -125,7 +125,7 @@
ActivationSpec activationSpec = createActivationSpec(deploymentInfo);
// create the message endpoint
- MdbInstanceFactory instanceFactory = new MdbInstanceFactory(deploymentInfo, transactionManager, securityService, instanceLimit);
+ MdbInstanceFactory instanceFactory = new MdbInstanceFactory(deploymentInfo, securityService, instanceLimit);
EndpointFactory endpointFactory = new EndpointFactory(activationSpec, this, deploymentInfo, instanceFactory, xaResourceWrapper);
// update the data structures
@@ -224,7 +224,7 @@
EndpointFactory endpointFactory = (EndpointFactory) deploymentInfo.getContainerData();
MdbInstanceFactory instanceFactory = endpointFactory.getInstanceFactory();
- Instance instance = null;
+ Instance instance;
try {
instance = (Instance) instanceFactory.createInstance(true);
} catch (UnavailableException e) {
@@ -252,21 +252,13 @@
mdbCallContext.deliveryMethod = method;
mdbCallContext.oldCallContext = oldContext;
- // add tx data
- mdbCallContext.txPolicy = deployInfo.getTransactionPolicy(method);
- mdbCallContext.txContext = new TransactionContext(callContext, transactionManager);
-
// call the tx before method
try {
- boolean adapterTransaction = transactionManager.getTransaction() != null;
- mdbCallContext.txPolicy.beforeInvoke(instance, mdbCallContext.txContext);
+ mdbCallContext.txPolicy = createTransactionPolicy(deployInfo.getTransactionType(method), callContext);
// if we have an xaResource and a transaction was not imported from the adapter, enlist the xaResource
- if (xaResource != null && !adapterTransaction) {
- Transaction transaction = transactionManager.getTransaction();
- if (transaction != null) {
- transaction.enlistResource(xaResource);
- }
+ if (xaResource != null && mdbCallContext.txPolicy.isNewTransaction()) {
+ mdbCallContext.txPolicy.enlistResource(xaResource);
}
} catch (ApplicationException e) {
ThreadContext.exit(oldContext);
@@ -342,46 +334,38 @@
}
private Object _invoke(Object instance, Method runMethod, Object [] args, DeploymentInfo deploymentInfo, MdbCallContext mdbCallContext) throws SystemException, ApplicationException {
- Object returnValue = null;
+ Object returnValue;
try {
List<InterceptorData> interceptors = deploymentInfo.getMethodInterceptors(runMethod);
InterceptorStack interceptorStack = new InterceptorStack(((Instance)instance).bean, runMethod, Operation.BUSINESS, interceptors, ((Instance)instance).interceptors);
returnValue = interceptorStack.invoke(args);
return returnValue;
- } catch (java.lang.reflect.InvocationTargetException ite) {// handle exceptions thrown by enterprise bean
- if (!isApplicationException(deploymentInfo, ite.getTargetException())) {
- //
- /// System Exception ****************************
- mdbCallContext.txPolicy.handleSystemException(ite.getTargetException(), instance, mdbCallContext.txContext);
- } else {
- //
- // Application Exception ***********************
- mdbCallContext.txPolicy.handleApplicationException(ite.getTargetException(), false, mdbCallContext.txContext);
+ } catch (Throwable e) {
+ // unwrap invocation target exception
+ if (e instanceof InvocationTargetException) {
+ e = ((InvocationTargetException) e).getTargetException();
}
- } catch (Throwable re) {// handle reflection exception
+
// Any exception thrown by reflection; not by the enterprise bean. Possible
// Exceptions are:
// IllegalAccessException - if the underlying method is inaccessible.
// IllegalArgumentException - if the number of actual and formal parameters differ, or if an unwrapping conversion fails.
// NullPointerException - if the specified object is null and the method is an instance method.
// ExceptionInInitializerError - if the initialization provoked by this method fails.
- if (!isApplicationException(deploymentInfo, re)) {
+ ExceptionType type = deploymentInfo.getExceptionType(e);
+ if (type == ExceptionType.SYSTEM) {
//
/// System Exception ****************************
- mdbCallContext.txPolicy.handleSystemException(re, instance, mdbCallContext.txContext);
+ handleSystemException(mdbCallContext.txPolicy, e, ThreadContext.getThreadContext());
} else {
//
// Application Exception ***********************
- mdbCallContext.txPolicy.handleApplicationException(re, false, mdbCallContext.txContext);
+ handleApplicationException(mdbCallContext.txPolicy, e, false);
}
}
throw new AssertionError("Should not get here");
}
- private boolean isApplicationException(DeploymentInfo deploymentInfo, Throwable e) {
- return e instanceof Exception && !(e instanceof RuntimeException);
- }
-
public void afterDelivery(Object instance) throws SystemException {
// get the mdb call context
ThreadContext callContext = ThreadContext.getThreadContext();
@@ -389,7 +373,7 @@
// invoke the tx after method
try {
- mdbCallContext.txPolicy.afterInvoke(instance, mdbCallContext.txContext);
+ afterInvoke(mdbCallContext.txPolicy, callContext);
} catch (ApplicationException e) {
throw new SystemException("Should never get an Application exception", e);
} finally {
@@ -410,7 +394,7 @@
MdbCallContext mdbCallContext = callContext.get(MdbCallContext.class);
if (mdbCallContext != null) {
try {
- mdbCallContext.txPolicy.afterInvoke(instance, mdbCallContext.txContext);
+ afterInvoke(mdbCallContext.txPolicy, callContext);
} catch (Exception e) {
logger.error("error while releasing message endpoint", e);
} finally {
@@ -425,10 +409,6 @@
private static class MdbCallContext {
private Method deliveryMethod;
private TransactionPolicy txPolicy;
- private TransactionContext txContext;
private ThreadContext oldCallContext;
}
-
- public void discardInstance(Object instance, ThreadContext context) {
- }
}
Modified: openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/mdb/MdbContext.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/mdb/MdbContext.java?rev=688602&r1=688601&r2=688602&view=diff
==============================================================================
--- openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/mdb/MdbContext.java (original)
+++ openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/mdb/MdbContext.java Sun Aug 24 19:39:06 2008
@@ -21,7 +21,6 @@
import javax.ejb.EJBLocalHome;
import javax.ejb.MessageDrivenContext;
import javax.ejb.TimerService;
-import javax.transaction.TransactionManager;
import javax.transaction.UserTransaction;
import org.apache.openejb.core.BaseContext;
@@ -29,7 +28,6 @@
import org.apache.openejb.core.ThreadContext;
import org.apache.openejb.spi.SecurityService;
-
/**
* @version $Rev$ $Date$
*/
@@ -40,13 +38,9 @@
public static State[] getStates() {
return states;
}
-
- public MdbContext(TransactionManager transactionManager, SecurityService securityService) {
- super(transactionManager, securityService);
- }
- protected MdbContext(TransactionManager transactionManager, SecurityService securityService, UserTransaction userTransaction) {
- super(transactionManager, securityService, userTransaction);
+ public MdbContext(SecurityService securityService) {
+ super(securityService);
}
protected State getState() {
@@ -88,12 +82,12 @@
}
@Override
- public boolean getRollbackOnly(TransactionManager transactionManager) throws IllegalStateException {
+ public boolean getRollbackOnly() throws IllegalStateException {
throw new IllegalStateException();
}
@Override
- public void setRollbackOnly(TransactionManager transactionManager) throws IllegalStateException {
+ public void setRollbackOnly() throws IllegalStateException {
throw new IllegalStateException();
}
@@ -158,12 +152,12 @@
}
@Override
- public boolean getRollbackOnly(TransactionManager transactionManager) throws IllegalStateException {
+ public boolean getRollbackOnly() throws IllegalStateException {
throw new IllegalStateException();
}
@Override
- public void setRollbackOnly(TransactionManager transactionManager) throws IllegalStateException {
+ public void setRollbackOnly() throws IllegalStateException {
throw new IllegalStateException();
}
Modified: openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/mdb/MdbInstanceFactory.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/mdb/MdbInstanceFactory.java?rev=688602&r1=688601&r2=688602&view=diff
==============================================================================
--- openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/mdb/MdbInstanceFactory.java (original)
+++ openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/mdb/MdbInstanceFactory.java Sun Aug 24 19:39:06 2008
@@ -17,31 +17,28 @@
*/
package org.apache.openejb.core.mdb;
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import javax.ejb.MessageDrivenBean;
+import javax.naming.Context;
+import javax.naming.NamingException;
+import javax.resource.spi.UnavailableException;
+
+import org.apache.openejb.Injection;
import org.apache.openejb.core.BaseContext;
import org.apache.openejb.core.CoreDeploymentInfo;
import org.apache.openejb.core.Operation;
import org.apache.openejb.core.ThreadContext;
import org.apache.openejb.core.interceptor.InterceptorData;
import org.apache.openejb.core.interceptor.InterceptorStack;
-import org.apache.openejb.core.mdb.Instance;
import org.apache.openejb.spi.SecurityService;
-import org.apache.openejb.Injection;
import org.apache.openejb.util.LogCategory;
import org.apache.openejb.util.Logger;
+import org.apache.xbean.recipe.ConstructionException;
import org.apache.xbean.recipe.ObjectRecipe;
import org.apache.xbean.recipe.Option;
-import org.apache.xbean.recipe.StaticRecipe;
-import org.apache.xbean.recipe.ConstructionException;
-
-import javax.ejb.MessageDrivenBean;
-import javax.naming.Context;
-import javax.naming.NamingException;
-import javax.resource.spi.UnavailableException;
-import javax.transaction.TransactionManager;
-import java.lang.reflect.Method;
-import java.util.List;
-import java.util.ArrayList;
-import java.util.HashMap;
/**
* A MdbInstanceFactory creates instances of message driven beans for a single instance. This class differs from other
@@ -58,7 +55,6 @@
private static final Logger logger = Logger.getInstance(LogCategory.OPENEJB, "org.apache.openejb.util.resources");
private final CoreDeploymentInfo deploymentInfo;
- private final TransactionManager transactionManager;
private final SecurityService securityService;
private final int instanceLimit;
private int instanceCount;
@@ -66,13 +62,11 @@
/**
* Creates a MdbInstanceFactory for a single specific deployment.
* @param deploymentInfo the deployment for which instances will be created
- * @param transactionManager the transaction manager for this container system
* @param securityService the transaction manager for this container system
* @param instanceLimit the maximal number of instances or <= 0 if unlimited
*/
- public MdbInstanceFactory(CoreDeploymentInfo deploymentInfo, TransactionManager transactionManager, SecurityService securityService, int instanceLimit) {
+ public MdbInstanceFactory(CoreDeploymentInfo deploymentInfo, SecurityService securityService, int instanceLimit) {
this.deploymentInfo = deploymentInfo;
- this.transactionManager = transactionManager;
this.securityService = securityService;
this.instanceLimit = instanceLimit;
}
@@ -187,12 +181,12 @@
try {
Context ctx = deploymentInfo.getJndiEnc();
// construct the bean instance
- MdbContext mdbContext = null;
+ MdbContext mdbContext;
synchronized(this) {
try {
mdbContext = (MdbContext) ctx.lookup("java:comp/EJBContext");
} catch (NamingException e) {
- mdbContext = new MdbContext(transactionManager, securityService);
+ mdbContext = new MdbContext(securityService);
ctx.bind("java:comp/EJBContext",mdbContext);
}
}
@@ -202,7 +196,7 @@
callContext.setCurrentOperation(Operation.INJECTION);
callContext.setCurrentAllowedStates(MdbContext.getStates());
if(MessageDrivenBean.class.isAssignableFrom(beanClass)) {
- objectRecipe.setProperty("messageDrivenContext", new StaticRecipe(mdbContext));
+ objectRecipe.setProperty("messageDrivenContext", mdbContext);
}
Object bean = objectRecipe.create();
@@ -228,27 +222,19 @@
// TODO: We need to keep these somehwere
interceptorInstances.put(beanClass.getName(), bean);
Instance instance = new Instance(bean,interceptorInstances);
- try {
- callContext.setCurrentOperation(Operation.POST_CONSTRUCT);
- callContext.setCurrentAllowedStates(MdbContext.getStates());
+ callContext.setCurrentOperation(Operation.POST_CONSTRUCT);
+ callContext.setCurrentAllowedStates(MdbContext.getStates());
- List<InterceptorData> callbackInterceptors = deploymentInfo.getCallbackInterceptors();
- InterceptorStack interceptorStack = new InterceptorStack(bean, null, Operation.POST_CONSTRUCT, callbackInterceptors, interceptorInstances);
- interceptorStack.invoke();
- } catch (Exception e) {
- throw e;
- }
+ List<InterceptorData> callbackInterceptors = deploymentInfo.getCallbackInterceptors();
+ InterceptorStack interceptorStack = new InterceptorStack(bean, null, Operation.POST_CONSTRUCT, callbackInterceptors, interceptorInstances);
+ interceptorStack.invoke();
- try {
- if (bean instanceof MessageDrivenBean){
- callContext.setCurrentOperation(Operation.CREATE);
- callContext.setCurrentAllowedStates(MdbContext.getStates());
- Method create = deploymentInfo.getCreateMethod();
- InterceptorStack interceptorStack = new InterceptorStack(bean, create, Operation.CREATE, new ArrayList(), new HashMap());
- interceptorStack.invoke();
- }
- } catch (Exception e) {
- throw e;
+ if (bean instanceof MessageDrivenBean){
+ callContext.setCurrentOperation(Operation.CREATE);
+ callContext.setCurrentAllowedStates(MdbContext.getStates());
+ Method create = deploymentInfo.getCreateMethod();
+ interceptorStack = new InterceptorStack(bean, create, Operation.CREATE, new ArrayList(), new HashMap());
+ interceptorStack.invoke();
}
return instance;
@@ -276,7 +262,7 @@
// another data type by an xbean-reflect property editor
objectRecipe.setProperty(injection.getTarget().getName() + "/" + injection.getName(), string);
} else {
- objectRecipe.setProperty(injection.getTarget().getName() + "/" + injection.getName(), new StaticRecipe(object));
+ objectRecipe.setProperty(injection.getTarget().getName() + "/" + injection.getName(), object);
}
} catch (NamingException e) {
logger.warning("Injection data not found in enc: jndiName='" + injection.getJndiName() + "', target=" + injection.getTarget() + "/" + injection.getName());
Modified: openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/singleton/SingletonContainer.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/singleton/SingletonContainer.java?rev=688602&r1=688601&r2=688602&view=diff
==============================================================================
--- openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/singleton/SingletonContainer.java (original)
+++ openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/singleton/SingletonContainer.java Sun Aug 24 19:39:06 2008
@@ -31,13 +31,13 @@
import javax.ejb.EJBObject;
import javax.ejb.ConcurrentAccessTimeoutException;
import javax.interceptor.AroundInvoke;
-import javax.transaction.TransactionManager;
import org.apache.openejb.ContainerType;
import org.apache.openejb.DeploymentInfo;
import org.apache.openejb.OpenEJBException;
import org.apache.openejb.ProxyInfo;
import org.apache.openejb.InterfaceType;
+import org.apache.openejb.RpcContainer;
import org.apache.openejb.util.Duration;
import org.apache.openejb.core.CoreDeploymentInfo;
import org.apache.openejb.core.Operation;
@@ -46,34 +46,34 @@
import org.apache.openejb.core.interceptor.InterceptorData;
import org.apache.openejb.core.interceptor.InterceptorStack;
import org.apache.openejb.core.timer.EjbTimerService;
-import org.apache.openejb.core.transaction.TransactionContainer;
-import org.apache.openejb.core.transaction.TransactionContext;
import org.apache.openejb.core.transaction.TransactionPolicy;
+import static org.apache.openejb.core.transaction.EjbTransactionUtil.handleApplicationException;
+import static org.apache.openejb.core.transaction.EjbTransactionUtil.handleSystemException;
+import static org.apache.openejb.core.transaction.EjbTransactionUtil.afterInvoke;
+import static org.apache.openejb.core.transaction.EjbTransactionUtil.createTransactionPolicy;
import org.apache.openejb.spi.SecurityService;
import org.apache.openejb.finder.ClassFinder;
/**
* @org.apache.xbean.XBean element="statelessContainer"
*/
-public class SingletonContainer implements org.apache.openejb.RpcContainer, TransactionContainer {
+public class SingletonContainer implements RpcContainer {
private SingletonInstanceManager instanceManager;
private HashMap<String,DeploymentInfo> deploymentRegistry = new HashMap<String,DeploymentInfo>();
private Object containerID = null;
- private TransactionManager transactionManager;
private SecurityService securityService;
private long wait = 30;
private TimeUnit unit = TimeUnit.SECONDS;
- public SingletonContainer(Object id, TransactionManager transactionManager, SecurityService securityService) throws OpenEJBException {
+ public SingletonContainer(Object id, SecurityService securityService) throws OpenEJBException {
this.containerID = id;
- this.transactionManager = transactionManager;
this.securityService = securityService;
- instanceManager = new SingletonInstanceManager(transactionManager, securityService);
+ instanceManager = new SingletonInstanceManager(securityService);
for (DeploymentInfo deploymentInfo : deploymentRegistry.values()) {
org.apache.openejb.core.CoreDeploymentInfo di = (org.apache.openejb.core.CoreDeploymentInfo) deploymentInfo;
@@ -220,14 +220,8 @@
return _invoke(callInterface, callMethod, runMethod, args, (Instance) object, callContext);
}
- protected Object _invoke(Class callInterface, Method callMethod, Method runMethod, Object[] args, Instance instance, ThreadContext callContext)
- throws OpenEJBException {
-
+ protected Object _invoke(Class callInterface, Method callMethod, Method runMethod, Object[] args, Instance instance, ThreadContext callContext) throws OpenEJBException {
CoreDeploymentInfo deploymentInfo = callContext.getDeploymentInfo();
- TransactionPolicy txPolicy = deploymentInfo.getTransactionPolicy(callMethod);
- TransactionContext txContext = new TransactionContext(callContext, getTransactionManager());
- txContext.callContext = callContext;
-
boolean read = deploymentInfo.getConcurrencyAttribute(runMethod) == DeploymentInfo.READ_LOCK;
@@ -235,7 +229,7 @@
Object returnValue;
try {
- txPolicy.beforeInvoke(instance, txContext);
+ TransactionPolicy txPolicy = createTransactionPolicy(deploymentInfo.getTransactionType(callMethod), callContext);
returnValue = null;
try {
@@ -248,26 +242,23 @@
InterceptorStack interceptorStack = new InterceptorStack(instance.bean, runMethod, Operation.BUSINESS, interceptors, instance.interceptors);
returnValue = interceptorStack.invoke(args);
}
- } catch (Throwable re) {// handle reflection exception
- ExceptionType type = deploymentInfo.getExceptionType(re);
+ } catch (Throwable e) {// handle reflection exception
+ ExceptionType type = deploymentInfo.getExceptionType(e);
if (type == ExceptionType.SYSTEM) {
/* System Exception ****************************/
- /**
- * The bean instance is not put into the pool via instanceManager.poolInstance
- * and therefore the instance will be garbage collected and destroyed.
- * For this reason the discardInstance method of the StatelessInstanceManager
- * does nothing.
- */
-
- txPolicy.handleSystemException(re, instance, txContext);
+ // The bean instance is not put into the pool via instanceManager.poolInstance
+ // and therefore the instance will be garbage collected and destroyed.
+ // For this reason the discardInstance method of the StatelessInstanceManager
+ // does nothing.
+ handleSystemException(txPolicy, e, callContext);
} else {
/* Application Exception ***********************/
- txPolicy.handleApplicationException(re, type == ExceptionType.APPLICATION_ROLLBACK, txContext);
+ handleApplicationException(txPolicy, e, type == ExceptionType.APPLICATION_ROLLBACK);
}
} finally {
- txPolicy.afterInvoke(instance, txContext);
+ afterInvoke(txPolicy, callContext);
}
} finally {
lock.unlock();
@@ -340,15 +331,7 @@
throw new IllegalArgumentException("Uknown MessageContext type: " + messageContext.getClass().getName());
}
- private TransactionManager getTransactionManager() {
- return transactionManager;
- }
-
protected ProxyInfo createEJBObject(org.apache.openejb.core.CoreDeploymentInfo deploymentInfo, Method callMethod) {
return new ProxyInfo(deploymentInfo, null);
}
-
- public void discardInstance(Object instance, ThreadContext context) {
-// instanceManager.discardInstance(context, instance);
- }
}
Modified: openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/singleton/SingletonContext.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/singleton/SingletonContext.java?rev=688602&r1=688601&r2=688602&view=diff
==============================================================================
--- openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/singleton/SingletonContext.java (original)
+++ openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/singleton/SingletonContext.java Sun Aug 24 19:39:06 2008
@@ -16,32 +16,23 @@
*/
package org.apache.openejb.core.singleton;
-import javax.transaction.TransactionManager;
-import javax.transaction.UserTransaction;
-
import org.apache.openejb.core.BaseSessionContext;
import org.apache.openejb.core.Operation;
import org.apache.openejb.core.ThreadContext;
import org.apache.openejb.spi.SecurityService;
-
/**
* @version $Rev$ $Date$
*/
public class SingletonContext extends BaseSessionContext {
-
protected final static State[] states = new State[Operation.values().length];
public static State[] getStates() {
return states;
}
-
- public SingletonContext(TransactionManager transactionManager, SecurityService securityService) {
- super(transactionManager, securityService);
- }
- public SingletonContext(TransactionManager transactionManager, SecurityService securityService, UserTransaction userTransaction) {
- super(transactionManager, securityService, userTransaction);
+ public SingletonContext(SecurityService securityService) {
+ super(securityService);
}
protected State getState() {
Modified: openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/singleton/SingletonInstanceManager.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/singleton/SingletonInstanceManager.java?rev=688602&r1=688601&r2=688602&view=diff
==============================================================================
--- openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/singleton/SingletonInstanceManager.java (original)
+++ openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/singleton/SingletonInstanceManager.java Sun Aug 24 19:39:06 2008
@@ -32,7 +32,6 @@
import javax.ejb.SessionContext;
import javax.naming.Context;
import javax.naming.NamingException;
-import javax.transaction.TransactionManager;
import javax.xml.ws.WebServiceContext;
import org.apache.openejb.Injection;
@@ -50,17 +49,14 @@
import org.apache.xbean.recipe.ConstructionException;
import org.apache.xbean.recipe.ObjectRecipe;
import org.apache.xbean.recipe.Option;
-import org.apache.xbean.recipe.StaticRecipe;
public class SingletonInstanceManager {
private static final Logger logger = Logger.getInstance(LogCategory.OPENEJB, "org.apache.openejb.util.resources");
protected final SafeToolkit toolkit = SafeToolkit.getToolkit("SingletonInstanceManager");
- private TransactionManager transactionManager;
private SecurityService securityService;
- public SingletonInstanceManager(TransactionManager transactionManager, SecurityService securityService) {
- this.transactionManager = transactionManager;
+ public SingletonInstanceManager(SecurityService securityService) {
this.securityService = securityService;
}
@@ -114,15 +110,15 @@
if (javax.ejb.SessionBean.class.isAssignableFrom(beanClass) || hasSetSessionContext(beanClass)) {
callContext.setCurrentOperation(Operation.INJECTION);
callContext.setCurrentAllowedStates(SingletonContext.getStates());
- objectRecipe.setProperty("sessionContext", new StaticRecipe(sessionContext));
+ objectRecipe.setProperty("sessionContext", sessionContext);
}
- WebServiceContext wsContext;
// This is a fix for GERONIMO-3444
synchronized(this){
try {
- wsContext = (WebServiceContext) ctx.lookup("java:comp/WebServiceContext");
+ ctx.lookup("java:comp/WebServiceContext");
} catch (NamingException e) {
+ WebServiceContext wsContext;
wsContext = new EjbWsContext(sessionContext);
ctx.bind("java:comp/WebServiceContext", wsContext);
}
@@ -162,27 +158,19 @@
interceptorInstances.put(beanClass.getName(), bean);
- try {
- callContext.setCurrentOperation(Operation.POST_CONSTRUCT);
- callContext.setCurrentAllowedStates(SingletonContext.getStates());
+ callContext.setCurrentOperation(Operation.POST_CONSTRUCT);
+ callContext.setCurrentAllowedStates(SingletonContext.getStates());
- List<InterceptorData> callbackInterceptors = deploymentInfo.getCallbackInterceptors();
- InterceptorStack interceptorStack = new InterceptorStack(bean, null, Operation.POST_CONSTRUCT, callbackInterceptors, interceptorInstances);
- interceptorStack.invoke();
- } catch (Exception e) {
- throw e;
- }
+ List<InterceptorData> callbackInterceptors = deploymentInfo.getCallbackInterceptors();
+ InterceptorStack interceptorStack = new InterceptorStack(bean, null, Operation.POST_CONSTRUCT, callbackInterceptors, interceptorInstances);
+ interceptorStack.invoke();
- try {
- if (bean instanceof SessionBean){
- callContext.setCurrentOperation(Operation.CREATE);
- callContext.setCurrentAllowedStates(SingletonContext.getStates());
- Method create = deploymentInfo.getCreateMethod();
- InterceptorStack interceptorStack = new InterceptorStack(bean, create, Operation.CREATE, new ArrayList<InterceptorData>(), new HashMap());
- interceptorStack.invoke();
- }
- } catch (Exception e) {
- throw e;
+ if (bean instanceof SessionBean){
+ callContext.setCurrentOperation(Operation.CREATE);
+ callContext.setCurrentAllowedStates(SingletonContext.getStates());
+ Method create = deploymentInfo.getCreateMethod();
+ interceptorStack = new InterceptorStack(bean, create, Operation.CREATE, new ArrayList<InterceptorData>(), new HashMap());
+ interceptorStack.invoke();
}
ReadWriteLock lock;
@@ -240,7 +228,7 @@
// another data type by an xbean-reflect property editor
objectRecipe.setProperty(prefix + injection.getName(), string);
} else {
- objectRecipe.setProperty(prefix + injection.getName(), new StaticRecipe(object));
+ objectRecipe.setProperty(prefix + injection.getName(), object);
}
} catch (NamingException e) {
logger.warning("Injection data not found in enc: jndiName='" + injection.getJndiName() + "', target=" + injection.getTarget() + "/" + injection.getName());
@@ -258,7 +246,7 @@
}
private SessionContext createSessionContext() {
- return new SingletonContext(transactionManager, securityService);
+ return new SingletonContext(securityService);
}
public void freeInstance(ThreadContext callContext) {
Modified: openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/stateful/BeanEntry.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/stateful/BeanEntry.java?rev=688602&r1=688601&r2=688602&view=diff
==============================================================================
--- openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/stateful/BeanEntry.java (original)
+++ openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/stateful/BeanEntry.java Sun Aug 24 19:39:06 2008
@@ -19,21 +19,22 @@
import java.io.Serializable;
import java.util.Map;
import java.util.HashMap;
-import javax.transaction.Transaction;
import javax.persistence.EntityManagerFactory;
import javax.persistence.EntityManager;
import org.apache.openejb.util.Index;
+import org.apache.openejb.core.transaction.BeanTransactionPolicy.SuspendedTransaction;
public class BeanEntry implements Serializable {
private static final long serialVersionUID = 5940667199866151048L;
protected final Object bean;
protected final Object primaryKey;
- protected boolean inQueue = false;
+ protected boolean inUse = false;
+ protected transient boolean inQueue = false;
private long timeStamp;
protected long timeOutInterval;
- protected transient Transaction beanTransaction;
+ protected transient SuspendedTransaction beanTransaction;
// todo if we keyed by an entity manager factory id we would not have to make this transient and rebuild the index below
// This would require that we crete an id and that we track it
// alternatively, we could use ImmutableArtifact with some read/write replace magic
@@ -55,7 +56,15 @@
timeStamp = prototype.timeStamp;
timeOutInterval = prototype.timeOutInterval;
}
-
+
+ public boolean isInUse() {
+ return inUse;
+ }
+
+ public void setInUse(boolean inUse) {
+ this.inUse = inUse;
+ }
+
protected boolean isTimedOut() {
if (timeOutInterval == 0) {
return false;