[jboss-cvs] JBossAS SVN: r72525 - in projects/ejb3/dev/ejbthree1269: core/src/main/java/org/jboss/injection and 7 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Mon Apr 21 17:17:56 EDT 2008


Author: ALRubinger
Date: 2008-04-21 17:17:56 -0400 (Mon, 21 Apr 2008)
New Revision: 72525

Added:
   projects/ejb3/dev/ejbthree1269/transactions/src/main/java/org/jboss/ejb3/tx/BMTTxInterceptorFactory.java
   projects/ejb3/dev/ejbthree1269/transactions/src/main/java/org/jboss/ejb3/tx/CMTTxInterceptorFactory.java
   projects/ejb3/dev/ejbthree1269/transactions/src/main/java/org/jboss/ejb3/tx/StatefulBMTInterceptor.java
   projects/ejb3/dev/ejbthree1269/transactions/src/main/java/org/jboss/ejb3/tx/StatelessBMTInterceptor.java
   projects/ejb3/dev/ejbthree1269/transactions/src/test/java/org/jboss/ejb3/test/tx/common/MockEJBContext.java
   projects/ejb3/dev/ejbthree1269/transactions/src/test/java/org/jboss/ejb3/test/tx/getrollback/
   projects/ejb3/dev/ejbthree1269/transactions/src/test/java/org/jboss/ejb3/test/tx/getrollback/GetRollbackTestBean.java
   projects/ejb3/dev/ejbthree1269/transactions/src/test/java/org/jboss/ejb3/test/tx/getrollback/unit/
   projects/ejb3/dev/ejbthree1269/transactions/src/test/java/org/jboss/ejb3/test/tx/getrollback/unit/GetRollbackTestCase.java
Removed:
   projects/ejb3/dev/ejbthree1269/transactions/src/main/java/org/jboss/ejb3/tx/TxInterceptorFactory.java
   projects/ejb3/dev/ejbthree1269/transactions/src/test/java/org/jboss/ejb3/test/tx/getrollback/GetRollbackTestBean.java
   projects/ejb3/dev/ejbthree1269/transactions/src/test/java/org/jboss/ejb3/test/tx/getrollback/unit/
   projects/ejb3/dev/ejbthree1269/transactions/src/test/java/org/jboss/ejb3/test/tx/getrollback/unit/GetRollbackTestCase.java
Modified:
   projects/ejb3/dev/ejbthree1269/core/jboss-ejb3-client.xml
   projects/ejb3/dev/ejbthree1269/core/src/main/java/org/jboss/injection/EJBRemoteHandler.java
   projects/ejb3/dev/ejbthree1269/transactions/pom.xml
   projects/ejb3/dev/ejbthree1269/transactions/src/main/java/org/jboss/ejb3/tx/BMTInterceptor.java
   projects/ejb3/dev/ejbthree1269/transactions/src/main/java/org/jboss/ejb3/tx/TxUtil.java
   projects/ejb3/dev/ejbthree1269/transactions/src/test/resources/instance/jboss-aop.xml
Log:
[EJBTHREE-1269] Backmerged current development in trunk from 72451:72523

Modified: projects/ejb3/dev/ejbthree1269/core/jboss-ejb3-client.xml
===================================================================
--- projects/ejb3/dev/ejbthree1269/core/jboss-ejb3-client.xml	2008-04-21 21:14:20 UTC (rev 72524)
+++ projects/ejb3/dev/ejbthree1269/core/jboss-ejb3-client.xml	2008-04-21 21:17:56 UTC (rev 72525)
@@ -56,5 +56,16 @@
         <include>org/jboss/ejb3/ThreadLocalENCFactory.class</include>
       </includes>
     </fileSet>
+
+    <!-- Include the EJB3 Security Client classes -->
+    <fileSet>
+      <directory>../security/target/classes</directory>
+      <outputDirectory></outputDirectory>
+      <includes>
+        <include>org/jboss/ejb3/security/client/SecurityActions.class</include>
+        <include>org/jboss/ejb3/security/client/SecurityClientInterceptor.class</include>
+      </includes>
+    </fileSet>
+
   </fileSets>
 </assembly>

Modified: projects/ejb3/dev/ejbthree1269/core/src/main/java/org/jboss/injection/EJBRemoteHandler.java
===================================================================
--- projects/ejb3/dev/ejbthree1269/core/src/main/java/org/jboss/injection/EJBRemoteHandler.java	2008-04-21 21:14:20 UTC (rev 72524)
+++ projects/ejb3/dev/ejbthree1269/core/src/main/java/org/jboss/injection/EJBRemoteHandler.java	2008-04-21 21:17:56 UTC (rev 72525)
@@ -161,14 +161,17 @@
       {
          //
          AnnotatedEJBReferencesMetaData amds = container.getEnvironmentRefGroup().getAnnotatedEjbReferences();
-         AnnotatedEJBReferenceMetaData amd = amds.get(encName);
-         if(amd == null)
-            amd = amds.get(fieldName);
-         if(amd != null)
+         if(amds != null)
          {
-            mappedName = amd.getMappedName();
-            if(mappedName == null)
-               mappedName = amd.getResolvedJndiName();
+            AnnotatedEJBReferenceMetaData amd = amds.get(encName);
+            if(amd == null)
+               amd = amds.get(fieldName);
+            if(amd != null)
+            {
+               mappedName = amd.getMappedName();
+               if(mappedName == null)
+                  mappedName = amd.getResolvedJndiName();
+            }
          }
       }
 

Modified: projects/ejb3/dev/ejbthree1269/transactions/pom.xml
===================================================================
--- projects/ejb3/dev/ejbthree1269/transactions/pom.xml	2008-04-21 21:14:20 UTC (rev 72524)
+++ projects/ejb3/dev/ejbthree1269/transactions/pom.xml	2008-04-21 21:17:56 UTC (rev 72525)
@@ -36,6 +36,11 @@
       <scope>test</scope>
     </dependency>
     <dependency>
+      <groupId>org.jboss.aspects</groupId>
+      <artifactId>jboss-current-invocation-aspects</artifactId>
+      <version>0.1-SNAPSHOT</version>
+    </dependency>
+    <dependency>
       <groupId>org.jboss.logging</groupId>
       <artifactId>jboss-logging-spi</artifactId>
     </dependency>

Modified: projects/ejb3/dev/ejbthree1269/transactions/src/main/java/org/jboss/ejb3/tx/BMTInterceptor.java
===================================================================
--- projects/ejb3/dev/ejbthree1269/transactions/src/main/java/org/jboss/ejb3/tx/BMTInterceptor.java	2008-04-21 21:14:20 UTC (rev 72524)
+++ projects/ejb3/dev/ejbthree1269/transactions/src/main/java/org/jboss/ejb3/tx/BMTInterceptor.java	2008-04-21 21:17:56 UTC (rev 72525)
@@ -21,192 +21,42 @@
  */
 package org.jboss.ejb3.tx;
 
-import javax.ejb.EJBException;
-import javax.transaction.Status;
-import javax.transaction.SystemException;
 import javax.transaction.Transaction;
 import javax.transaction.TransactionManager;
 
 import org.jboss.aop.joinpoint.Invocation;
-import org.jboss.aop.util.PayloadKey;
-import org.jboss.ejb3.interceptors.container.ContainerMethodInvocation;
-import org.jboss.ejb3.tx.container.StatefulBeanContext;
 import org.jboss.logging.Logger;
-import org.jboss.tm.TxUtils;
 
 /**
  * Comment
  *
  * @author <a href="mailto:bill at jboss.org">Bill Burke</a>
  *  @author <a href="mailto:osh at sparre.dk">Ole Husgaard</a>
- * @version $Revision$
+ * @version $Revision:72368 $
  */
-public class BMTInterceptor extends AbstractInterceptor
+public abstract class BMTInterceptor extends AbstractInterceptor
 {
-   private TransactionManager tm;
-   private boolean isStateless;
-   protected static Logger log = Logger.getLogger(BMTInterceptor.class);
+   private static final Logger log = Logger.getLogger(BMTInterceptor.class);
+   
+   protected final TransactionManager tm;
 
-   public BMTInterceptor(TransactionManager tm, boolean stateless)
+   protected BMTInterceptor(TransactionManager tm)
    {
       this.tm = tm;
-      isStateless = stateless;
    }
 
-   public Object handleStateless(Invocation invocation) throws Throwable
-   {
-      String ejbName = invocation.getAdvisor().getName();
-      boolean exceptionThrown = false;
-      try
-      {
-         return invocation.invokeNext();
-      }
-      catch (Exception ex)
-      {
-         exceptionThrown = true;
-         checkStatelessDone(ejbName, ex);
-         throw ex;
-      }
-      finally
-      {
-         try
-         {
-            if (!exceptionThrown) checkStatelessDone(ejbName, null);
-         }
-         finally
-         {
-            tm.suspend();
-         }
-      }
-   }
-
-   public Object handleStateful(Invocation invocation) throws Throwable
-   {
-      StatefulBeanContext<?> ctx = (StatefulBeanContext<?>) ContainerMethodInvocation.getContainerMethodInvocation(invocation).getBeanContext();
-      String ejbName = invocation.getAdvisor().getName();
-
-      Transaction tx = (Transaction)ctx.getMetaData().getMetaData("TX", "TX");
-      if (tx != null)
-      {
-         ctx.getMetaData().addMetaData("TX", "TX", null, PayloadKey.TRANSIENT);
-         tm.resume(tx);
-      }
-      try
-      {
-         return invocation.invokeNext();
-      }
-      finally
-      {
-         checkBadStateful(ejbName);
-         Transaction newTx = tm.getTransaction();
-         if (newTx != null)
-         {
-            ctx.getMetaData().addMetaData("TX", "TX", newTx, PayloadKey.TRANSIENT);
-            tm.suspend();
-         }
-         else
-         {
-            ctx.getMetaData().addMetaData("TX", "TX", null, PayloadKey.TRANSIENT);
-         }
-      }
-   }
-
+   protected abstract Object handleInvocation(Invocation invocation) throws Throwable;
+   
    public Object invoke(Invocation invocation) throws Throwable
    {
-      Transaction oldTx = tm.getTransaction();
-      if (oldTx != null) tm.suspend();
-
+      Transaction oldTx = tm.suspend();
       try
       {
-         if (isStateless) return handleStateless(invocation);
-         else return handleStateful(invocation);
+         return handleInvocation(invocation);
       }
       finally
       {
          if (oldTx != null) tm.resume(oldTx);
       }
-
-
    }
-
-   private void checkStatelessDone(String ejbName, Exception ex)
-   {
-      int status = Status.STATUS_NO_TRANSACTION;
-
-      try
-      {
-         status = tm.getStatus();
-      }
-      catch (SystemException sex)
-      {
-         log.error("Failed to get status", sex);
-      }
-
-      switch (status)
-      {
-         case Status.STATUS_ACTIVE :
-         case Status.STATUS_COMMITTING :
-         case Status.STATUS_MARKED_ROLLBACK :
-         case Status.STATUS_PREPARING :
-         case Status.STATUS_ROLLING_BACK :
-            try
-            {
-               tm.rollback();
-            }
-            catch (Exception sex)
-            {
-               log.error("Failed to rollback", sex);
-            }
-         // fall through...
-         case Status.STATUS_PREPARED :
-            String msg = "Application error: BMT stateless bean " + ejbName
-                         + " should complete transactions before" + " returning (ejb1.1 spec, 11.6.1)";
-            log.error(msg);
-
-            // the instance interceptor will discard the instance
-            if (ex != null)
-            {
-               if (ex instanceof EJBException)
-                  throw (EJBException)ex;
-               else
-                  throw new EJBException(msg, ex);
-            }
-            else throw new EJBException(msg);
-      }
-   }
-
-   private void checkBadStateful(String ejbName)
-   {
-      int status = Status.STATUS_NO_TRANSACTION;
-
-      try
-      {
-         status = tm.getStatus();
-      }
-      catch (SystemException ex)
-      {
-         log.error("Failed to get status", ex);
-      }
-
-      switch (status)
-      {
-         case Status.STATUS_COMMITTING :
-         case Status.STATUS_MARKED_ROLLBACK :
-         case Status.STATUS_PREPARING :
-         case Status.STATUS_ROLLING_BACK :
-            try
-            {
-               tm.rollback();
-            }
-            catch (Exception ex)
-            {
-               log.error("Failed to rollback", ex);
-            }
-            String msg = "BMT stateful bean '" + ejbName
-                         + "' did not complete user transaction properly status=" + TxUtils.getStatusAsString(status);
-            log.error(msg);
-      }
-   }
-
-
 }

Copied: projects/ejb3/dev/ejbthree1269/transactions/src/main/java/org/jboss/ejb3/tx/BMTTxInterceptorFactory.java (from rev 72523, projects/ejb3/trunk/transactions/src/main/java/org/jboss/ejb3/tx/BMTTxInterceptorFactory.java)
===================================================================
--- projects/ejb3/dev/ejbthree1269/transactions/src/main/java/org/jboss/ejb3/tx/BMTTxInterceptorFactory.java	                        (rev 0)
+++ projects/ejb3/dev/ejbthree1269/transactions/src/main/java/org/jboss/ejb3/tx/BMTTxInterceptorFactory.java	2008-04-21 21:17:56 UTC (rev 72525)
@@ -0,0 +1,59 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, 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.tx;
+
+import javax.ejb.Stateful;
+import javax.ejb.TransactionManagementType;
+import javax.transaction.TransactionManager;
+
+import org.jboss.aop.Advisor;
+import org.jboss.aop.joinpoint.Joinpoint;
+import org.jboss.ejb3.interceptors.aop.AbstractInterceptorFactory;
+import org.jboss.logging.Logger;
+
+/**
+ * This interceptor handles transactions for AOP
+ *
+ * @author <a href="mailto:bill at jboss.org">Bill Burke</a>
+ * @version $Revision:72368 $
+ */
+public class BMTTxInterceptorFactory extends AbstractInterceptorFactory
+{
+   @SuppressWarnings("unused")
+   private static final Logger log = Logger.getLogger(CMTTxInterceptorFactory.class);
+
+   public Object createPerJoinpoint(Advisor advisor, Joinpoint jp)
+   {
+      // We have to do this until AOP supports matching based on annotation attributes
+      TransactionManagementType type = TxUtil.getTransactionManagementType(advisor);
+      if (type != TransactionManagementType.BEAN)
+         return new NullInterceptor();
+      
+      TransactionManager tm = TxUtil.getTransactionManager();
+      boolean stateful = advisor.resolveAnnotation(Stateful.class) != null;
+      // Both MessageDriven and Stateless are stateless
+      if(stateful)
+         return new StatefulBMTInterceptor(tm);
+      else
+         return new StatelessBMTInterceptor(tm);
+   }
+}

Copied: projects/ejb3/dev/ejbthree1269/transactions/src/main/java/org/jboss/ejb3/tx/CMTTxInterceptorFactory.java (from rev 72523, projects/ejb3/trunk/transactions/src/main/java/org/jboss/ejb3/tx/CMTTxInterceptorFactory.java)
===================================================================
--- projects/ejb3/dev/ejbthree1269/transactions/src/main/java/org/jboss/ejb3/tx/CMTTxInterceptorFactory.java	                        (rev 0)
+++ projects/ejb3/dev/ejbthree1269/transactions/src/main/java/org/jboss/ejb3/tx/CMTTxInterceptorFactory.java	2008-04-21 21:17:56 UTC (rev 72525)
@@ -0,0 +1,123 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, 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.tx;
+
+import java.lang.reflect.Method;
+
+import javax.ejb.TransactionAttributeType;
+import javax.ejb.TransactionManagementType;
+import javax.transaction.TransactionManager;
+
+import org.jboss.aop.Advisor;
+import org.jboss.aop.joinpoint.Joinpoint;
+import org.jboss.aop.joinpoint.MethodJoinpoint;
+import org.jboss.ejb3.annotation.TransactionTimeout;
+import org.jboss.logging.Logger;
+
+/**
+ * This interceptor handles transactions for AOP
+ *
+ * @author <a href="mailto:bill at jboss.org">Bill Burke</a>
+ * @version $Revision:72368 $
+ */
+public class CMTTxInterceptorFactory extends org.jboss.aspects.tx.TxInterceptorFactory
+{
+   @SuppressWarnings("unused")
+   private static final Logger log = Logger.getLogger(CMTTxInterceptorFactory.class);
+
+   protected TransactionAttributeType getTxType(Advisor advisor, Joinpoint jp)
+   {
+      Method method = ((MethodJoinpoint) jp).getMethod();
+      return TxUtil.getTxType(advisor, method);
+   }
+
+   protected int resolveTransactionTimeout(Advisor advisor, Method method)
+   {
+      TransactionTimeout annotation = (TransactionTimeout)advisor.resolveAnnotation(method, TransactionTimeout.class);
+      
+      if (annotation == null)
+         annotation = (TransactionTimeout)advisor.resolveAnnotation(TransactionTimeout.class);
+      
+      if (annotation != null)
+      {
+         return annotation.value();
+      }
+
+      return -1;
+   }
+
+   @Override
+   protected void initializePolicy()
+   {
+      policy = new Ejb3TxPolicy();
+   }
+
+   @Override
+   public Object createPerJoinpoint(Advisor advisor, Joinpoint jp)
+   {
+      // We have to do this until AOP supports matching based on annotation attributes
+      TransactionManagementType type = TxUtil.getTransactionManagementType(advisor);
+      if (type == TransactionManagementType.BEAN)
+         return new NullInterceptor();
+
+      TransactionManager tm = TxUtil.getTransactionManager();
+      
+      Method method = ((MethodJoinpoint) jp).getMethod();
+      int timeout = resolveTransactionTimeout(advisor, method);
+
+      if (policy == null);
+         super.initialize();
+
+      TransactionAttributeType txType = getTxType(advisor, jp);
+      
+      if (txType.equals(TransactionAttributeType.NEVER))
+      {
+         // make sure we use the EJB3 interceptor, not the AOP one. 
+         return new TxInterceptor.Never(tm, policy);
+      }
+      else if (txType.equals(TransactionAttributeType.REQUIRED))
+      {
+         return new TxInterceptor.Required(tm, policy, timeout);
+      }
+      else if (txType.equals(TransactionAttributeType.REQUIRES_NEW))
+      {
+         return new TxInterceptor.RequiresNew(tm, policy, timeout);
+      }
+      else if(txType.equals(TransactionAttributeType.NOT_SUPPORTED))
+      {
+         return new TxInterceptor.NotSupported(tm, policy, timeout);
+      }
+      else if(txType.equals(TransactionAttributeType.MANDATORY))
+      {
+         return new TxInterceptor.Mandatory(tm, policy, timeout);
+      }
+      else if(txType.equals(TransactionAttributeType.SUPPORTS))
+      {
+         return new TxInterceptor.Supports(tm, policy, timeout);
+      }
+      else
+      {
+         Object interceptor = super.createPerJoinpoint(advisor, jp);
+         return interceptor;
+      }
+   }
+}

Copied: projects/ejb3/dev/ejbthree1269/transactions/src/main/java/org/jboss/ejb3/tx/StatefulBMTInterceptor.java (from rev 72523, projects/ejb3/trunk/transactions/src/main/java/org/jboss/ejb3/tx/StatefulBMTInterceptor.java)
===================================================================
--- projects/ejb3/dev/ejbthree1269/transactions/src/main/java/org/jboss/ejb3/tx/StatefulBMTInterceptor.java	                        (rev 0)
+++ projects/ejb3/dev/ejbthree1269/transactions/src/main/java/org/jboss/ejb3/tx/StatefulBMTInterceptor.java	2008-04-21 21:17:56 UTC (rev 72525)
@@ -0,0 +1,131 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, 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.tx;
+
+import javax.transaction.Status;
+import javax.transaction.SystemException;
+import javax.transaction.Transaction;
+import javax.transaction.TransactionManager;
+
+import org.jboss.aop.joinpoint.Invocation;
+import org.jboss.aop.util.PayloadKey;
+import org.jboss.ejb3.interceptors.container.ContainerMethodInvocation;
+import org.jboss.ejb3.tx.container.StatefulBeanContext;
+import org.jboss.logging.Logger;
+import org.jboss.tm.TxUtils;
+
+/**
+ * EJB 3 13.6.1:
+ * In the case of a stateful session bean, it is possible that the business method that started a transaction
+ * completes without committing or rolling back the transaction. In such a case, the container must retain
+ * the association between the transaction and the instance across multiple client calls until the instance
+ * commits or rolls back the transaction. When the client invokes the next business method, the container
+ * must invoke the business method (and any applicable interceptor methods for the bean) in this transac-
+ * tion context.
+ * 
+ * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public class StatefulBMTInterceptor extends BMTInterceptor
+{
+   private static final Logger log = Logger.getLogger(StatefulBMTInterceptor.class);
+   
+   /**
+    * @param tm
+    */
+   public StatefulBMTInterceptor(TransactionManager tm)
+   {
+      super(tm);
+   }
+
+   private void checkBadStateful(String ejbName)
+   {
+      int status = Status.STATUS_NO_TRANSACTION;
+
+      try
+      {
+         status = tm.getStatus();
+      }
+      catch (SystemException ex)
+      {
+         log.error("Failed to get status", ex);
+      }
+
+      switch (status)
+      {
+         case Status.STATUS_COMMITTING :
+         case Status.STATUS_MARKED_ROLLBACK :
+         case Status.STATUS_PREPARING :
+         case Status.STATUS_ROLLING_BACK :
+            try
+            {
+               tm.rollback();
+            }
+            catch (Exception ex)
+            {
+               log.error("Failed to rollback", ex);
+            }
+            String msg = "BMT stateful bean '" + ejbName
+                         + "' did not complete user transaction properly status=" + TxUtils.getStatusAsString(status);
+            log.error(msg);
+      }
+   }
+
+   protected Object handleInvocation(Invocation invocation) throws Throwable
+   {
+      assert tm.getTransaction() == null : "can't handle BMT transaction, there is a transaction active";
+      
+      StatefulBeanContext<?> ctx = (StatefulBeanContext<?>) ContainerMethodInvocation.getContainerMethodInvocation(invocation).getBeanContext();
+      String ejbName = invocation.getAdvisor().getName();
+      
+      // Is the instance already associated with a transaction?
+      Transaction tx = (Transaction)ctx.getMetaData().getMetaData("TX", "TX");
+      if (tx != null)
+      {
+         ctx.getMetaData().addMetaData("TX", "TX", null, PayloadKey.TRANSIENT);
+         // then resume that transaction.
+         tm.resume(tx);
+      }
+      try
+      {
+         return invocation.invokeNext();
+      }
+      finally
+      {
+         checkBadStateful(ejbName);
+         // Is the instance finished with the transaction?
+         Transaction newTx = tm.getTransaction();
+         if (newTx != null)
+         {
+            // remember the association
+            ctx.getMetaData().addMetaData("TX", "TX", newTx, PayloadKey.TRANSIENT);
+            // and suspend it.
+            tm.suspend();
+         }
+         else
+         {
+            // forget any previous associated transaction 
+            ctx.getMetaData().addMetaData("TX", "TX", null, PayloadKey.TRANSIENT);
+         }
+      }
+   }
+}

Copied: projects/ejb3/dev/ejbthree1269/transactions/src/main/java/org/jboss/ejb3/tx/StatelessBMTInterceptor.java (from rev 72523, projects/ejb3/trunk/transactions/src/main/java/org/jboss/ejb3/tx/StatelessBMTInterceptor.java)
===================================================================
--- projects/ejb3/dev/ejbthree1269/transactions/src/main/java/org/jboss/ejb3/tx/StatelessBMTInterceptor.java	                        (rev 0)
+++ projects/ejb3/dev/ejbthree1269/transactions/src/main/java/org/jboss/ejb3/tx/StatelessBMTInterceptor.java	2008-04-21 21:17:56 UTC (rev 72525)
@@ -0,0 +1,127 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, 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.tx;
+
+import javax.ejb.EJBException;
+import javax.transaction.Status;
+import javax.transaction.SystemException;
+import javax.transaction.TransactionManager;
+
+import org.jboss.aop.joinpoint.Invocation;
+import org.jboss.logging.Logger;
+
+/**
+ * EJB 3 13.6.1:
+ * If a stateless session bean instance starts a transaction in a business method or interceptor method, it
+ * must commit the transaction before the business method (or all its interceptor methods) returns.
+ * 
+ * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public class StatelessBMTInterceptor extends BMTInterceptor
+{
+   private static final Logger log = Logger.getLogger(StatelessBMTInterceptor.class);
+   
+   /**
+    * @param tm
+    */
+   public StatelessBMTInterceptor(TransactionManager tm)
+   {
+      super(tm);
+   }
+
+   private void checkStatelessDone(String ejbName, Exception ex)
+   {
+      int status = Status.STATUS_NO_TRANSACTION;
+   
+      try
+      {
+         status = tm.getStatus();
+      }
+      catch (SystemException sex)
+      {
+         log.error("Failed to get status", sex);
+      }
+   
+      switch (status)
+      {
+         case Status.STATUS_ACTIVE :
+         case Status.STATUS_COMMITTING :
+         case Status.STATUS_MARKED_ROLLBACK :
+         case Status.STATUS_PREPARING :
+         case Status.STATUS_ROLLING_BACK :
+            try
+            {
+               tm.rollback();
+            }
+            catch (Exception sex)
+            {
+               log.error("Failed to rollback", sex);
+            }
+         // fall through...
+         case Status.STATUS_PREPARED :
+            String msg = "Application error: BMT stateless bean " + ejbName
+                         + " should complete transactions before" + " returning (ejb1.1 spec, 11.6.1)";
+            log.error(msg);
+   
+            // the instance interceptor will discard the instance
+            if (ex != null)
+            {
+               if (ex instanceof EJBException)
+                  throw (EJBException)ex;
+               else
+                  throw new EJBException(msg, ex);
+            }
+            else throw new EJBException(msg);
+      }
+   }
+
+   public Object handleInvocation(Invocation invocation) throws Throwable
+   {
+      assert tm.getTransaction() == null : "can't handle BMT transaction, there is a transaction active";
+      
+      String ejbName = invocation.getAdvisor().getName();
+      boolean exceptionThrown = false;
+      try
+      {
+         return invocation.invokeNext();
+      }
+      catch (Exception ex)
+      {
+         exceptionThrown = true;
+         checkStatelessDone(ejbName, ex);
+         throw ex;
+      }
+      finally
+      {
+         try
+         {
+            if (!exceptionThrown) checkStatelessDone(ejbName, null);
+         }
+         finally
+         {
+            tm.suspend();
+         }
+      }
+   }
+   
+}

Deleted: projects/ejb3/dev/ejbthree1269/transactions/src/main/java/org/jboss/ejb3/tx/TxInterceptorFactory.java
===================================================================
--- projects/ejb3/dev/ejbthree1269/transactions/src/main/java/org/jboss/ejb3/tx/TxInterceptorFactory.java	2008-04-21 21:14:20 UTC (rev 72524)
+++ projects/ejb3/dev/ejbthree1269/transactions/src/main/java/org/jboss/ejb3/tx/TxInterceptorFactory.java	2008-04-21 21:17:56 UTC (rev 72525)
@@ -1,141 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2006, 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.tx;
-
-import java.lang.reflect.Method;
-
-import javax.ejb.Stateful;
-import javax.ejb.TransactionAttribute;
-import javax.ejb.TransactionAttributeType;
-import javax.ejb.TransactionManagementType;
-
-import org.jboss.aop.Advisor;
-import org.jboss.aop.joinpoint.Joinpoint;
-import org.jboss.aop.joinpoint.MethodJoinpoint;
-import org.jboss.ejb3.annotation.TransactionTimeout;
-import org.jboss.logging.Logger;
-
-/**
- * This interceptor handles transactions for AOP
- *
- * @author <a href="mailto:bill at jboss.org">Bill Burke</a>
- * @version $Revision$
- */
-public class TxInterceptorFactory extends org.jboss.aspects.tx.TxInterceptorFactory
-{
-   @SuppressWarnings("unused")
-   private static final Logger log = Logger.getLogger(TxInterceptorFactory.class);
-
-   protected TransactionAttributeType getTxType(Advisor advisor, Joinpoint jp)
-   {
-      Method method = ((MethodJoinpoint) jp).getMethod();
-      TransactionAttribute tx = (TransactionAttribute) advisor.resolveAnnotation(method, TransactionAttribute.class);
-
-      if (tx == null)
-         tx = (TransactionAttribute) advisor.resolveAnnotation(TransactionAttribute.class);
-
-      TransactionAttributeType value = TransactionAttributeType.REQUIRED;
-      if (tx != null && tx.value() != null)
-      {
-         value = tx.value();
-      }
-
-      return value;
-   }
-
-   protected int resolveTransactionTimeout(Advisor advisor, Method method)
-   {
-      TransactionTimeout annotation = (TransactionTimeout)advisor.resolveAnnotation(method, TransactionTimeout.class);
-      
-      if (annotation == null)
-         annotation = (TransactionTimeout)advisor.resolveAnnotation(TransactionTimeout.class);
-      
-      if (annotation != null)
-      {
-         return annotation.value();
-      }
-
-      return -1;
-   }
-
-   protected void initializePolicy()
-   {
-      policy = new Ejb3TxPolicy();
-   }
-
-   public Object createPerJoinpoint(Advisor advisor, Joinpoint jp)
-   {
-      // We have to do this until AOP supports matching based on annotation attributes
-      TransactionManagementType type = TxUtil.getTransactionManagementType(advisor);
-      if (type == TransactionManagementType.BEAN)
-      {
-         // Must be a separate line (EJBContainer cannot be dereferenced)
-         boolean stateful = advisor.resolveAnnotation(Stateful.class) != null;
-         // Both MessageDriven and Stateless are stateless
-         return new BMTInterceptor(TxUtil.getTransactionManager(), !stateful);
-      }
-
-      Method method = ((MethodJoinpoint) jp).getMethod();
-      int timeout = resolveTransactionTimeout(advisor, method);
-
-      if (policy == null);
-         super.initialize();
-
-      TransactionAttributeType txType = getTxType(advisor, jp);
-      
-      if (txType.equals(TransactionAttributeType.NEVER))
-      {
-         // make sure we use the EJB3 interceptor, not the AOP one. 
-         return new TxInterceptor.Never(TxUtil.getTransactionManager(), policy);
-      }
-      else if (txType.equals(TransactionAttributeType.REQUIRED))
-      {
-         return new TxInterceptor.Required(TxUtil.getTransactionManager(), policy, timeout);
-      }
-      else if (txType.equals(TransactionAttributeType.REQUIRES_NEW))
-      {
-         return new TxInterceptor.RequiresNew(TxUtil.getTransactionManager(), policy, timeout);
-      }
-      else if(txType.equals(TransactionAttributeType.NOT_SUPPORTED))
-      {
-         return new TxInterceptor.NotSupported(TxUtil.getTransactionManager(), policy, timeout);
-      }
-      else if(txType.equals(TransactionAttributeType.MANDATORY))
-      {
-         return new TxInterceptor.Mandatory(TxUtil.getTransactionManager(), policy, timeout);
-      }
-      else if(txType.equals(TransactionAttributeType.SUPPORTS))
-      {
-         return new TxInterceptor.Supports(TxUtil.getTransactionManager(), policy, timeout);
-      }
-      else
-      {
-         Object interceptor = super.createPerJoinpoint(advisor, jp);
-         return interceptor;
-      }
-   }
-
-   public String getName()
-   {
-      return getClass().getName();
-   }
-}

Modified: projects/ejb3/dev/ejbthree1269/transactions/src/main/java/org/jboss/ejb3/tx/TxUtil.java
===================================================================
--- projects/ejb3/dev/ejbthree1269/transactions/src/main/java/org/jboss/ejb3/tx/TxUtil.java	2008-04-21 21:14:20 UTC (rev 72524)
+++ projects/ejb3/dev/ejbthree1269/transactions/src/main/java/org/jboss/ejb3/tx/TxUtil.java	2008-04-21 21:17:56 UTC (rev 72525)
@@ -21,29 +21,39 @@
  */
 package org.jboss.ejb3.tx;
 
+import java.lang.reflect.Method;
+
 import javax.ejb.ApplicationException;
+import javax.ejb.TransactionAttribute;
+import javax.ejb.TransactionAttributeType;
 import javax.ejb.TransactionManagement;
 import javax.ejb.TransactionManagementType;
+import javax.transaction.Status;
+import javax.transaction.SystemException;
 import javax.transaction.TransactionManager;
 
 import org.jboss.aop.Advisor;
 import org.jboss.aop.joinpoint.Invocation;
+import org.jboss.aop.joinpoint.MethodInvocation;
+import org.jboss.logging.Logger;
 import org.jboss.tm.TransactionManagerLocator;
 
 /**
  * Comment
  *
  * @author <a href="mailto:bill at jboss.org">Bill Burke</a>
- * @version $Revision$
+ * @version $Revision:72368 $
  */
 public class TxUtil
 {
-   public static TransactionManager getTransactionManager()
+   private static final Logger log = Logger.getLogger(TxUtil.class);
+   
+   protected static TransactionManager getTransactionManager()
    {
       return TransactionManagerLocator.getInstance().locate();
    }
 
-   public static TransactionManagementType getTransactionManagementType(Advisor advisor)
+   protected static TransactionManagementType getTransactionManagementType(Advisor advisor)
    {
       TransactionManagement transactionManagement =  (TransactionManagement) advisor.resolveAnnotation(TransactionManagement.class);
       if (transactionManagement == null) return TransactionManagementType.CONTAINER;
@@ -81,4 +91,64 @@
       */
       
    }
+
+   /**
+    * @param currentInvocation
+    * @return
+    */
+   public static boolean getRollbackOnly(Invocation currentInvocation)
+   {
+      Advisor advisor = currentInvocation.getAdvisor();
+      // EJB1.1 11.6.1: Must throw IllegalStateException if BMT
+      TransactionManagementType type = TxUtil.getTransactionManagementType(advisor);
+      if (type != TransactionManagementType.CONTAINER)
+         throw new IllegalStateException("Container " + advisor.getName() + ": it is illegal to call getRollbackOnly from BMT: " + type);
+
+      // TODO: we should really ask a TxType object to handle getRollbackOnly()
+      if(getTxType(currentInvocation) == TransactionAttributeType.SUPPORTS)
+         throw new IllegalStateException("getRollbackOnly() not allowed with TransactionAttributeType.SUPPORTS (EJB 3 13.6.2.9)");
+      
+      try
+      {
+         TransactionManager tm = TxUtil.getTransactionManager();
+
+         // The getRollbackOnly and setRollBackOnly method of the SessionContext interface should be used
+         // only in the session bean methods that execute in the context of a transaction.
+         if (tm.getTransaction() == null)
+            throw new IllegalStateException("getRollbackOnly() not allowed without a transaction.");
+
+         // EJBTHREE-805, consider an asynchronous rollback due to timeout
+         int status = tm.getStatus();
+         return status == Status.STATUS_MARKED_ROLLBACK
+             || status == Status.STATUS_ROLLING_BACK
+             || status == Status.STATUS_ROLLEDBACK;
+      }
+      catch (SystemException e)
+      {
+         log.warn("failed to get tx manager status; ignoring", e);
+         return true;
+      }
+   }
+   
+   protected static TransactionAttributeType getTxType(Advisor advisor, Method method)
+   {
+      TransactionAttribute tx = (TransactionAttribute) advisor.resolveAnnotation(method, TransactionAttribute.class);
+
+      if (tx == null)
+         tx = (TransactionAttribute) advisor.resolveAnnotation(TransactionAttribute.class);
+
+      TransactionAttributeType value = TransactionAttributeType.REQUIRED;
+      if (tx != null && tx.value() != null)
+      {
+         value = tx.value();
+      }
+
+      return value;
+   }
+   
+   private static TransactionAttributeType getTxType(Invocation invocation)
+   {
+      return getTxType(invocation.getAdvisor(), ((MethodInvocation) invocation).getActualMethod());
+   }
+
 }

Copied: projects/ejb3/dev/ejbthree1269/transactions/src/test/java/org/jboss/ejb3/test/tx/common/MockEJBContext.java (from rev 72523, projects/ejb3/trunk/transactions/src/test/java/org/jboss/ejb3/test/tx/common/MockEJBContext.java)
===================================================================
--- projects/ejb3/dev/ejbthree1269/transactions/src/test/java/org/jboss/ejb3/test/tx/common/MockEJBContext.java	                        (rev 0)
+++ projects/ejb3/dev/ejbthree1269/transactions/src/test/java/org/jboss/ejb3/test/tx/common/MockEJBContext.java	2008-04-21 21:17:56 UTC (rev 72525)
@@ -0,0 +1,109 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, 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.tx.common;
+
+import java.security.Identity;
+import java.security.Principal;
+import java.util.Properties;
+
+import javax.ejb.EJBContext;
+import javax.ejb.EJBHome;
+import javax.ejb.EJBLocalHome;
+import javax.ejb.TimerService;
+import javax.transaction.UserTransaction;
+
+import org.jboss.aop.joinpoint.Invocation;
+import org.jboss.aspects.currentinvocation.CurrentInvocation;
+import org.jboss.ejb3.tx.TxUtil;
+
+/**
+ * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+ at SuppressWarnings("deprecation")
+public class MockEJBContext implements EJBContext
+{
+   public Identity getCallerIdentity()
+   {
+      throw new IllegalStateException("N/A");
+   }
+
+   public Principal getCallerPrincipal()
+   {
+      throw new IllegalStateException("N/A");
+   }
+
+   private Invocation getCurrentInvocation()
+   {
+      return CurrentInvocation.getCurrentInvocation();
+   }
+   
+   public EJBHome getEJBHome()
+   {
+      throw new IllegalStateException("N/A");
+   }
+
+   public EJBLocalHome getEJBLocalHome()
+   {
+      throw new IllegalStateException("N/A");
+   }
+
+   public Properties getEnvironment()
+   {
+      throw new IllegalStateException("N/A");
+   }
+
+   public boolean getRollbackOnly() throws IllegalStateException
+   {
+      return TxUtil.getRollbackOnly(getCurrentInvocation());
+   }
+
+   public TimerService getTimerService() throws IllegalStateException
+   {
+      throw new IllegalStateException("N/A");
+   }
+
+   public UserTransaction getUserTransaction() throws IllegalStateException
+   {
+      throw new IllegalStateException("N/A");
+   }
+
+   public boolean isCallerInRole(Identity role)
+   {
+      throw new IllegalStateException("N/A");
+   }
+
+   public boolean isCallerInRole(String roleName)
+   {
+      throw new IllegalStateException("N/A");
+   }
+
+   public Object lookup(String name)
+   {
+      throw new IllegalStateException("N/A");
+   }
+
+   public void setRollbackOnly() throws IllegalStateException
+   {
+      throw new IllegalStateException("N/A");
+   }
+}

Copied: projects/ejb3/dev/ejbthree1269/transactions/src/test/java/org/jboss/ejb3/test/tx/getrollback (from rev 72523, projects/ejb3/trunk/transactions/src/test/java/org/jboss/ejb3/test/tx/getrollback)

Deleted: projects/ejb3/dev/ejbthree1269/transactions/src/test/java/org/jboss/ejb3/test/tx/getrollback/GetRollbackTestBean.java
===================================================================
--- projects/ejb3/trunk/transactions/src/test/java/org/jboss/ejb3/test/tx/getrollback/GetRollbackTestBean.java	2008-04-21 21:13:11 UTC (rev 72523)
+++ projects/ejb3/dev/ejbthree1269/transactions/src/test/java/org/jboss/ejb3/test/tx/getrollback/GetRollbackTestBean.java	2008-04-21 21:17:56 UTC (rev 72525)
@@ -1,79 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2008, 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.tx.getrollback;
-
-import static javax.ejb.TransactionAttributeType.MANDATORY;
-import static javax.ejb.TransactionAttributeType.NEVER;
-import static javax.ejb.TransactionAttributeType.REQUIRED;
-
-import javax.ejb.EJBContext;
-import javax.ejb.Stateless;
-import javax.ejb.TransactionAttribute;
-import javax.ejb.TransactionAttributeType;
-
-import org.jboss.ejb3.test.tx.common.MockEJBContext;
-
-/**
- * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
- * @version $Revision: $
- */
- at Stateless
-public class GetRollbackTestBean
-{
-   private EJBContext ctx = new MockEJBContext();
-   
-   @TransactionAttribute(MANDATORY)
-   public boolean mandatory()
-   {
-      return ctx.getRollbackOnly();
-   }
-   
-   @TransactionAttribute(NEVER)
-   public boolean never()
-   {
-      return ctx.getRollbackOnly();
-   }
-   
-   @TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)
-   public boolean notSupported()
-   {
-      return ctx.getRollbackOnly();
-   }
-   
-   @TransactionAttribute(REQUIRED)
-   public boolean required()
-   {
-      return ctx.getRollbackOnly();
-   }
-   
-   @TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
-   public boolean requiresNew()
-   {
-      return ctx.getRollbackOnly();
-   }
-   
-   @TransactionAttribute(TransactionAttributeType.SUPPORTS)
-   public boolean supports()
-   {
-      return ctx.getRollbackOnly();
-   }
-}

Copied: projects/ejb3/dev/ejbthree1269/transactions/src/test/java/org/jboss/ejb3/test/tx/getrollback/GetRollbackTestBean.java (from rev 72523, projects/ejb3/trunk/transactions/src/test/java/org/jboss/ejb3/test/tx/getrollback/GetRollbackTestBean.java)
===================================================================
--- projects/ejb3/dev/ejbthree1269/transactions/src/test/java/org/jboss/ejb3/test/tx/getrollback/GetRollbackTestBean.java	                        (rev 0)
+++ projects/ejb3/dev/ejbthree1269/transactions/src/test/java/org/jboss/ejb3/test/tx/getrollback/GetRollbackTestBean.java	2008-04-21 21:17:56 UTC (rev 72525)
@@ -0,0 +1,79 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, 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.tx.getrollback;
+
+import static javax.ejb.TransactionAttributeType.MANDATORY;
+import static javax.ejb.TransactionAttributeType.NEVER;
+import static javax.ejb.TransactionAttributeType.REQUIRED;
+
+import javax.ejb.EJBContext;
+import javax.ejb.Stateless;
+import javax.ejb.TransactionAttribute;
+import javax.ejb.TransactionAttributeType;
+
+import org.jboss.ejb3.test.tx.common.MockEJBContext;
+
+/**
+ * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+ at Stateless
+public class GetRollbackTestBean
+{
+   private EJBContext ctx = new MockEJBContext();
+   
+   @TransactionAttribute(MANDATORY)
+   public boolean mandatory()
+   {
+      return ctx.getRollbackOnly();
+   }
+   
+   @TransactionAttribute(NEVER)
+   public boolean never()
+   {
+      return ctx.getRollbackOnly();
+   }
+   
+   @TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)
+   public boolean notSupported()
+   {
+      return ctx.getRollbackOnly();
+   }
+   
+   @TransactionAttribute(REQUIRED)
+   public boolean required()
+   {
+      return ctx.getRollbackOnly();
+   }
+   
+   @TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
+   public boolean requiresNew()
+   {
+      return ctx.getRollbackOnly();
+   }
+   
+   @TransactionAttribute(TransactionAttributeType.SUPPORTS)
+   public boolean supports()
+   {
+      return ctx.getRollbackOnly();
+   }
+}

Copied: projects/ejb3/dev/ejbthree1269/transactions/src/test/java/org/jboss/ejb3/test/tx/getrollback/unit (from rev 72523, projects/ejb3/trunk/transactions/src/test/java/org/jboss/ejb3/test/tx/getrollback/unit)

Deleted: projects/ejb3/dev/ejbthree1269/transactions/src/test/java/org/jboss/ejb3/test/tx/getrollback/unit/GetRollbackTestCase.java
===================================================================
--- projects/ejb3/trunk/transactions/src/test/java/org/jboss/ejb3/test/tx/getrollback/unit/GetRollbackTestCase.java	2008-04-21 21:13:11 UTC (rev 72523)
+++ projects/ejb3/dev/ejbthree1269/transactions/src/test/java/org/jboss/ejb3/test/tx/getrollback/unit/GetRollbackTestCase.java	2008-04-21 21:17:56 UTC (rev 72525)
@@ -1,209 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2008, 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.tx.getrollback.unit;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.fail;
-
-import java.net.URL;
-
-import javax.ejb.EJBTransactionRolledbackException;
-import javax.naming.InitialContext;
-import javax.transaction.TransactionManager;
-
-import org.jboss.ejb3.interceptors.container.BeanContext;
-import org.jboss.ejb3.interceptors.direct.DirectContainer;
-import org.jboss.ejb3.test.tx.getrollback.GetRollbackTestBean;
-import org.jboss.ejb3.test.tx.mc.UnitTestBootstrap;
-import org.junit.After;
-import org.junit.AfterClass;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
-
-/**
- * EJB 3 13.6.2.9
- * 
- * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
- * @version $Revision: $
- */
-public class GetRollbackTestCase
-{
-   private static UnitTestBootstrap bootstrap;
-   
-   private static DirectContainer<GetRollbackTestBean> container;
-   private BeanContext<GetRollbackTestBean> instance;
-   
-   private void expectException(String methodName, Class<? extends Exception> exceptionClass) throws Throwable
-   {
-      try
-      {
-         container.invoke(instance, methodName);
-         fail("Expecting an IllegalStateException on " + methodName);
-      }
-      catch(Exception e)
-      {
-         assertEquals(exceptionClass, e.getClass());
-      }
-   }
-   
-   private void expectFalse(String methodName) throws Throwable
-   {
-      Boolean actual = container.invoke(instance, methodName);
-      assertFalse(actual);
-   }
-   
-   private void expectIllegalState(String methodName) throws Throwable
-   {
-      try
-      {
-         container.invoke(instance, methodName);
-         fail("Expecting an IllegalStateException on " + methodName);
-      }
-      catch(IllegalStateException e)
-      {
-         // Happy, happy, joy, joy
-      }
-   }
-   
-   private static URL getResource(String name)
-   {
-      return Thread.currentThread().getContextClassLoader().getResource(name);
-   }
-   
-   @BeforeClass
-   public static void setUpBeforeClass() throws Throwable
-   {
-      bootstrap = new UnitTestBootstrap();
-      bootstrap.deploy(getResource("instance/beans.xml"));
-      
-      // TODO: should not use Stateful Container
-      container = new DirectContainer<GetRollbackTestBean>("GetRollbackTest", "Stateless Container", GetRollbackTestBean.class);
-   }
-
-   @AfterClass
-   public static void tearDownAfterClass() throws Exception
-   {
-      if(bootstrap != null)
-         bootstrap.shutdown();
-   }
-
-   @Before
-   public void setUp() throws Exception
-   {
-      instance = container.construct();
-   }
-
-   @After
-   public void tearDown() throws Exception
-   {
-      container.destroy(instance);
-   }
-   
-
-   /**
-    * Test method for {@link org.jboss.ejb3.test.tx.getrollback.GetRollbackTestBean#mandatory()}.
-    * @throws Throwable 
-    */
-   @Test
-   public void testMandatory() throws Throwable
-   {
-      InitialContext ctx = new InitialContext();
-      TransactionManager tm = (TransactionManager) ctx.lookup("java:/TransactionManager");
-      tm.begin();
-      try
-      {
-         expectFalse("mandatory");
-      }
-      finally
-      {
-         tm.rollback();
-      }
-   }
-
-   /**
-    * Test method for {@link org.jboss.ejb3.test.tx.getrollback.GetRollbackTestBean#never()}.
-    * @throws Throwable 
-    */
-   @Test
-   public void testNever() throws Throwable
-   {
-      expectIllegalState("never");
-   }
-
-   /**
-    * Test method for {@link org.jboss.ejb3.test.tx.getrollback.GetRollbackTestBean#notSupported()}.
-    * @throws Throwable 
-    */
-   @Test
-   public void testNotSupported() throws Throwable
-   {
-      expectIllegalState("notSupported");
-   }
-
-   /**
-    * Test method for {@link org.jboss.ejb3.test.tx.getrollback.GetRollbackTestBean#required()}.
-    * @throws Throwable 
-    */
-   @Test
-   public void testRequired() throws Throwable
-   {
-      expectFalse("required");
-   }
-
-   /**
-    * Test method for {@link org.jboss.ejb3.test.tx.getrollback.GetRollbackTestBean#requiresNew()}.
-    * @throws Throwable 
-    */
-   @Test
-   public void testRequiresNew() throws Throwable
-   {
-      expectFalse("requiresNew");
-   }
-
-   /**
-    * Test method for {@link org.jboss.ejb3.test.tx.getrollback.GetRollbackTestBean#supports()}.
-    * @throws Throwable 
-    */
-   @Test
-   public void testSupports() throws Throwable
-   {
-      expectIllegalState("supports");
-   }
-   
-   @Test
-   public void testSupportsWithTransaction() throws Throwable
-   {
-      InitialContext ctx = new InitialContext();
-      TransactionManager tm = (TransactionManager) ctx.lookup("java:/TransactionManager");
-      tm.begin();
-      try
-      {
-         expectException("supports", EJBTransactionRolledbackException.class);
-      }
-      finally
-      {
-         tm.rollback();
-      }
-   }
-}

Copied: projects/ejb3/dev/ejbthree1269/transactions/src/test/java/org/jboss/ejb3/test/tx/getrollback/unit/GetRollbackTestCase.java (from rev 72523, projects/ejb3/trunk/transactions/src/test/java/org/jboss/ejb3/test/tx/getrollback/unit/GetRollbackTestCase.java)
===================================================================
--- projects/ejb3/dev/ejbthree1269/transactions/src/test/java/org/jboss/ejb3/test/tx/getrollback/unit/GetRollbackTestCase.java	                        (rev 0)
+++ projects/ejb3/dev/ejbthree1269/transactions/src/test/java/org/jboss/ejb3/test/tx/getrollback/unit/GetRollbackTestCase.java	2008-04-21 21:17:56 UTC (rev 72525)
@@ -0,0 +1,209 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, 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.tx.getrollback.unit;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.fail;
+
+import java.net.URL;
+
+import javax.ejb.EJBTransactionRolledbackException;
+import javax.naming.InitialContext;
+import javax.transaction.TransactionManager;
+
+import org.jboss.ejb3.interceptors.container.BeanContext;
+import org.jboss.ejb3.interceptors.direct.DirectContainer;
+import org.jboss.ejb3.test.tx.getrollback.GetRollbackTestBean;
+import org.jboss.ejb3.test.tx.mc.UnitTestBootstrap;
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ * EJB 3 13.6.2.9
+ * 
+ * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public class GetRollbackTestCase
+{
+   private static UnitTestBootstrap bootstrap;
+   
+   private static DirectContainer<GetRollbackTestBean> container;
+   private BeanContext<GetRollbackTestBean> instance;
+   
+   private void expectException(String methodName, Class<? extends Exception> exceptionClass) throws Throwable
+   {
+      try
+      {
+         container.invoke(instance, methodName);
+         fail("Expecting an IllegalStateException on " + methodName);
+      }
+      catch(Exception e)
+      {
+         assertEquals(exceptionClass, e.getClass());
+      }
+   }
+   
+   private void expectFalse(String methodName) throws Throwable
+   {
+      Boolean actual = container.invoke(instance, methodName);
+      assertFalse(actual);
+   }
+   
+   private void expectIllegalState(String methodName) throws Throwable
+   {
+      try
+      {
+         container.invoke(instance, methodName);
+         fail("Expecting an IllegalStateException on " + methodName);
+      }
+      catch(IllegalStateException e)
+      {
+         // Happy, happy, joy, joy
+      }
+   }
+   
+   private static URL getResource(String name)
+   {
+      return Thread.currentThread().getContextClassLoader().getResource(name);
+   }
+   
+   @BeforeClass
+   public static void setUpBeforeClass() throws Throwable
+   {
+      bootstrap = new UnitTestBootstrap();
+      bootstrap.deploy(getResource("instance/beans.xml"));
+      
+      // TODO: should not use Stateful Container
+      container = new DirectContainer<GetRollbackTestBean>("GetRollbackTest", "Stateless Container", GetRollbackTestBean.class);
+   }
+
+   @AfterClass
+   public static void tearDownAfterClass() throws Exception
+   {
+      if(bootstrap != null)
+         bootstrap.shutdown();
+   }
+
+   @Before
+   public void setUp() throws Exception
+   {
+      instance = container.construct();
+   }
+
+   @After
+   public void tearDown() throws Exception
+   {
+      container.destroy(instance);
+   }
+   
+
+   /**
+    * Test method for {@link org.jboss.ejb3.test.tx.getrollback.GetRollbackTestBean#mandatory()}.
+    * @throws Throwable 
+    */
+   @Test
+   public void testMandatory() throws Throwable
+   {
+      InitialContext ctx = new InitialContext();
+      TransactionManager tm = (TransactionManager) ctx.lookup("java:/TransactionManager");
+      tm.begin();
+      try
+      {
+         expectFalse("mandatory");
+      }
+      finally
+      {
+         tm.rollback();
+      }
+   }
+
+   /**
+    * Test method for {@link org.jboss.ejb3.test.tx.getrollback.GetRollbackTestBean#never()}.
+    * @throws Throwable 
+    */
+   @Test
+   public void testNever() throws Throwable
+   {
+      expectIllegalState("never");
+   }
+
+   /**
+    * Test method for {@link org.jboss.ejb3.test.tx.getrollback.GetRollbackTestBean#notSupported()}.
+    * @throws Throwable 
+    */
+   @Test
+   public void testNotSupported() throws Throwable
+   {
+      expectIllegalState("notSupported");
+   }
+
+   /**
+    * Test method for {@link org.jboss.ejb3.test.tx.getrollback.GetRollbackTestBean#required()}.
+    * @throws Throwable 
+    */
+   @Test
+   public void testRequired() throws Throwable
+   {
+      expectFalse("required");
+   }
+
+   /**
+    * Test method for {@link org.jboss.ejb3.test.tx.getrollback.GetRollbackTestBean#requiresNew()}.
+    * @throws Throwable 
+    */
+   @Test
+   public void testRequiresNew() throws Throwable
+   {
+      expectFalse("requiresNew");
+   }
+
+   /**
+    * Test method for {@link org.jboss.ejb3.test.tx.getrollback.GetRollbackTestBean#supports()}.
+    * @throws Throwable 
+    */
+   @Test
+   public void testSupports() throws Throwable
+   {
+      expectIllegalState("supports");
+   }
+   
+   @Test
+   public void testSupportsWithTransaction() throws Throwable
+   {
+      InitialContext ctx = new InitialContext();
+      TransactionManager tm = (TransactionManager) ctx.lookup("java:/TransactionManager");
+      tm.begin();
+      try
+      {
+         expectException("supports", EJBTransactionRolledbackException.class);
+      }
+      finally
+      {
+         tm.rollback();
+      }
+   }
+}

Modified: projects/ejb3/dev/ejbthree1269/transactions/src/test/resources/instance/jboss-aop.xml
===================================================================
--- projects/ejb3/dev/ejbthree1269/transactions/src/test/resources/instance/jboss-aop.xml	2008-04-21 21:14:20 UTC (rev 72524)
+++ projects/ejb3/dev/ejbthree1269/transactions/src/test/resources/instance/jboss-aop.xml	2008-04-21 21:17:56 UTC (rev 72525)
@@ -1,13 +1,25 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <aop>
+   <interceptor class="org.jboss.aspects.currentinvocation.CurrentInvocationInterceptor" scope="PER_VM"/>
    <interceptor class="org.jboss.ejb3.test.tx.common.StatefulInstanceInterceptor" scope="PER_VM"/>
-   <interceptor factory="org.jboss.ejb3.tx.TxInterceptorFactory" scope="PER_CLASS_JOINPOINT"/>
-    
+   <interceptor factory="org.jboss.ejb3.tx.BMTTxInterceptorFactory" scope="PER_CLASS_JOINPOINT"/>
+   <interceptor factory="org.jboss.ejb3.tx.CMTTxInterceptorFactory" scope="PER_CLASS_JOINPOINT"/>
+   
+   <domain name="Stateless Container">
+      <bind pointcut="execution(public * *->*(..))">
+         <interceptor-ref name="org.jboss.aspects.currentinvocation.CurrentInvocationInterceptor"/>
+         <interceptor-ref name="org.jboss.ejb3.tx.CMTTxInterceptorFactory"/>
+         <!-- here be an instance interceptor -->
+         <interceptor-ref name="org.jboss.ejb3.tx.BMTTxInterceptorFactory"/>
+      </bind>
+   </domain>
+   
    <domain name="Stateful Container">
       <bind pointcut="execution(public * *->*(..))">
+         <!--interceptor-ref name="org.jboss.aspects.tx.TxPropagationInterceptor"/-->
+         <interceptor-ref name="org.jboss.ejb3.tx.CMTTxInterceptorFactory"/>
          <interceptor-ref name="org.jboss.ejb3.test.tx.common.StatefulInstanceInterceptor"/>
-         <!--interceptor-ref name="org.jboss.aspects.tx.TxPropagationInterceptor"/-->
-         <interceptor-ref name="org.jboss.ejb3.tx.TxInterceptorFactory"/>
+         <interceptor-ref name="org.jboss.ejb3.tx.BMTTxInterceptorFactory"/>
       </bind>
       <!--
       <bind pointcut="execution(public * $instanceof{javax.ejb.SessionSynchronization}->*(..))">




More information about the jboss-cvs-commits mailing list