[jboss-cvs] JBossAS SVN: r81720 - in projects/ejb3/trunk: core/src/main/java/org/jboss/ejb3 and 21 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Thu Nov 27 05:51:35 EST 2008


Author: wolfc
Date: 2008-11-27 05:51:35 -0500 (Thu, 27 Nov 2008)
New Revision: 81720

Added:
   projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/connectionmanager/
   projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/connectionmanager/CachedConnectionInterceptor.java
   projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/connectionmanager/CachedConnectionInterceptorFactory.java
   projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/connectionmanager/CachedConnectionManager.java
   projects/ejb3/trunk/core/src/main/resources/ejb3-container-jboss-beans.xml
   projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/core/test/common/MockCachedConnectionManager.java
   projects/ejb3/trunk/core/src/test/resources/container-beans.xml
   projects/ejb3/trunk/embedded/src/main/java/org/jboss/ejb3/embedded/connectionmanager/
   projects/ejb3/trunk/embedded/src/main/java/org/jboss/ejb3/embedded/connectionmanager/EmbeddedCachedConnectionManager.java
   projects/ejb3/trunk/embedded/src/main/resources/META-INF/ejb-container-beans.xml
   projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1028/
   projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1028/ATM.java
   projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1028/ATMBean.java
   projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1028/Account.java
   projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1028/unit/
   projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1028/unit/LazyTransactionEnlistmentUnitTestCase.java
   projects/ejb3/trunk/testsuite/src/test/resources/test/ejbthree1028/
   projects/ejb3/trunk/testsuite/src/test/resources/test/ejbthree1028/META-INF/
   projects/ejb3/trunk/testsuite/src/test/resources/test/ejbthree1028/META-INF/persistence.xml
   projects/ejb3/trunk/transactions/src/main/java/org/jboss/ejb3/tx/EJB3UserTransactionProvider.java
Modified:
   projects/ejb3/trunk/build/pom.xml
   projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/EJBContainer.java
   projects/ejb3/trunk/core/src/main/resources/ejb3-interceptors-aop.xml
   projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/core/test/common/AbstractEJB3TestCase.java
   projects/ejb3/trunk/embedded/pom.xml
   projects/ejb3/trunk/embedded/src/main/java/org/jboss/ejb3/embedded/deployers/EjbComponentDeployer.java
   projects/ejb3/trunk/embedded/src/main/java/org/jboss/ejb3/embedded/deployers/EjbModuleDeployer.java
   projects/ejb3/trunk/proxy/pom.xml
   projects/ejb3/trunk/testsuite/build-test.xml
   projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/common/EJB3TestCase.java
   projects/ejb3/trunk/transactions/pom.xml
   projects/ejb3/trunk/transactions/src/main/java/org/jboss/ejb3/tx/UserTransactionImpl.java
   projects/ejb3/trunk/transactions/src/test/resources/instance/beans.xml
Log:
EJBTHREE-1028: hook up to the CachedConnectionManager

Modified: projects/ejb3/trunk/build/pom.xml
===================================================================
--- projects/ejb3/trunk/build/pom.xml	2008-11-27 10:49:27 UTC (rev 81719)
+++ projects/ejb3/trunk/build/pom.xml	2008-11-27 10:51:35 UTC (rev 81720)
@@ -164,6 +164,8 @@
                 <exclude>org.jboss:javassist</exclude>
                 <!-- deprecated, should be org.jboss.metadata:jboss-metadata -->
                 <exclude>org.jboss:jboss-metadata</exclude>
+                <!-- deprecated, should be org.jboss.integration:jboss-transaction-spi -->
+                <exclude>org.jboss:jboss-transaction-spi</exclude>
                 <!-- deprecated, split up into multiple components -->
                 <exclude>org.jboss.microcontainer:jboss-container</exclude>
                 <!-- deprecated, should be org.jboss.deployers:jboss-deployers-core-spi -->

Modified: projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/EJBContainer.java
===================================================================
--- projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/EJBContainer.java	2008-11-27 10:49:27 UTC (rev 81719)
+++ projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/EJBContainer.java	2008-11-27 10:51:35 UTC (rev 81720)
@@ -66,12 +66,14 @@
 import org.jboss.aop.joinpoint.ConstructionInvocation;
 import org.jboss.aop.util.MethodHashing;
 import org.jboss.aspects.currentinvocation.CurrentInvocationInterceptor;
+import org.jboss.beans.metadata.api.annotations.Inject;
 import org.jboss.ejb.AllowedOperationsAssociation;
 import org.jboss.ejb3.annotation.Clustered;
 import org.jboss.ejb3.annotation.SecurityDomain;
 import org.jboss.ejb3.annotation.defaults.PoolDefaults;
 import org.jboss.ejb3.aop.BeanContainer;
 import org.jboss.ejb3.common.spi.ErrorCodes;
+import org.jboss.ejb3.connectionmanager.CachedConnectionManager;
 import org.jboss.ejb3.deployers.JBoss5DependencyPolicy;
 import org.jboss.ejb3.injection.InjectionInvocation;
 import org.jboss.ejb3.interceptor.InterceptorInfoRepository;
@@ -190,6 +192,8 @@
    
    private static final Interceptor[] currentInvocationStack = new Interceptor[] { new CurrentInvocationInterceptor() };
    
+   private CachedConnectionManager cachedConnectionManager;
+   
    /**
     * @param name                  Advisor name
     * @param manager               Domain to get interceptor bindings from
@@ -723,6 +727,11 @@
       return encInjectors;
    }
 
+   public CachedConnectionManager getCachedConnectionManager()
+   {
+      return cachedConnectionManager;
+   }
+   
    public ClassLoader getClassloader()
    {
       return classloader;
@@ -1549,6 +1558,12 @@
       beanContainer.reinitializeAdvisor();
    }
    
+   @Inject
+   public void setCachedConnectionManager(CachedConnectionManager ccm)
+   {
+      this.cachedConnectionManager = ccm;
+   }
+   
    public void setDirectContainer(DirectContainer<EJBContainer> container)
    {
       this.directContainer = container;

Added: projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/connectionmanager/CachedConnectionInterceptor.java
===================================================================
--- projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/connectionmanager/CachedConnectionInterceptor.java	                        (rev 0)
+++ projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/connectionmanager/CachedConnectionInterceptor.java	2008-11-27 10:51:35 UTC (rev 81720)
@@ -0,0 +1,61 @@
+/*
+ * 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.connectionmanager;
+
+import java.util.Set;
+
+import org.jboss.aop.joinpoint.Invocation;
+import org.jboss.ejb3.BeanContext;
+import org.jboss.ejb3.EJBContainer;
+import org.jboss.ejb3.EJBContainerInvocation;
+import org.jboss.ejb3.aop.AbstractInterceptor;
+
+/**
+ * @author <a href="mailto:cdewolf at redhat.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public class CachedConnectionInterceptor extends AbstractInterceptor
+{
+   private final Set<String> unsharableResources;
+   
+   public CachedConnectionInterceptor(Set<String> unsharableResources)
+   {
+      this.unsharableResources = unsharableResources;
+   }
+   
+   public Object invoke(Invocation invocation) throws Throwable
+   {
+      EJBContainerInvocation<EJBContainer, BeanContext<?>> containerInvocation = (EJBContainerInvocation<EJBContainer, BeanContext<?>>) invocation;
+      EJBContainer container = getEJBContainer(invocation);
+      CachedConnectionManager ccm = container.getCachedConnectionManager();
+      Object key = containerInvocation.getBeanContext().getInstance();
+      ccm.pushMetaDataAwareObject(key, unsharableResources);
+      try
+      {
+         return containerInvocation.invokeNext();
+      }
+      finally
+      {
+         ccm.popMetaDataAwareObject(unsharableResources);
+      }
+   }
+}

Added: projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/connectionmanager/CachedConnectionInterceptorFactory.java
===================================================================
--- projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/connectionmanager/CachedConnectionInterceptorFactory.java	                        (rev 0)
+++ projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/connectionmanager/CachedConnectionInterceptorFactory.java	2008-11-27 10:51:35 UTC (rev 81720)
@@ -0,0 +1,62 @@
+/*
+ * 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.connectionmanager;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import org.jboss.aop.Advisor;
+import org.jboss.ejb3.EJBContainer;
+import org.jboss.ejb3.interceptors.aop.AbstractInterceptorFactory;
+import org.jboss.metadata.ejb.jboss.JBossEnterpriseBeanMetaData;
+import org.jboss.metadata.javaee.spec.ResourceReferenceMetaData;
+import org.jboss.metadata.javaee.spec.ResourceReferencesMetaData;
+
+/**
+ * @author <a href="mailto:cdewolf at redhat.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public class CachedConnectionInterceptorFactory extends AbstractInterceptorFactory
+{
+   @Override
+   public Object createPerClass(Advisor advisor)
+   {
+      EJBContainer container = EJBContainer.getEJBContainer(advisor);
+      Set<String> unsharableResources = new HashSet<String>();
+      JBossEnterpriseBeanMetaData metaData = container.getXml();
+      ResourceReferencesMetaData resRefs = metaData.getResourceReferences();
+      if(resRefs != null)
+      {
+         for(ResourceReferenceMetaData resRef : resRefs)
+         {
+            String jndiName = resRef.getJndiName();
+            if(jndiName == null)
+               jndiName = resRef.getResolvedJndiName();
+            int i = jndiName.indexOf(':');
+            if(jndiName.charAt(i + 1) == '/')
+               i++;
+            unsharableResources.add(jndiName.substring(i + 1));
+         }
+      }
+      return new CachedConnectionInterceptor(unsharableResources);
+   }
+}

Added: projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/connectionmanager/CachedConnectionManager.java
===================================================================
--- projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/connectionmanager/CachedConnectionManager.java	                        (rev 0)
+++ projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/connectionmanager/CachedConnectionManager.java	2008-11-27 10:51:35 UTC (rev 81720)
@@ -0,0 +1,46 @@
+/*
+ * 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.connectionmanager;
+
+import java.util.Set;
+
+import javax.resource.ResourceException;
+
+/**
+ * @author <a href="mailto:cdewolf at redhat.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public interface CachedConnectionManager
+{
+
+   /**
+    * @param key
+    * @param unsharableResources
+    */
+   void pushMetaDataAwareObject(Object key, Set<String> unsharableResources) throws ResourceException;
+
+   /**
+    * @param unsharableResources
+    */
+   void popMetaDataAwareObject(Set<String> unsharableResources) throws ResourceException;
+
+}

Added: projects/ejb3/trunk/core/src/main/resources/ejb3-container-jboss-beans.xml
===================================================================
--- projects/ejb3/trunk/core/src/main/resources/ejb3-container-jboss-beans.xml	                        (rev 0)
+++ projects/ejb3/trunk/core/src/main/resources/ejb3-container-jboss-beans.xml	2008-11-27 10:51:35 UTC (rev 81720)
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<deployment xmlns="urn:jboss:bean-deployer:2.0">
+   <!-- The provider for EJB3 UserTransactions -->
+   <bean name="EJB3UserTransactionprovider" class="org.jboss.ejb3.tx.EJB3UserTransactionProvider">
+      <depends>UserTransactionRegistry</depends>
+      <constructor factoryClass="org.jboss.ejb3.tx.EJB3UserTransactionProvider" factoryMethod="getSingleton"/>
+   </bean>
+   
+   <bean name="EJB3CachedConnectionManagerBridge" class="org.jboss.as.ejb3.connectionmanager.CachedConnectionManagerBridge">
+   </bean>
+</deployment>

Modified: projects/ejb3/trunk/core/src/main/resources/ejb3-interceptors-aop.xml
===================================================================
--- projects/ejb3/trunk/core/src/main/resources/ejb3-interceptors-aop.xml	2008-11-27 10:49:27 UTC (rev 81719)
+++ projects/ejb3/trunk/core/src/main/resources/ejb3-interceptors-aop.xml	2008-11-27 10:51:35 UTC (rev 81720)
@@ -83,6 +83,7 @@
    <interceptor factory="org.jboss.ejb3.mdb.CurrentMessageInjectorInterceptorFactory" scope="PER_CLASS"/>
    <interceptor class="org.jboss.ejb3.entity.TransactionScopedEntityManagerInterceptor" scope="PER_VM"/>
    <interceptor class="org.jboss.ejb3.BlockContainerShutdownInterceptor" scope="PER_VM"/>
+   <interceptor factory="org.jboss.ejb3.connectionmanager.CachedConnectionInterceptorFactory" scope="PER_CLASS"/>
 
    <!--
          INTERCEPTORS
@@ -134,6 +135,8 @@
       </bind>
       -->
       <stack name="EJBInterceptors">
+         <interceptor-ref name="org.jboss.ejb3.connectionmanager.CachedConnectionInterceptorFactory"/>
+         
          <advice name="setup" aspect="InvocationContextInterceptor"/>
          <advice name="fillMethod" aspect="InvocationContextInterceptor"/>
          <advice name="aroundInvoke" aspect="InjectInterceptorsFactory"/>

Modified: projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/core/test/common/AbstractEJB3TestCase.java
===================================================================
--- projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/core/test/common/AbstractEJB3TestCase.java	2008-11-27 10:49:27 UTC (rev 81719)
+++ projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/core/test/common/AbstractEJB3TestCase.java	2008-11-27 10:51:35 UTC (rev 81720)
@@ -38,7 +38,6 @@
 import org.jboss.ejb3.Ejb3Registry;
 import org.jboss.ejb3.InitialContextFactory;
 import org.jboss.ejb3.cache.CacheFactoryRegistry;
-import org.jboss.ejb3.cache.Ejb3CacheFactory;
 import org.jboss.ejb3.cache.persistence.PersistenceManagerFactoryRegistry;
 import org.jboss.ejb3.common.registrar.plugin.mc.Ejb3McRegistrar;
 import org.jboss.ejb3.common.registrar.spi.DuplicateBindException;
@@ -133,6 +132,7 @@
       deploy("statefulcontainer-beans.xml");
       deploy("statelesscontainer-beans.xml");
       deploy("connector-beans.xml");
+      deploy("container-beans.xml");
 
       // TODO: AspectDeployment
       URL url = Thread.currentThread().getContextClassLoader().getResource("ejb3-interceptors-aop.xml");
@@ -350,6 +350,24 @@
          throw new RuntimeException("Object Store already has binding under " + containerName, dbe);
       }
 
+      // make sure we're installed
+      try
+      {
+         bootstrap.lookup(containerName, Object.class);
+      }
+      catch(RuntimeException e)
+      {
+         throw e;
+      }
+      catch(Error e)
+      {
+         throw e;
+      }
+      catch(Throwable t)
+      {
+         throw new RuntimeException(t);
+      }
+      
       // Return
       return container;
    }

Added: projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/core/test/common/MockCachedConnectionManager.java
===================================================================
--- projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/core/test/common/MockCachedConnectionManager.java	                        (rev 0)
+++ projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/core/test/common/MockCachedConnectionManager.java	2008-11-27 10:51:35 UTC (rev 81720)
@@ -0,0 +1,43 @@
+/*
+ * 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.core.test.common;
+
+import java.util.Set;
+
+import javax.resource.ResourceException;
+
+import org.jboss.ejb3.connectionmanager.CachedConnectionManager;
+
+/**
+ * @author <a href="mailto:cdewolf at redhat.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public class MockCachedConnectionManager implements CachedConnectionManager
+{
+   public void popMetaDataAwareObject(Set<String> unsharableResources) throws ResourceException
+   {
+   }
+
+   public void pushMetaDataAwareObject(Object key, Set<String> unsharableResources) throws ResourceException
+   {
+   }
+}

Added: projects/ejb3/trunk/core/src/test/resources/container-beans.xml
===================================================================
--- projects/ejb3/trunk/core/src/test/resources/container-beans.xml	                        (rev 0)
+++ projects/ejb3/trunk/core/src/test/resources/container-beans.xml	2008-11-27 10:51:35 UTC (rev 81720)
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<deployment xmlns="urn:jboss:bean-deployer:2.0">
+   <!-- The provider for EJB3 UserTransactions -->
+   <bean name="EJB3UserTransactionprovider" class="org.jboss.ejb3.tx.EJB3UserTransactionProvider">
+      <depends>UserTransactionRegistry</depends>
+      <constructor factoryClass="org.jboss.ejb3.tx.EJB3UserTransactionProvider" factoryMethod="getSingleton"/>
+   </bean>
+   
+   <bean name="TestCachedConnectionManagerBridge" class="org.jboss.ejb3.core.test.common.MockCachedConnectionManager">
+   </bean>
+</deployment>

Modified: projects/ejb3/trunk/embedded/pom.xml
===================================================================
--- projects/ejb3/trunk/embedded/pom.xml	2008-11-27 10:49:27 UTC (rev 81719)
+++ projects/ejb3/trunk/embedded/pom.xml	2008-11-27 10:51:35 UTC (rev 81720)
@@ -21,6 +21,7 @@
   
   <properties>
     <version.org.jboss.deployers>[2.0.0.CR5]</version.org.jboss.deployers>
+    <version.org.jboss.microcontainer>[2.0.0.GA]</version.org.jboss.microcontainer>
   </properties>
 
   <build>
@@ -49,9 +50,14 @@
         <version>2.0.0.GA</version>
       </dependency>
       <dependency>
+        <groupId>org.jboss.integration</groupId>
+        <artifactId>jboss-transaction-spi</artifactId>
+        <version>5.0.3.GA</version>
+      </dependency>
+      <dependency>
         <groupId>org.jboss.microcontainer</groupId>
         <artifactId>jboss-kernel</artifactId>
-        <version>[2.0.0.CR5]</version>
+        <version>${version.org.jboss.microcontainer}</version>
       </dependency>
     </dependencies>
   </dependencyManagement>
@@ -173,12 +179,11 @@
     <dependency>
       <groupId>org.jboss.microcontainer</groupId>
       <artifactId>jboss-dependency</artifactId>
-      <version>[2.0.0.CR5]</version>
+      <version>${version.org.jboss.microcontainer}</version>
     </dependency>
     <dependency>
       <groupId>org.jboss.microcontainer</groupId>
       <artifactId>jboss-kernel</artifactId>
-      <version>[2.0.0.CR5]</version>
     </dependency>
     <dependency>
       <groupId>org.jboss.naming</groupId>

Added: projects/ejb3/trunk/embedded/src/main/java/org/jboss/ejb3/embedded/connectionmanager/EmbeddedCachedConnectionManager.java
===================================================================
--- projects/ejb3/trunk/embedded/src/main/java/org/jboss/ejb3/embedded/connectionmanager/EmbeddedCachedConnectionManager.java	                        (rev 0)
+++ projects/ejb3/trunk/embedded/src/main/java/org/jboss/ejb3/embedded/connectionmanager/EmbeddedCachedConnectionManager.java	2008-11-27 10:51:35 UTC (rev 81720)
@@ -0,0 +1,44 @@
+/*
+ * 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.embedded.connectionmanager;
+
+import java.util.Set;
+
+import javax.resource.ResourceException;
+
+import org.jboss.ejb3.connectionmanager.CachedConnectionManager;
+
+/**
+ * @author <a href="mailto:cdewolf at redhat.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public class EmbeddedCachedConnectionManager implements CachedConnectionManager
+{
+   public void popMetaDataAwareObject(Set<String> unsharableResources) throws ResourceException
+   {
+   }
+
+   public void pushMetaDataAwareObject(Object key, Set<String> unsharableResources) throws ResourceException
+   {
+   }
+
+}

Modified: projects/ejb3/trunk/embedded/src/main/java/org/jboss/ejb3/embedded/deployers/EjbComponentDeployer.java
===================================================================
--- projects/ejb3/trunk/embedded/src/main/java/org/jboss/ejb3/embedded/deployers/EjbComponentDeployer.java	2008-11-27 10:49:27 UTC (rev 81719)
+++ projects/ejb3/trunk/embedded/src/main/java/org/jboss/ejb3/embedded/deployers/EjbComponentDeployer.java	2008-11-27 10:51:35 UTC (rev 81720)
@@ -98,6 +98,11 @@
       builder.setConstructorValue(component);
       addDependencies(builder, unit, component);
       
-      unit.addAttachment(BeanMetaData.class, builder.getBeanMetaData());
+      DeploymentUnit parent = unit.getParent();
+      assert parent != null : "parent should not be null of component " + unit;
+      
+      // add the bean meta data to the parent, because else scope merging won't occur (whatever that is)
+      // (e.g. the bean won't get injected)
+      parent.addAttachment(BeanMetaData.class + ":" + componentName, builder.getBeanMetaData());
    }
 }

Modified: projects/ejb3/trunk/embedded/src/main/java/org/jboss/ejb3/embedded/deployers/EjbModuleDeployer.java
===================================================================
--- projects/ejb3/trunk/embedded/src/main/java/org/jboss/ejb3/embedded/deployers/EjbModuleDeployer.java	2008-11-27 10:49:27 UTC (rev 81719)
+++ projects/ejb3/trunk/embedded/src/main/java/org/jboss/ejb3/embedded/deployers/EjbModuleDeployer.java	2008-11-27 10:51:35 UTC (rev 81720)
@@ -72,12 +72,20 @@
       {
          log.info("Found " + metaData + " in " + unit);
          
+         // FIXME
+         if(metaData.getEnterpriseBeans() == null)
+         {
+            log.warn(unit + " contains no beans");
+            return;
+         }
+         
          Ejb3Deployment module = createModule(unit, metaData);
          unit.addAttachment(Ejb3Deployment.class, module);
          
-         BeanMetaDataBuilder builder = BeanMetaDataBuilder.createBuilder("org.jboss.ejb3.deployment:" + unit.getSimpleName(), module.getClass().getName());
+         String name = "org.jboss.ejb3.deployment:" + unit.getSimpleName();
+         BeanMetaDataBuilder builder = BeanMetaDataBuilder.createBuilder(name, module.getClass().getName());
          builder.setConstructorValue(module);
-         unit.addAttachment(BeanMetaData.class, builder.getBeanMetaData());
+         unit.addAttachment(BeanMetaData.class + ":" + name, builder.getBeanMetaData());
          
          for(JBossEnterpriseBeanMetaData bean : metaData.getEnterpriseBeans())
          {
@@ -93,6 +101,12 @@
 
       public void undeploy(DeploymentUnit unit, JBossMetaData metaData)
       {
+         // FIXME
+         if(metaData.getEnterpriseBeans() == null)
+         {
+            return;
+         }
+         
          for(JBossEnterpriseBeanMetaData bean : metaData.getEnterpriseBeans())
          {
             unit.removeComponent(bean.getEjbName());

Added: projects/ejb3/trunk/embedded/src/main/resources/META-INF/ejb-container-beans.xml
===================================================================
--- projects/ejb3/trunk/embedded/src/main/resources/META-INF/ejb-container-beans.xml	                        (rev 0)
+++ projects/ejb3/trunk/embedded/src/main/resources/META-INF/ejb-container-beans.xml	2008-11-27 10:51:35 UTC (rev 81720)
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<deployment xmlns="urn:jboss:bean-deployer:2.0">
+   <!-- The provider for EJB3 UserTransactions -->
+   <bean name="EJB3UserTransactionprovider" class="org.jboss.ejb3.tx.EJB3UserTransactionProvider">
+      <constructor factoryClass="org.jboss.ejb3.tx.EJB3UserTransactionProvider" factoryMethod="getSingleton"/>
+   </bean>
+   
+   <bean name="EmbeddedCachedConnectionManagerBridge" class="org.jboss.ejb3.embedded.connectionmanager.EmbeddedCachedConnectionManager"/>
+</deployment>

Modified: projects/ejb3/trunk/proxy/pom.xml
===================================================================
--- projects/ejb3/trunk/proxy/pom.xml	2008-11-27 10:49:27 UTC (rev 81719)
+++ projects/ejb3/trunk/proxy/pom.xml	2008-11-27 10:51:35 UTC (rev 81720)
@@ -90,6 +90,12 @@
     <dependency>
       <groupId>org.jboss.aspects</groupId>
       <artifactId>jboss-remoting-aspects</artifactId>
+      <exclusions>
+        <exclusion>
+	  <groupId>org.jboss</groupId>
+	  <artifactId>jboss-transaction-spi</artifactId>
+	</exclusion>
+      </exclusions>
     </dependency>
 
     <dependency>

Modified: projects/ejb3/trunk/testsuite/build-test.xml
===================================================================
--- projects/ejb3/trunk/testsuite/build-test.xml	2008-11-27 10:49:27 UTC (rev 81719)
+++ projects/ejb3/trunk/testsuite/build-test.xml	2008-11-27 10:51:35 UTC (rev 81720)
@@ -2334,6 +2334,10 @@
       <build-simple-jar name="ejbthree1025"/>
    </target>
 	
+   <target name="ejbthree1028" description="Builds a simple jar file.">
+      <build-simple-jar name="ejbthree1028"/>
+   </target>
+   
 	<target name="ejbthree1040"
       description="Builds a simple jar files."
       >	      
@@ -4231,7 +4235,9 @@
       ejbthree832, ejbthree921, ejbthree936,
       ejbthree939,
       ejbthree953, ejbthree957, ejbthree959, ejbthree963, ejbthree967, ejbthree971, ejbthree973, ejbthree985, ejbthree986,
-      ejbthree989, ejbthree994, ejbthree1020, ejbthree1023, ejbthree1025, ejbthree1040,
+      ejbthree989, ejbthree994, ejbthree1020, ejbthree1023, ejbthree1025,
+      ejbthree1028,
+      ejbthree1040,
       ejbthree1057, ejbthree1059, ejbthree1060,
       ejbthree1062,
       ejbthree1066, ejbthree1071, ejbthree1075, ejbthree1082, ejbthree1090, ejbthree1092, ejbthree1116, ejbthree1119, ejbthree1122, ejbthree1123, ejbthree1127,
@@ -4979,6 +4985,9 @@
          <param name="test" value="ejbthree1025"/>
       </antcall>
       <antcall target="test" inheritRefs="true">
+         <param name="test" value="ejbthree1028"/>
+      </antcall>
+      <antcall target="test" inheritRefs="true">
          <param name="test" value="ejbthree1040"/>
       </antcall>
       <antcall target="test" inheritRefs="true">

Modified: projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/common/EJB3TestCase.java
===================================================================
--- projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/common/EJB3TestCase.java	2008-11-27 10:49:27 UTC (rev 81719)
+++ projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/common/EJB3TestCase.java	2008-11-27 10:51:35 UTC (rev 81720)
@@ -34,6 +34,11 @@
       super(name);
    }
 
+   protected <T> T lookup(String name, Class<T> expectedType) throws Exception
+   {
+      return expectedType.cast(getInitialContext().lookup(name));
+   }
+   
    /**
     * Make sure the deployment is successful.
     * @throws Exception

Added: projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1028/ATM.java
===================================================================
--- projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1028/ATM.java	                        (rev 0)
+++ projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1028/ATM.java	2008-11-27 10:51:35 UTC (rev 81720)
@@ -0,0 +1,40 @@
+/*
+ * 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.ejbthree1028;
+
+import javax.ejb.Remote;
+
+/**
+ * @author <a href="mailto:cdewolf at redhat.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+ at Remote
+public interface ATM
+{
+   long createAccount(double balance);
+   
+   double getBalance(long id);
+   
+   double depositTwiceWithRollback(long id, double a1, double a2);
+   
+   double withdrawTwiceWithRollback(long id, double a1, double a2);
+}

Added: projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1028/ATMBean.java
===================================================================
--- projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1028/ATMBean.java	                        (rev 0)
+++ projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1028/ATMBean.java	2008-11-27 10:51:35 UTC (rev 81720)
@@ -0,0 +1,265 @@
+/*
+ * 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.ejbthree1028;
+
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+
+import javax.annotation.Resource;
+import javax.ejb.Stateless;
+import javax.ejb.TransactionManagement;
+import javax.ejb.TransactionManagementType;
+import javax.persistence.EntityManager;
+import javax.persistence.PersistenceContext;
+import javax.sql.DataSource;
+import javax.transaction.NotSupportedException;
+import javax.transaction.Status;
+import javax.transaction.SystemException;
+import javax.transaction.UserTransaction;
+
+/**
+ * @author <a href="mailto:cdewolf at redhat.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+ at Stateless
+ at TransactionManagement(TransactionManagementType.BEAN)
+public class ATMBean implements ATM
+{
+   @PersistenceContext
+   private EntityManager em;
+   
+   @Resource
+   private UserTransaction ut;
+   
+   @Resource(mappedName="java:/DefaultDS")
+   private DataSource ds;
+   
+   private void beginTx()
+   {
+      try
+      {
+         ut.begin();
+      }
+      catch (NotSupportedException e)
+      {
+         throw new RuntimeException(e);
+      }
+      catch (SystemException e)
+      {
+         throw new RuntimeException(e);
+      }
+   }
+   
+   private void commitTx()
+   {
+      try
+      {
+         ut.commit();
+      }
+      catch (RuntimeException e)
+      {
+         throw e;
+      }
+      // RollbackException, HeuristicMixedException, HeuristicRollbackException, SystemException
+      catch (Exception e)
+      {
+         throw new RuntimeException(e);
+      }
+   }
+   
+   public long createAccount(double balance)
+   {
+      beginTx();
+      try
+      {
+         Account a = new Account();
+         a.setBalance(balance);
+         em.persist(a);
+         commitTx();
+         return a.getId();
+      }
+      finally
+      {
+         rollbackTxIfNeeded();
+      }
+   }
+   
+   public double getBalance(long id)
+   {
+      Account a = em.find(Account.class, id);
+      return a.getBalance();
+   }
+   
+   private void rollbackTx()
+   {
+      try
+      {
+         ut.rollback();
+      }
+      catch (RuntimeException e)
+      {
+         throw e;
+      }
+      // SecurityException, SystemException
+      catch (Exception e)
+      {
+         throw new RuntimeException(e);
+      }
+   }
+   
+   private void rollbackTxIfNeeded()
+   {
+      try
+      {
+         switch(ut.getStatus())
+         {
+            case Status.STATUS_COMMITTED:
+            case Status.STATUS_NO_TRANSACTION:
+               break;
+            default:
+               ut.rollback();
+         }
+      }
+      catch (RuntimeException e)
+      {
+         throw e;
+      }
+      // SecurityException, SystemException
+      catch (Exception e)
+      {
+         throw new RuntimeException(e);
+      }
+   }
+   
+   public double depositTwiceWithRollback(long id, double a1, double a2)
+   {
+      Account a;
+      beginTx();
+      try
+      {
+         a = em.find(Account.class, id);
+         // unsafe (nolock)
+         a.setBalance(a.getBalance() + a1);
+         em.flush();
+         commitTx();
+      }
+      finally
+      {
+         rollbackTxIfNeeded();
+      }
+      
+      beginTx();
+      try
+      {
+         // unsafe
+         a.setBalance(a.getBalance() + a2);
+         em.flush();
+      }
+      finally
+      {
+         rollbackTx();
+      }
+      return a.getBalance();
+   }
+   
+   /**
+    * Do the same, but then raw sql.
+    * @param id
+    * @param a1
+    * @param a2
+    */
+   public double withdrawTwiceWithRollback(long id, double a1, double a2)
+   {
+      try
+      {
+         Connection conn = ds.getConnection();
+         try
+         {
+            double balance;
+            PreparedStatement ps = conn.prepareStatement("SELECT balance FROM account WHERE id = ?");
+            try
+            {
+               ps.setLong(1, id);
+               ResultSet rs = ps.executeQuery();
+               if(!rs.next())
+                  throw new IllegalArgumentException("can't find account " + id);
+               balance = rs.getDouble(1);
+            }
+            finally
+            {
+               ps.close();
+            }
+            
+            ps = conn.prepareStatement("UPDATE account SET balance = ? WHERE id = ?");
+            try
+            {
+               beginTx();
+               try
+               {
+                  balance -= a1;
+                  ps.setDouble(1, balance);
+                  ps.setLong(2, id);
+                  int rows = ps.executeUpdate();
+                  if(rows != 1)
+                     throw new IllegalStateException("first update failed");
+                  
+                  commitTx();
+               }
+               finally
+               {
+                  rollbackTxIfNeeded();
+               }
+               
+               beginTx();
+               try
+               {
+                  balance -= a2;
+                  ps.setDouble(1, balance);
+                  ps.setLong(2, id);
+                  int rows = ps.executeUpdate();
+                  if(rows != 1)
+                     throw new IllegalStateException("second update failed");
+               }
+               finally
+               {
+                  rollbackTx();
+               }
+            }
+            finally
+            {
+               ps.close();
+            }
+            return balance;
+         }
+         finally
+         {
+            conn.close();
+         }
+      }
+      catch(SQLException e)
+      {
+         throw new RuntimeException(e);
+      }
+   }
+}

Added: projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1028/Account.java
===================================================================
--- projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1028/Account.java	                        (rev 0)
+++ projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1028/Account.java	2008-11-27 10:51:35 UTC (rev 81720)
@@ -0,0 +1,59 @@
+/*
+ * 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.ejbthree1028;
+
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+
+/**
+ * @author <a href="mailto:cdewolf at redhat.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+ at Entity
+public class Account
+{
+   private long id;
+   private double balance; // don't look, not financially save
+   
+   public double getBalance()
+   {
+      return balance;  
+   }
+   
+   @Id
+   @GeneratedValue
+   public long getId()
+   {
+      return id;
+   }
+   
+   public void setBalance(double balance)
+   {
+      this.balance = balance;
+   }
+   
+   public void setId(long id)
+   {
+      this.id = id;
+   }
+}

Added: projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1028/unit/LazyTransactionEnlistmentUnitTestCase.java
===================================================================
--- projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1028/unit/LazyTransactionEnlistmentUnitTestCase.java	                        (rev 0)
+++ projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1028/unit/LazyTransactionEnlistmentUnitTestCase.java	2008-11-27 10:51:35 UTC (rev 81720)
@@ -0,0 +1,81 @@
+/*
+ * 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.ejbthree1028.unit;
+
+import junit.framework.Test;
+
+import org.jboss.ejb3.test.common.EJB3TestCase;
+import org.jboss.ejb3.test.ejbthree1028.ATM;
+
+/**
+ * @author <a href="mailto:cdewolf at redhat.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public class LazyTransactionEnlistmentUnitTestCase extends EJB3TestCase
+{
+   public LazyTransactionEnlistmentUnitTestCase(String name)
+   {
+      super(name);
+   }
+   
+   public static Test suite() throws Exception
+   {
+      // do not deploy any jars
+      return getDeploySetup(LazyTransactionEnlistmentUnitTestCase.class, "ejbthree1028.jar");
+   }
+   
+   public void test1() throws Exception
+   {
+      ATM atm = lookup("ATMBean/remote", ATM.class);
+      // if only
+      long id = atm.createAccount(1000000);
+      System.out.println("*** id " + id);
+      double balance = atm.getBalance(id);
+      System.out.println("*** balance " + balance);
+      assertEquals(1000000, balance);
+      
+      balance = atm.depositTwiceWithRollback(id, 125000, 250000);
+      System.out.println("*** balance " + balance);
+      // the entity state itself won't be rolled back
+      assertEquals(1375000, balance);
+      balance = atm.getBalance(id);
+      System.out.println("*** balance " + balance);
+      assertEquals(1125000, balance);
+   }
+   
+   public void testRawSQL() throws Exception
+   {
+      ATM atm = lookup("ATMBean/remote", ATM.class);
+      // if only
+      long id = atm.createAccount(1000000);
+      System.out.println("*** id " + id);
+      double balance = atm.getBalance(id);
+      System.out.println("*** balance " + balance);
+      assertEquals(1000000, balance);
+      
+      balance = atm.withdrawTwiceWithRollback(id, 125000, 250000);
+      System.out.println("*** balance " + balance);
+      balance = atm.getBalance(id);
+      System.out.println("*** balance " + balance);
+      assertEquals(875000, balance);
+   }
+}

Added: projects/ejb3/trunk/testsuite/src/test/resources/test/ejbthree1028/META-INF/persistence.xml
===================================================================
--- projects/ejb3/trunk/testsuite/src/test/resources/test/ejbthree1028/META-INF/persistence.xml	                        (rev 0)
+++ projects/ejb3/trunk/testsuite/src/test/resources/test/ejbthree1028/META-INF/persistence.xml	2008-11-27 10:51:35 UTC (rev 81720)
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<persistence xmlns="http://java.sun.com/xml/ns/persistence"
+   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+   xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
+   http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"
+   version="1.0">
+   <persistence-unit name="ejbthree1028">
+      <jta-data-source>java:/DefaultDS</jta-data-source>
+      <properties>
+          <property name="hibernate.hbm2ddl.auto" value="create"/>
+          <property name="hibernate.dialect" value="org.hibernate.dialect.HSQLDialect"/>
+      </properties>
+   </persistence-unit>
+</persistence>

Modified: projects/ejb3/trunk/transactions/pom.xml
===================================================================
--- projects/ejb3/trunk/transactions/pom.xml	2008-11-27 10:49:27 UTC (rev 81719)
+++ projects/ejb3/trunk/transactions/pom.xml	2008-11-27 10:51:35 UTC (rev 81720)
@@ -35,6 +35,11 @@
       <version>1.0.0.CR1</version>
     </dependency>
     <dependency>
+      <groupId>org.jboss.integration</groupId>
+      <artifactId>jboss-transaction-spi</artifactId>
+      <version>5.0.3.GA</version>
+    </dependency>
+    <dependency>
       <groupId>org.jboss.logging</groupId>
       <artifactId>jboss-logging-spi</artifactId>
     </dependency>
@@ -48,11 +53,6 @@
       <artifactId>junit</artifactId>
       <scope>test</scope>
     </dependency>
-    <dependency>
-      <groupId>org.jboss</groupId>
-      <artifactId>jboss-transaction-spi</artifactId>
-      <version>5.0.0.Beta4</version>
-    </dependency>
     <!-- TODO: remove dependency -->
     <!-- Bring in the AOP deployers -->
     <dependency>
@@ -108,6 +108,12 @@
       <groupId>org.jboss.aspects</groupId>
       <artifactId>jboss-transaction-aspects</artifactId>
       <version>1.0.0.Beta1</version>
+      <exclusions>
+        <exclusion>
+          <groupId>org.jboss</groupId>
+          <artifactId>jboss-transaction-spi</artifactId>
+        </exclusion>
+      </exclusions>
     </dependency>
     <dependency>
       <groupId>org.jboss.deployers</groupId>

Added: projects/ejb3/trunk/transactions/src/main/java/org/jboss/ejb3/tx/EJB3UserTransactionProvider.java
===================================================================
--- projects/ejb3/trunk/transactions/src/main/java/org/jboss/ejb3/tx/EJB3UserTransactionProvider.java	                        (rev 0)
+++ projects/ejb3/trunk/transactions/src/main/java/org/jboss/ejb3/tx/EJB3UserTransactionProvider.java	2008-11-27 10:51:35 UTC (rev 81720)
@@ -0,0 +1,67 @@
+/*
+ * 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 org.jboss.tm.usertx.UserTransactionProvider;
+import org.jboss.tm.usertx.UserTransactionRegistry;
+
+/**
+ * @author <a href="mailto:cdewolf at redhat.com">Carlo de Wolf</a>
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: $
+ */
+public class EJB3UserTransactionProvider implements UserTransactionProvider
+{
+   /** The singleton */
+   private static EJB3UserTransactionProvider singleton = new EJB3UserTransactionProvider();
+   
+   /** The registry */
+   private volatile UserTransactionRegistry registry;
+
+   private EJB3UserTransactionProvider()
+   {   
+   }
+   
+   /**
+    * Get the singleton
+    * 
+    * @return the singleton
+    */
+   public static EJB3UserTransactionProvider getSingleton()
+   {
+      return singleton;
+   }
+   
+   public void setTransactionRegistry(UserTransactionRegistry registry)
+   {
+      this.registry = registry;
+   }
+
+   /**
+    * Fire the user transaction started event
+    */
+   void userTransactionStarted() 
+   {
+      assert registry != null : "registry is null";
+      registry.userTransactionStarted();
+   }
+}

Modified: projects/ejb3/trunk/transactions/src/main/java/org/jboss/ejb3/tx/UserTransactionImpl.java
===================================================================
--- projects/ejb3/trunk/transactions/src/main/java/org/jboss/ejb3/tx/UserTransactionImpl.java	2008-11-27 10:49:27 UTC (rev 81719)
+++ projects/ejb3/trunk/transactions/src/main/java/org/jboss/ejb3/tx/UserTransactionImpl.java	2008-11-27 10:51:35 UTC (rev 81720)
@@ -24,6 +24,7 @@
 import java.io.IOException;
 import java.io.ObjectInput;
 import java.io.ObjectOutput;
+
 import javax.transaction.HeuristicMixedException;
 import javax.transaction.HeuristicRollbackException;
 import javax.transaction.NotSupportedException;
@@ -32,6 +33,7 @@
 import javax.transaction.Transaction;
 import javax.transaction.TransactionManager;
 import javax.transaction.UserTransaction;
+
 import org.jboss.logging.Logger;
 
 /**
@@ -69,6 +71,7 @@
       if (log.isDebugEnabled())
          log.debug("UserTx begin: " + tx);
 
+      EJB3UserTransactionProvider.getSingleton().userTransactionStarted();
    }
 
    public void commit()

Modified: projects/ejb3/trunk/transactions/src/test/resources/instance/beans.xml
===================================================================
--- projects/ejb3/trunk/transactions/src/test/resources/instance/beans.xml	2008-11-27 10:49:27 UTC (rev 81719)
+++ projects/ejb3/trunk/transactions/src/test/resources/instance/beans.xml	2008-11-27 10:51:35 UTC (rev 81720)
@@ -26,6 +26,16 @@
       </constructor>
    </bean>
    
+   <!-- Handles user transaction providers and listeners -->
+   <bean name="UserTransactionRegistry" class="org.jboss.tm.usertx.UserTransactionRegistry">
+      <!-- Register providers -->
+      <incallback method="addProvider"/>
+      <uncallback method="removeProvider"/>
+      <!-- Register listeners -->
+      <incallback method="addListener"/>
+      <uncallback method="removeListener"/>
+   </bean>
+   
    <bean name="AspectDeployment" class="org.jboss.ejb3.test.tx.common.AspectDeployment">
       <property name="mainDeployer"><inject bean="MainDeployer"/></property>
       <property name="resource">instance/jboss-aop.xml</property>
@@ -41,4 +51,10 @@
       <depends>AspectDeployment</depends>
       <!-- depends>TransactionManager</depends -->
    </bean>
+   
+   <!-- The provider for EJB3 UserTransactions -->
+   <bean name="EJB3UserTransactionprovider" class="org.jboss.ejb3.tx.EJB3UserTransactionProvider">
+      <depends>UserTransactionRegistry</depends>
+      <constructor factoryClass="org.jboss.ejb3.tx.EJB3UserTransactionProvider" factoryMethod="getSingleton"/>
+   </bean>
 </deployment>
\ No newline at end of file




More information about the jboss-cvs-commits mailing list