[jboss-cvs] JBossAS SVN: r69892 - in projects/ejb3/trunk/core: src/main/java/org/jboss/ejb3/entity and 6 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Mon Feb 18 12:27:56 EST 2008
Author: bdecoste
Date: 2008-02-18 12:27:56 -0500 (Mon, 18 Feb 2008)
New Revision: 69892
Added:
projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/test/epcpropagation/
projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/test/epcpropagation/CMTEPCStatefulBean.java
projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/test/epcpropagation/CMTStatefulBean.java
projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/test/epcpropagation/EPCStatefulBean.java
projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/test/epcpropagation/InitEPCStatefulBean.java
projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/test/epcpropagation/IntermediateStatefulBean.java
projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/test/epcpropagation/IntermediateStatefulRemote.java
projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/test/epcpropagation/MyEntity.java
projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/test/epcpropagation/NoTxEPCStatefulBean.java
projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/test/epcpropagation/NoTxStatefulBean.java
projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/test/epcpropagation/StatefulBean.java
projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/test/epcpropagation/StatefulRemote.java
projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/test/epcpropagation/StatelessBean.java
projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/test/epcpropagation/StatelessRemote.java
projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/test/epcpropagation/unit/
projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/test/epcpropagation/unit/EPCPropagationTestCase.java
projects/ejb3/trunk/core/src/test/resources/test/epcpropagation/
projects/ejb3/trunk/core/src/test/resources/test/epcpropagation/META-INF/
projects/ejb3/trunk/core/src/test/resources/test/epcpropagation/META-INF/persistence.xml
Modified:
projects/ejb3/trunk/core/build-test.xml
projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/entity/TransactionScopedEntityManager.java
Log:
[JBPAPP-586] merged fix and test from EAP
Modified: projects/ejb3/trunk/core/build-test.xml
===================================================================
--- projects/ejb3/trunk/core/build-test.xml 2008-02-18 17:06:30 UTC (rev 69891)
+++ projects/ejb3/trunk/core/build-test.xml 2008-02-18 17:27:56 UTC (rev 69892)
@@ -1986,7 +1986,21 @@
</fileset>
</copy>
</target>
+
+ <target name="epcpropagation"
+ description="Builds all jar files."
+ >
+ <mkdir dir="${build.lib}"/>
+
+ <jar jarfile="${build.lib}/epcpropagation-test.jar">
+ <fileset dir="${build.classes}">
+ <include name="org/jboss/ejb3/test/epcpropagation/*.class"/>
+ </fileset>
+ <fileset dir="${resources}/test/epcpropagation"/>
+ </jar>
+ </target>
+
<target name="ejbthree959"
description="Builds a simple jar files."
>
@@ -3968,6 +3982,7 @@
ejbthree1066, ejbthree1071, ejbthree1075, ejbthree1082, ejbthree1090, ejbthree1092, ejbthree1119, ejbthree1122, ejbthree1123, ejbthree1127,
ejbthree1130,
ejbthree1146, ejbthree1148, ejbthree1154, ejbthree1155, ejbthree1157, jaxws, jbas4489,
+ epcpropagation,
aspectdomain, ejbcontext, schema, mail, scopedclassloader, dependency,
securitydomain, enventry, security5,
jms/managed, naming, bmt, jca/inflowmdb, pool, jms, security, reference21_30, factory, dd/web, txexceptions,
@@ -5023,6 +5038,9 @@
</target>
<target name="no-start-jboss-entity-tests" depends="init" description="Execute all tests">
+ <antcall target="test" inheritRefs="true">
+ <param name="test" value="epcpropagation"/>
+ </antcall>
<antcall target="test" inheritRefs="true">
<param name="test" value="regression/ejbthree440"/>
</antcall>
Modified: projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/entity/TransactionScopedEntityManager.java
===================================================================
--- projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/entity/TransactionScopedEntityManager.java 2008-02-18 17:06:30 UTC (rev 69891)
+++ projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/entity/TransactionScopedEntityManager.java 2008-02-18 17:27:56 UTC (rev 69892)
@@ -24,6 +24,8 @@
import org.hibernate.Session;
import org.hibernate.ejb.HibernateEntityManager;
import org.jboss.ejb3.PersistenceUnitRegistry;
+import org.jboss.ejb3.stateful.StatefulBeanContext;
+import org.jboss.logging.Logger;
import javax.persistence.*;
import java.io.Externalizable;
@@ -31,6 +33,7 @@
import java.io.ObjectInput;
import java.io.ObjectOutput;
+import java.util.List;
/**
* @author <a href="mailto:bill at jboss.org">Bill Burke</a>
@@ -40,6 +43,8 @@
{
private static final long serialVersionUID = 4260828563883650376L;
+ private static final Logger log = Logger.getLogger(TransactionScopedEntityManager.class);
+
private transient ManagedEntityManagerFactory factory;
public Session getHibernateSession()
@@ -78,34 +83,34 @@
public Object getDelegate()
{
- return factory.getTransactionScopedEntityManager().getDelegate();
+ return getEntityManager().getDelegate();
}
public void joinTransaction()
{
factory.verifyInTx();
- factory.getTransactionScopedEntityManager().joinTransaction();
+ getEntityManager().joinTransaction();
}
public void clear()
{
- factory.getTransactionScopedEntityManager().clear();
+ getEntityManager().clear();
}
public FlushModeType getFlushMode()
{
- return factory.getTransactionScopedEntityManager().getFlushMode();
+ return getEntityManager().getFlushMode();
}
public void lock(Object entity, LockModeType lockMode)
{
factory.verifyInTx();
- factory.getTransactionScopedEntityManager().lock(entity, lockMode);
+ getEntityManager().lock(entity, lockMode);
}
public <T> T getReference(Class<T> entityClass, Object primaryKey)
{
- EntityManager em = factory.getTransactionScopedEntityManager();
+ EntityManager em = getEntityManager();
if (!factory.isInTx()) em.clear(); // em will be closed by interceptor
try
{
@@ -119,47 +124,47 @@
public void setFlushMode(FlushModeType flushMode)
{
- factory.getTransactionScopedEntityManager().setFlushMode(flushMode);
+ getEntityManager().setFlushMode(flushMode);
}
public Query createQuery(String ejbqlString)
{
- EntityManager em = factory.getTransactionScopedEntityManager();
+ EntityManager em = getEntityManager();
if (!factory.isInTx()) em.clear(); // em will be closed by interceptor
return em.createQuery(ejbqlString);
}
public Query createNamedQuery(String name)
{
- EntityManager em = factory.getTransactionScopedEntityManager();
+ EntityManager em = getEntityManager();
if (!factory.isInTx()) em.clear(); // em will be closed by interceptor
return em.createNamedQuery(name);
}
public Query createNativeQuery(String sqlString)
{
- EntityManager em = factory.getTransactionScopedEntityManager();
+ EntityManager em = getEntityManager();
if (!factory.isInTx()) em.clear(); // em will be closed by interceptor
return em.createNativeQuery(sqlString);
}
public Query createNativeQuery(String sqlString, Class resultClass)
{
- EntityManager em = factory.getTransactionScopedEntityManager();
+ EntityManager em = getEntityManager();
if (!factory.isInTx()) em.clear(); // em will be closed by interceptor
return em.createNativeQuery(sqlString, resultClass);
}
public Query createNativeQuery(String sqlString, String resultSetMapping)
{
- EntityManager em = factory.getTransactionScopedEntityManager();
+ EntityManager em = getEntityManager();
if (!factory.isInTx()) em.clear(); // em will be closed by interceptor
return em.createNativeQuery(sqlString, resultSetMapping);
}
public <A> A find(Class<A> entityClass, Object primaryKey)
{
- EntityManager em = factory.getTransactionScopedEntityManager();
+ EntityManager em = getEntityManager();
if (!factory.isInTx()) em.clear(); // em will be closed by interceptor
try
{
@@ -174,36 +179,36 @@
public void persist(Object entity)
{
factory.verifyInTx();
- factory.getTransactionScopedEntityManager().persist(entity);
+ getEntityManager().persist(entity);
}
public <A> A merge(A entity)
{
factory.verifyInTx();
- return (A) factory.getTransactionScopedEntityManager().merge(entity);
+ return (A) getEntityManager().merge(entity);
}
public void remove(Object entity)
{
factory.verifyInTx();
- factory.getTransactionScopedEntityManager().remove(entity);
+ getEntityManager().remove(entity);
}
public void refresh(Object entity)
{
factory.verifyInTx();
- factory.getTransactionScopedEntityManager().refresh(entity);
+ getEntityManager().refresh(entity);
}
public boolean contains(Object entity)
{
- return factory.getTransactionScopedEntityManager().contains(entity);
+ return getEntityManager().contains(entity);
}
public void flush()
{
factory.verifyInTx();
- factory.getTransactionScopedEntityManager().flush();
+ getEntityManager().flush();
}
public void close()
@@ -220,5 +225,24 @@
{
throw new IllegalStateException("Illegal to call this method from injected, managed EntityManager");
}
+
+ protected EntityManager getEntityManager()
+ {
+ StatefulBeanContext beanContext = StatefulBeanContext.currentBean.get();
+
+ EntityManager em;
+ if (beanContext != null)
+ {
+ List<StatefulBeanContext> beanContexts = StatefulBeanContext.currentBean.getList();
+ for( StatefulBeanContext bc : beanContexts)
+ {
+ em = bc.getExtendedPersistenceContext(factory.getKernelName());
+ if (em != null)
+ return em;
+ }
+ }
+
+ return factory.getTransactionScopedEntityManager();
+ }
}
Added: projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/test/epcpropagation/CMTEPCStatefulBean.java
===================================================================
--- projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/test/epcpropagation/CMTEPCStatefulBean.java (rev 0)
+++ projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/test/epcpropagation/CMTEPCStatefulBean.java 2008-02-18 17:27:56 UTC (rev 69892)
@@ -0,0 +1,67 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2007, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ejb3.test.epcpropagation;
+
+import javax.annotation.Resource;
+import javax.ejb.EJB;
+import javax.ejb.Local;
+import javax.ejb.Remote;
+import javax.ejb.SessionContext;
+import javax.ejb.Stateful;
+import javax.ejb.TransactionManagement;
+import javax.ejb.TransactionManagementType;
+import javax.persistence.EntityManager;
+import javax.persistence.PersistenceContext;
+import javax.persistence.PersistenceContextType;
+import javax.transaction.Status;
+import javax.transaction.UserTransaction;
+
+import org.jboss.logging.Logger;
+
+/**
+ * @author <a href="mailto:bdecoste at jboss.com">William DeCoste</a>
+ */
+ at Stateful
+ at Remote(StatefulRemote.class)
+public class CMTEPCStatefulBean implements StatefulRemote
+{
+ private static final Logger log = Logger.getLogger(CMTEPCStatefulBean.class);
+
+ @PersistenceContext(type=PersistenceContextType.EXTENDED, unitName="mypc")
+ EntityManager em;
+
+ @Resource
+ SessionContext sessionContext;
+
+ @EJB
+ StatelessRemote cmtBean;
+
+ public boolean execute(Integer id, String name) throws Exception
+ {
+ MyEntity eb = em.find(MyEntity.class, id);
+ eb.setName(name.toUpperCase());
+
+ String propagatedName = cmtBean.updateEntity(id, name.toLowerCase());
+
+ return propagatedName.equals(name.toUpperCase());
+ }
+}
\ No newline at end of file
Added: projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/test/epcpropagation/CMTStatefulBean.java
===================================================================
--- projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/test/epcpropagation/CMTStatefulBean.java (rev 0)
+++ projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/test/epcpropagation/CMTStatefulBean.java 2008-02-18 17:27:56 UTC (rev 69892)
@@ -0,0 +1,67 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2007, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ejb3.test.epcpropagation;
+
+import javax.annotation.Resource;
+import javax.ejb.EJB;
+import javax.ejb.Local;
+import javax.ejb.Remote;
+import javax.ejb.SessionContext;
+import javax.ejb.Stateful;
+import javax.ejb.TransactionManagement;
+import javax.ejb.TransactionManagementType;
+import javax.persistence.EntityManager;
+import javax.persistence.PersistenceContext;
+import javax.persistence.PersistenceContextType;
+import javax.transaction.Status;
+import javax.transaction.UserTransaction;
+
+import org.jboss.logging.Logger;
+
+/**
+ * @author <a href="mailto:bdecoste at jboss.com">William DeCoste</a>
+ */
+ at Stateful
+ at Remote(StatefulRemote.class)
+public class CMTStatefulBean implements StatefulRemote
+{
+ private static final Logger log = Logger.getLogger(CMTStatefulBean.class);
+
+ @PersistenceContext(unitName="mypc")
+ EntityManager em;
+
+ @Resource
+ SessionContext sessionContext;
+
+ @EJB
+ StatelessRemote cmtBean;
+
+ public boolean execute(Integer id, String name) throws Exception
+ {
+ MyEntity eb = em.find(MyEntity.class, id);
+ eb.setName(name.toUpperCase());
+
+ String propagatedName = cmtBean.updateEntity(id, name.toLowerCase());
+
+ return propagatedName.equals(name.toUpperCase());
+ }
+}
\ No newline at end of file
Added: projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/test/epcpropagation/EPCStatefulBean.java
===================================================================
--- projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/test/epcpropagation/EPCStatefulBean.java (rev 0)
+++ projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/test/epcpropagation/EPCStatefulBean.java 2008-02-18 17:27:56 UTC (rev 69892)
@@ -0,0 +1,87 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2007, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ejb3.test.epcpropagation;
+
+import javax.annotation.Resource;
+import javax.ejb.EJB;
+import javax.ejb.Local;
+import javax.ejb.Remote;
+import javax.ejb.SessionContext;
+import javax.ejb.Stateful;
+import javax.ejb.TransactionManagement;
+import javax.ejb.TransactionManagementType;
+import javax.persistence.EntityManager;
+import javax.persistence.PersistenceContext;
+import javax.persistence.PersistenceContextType;
+import javax.transaction.Status;
+import javax.transaction.UserTransaction;
+
+import org.jboss.logging.Logger;
+
+/**
+ * @author <a href="mailto:bdecoste at jboss.com">William DeCoste</a>
+ */
+ at Stateful
+ at TransactionManagement(TransactionManagementType.BEAN)
+ at Remote(StatefulRemote.class)
+public class EPCStatefulBean implements StatefulRemote
+{
+ private static final Logger log = Logger.getLogger(EPCStatefulBean.class);
+
+ @PersistenceContext(type=PersistenceContextType.EXTENDED, unitName="mypc")
+ EntityManager em;
+
+ @Resource
+ SessionContext sessionContext;
+
+ @EJB
+ StatelessRemote cmtBean;
+
+ public boolean execute(Integer id, String name) throws Exception
+ {
+ try
+ {
+ UserTransaction tx1 = sessionContext.getUserTransaction();
+ tx1.begin();
+ em.joinTransaction();
+ MyEntity entity = em.find(MyEntity.class, id);
+ entity.setName(name.toUpperCase());
+
+ String propagatedName = cmtBean.updateEntity(id, name.toLowerCase());
+ tx1.commit();
+
+ return propagatedName.equals(name.toUpperCase());
+ }
+ catch (Exception e)
+ {
+ try
+ {
+ sessionContext.getUserTransaction().rollback();
+ }
+ catch (Exception e1)
+ {
+ log.info("ROLLBACK: "+e1);
+ }
+ throw e;
+ }
+ }
+}
\ No newline at end of file
Added: projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/test/epcpropagation/InitEPCStatefulBean.java
===================================================================
--- projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/test/epcpropagation/InitEPCStatefulBean.java (rev 0)
+++ projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/test/epcpropagation/InitEPCStatefulBean.java 2008-02-18 17:27:56 UTC (rev 69892)
@@ -0,0 +1,87 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2007, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ejb3.test.epcpropagation;
+
+import javax.annotation.Resource;
+import javax.ejb.EJB;
+import javax.ejb.Local;
+import javax.ejb.Remote;
+import javax.ejb.SessionContext;
+import javax.ejb.Stateful;
+import javax.ejb.TransactionManagement;
+import javax.ejb.TransactionManagementType;
+import javax.persistence.EntityManager;
+import javax.persistence.PersistenceContext;
+import javax.persistence.PersistenceContextType;
+import javax.transaction.Status;
+import javax.transaction.UserTransaction;
+
+import org.jboss.logging.Logger;
+
+/**
+ * @author <a href="mailto:bdecoste at jboss.com">William DeCoste</a>
+ */
+ at Stateful
+ at TransactionManagement(TransactionManagementType.BEAN)
+ at Remote(StatefulRemote.class)
+public class InitEPCStatefulBean implements StatefulRemote
+{
+ private static final Logger log = Logger.getLogger(InitEPCStatefulBean.class);
+
+ @PersistenceContext(type=PersistenceContextType.EXTENDED, unitName="mypc")
+ EntityManager em;
+
+ @Resource
+ SessionContext sessionContext;
+
+ @EJB(beanName="IntermediateStatefulBean")
+ StatefulRemote cmtBean;
+
+ public boolean execute(Integer id, String name) throws Exception
+ {
+ try
+ {
+ UserTransaction tx1 = sessionContext.getUserTransaction();
+ tx1.begin();
+ em.joinTransaction();
+ MyEntity entity = em.find(MyEntity.class, id);
+ entity.setName(name.toUpperCase());
+
+ boolean result = cmtBean.execute(id, name.toLowerCase());
+ tx1.commit();
+
+ return result;
+ }
+ catch (Exception e)
+ {
+ try
+ {
+ sessionContext.getUserTransaction().rollback();
+ }
+ catch (Exception e1)
+ {
+ log.info("ROLLBACK: "+e1);
+ }
+ throw e;
+ }
+ }
+}
\ No newline at end of file
Added: projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/test/epcpropagation/IntermediateStatefulBean.java
===================================================================
--- projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/test/epcpropagation/IntermediateStatefulBean.java (rev 0)
+++ projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/test/epcpropagation/IntermediateStatefulBean.java 2008-02-18 17:27:56 UTC (rev 69892)
@@ -0,0 +1,66 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2007, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ejb3.test.epcpropagation;
+
+import javax.annotation.Resource;
+import javax.ejb.EJB;
+import javax.ejb.Local;
+import javax.ejb.Remote;
+import javax.ejb.SessionContext;
+import javax.ejb.Stateful;
+import javax.ejb.TransactionManagement;
+import javax.ejb.TransactionManagementType;
+import javax.persistence.EntityManager;
+import javax.persistence.PersistenceContext;
+import javax.persistence.PersistenceContextType;
+import javax.transaction.Status;
+import javax.transaction.UserTransaction;
+
+import org.jboss.logging.Logger;
+
+/**
+ * @author <a href="mailto:bdecoste at jboss.com">William DeCoste</a>
+ */
+ at Stateful
+ at Remote(StatefulRemote.class)
+public class IntermediateStatefulBean implements IntermediateStatefulRemote
+{
+ private static final Logger log = Logger.getLogger(IntermediateStatefulBean.class);
+
+ @PersistenceContext(unitName="mypc")
+ EntityManager em;
+
+ @Resource
+ SessionContext sessionContext;
+
+ @EJB
+ StatelessRemote cmtBean;
+
+ public boolean execute(Integer id, String name) throws Exception
+ {
+ MyEntity entity = em.find(MyEntity.class, id);
+
+ String propagatedName = cmtBean.updateEntity(id, name.toLowerCase());
+
+ return propagatedName.equals(name.toUpperCase());
+ }
+}
\ No newline at end of file
Added: projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/test/epcpropagation/IntermediateStatefulRemote.java
===================================================================
--- projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/test/epcpropagation/IntermediateStatefulRemote.java (rev 0)
+++ projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/test/epcpropagation/IntermediateStatefulRemote.java 2008-02-18 17:27:56 UTC (rev 69892)
@@ -0,0 +1,30 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2007, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ejb3.test.epcpropagation;
+
+/**
+ * @author <a href="mailto:bdecoste at jboss.com">William DeCoste</a>
+ */
+public interface IntermediateStatefulRemote
+{
+ public boolean execute(Integer id, String name) throws Exception;
+}
Added: projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/test/epcpropagation/MyEntity.java
===================================================================
--- projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/test/epcpropagation/MyEntity.java (rev 0)
+++ projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/test/epcpropagation/MyEntity.java 2008-02-18 17:27:56 UTC (rev 69892)
@@ -0,0 +1,75 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2007, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ejb3.test.epcpropagation;
+
+import java.io.Serializable;
+
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+
+/**
+ * @author <a href="mailto:bdecoste at jboss.com">William DeCoste</a>
+ */
+ at Entity
+public class MyEntity implements Serializable
+{
+ private Integer id;
+ private String name;
+
+ public MyEntity()
+ {
+
+ }
+
+ public MyEntity(String name)
+ {
+ this.name = name;
+ }
+
+ @Id
+ public Integer getId()
+ {
+ return id;
+ }
+
+ public void setId(Integer id)
+ {
+ this.id = id;
+ }
+
+ public String getName()
+ {
+ return name;
+ }
+
+ public void setName(String name)
+ {
+ this.name = name;
+ }
+
+ public String toString()
+ {
+ return "MyEntity:id=" + id + ",name=" + name;
+ }
+}
Added: projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/test/epcpropagation/NoTxEPCStatefulBean.java
===================================================================
--- projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/test/epcpropagation/NoTxEPCStatefulBean.java (rev 0)
+++ projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/test/epcpropagation/NoTxEPCStatefulBean.java 2008-02-18 17:27:56 UTC (rev 69892)
@@ -0,0 +1,68 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2007, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ejb3.test.epcpropagation;
+
+import javax.annotation.Resource;
+import javax.ejb.EJB;
+import javax.ejb.Local;
+import javax.ejb.Remote;
+import javax.ejb.SessionContext;
+import javax.ejb.Stateful;
+import javax.ejb.TransactionManagement;
+import javax.ejb.TransactionManagementType;
+import javax.persistence.EntityManager;
+import javax.persistence.PersistenceContext;
+import javax.persistence.PersistenceContextType;
+import javax.transaction.Status;
+import javax.transaction.UserTransaction;
+
+import org.jboss.logging.Logger;
+
+/**
+ * @author <a href="mailto:bdecoste at jboss.com">William DeCoste</a>
+ */
+ at Stateful
+ at TransactionManagement(TransactionManagementType.BEAN)
+ at Remote(StatefulRemote.class)
+public class NoTxEPCStatefulBean implements StatefulRemote
+{
+ private static final Logger log = Logger.getLogger(NoTxEPCStatefulBean.class);
+
+ @PersistenceContext(type=PersistenceContextType.EXTENDED, unitName="mypc")
+ EntityManager em;
+
+ @Resource
+ SessionContext sessionContext;
+
+ @EJB
+ StatelessRemote cmtBean;
+
+ public boolean execute(Integer id, String name) throws Exception
+ {
+ MyEntity eb = em.find(MyEntity.class, id);
+ eb.setName(name.toUpperCase());
+
+ String propagatedName = cmtBean.updateEntity(id, name.toLowerCase());
+
+ return propagatedName.equals(name.toUpperCase());
+ }
+}
\ No newline at end of file
Added: projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/test/epcpropagation/NoTxStatefulBean.java
===================================================================
--- projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/test/epcpropagation/NoTxStatefulBean.java (rev 0)
+++ projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/test/epcpropagation/NoTxStatefulBean.java 2008-02-18 17:27:56 UTC (rev 69892)
@@ -0,0 +1,68 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2007, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ejb3.test.epcpropagation;
+
+import javax.annotation.Resource;
+import javax.ejb.EJB;
+import javax.ejb.Local;
+import javax.ejb.Remote;
+import javax.ejb.SessionContext;
+import javax.ejb.Stateful;
+import javax.ejb.TransactionManagement;
+import javax.ejb.TransactionManagementType;
+import javax.persistence.EntityManager;
+import javax.persistence.PersistenceContext;
+import javax.persistence.PersistenceContextType;
+import javax.transaction.Status;
+import javax.transaction.UserTransaction;
+
+import org.jboss.logging.Logger;
+
+/**
+ * @author <a href="mailto:bdecoste at jboss.com">William DeCoste</a>
+ */
+ at Stateful
+ at TransactionManagement(TransactionManagementType.BEAN)
+ at Remote(StatefulRemote.class)
+public class NoTxStatefulBean implements StatefulRemote
+{
+ private static final Logger log = Logger.getLogger(NoTxStatefulBean.class);
+
+ @PersistenceContext(unitName="mypc")
+ EntityManager em;
+
+ @Resource
+ SessionContext sessionContext;
+
+ @EJB
+ StatelessRemote cmtBean;
+
+ public boolean execute(Integer id, String name) throws Exception
+ {
+ MyEntity eb = em.find(MyEntity.class, id);
+ eb.setName(name.toUpperCase());
+
+ String propagatedName = cmtBean.updateEntity(id, name.toLowerCase());
+
+ return propagatedName.equals(name.toUpperCase());
+ }
+}
\ No newline at end of file
Added: projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/test/epcpropagation/StatefulBean.java
===================================================================
--- projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/test/epcpropagation/StatefulBean.java (rev 0)
+++ projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/test/epcpropagation/StatefulBean.java 2008-02-18 17:27:56 UTC (rev 69892)
@@ -0,0 +1,87 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2007, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ejb3.test.epcpropagation;
+
+import javax.annotation.Resource;
+import javax.ejb.EJB;
+import javax.ejb.Local;
+import javax.ejb.Remote;
+import javax.ejb.SessionContext;
+import javax.ejb.Stateful;
+import javax.ejb.TransactionManagement;
+import javax.ejb.TransactionManagementType;
+import javax.persistence.EntityManager;
+import javax.persistence.PersistenceContext;
+import javax.persistence.PersistenceContextType;
+import javax.transaction.Status;
+import javax.transaction.UserTransaction;
+
+import org.jboss.logging.Logger;
+
+/**
+ * @author <a href="mailto:bdecoste at jboss.com">William DeCoste</a>
+ */
+ at Stateful
+ at TransactionManagement(TransactionManagementType.BEAN)
+ at Remote(StatefulRemote.class)
+public class StatefulBean implements StatefulRemote
+{
+ private static final Logger log = Logger.getLogger(StatefulBean.class);
+
+ @PersistenceContext(unitName="mypc")
+ EntityManager em;
+
+ @Resource
+ SessionContext sessionContext;
+
+ @EJB
+ StatelessRemote cmtBean;
+
+ public boolean execute(Integer id, String name) throws Exception
+ {
+ try
+ {
+ UserTransaction tx1 = sessionContext.getUserTransaction();
+ tx1.begin();
+ em.joinTransaction();
+ MyEntity entity = em.find(MyEntity.class, id);
+ entity.setName(name.toUpperCase());
+
+ String propagatedName = cmtBean.updateEntity(id, name.toLowerCase());
+ tx1.commit();
+
+ return propagatedName.equals(name.toUpperCase());
+ }
+ catch (Exception e)
+ {
+ try
+ {
+ sessionContext.getUserTransaction().rollback();
+ }
+ catch (Exception e1)
+ {
+ log.info("ROLLBACK: "+e1);
+ }
+ throw e;
+ }
+ }
+}
\ No newline at end of file
Added: projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/test/epcpropagation/StatefulRemote.java
===================================================================
--- projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/test/epcpropagation/StatefulRemote.java (rev 0)
+++ projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/test/epcpropagation/StatefulRemote.java 2008-02-18 17:27:56 UTC (rev 69892)
@@ -0,0 +1,30 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2007, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ejb3.test.epcpropagation;
+
+/**
+ * @author <a href="mailto:bdecoste at jboss.com">William DeCoste</a>
+ */
+public interface StatefulRemote
+{
+ public boolean execute(Integer id, String name) throws Exception;
+}
Added: projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/test/epcpropagation/StatelessBean.java
===================================================================
--- projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/test/epcpropagation/StatelessBean.java (rev 0)
+++ projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/test/epcpropagation/StatelessBean.java 2008-02-18 17:27:56 UTC (rev 69892)
@@ -0,0 +1,81 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2007, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ejb3.test.epcpropagation;
+
+import javax.annotation.Resource;
+import javax.ejb.Local;
+import javax.ejb.Remote;
+import javax.ejb.SessionContext;
+import javax.ejb.Stateless;
+import javax.ejb.TransactionAttribute;
+import javax.ejb.TransactionAttributeType;
+import javax.persistence.EntityManager;
+import javax.persistence.PersistenceContext;
+import javax.transaction.Transaction;
+import javax.transaction.TransactionManager;
+
+import org.jboss.ejb3.annotation.JndiInject;
+import org.jboss.logging.Logger;
+
+/**
+ * @author <a href="mailto:bdecoste at jboss.com">William DeCoste</a>
+ */
+ at Stateless
+ at Remote(StatelessRemote.class)
+public class StatelessBean implements StatelessRemote
+{
+ private static final Logger log = Logger.getLogger(StatelessBean.class);
+
+ @PersistenceContext(unitName="mypc")
+ EntityManager em;
+
+ @Resource
+ SessionContext sessionContext;
+
+ @JndiInject(jndiName="java:/TransactionManager")
+ TransactionManager tm;
+
+ @TransactionAttribute(TransactionAttributeType.REQUIRED)
+ public void createEntity(Integer id, String name)
+ {
+ MyEntity entity = em.find(MyEntity.class, id);
+ if (entity == null)
+ {
+ entity = new MyEntity();
+ entity.setId(id);
+ em.persist(entity);
+ }
+ entity.setName(name);
+ }
+
+ @TransactionAttribute(TransactionAttributeType.REQUIRED)
+ public String updateEntity(Integer id, String name)
+ {
+ MyEntity entity = em.find(MyEntity.class, id);
+ String propagatedName = entity.getName();
+
+ entity.setName(name);
+
+ return propagatedName;
+ }
+
+}
\ No newline at end of file
Added: projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/test/epcpropagation/StatelessRemote.java
===================================================================
--- projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/test/epcpropagation/StatelessRemote.java (rev 0)
+++ projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/test/epcpropagation/StatelessRemote.java 2008-02-18 17:27:56 UTC (rev 69892)
@@ -0,0 +1,32 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2007, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ejb3.test.epcpropagation;
+
+/**
+ * @author <a href="mailto:bdecoste at jboss.com">William DeCoste</a>
+ */
+public interface StatelessRemote
+{
+ public void createEntity(Integer id, String name);
+
+ public String updateEntity(Integer id, String name);
+}
Added: projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/test/epcpropagation/unit/EPCPropagationTestCase.java
===================================================================
--- projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/test/epcpropagation/unit/EPCPropagationTestCase.java (rev 0)
+++ projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/test/epcpropagation/unit/EPCPropagationTestCase.java 2008-02-18 17:27:56 UTC (rev 69892)
@@ -0,0 +1,125 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2007, Red Hat Middleware LLC, and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ejb3.test.epcpropagation.unit;
+
+import javax.naming.InitialContext;
+
+import junit.framework.Test;
+
+import org.jboss.ejb3.test.epcpropagation.StatefulRemote;
+import org.jboss.ejb3.test.epcpropagation.StatelessRemote;
+import org.jboss.test.JBossTestCase;
+
+/**
+ * @author <a href="mailto:bdecoste at jboss.com">William DeCoste</a>
+ */
+public class EPCPropagationTestCase extends JBossTestCase
+{
+
+ public EPCPropagationTestCase(String name)
+ {
+ super(name);
+ }
+
+ public void testBMTPropagation() throws Exception
+ {
+ StatelessRemote stateless = (StatelessRemote) new InitialContext().lookup("StatelessBean/remote");
+ stateless.createEntity(1, "EntityName");
+
+ StatefulRemote stateful = (StatefulRemote) new InitialContext().lookup("StatefulBean/remote");
+ boolean equal = stateful.execute(1, "EntityName");
+
+ assertTrue("Name changes should propagate", equal);
+ }
+
+ public void testBMTEPCPropagation() throws Exception
+ {
+ StatelessRemote stateless = (StatelessRemote) new InitialContext().lookup("StatelessBean/remote");
+ stateless.createEntity(2, "EntityName");
+
+ StatefulRemote stateful = (StatefulRemote) new InitialContext().lookup("EPCStatefulBean/remote");
+ boolean equal = stateful.execute(2, "EntityName");
+
+ assertTrue("Name changes should propagate", equal);
+ }
+
+ public void testCMTPropagation() throws Exception
+ {
+ StatelessRemote stateless = (StatelessRemote) new InitialContext().lookup("StatelessBean/remote");
+ stateless.createEntity(3, "EntityName");
+
+ StatefulRemote stateful = (StatefulRemote) new InitialContext().lookup("CMTStatefulBean/remote");
+ boolean equal = stateful.execute(3, "EntityName");
+
+ assertTrue("Name changes should propagate", equal);
+ }
+
+ public void testCMTEPCPropagation() throws Exception
+ {
+ StatelessRemote stateless = (StatelessRemote) new InitialContext().lookup("StatelessBean/remote");
+ stateless.createEntity(4, "EntityName");
+
+ StatefulRemote stateful = (StatefulRemote) new InitialContext().lookup("CMTEPCStatefulBean/remote");
+ boolean equal = stateful.execute(4, "EntityName");
+
+ assertTrue("Name changes should propagate", equal);
+ }
+
+ public void testNoTxPropagation() throws Exception
+ {
+ StatelessRemote stateless = (StatelessRemote) new InitialContext().lookup("StatelessBean/remote");
+ stateless.createEntity(5, "EntityName");
+
+ StatefulRemote stateful = (StatefulRemote) new InitialContext().lookup("NoTxStatefulBean/remote");
+ boolean equal = stateful.execute(5, "EntityName");
+
+ assertFalse("Name changes should not propagate", equal);
+ }
+
+ public void testNoTxEPCPropagation() throws Exception
+ {
+ StatelessRemote stateless = (StatelessRemote) new InitialContext().lookup("StatelessBean/remote");
+ stateless.createEntity(6, "EntityName");
+
+ StatefulRemote stateful = (StatefulRemote) new InitialContext().lookup("NoTxEPCStatefulBean/remote");
+ boolean equal = stateful.execute(6, "EntityName");
+
+ assertTrue("Name changes should propagate", equal);
+ }
+
+ public void testIntermediateEPCPropagation() throws Exception
+ {
+ StatelessRemote stateless = (StatelessRemote) new InitialContext().lookup("StatelessBean/remote");
+ stateless.createEntity(7, "EntityName");
+
+ StatefulRemote stateful = (StatefulRemote) new InitialContext().lookup("InitEPCStatefulBean/remote");
+ boolean equal = stateful.execute(7, "EntityName");
+
+ assertTrue("Name changes should propagate", equal);
+ }
+
+ public static Test suite() throws Exception
+ {
+ return getDeploySetup(EPCPropagationTestCase.class, "epcpropagation-test.jar");
+ }
+
+}
Added: projects/ejb3/trunk/core/src/test/resources/test/epcpropagation/META-INF/persistence.xml
===================================================================
--- projects/ejb3/trunk/core/src/test/resources/test/epcpropagation/META-INF/persistence.xml (rev 0)
+++ projects/ejb3/trunk/core/src/test/resources/test/epcpropagation/META-INF/persistence.xml 2008-02-18 17:27:56 UTC (rev 69892)
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<persistence>
+ <persistence-unit name="mypc" transaction-type="JTA">
+ <jta-data-source>java:/DefaultDS</jta-data-source>
+ <properties>
+ <property name="hibernate.hbm2ddl.auto" value="create-drop"/>
+ </properties>
+ </persistence-unit>
+</persistence>
More information about the jboss-cvs-commits
mailing list