[jboss-cvs] JBossAS SVN: r111001 - in projects/jboss-jca/trunk: adapters/src/main/resources/jdbc/local/META-INF and 31 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Tue Mar 22 15:22:36 EDT 2011


Author: jesper.pedersen
Date: 2011-03-22 15:22:35 -0400 (Tue, 22 Mar 2011)
New Revision: 111001

Added:
   projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/api/connectionmanager/listener/
   projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/api/connectionmanager/listener/ConnectionListener.java
   projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/api/connectionmanager/listener/package.html
   projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/spi/transaction/
   projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/spi/transaction/LastResource.java
   projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/spi/transaction/TransactionIntegration.java
   projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/spi/transaction/TransactionTimeoutConfiguration.java
   projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/spi/transaction/TxUtils.java
   projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/spi/transaction/local/
   projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/spi/transaction/local/LocalXAException.java
   projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/spi/transaction/local/LocalXAResource.java
   projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/spi/transaction/local/package.html
   projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/spi/transaction/package.html
   projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/spi/transaction/recovery/
   projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/spi/transaction/recovery/XAResourceRecovery.java
   projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/spi/transaction/recovery/XAResourceRecoveryRegistry.java
   projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/spi/transaction/recovery/package.html
   projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/spi/transaction/usertx/
   projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/spi/transaction/usertx/UserTransactionListener.java
   projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/spi/transaction/usertx/UserTransactionRegistry.java
   projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/spi/transaction/usertx/package.html
   projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/spi/transaction/xa/
   projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/spi/transaction/xa/XAResourceWrapper.java
   projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/spi/transaction/xa/XATerminator.java
   projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/spi/transaction/xa/XidWrapper.java
   projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/spi/transaction/xa/package.html
   projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/tx/
   projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/tx/jbossts/
   projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/tx/jbossts/LocalXAResourceImpl.java
   projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/tx/jbossts/TransactionIntegrationImpl.java
   projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/tx/jbossts/UserTransactionListenerImpl.java
   projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/tx/jbossts/UserTransactionRegistryImpl.java
   projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/tx/jbossts/XAResourceRecoveryImpl.java
   projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/tx/jbossts/XAResourceRecoveryRegistryImpl.java
   projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/tx/jbossts/XAResourceWrapperImpl.java
   projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/tx/jbossts/XATerminatorImpl.java
   projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/tx/jbossts/XidWrapperImpl.java
   projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/tx/jbossts/package.html
Removed:
   projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/api/connectionmanager/transaction/JTATransactionChecker.java
   projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/xa/
   projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/recovery/XAResourceRecoveryImpl.java
   projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/spi/connectionmanager/xa/
Modified:
   projects/jboss-jca/trunk/adapters/src/main/java/org/jboss/jca/adapters/jdbc/BaseWrapperManagedConnectionFactory.java
   projects/jboss-jca/trunk/adapters/src/main/java/org/jboss/jca/adapters/jdbc/WrapperDataSource.java
   projects/jboss-jca/trunk/adapters/src/main/resources/jdbc/local/META-INF/ra.xml
   projects/jboss-jca/trunk/adapters/src/main/resources/jdbc/xa/META-INF/ra.xml
   projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/api/connectionmanager/ConnectionManager.java
   projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/api/workmanager/WorkManager.java
   projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/AbstractConnectionManager.java
   projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/ConnectionManager.java
   projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/ConnectionManagerFactory.java
   projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/TxConnectionManager.java
   projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/ccm/CachedConnectionManager.java
   projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/listener/ConnectionListener.java
   projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/listener/TxConnectionListener.java
   projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/tx/TxConnectionManagerImpl.java
   projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/workmanager/WorkManagerImpl.java
   projects/jboss-jca/trunk/core/src/test/java/org/jboss/jca/core/connectionmanager/listener/TxConnectionListenerTestCase.java
   projects/jboss-jca/trunk/core/src/test/java/org/jboss/jca/core/connectionmanager/tx/SerializableTestCase.java
   projects/jboss-jca/trunk/core/src/test/java/org/jboss/jca/core/connectionmanager/tx/TxConnectionManagerTestCase.java
   projects/jboss-jca/trunk/core/src/test/java/org/jboss/jca/core/connectionmanager/tx/XATxConnectionManagerTestCase.java
   projects/jboss-jca/trunk/core/src/test/java/org/jboss/jca/core/inflow/PureInflowTestCase.java
   projects/jboss-jca/trunk/core/src/test/java/org/jboss/jca/core/workmanager/unit/WorkManagerTestCase.java
   projects/jboss-jca/trunk/core/src/test/java/org/jboss/jca/test/txmgr/JBossXATerminatorImpl.java
   projects/jboss-jca/trunk/core/src/test/java/org/jboss/jca/test/txmgr/TransactionManagerImpl.java
   projects/jboss-jca/trunk/core/src/test/resources/rejecting-workmanager.xml
   projects/jboss-jca/trunk/core/src/test/resources/transaction.xml
   projects/jboss-jca/trunk/core/src/test/resources/workmanager.xml
   projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/common/AbstractDsDeployer.java
   projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/common/AbstractResourceAdapterDeployer.java
   projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/common/CommonDeployment.java
   projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/fungal/AbstractFungalDeployment.java
   projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/fungal/AbstractFungalRADeployer.java
   projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/fungal/DsXmlDeployer.java
   projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/fungal/DsXmlDeployment.java
   projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/fungal/RAActivator.java
   projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/fungal/RAActivatorDeployment.java
   projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/fungal/RAConfiguration.java
   projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/fungal/RADeployer.java
   projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/fungal/RADeployment.java
   projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/fungal/RaXmlDeployer.java
   projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/fungal/RaXmlDeployment.java
   projects/jboss-jca/trunk/embedded/src/main/resources/ds.xml
   projects/jboss-jca/trunk/embedded/src/main/resources/jca.xml
   projects/jboss-jca/trunk/embedded/src/main/resources/transaction.xml
   projects/jboss-jca/trunk/sjc/src/main/resources/bootstrap/ds.xml
   projects/jboss-jca/trunk/sjc/src/main/resources/bootstrap/jca.xml
   projects/jboss-jca/trunk/sjc/src/main/resources/bootstrap/transaction.xml
Log:
[JBJCA-533] Transaction infrastructure (Part 1)

Modified: projects/jboss-jca/trunk/adapters/src/main/java/org/jboss/jca/adapters/jdbc/BaseWrapperManagedConnectionFactory.java
===================================================================
--- projects/jboss-jca/trunk/adapters/src/main/java/org/jboss/jca/adapters/jdbc/BaseWrapperManagedConnectionFactory.java	2011-03-22 18:25:09 UTC (rev 111000)
+++ projects/jboss-jca/trunk/adapters/src/main/java/org/jboss/jca/adapters/jdbc/BaseWrapperManagedConnectionFactory.java	2011-03-22 19:22:35 UTC (rev 111001)
@@ -227,6 +227,9 @@
 
    private ClassLoaderPlugin classLoaderPlugin;
 
+   /** The JNDI name for the transaction manager */
+   private String transactionManagerJndiName;
+
    /**
     * Constructor
     */
@@ -859,6 +862,27 @@
    }
 
    /**
+    * Get the transaction manager JNDI name
+    * @return The value
+    */
+   public String getTransactionManagerJndiName()
+   {
+      if (transactionManagerJndiName == null || transactionManagerJndiName.trim().equals(""))
+         return "java:/TransactionManager";
+
+      return transactionManagerJndiName;
+   }
+
+   /**
+    * Set the transaction manager JNDI name
+    * @param v The value
+    */
+   public void setTransactionManagerJndiName(String v)
+   {
+      this.transactionManagerJndiName = v;
+   }
+
+   /**
     * Get the invalid connections
     * @param connectionSet The connection set
     * @return The invalid connections

Modified: projects/jboss-jca/trunk/adapters/src/main/java/org/jboss/jca/adapters/jdbc/WrapperDataSource.java
===================================================================
--- projects/jboss-jca/trunk/adapters/src/main/java/org/jboss/jca/adapters/jdbc/WrapperDataSource.java	2011-03-22 18:25:09 UTC (rev 111000)
+++ projects/jboss-jca/trunk/adapters/src/main/java/org/jboss/jca/adapters/jdbc/WrapperDataSource.java	2011-03-22 19:22:35 UTC (rev 111001)
@@ -22,7 +22,8 @@
 
 package org.jboss.jca.adapters.jdbc;
 
-import org.jboss.jca.core.api.connectionmanager.transaction.JTATransactionChecker;
+import org.jboss.jca.core.spi.transaction.TransactionTimeoutConfiguration;
+import org.jboss.jca.core.spi.transaction.TxUtils;
 
 import java.io.PrintWriter;
 import java.io.Serializable;
@@ -30,6 +31,8 @@
 import java.sql.SQLException;
 import java.sql.SQLFeatureNotSupportedException;
 
+import javax.naming.Context;
+import javax.naming.InitialContext;
 import javax.naming.Reference;
 import javax.resource.Referenceable;
 import javax.resource.ResourceException;
@@ -37,9 +40,11 @@
 import javax.resource.spi.ConnectionRequestInfo;
 import javax.sql.DataSource;
 import javax.transaction.RollbackException;
+import javax.transaction.Status;
+import javax.transaction.Transaction;
+import javax.transaction.TransactionManager;
 
 import org.jboss.logging.Logger;
-import org.jboss.tm.TransactionTimeoutConfiguration;
 
 /**
  * WrapperDataSource
@@ -60,6 +65,7 @@
 
    private PrintWriter logger;
    private Reference reference;
+   private TransactionManager transactionManager;
 
    /**
     * Constructor
@@ -70,6 +76,7 @@
    {
       this.mcf = mcf;
       this.cm = cm;
+      this.transactionManager = null;
    }
 
    /**
@@ -204,16 +211,62 @@
     */
    protected void checkTransactionActive() throws SQLException
    {
-      if (cm == null)
-         throw new SQLException("No connection manager");
+      if (transactionManager == null)
+         initTransactionManager();
+
       try
       {
-         if (cm instanceof JTATransactionChecker)
-            ((JTATransactionChecker) cm).checkTransactionActive();
+         Transaction tx = transactionManager.getTransaction();
+         if (tx != null)
+         {
+            int status = tx.getStatus();
+
+            // Only allow states that will actually succeed
+            if (status != Status.STATUS_ACTIVE && status != Status.STATUS_PREPARING && 
+                status != Status.STATUS_PREPARED && status != Status.STATUS_COMMITTING)
+            {
+               throw new SQLException("Transaction " + tx + " cannot proceed " + TxUtils.getStatusAsString(status));
+            }
+         }
       }
-      catch (Exception e)
+      catch (SQLException se)
       {
-         throw new SQLException(e);
+         throw se;
       }
+      catch (Throwable t)
+      {
+         throw new SQLException(t.getMessage(), t);
+      }
    }
+
+   /**
+    * Init the transaction manager reference
+    */
+   private void initTransactionManager() throws SQLException
+   {
+      Context context = null;
+      try
+      {
+         context = new InitialContext();
+         transactionManager = (TransactionManager)context.lookup(mcf.getTransactionManagerJndiName());
+      }
+      catch (Throwable t)
+      {
+         throw new SQLException(t.getMessage(), t);
+      }
+      finally
+      {
+         if (context != null)
+         {
+            try
+            {
+               context.close();
+            }
+            catch (Exception e)
+            {
+               // Ignore
+            }
+         }
+      }
+   }
 }

Modified: projects/jboss-jca/trunk/adapters/src/main/resources/jdbc/local/META-INF/ra.xml
===================================================================
--- projects/jboss-jca/trunk/adapters/src/main/resources/jdbc/local/META-INF/ra.xml	2011-03-22 18:25:09 UTC (rev 111000)
+++ projects/jboss-jca/trunk/adapters/src/main/resources/jdbc/local/META-INF/ra.xml	2011-03-22 19:22:35 UTC (rev 111001)
@@ -167,6 +167,11 @@
           <config-property-name>JndiName</config-property-name>
           <config-property-type>java.lang.String</config-property-type>
         </config-property>
+        <config-property>
+          <description>The JNDI name of the transaction manager</description>
+          <config-property-name>TransactionManagerJndiName</config-property-name>
+          <config-property-type>java.lang.String</config-property-type>
+        </config-property>
         <connectionfactory-interface>javax.sql.DataSource</connectionfactory-interface>
         <connectionfactory-impl-class>org.jboss.jca.adapters.jdbc.WrapperDataSource</connectionfactory-impl-class>
         <connection-interface>java.sql.Connection</connection-interface>

Modified: projects/jboss-jca/trunk/adapters/src/main/resources/jdbc/xa/META-INF/ra.xml
===================================================================
--- projects/jboss-jca/trunk/adapters/src/main/resources/jdbc/xa/META-INF/ra.xml	2011-03-22 18:25:09 UTC (rev 111000)
+++ projects/jboss-jca/trunk/adapters/src/main/resources/jdbc/xa/META-INF/ra.xml	2011-03-22 19:22:35 UTC (rev 111001)
@@ -167,6 +167,11 @@
           <config-property-name>JndiName</config-property-name>
           <config-property-type>java.lang.String</config-property-type>
         </config-property>
+        <config-property>
+          <description>The JNDI name of the transaction manager</description>
+          <config-property-name>TransactionManagerJndiName</config-property-name>
+          <config-property-type>java.lang.String</config-property-type>
+        </config-property>
         <connectionfactory-interface>javax.sql.DataSource</connectionfactory-interface>
         <connectionfactory-impl-class>org.jboss.jca.adapters.jdbc.WrapperDataSource</connectionfactory-impl-class>
         <connection-interface>java.sql.Connection</connection-interface>

Modified: projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/api/connectionmanager/ConnectionManager.java
===================================================================
--- projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/api/connectionmanager/ConnectionManager.java	2011-03-22 18:25:09 UTC (rev 111000)
+++ projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/api/connectionmanager/ConnectionManager.java	2011-03-22 19:22:35 UTC (rev 111001)
@@ -22,12 +22,20 @@
 
 package org.jboss.jca.core.api.connectionmanager;
 
+import org.jboss.jca.core.api.connectionmanager.listener.ConnectionListener;
+
 /**
  * The JBoss specific connection manager interface.
  * 
  * @author <a href="mailto:gurkanerdogdu at yahoo.com">Gurkan Erdogdu</a>
- * @version $Rev$
+ * @author <a href="mailto:jesper.pedersen at jboss.org">Jesper Pedersen</a>
  */
 public interface ConnectionManager extends javax.resource.spi.ConnectionManager, java.io.Serializable
 {
+   /**
+    * Kill given connection listener wrapped connection instance.
+    * @param cl connection listener that wraps connection
+    * @param kill kill connection or not
+    */
+   public void returnManagedConnection(ConnectionListener cl, boolean kill);
 }

Added: projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/api/connectionmanager/listener/ConnectionListener.java
===================================================================
--- projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/api/connectionmanager/listener/ConnectionListener.java	                        (rev 0)
+++ projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/api/connectionmanager/listener/ConnectionListener.java	2011-03-22 19:22:35 UTC (rev 111001)
@@ -0,0 +1,40 @@
+/*
+ * 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.jca.core.api.connectionmanager.listener;
+
+import javax.resource.spi.ConnectionEventListener;
+import javax.resource.spi.ManagedConnection;
+
+/**
+ * Connection listener.
+ * 
+ * @author <a href="jesper.pedersen at jboss.org">Jesper Pedersen</a>
+ */
+public interface ConnectionListener extends ConnectionEventListener, Comparable
+{
+   /**
+    * Retrieve the managed connection for this listener.
+    * 
+    * @return the managed connection
+    */
+   public ManagedConnection getManagedConnection();
+}

Added: projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/api/connectionmanager/listener/package.html
===================================================================
--- projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/api/connectionmanager/listener/package.html	                        (rev 0)
+++ projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/api/connectionmanager/listener/package.html	2011-03-22 19:22:35 UTC (rev 111001)
@@ -0,0 +1,3 @@
+<body>
+This package contains the connection listener API.
+</body>

Deleted: projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/api/connectionmanager/transaction/JTATransactionChecker.java
===================================================================
--- projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/api/connectionmanager/transaction/JTATransactionChecker.java	2011-03-22 18:25:09 UTC (rev 111000)
+++ projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/api/connectionmanager/transaction/JTATransactionChecker.java	2011-03-22 19:22:35 UTC (rev 111001)
@@ -1,42 +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.jca.core.api.connectionmanager.transaction;
-
-import javax.transaction.RollbackException;
-import javax.transaction.SystemException;
-
-/**
- * JTATransactionChecker.
- * 
- * @author <a href="adrian at jboss.com">Adrian Brock</a>
- * @version $Revision: 85945 $
- */
-public interface JTATransactionChecker
-{
-   /**
-    * Check whether a tranasction is active
-    * 
-    * @throws RollbackException if the transaction is not active, preparing, prepared or committing
-    * @throws SystemException for any error in the transaction manager
-    */
-   void checkTransactionActive() throws RollbackException, SystemException;
-}

Modified: projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/api/workmanager/WorkManager.java
===================================================================
--- projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/api/workmanager/WorkManager.java	2011-03-22 18:25:09 UTC (rev 111000)
+++ projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/api/workmanager/WorkManager.java	2011-03-22 19:22:35 UTC (rev 111001)
@@ -23,9 +23,9 @@
 package org.jboss.jca.core.api.workmanager;
 
 import org.jboss.jca.core.spi.security.Callback;
+import org.jboss.jca.core.spi.transaction.xa.XATerminator;
 
 import org.jboss.threads.BlockingExecutor;
-import org.jboss.tm.JBossXATerminator;
 
 /**
  * The JBoss specific work manager interface
@@ -60,13 +60,13 @@
     * Get the XATerminator
     * @return The XA terminator
     */
-   public JBossXATerminator getXATerminator();
+   public XATerminator getXATerminator();
 
    /**
     * Set the XATerminator
     * @param xaTerminator The XA terminator
     */
-   public void setXATerminator(JBossXATerminator xaTerminator);
+   public void setXATerminator(XATerminator xaTerminator);
 
    /**
     * Is spec compliant

Modified: projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/AbstractConnectionManager.java
===================================================================
--- projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/AbstractConnectionManager.java	2011-03-22 18:25:09 UTC (rev 111000)
+++ projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/AbstractConnectionManager.java	2011-03-22 19:22:35 UTC (rev 111001)
@@ -27,6 +27,7 @@
 import org.jboss.jca.core.connectionmanager.listener.ConnectionListener;
 import org.jboss.jca.core.connectionmanager.listener.ConnectionState;
 import org.jboss.jca.core.connectionmanager.pool.api.Pool;
+import org.jboss.jca.core.spi.transaction.usertx.UserTransactionRegistry;
 
 import java.io.IOException;
 import java.io.NotSerializableException;
@@ -91,6 +92,9 @@
    /** Startup/ShutDown flag */
    private final AtomicBoolean shutdown = new AtomicBoolean(false);
 
+   /** User transaction registry */
+   private UserTransactionRegistry userTransactionRegistry;
+
    /** Cached connection manager */
    private CachedConnectionManager cachedConnectionManager;
 
@@ -133,12 +137,24 @@
    }
 
    /**
+    * Set the user transaction registry
+    * @param utr The value
+    */
+   public void setUserTransactionRegistry(UserTransactionRegistry utr)
+   {
+      this.userTransactionRegistry = utr;
+   }
+
+   /**
     * Sets cached connection manager.
     * @param cachedConnectionManager cached connection manager
     */
    public void setCachedConnectionManager(CachedConnectionManager cachedConnectionManager)
    {
       this.cachedConnectionManager = cachedConnectionManager;
+
+      if (userTransactionRegistry != null && cachedConnectionManager != null)
+         userTransactionRegistry.addListener(cachedConnectionManager);
    }
 
    /**
@@ -157,6 +173,12 @@
    public void setShutDown(boolean shutDown)
    {
       this.shutdown.set(shutDown);
+
+      if (shutDown)
+      {
+         if (userTransactionRegistry != null && cachedConnectionManager != null)
+            userTransactionRegistry.removeListener(cachedConnectionManager);
+      }
    }
 
    /**
@@ -365,11 +387,15 @@
 
    /**
     * Kill given connection listener wrapped connection instance.
-    * @param cl connection listener that wraps connection
+    * @param bcl connection listener that wraps connection
     * @param kill kill connection or not
     */
-   public void returnManagedConnection(ConnectionListener cl, boolean kill)
+   public void returnManagedConnection(org.jboss.jca.core.api.connectionmanager.listener.ConnectionListener bcl,
+                                       boolean kill)
    {
+      // Hack - We know that we can type cast it
+      ConnectionListener cl = (ConnectionListener)bcl;
+
       Pool localStrategy = cl.getPool();
       if (localStrategy != pool)
       {

Modified: projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/ConnectionManager.java
===================================================================
--- projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/ConnectionManager.java	2011-03-22 18:25:09 UTC (rev 111000)
+++ projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/ConnectionManager.java	2011-03-22 19:22:35 UTC (rev 111001)
@@ -82,13 +82,6 @@
    public void setJndiName(String value);
 
    /**
-    * Kill given connection listener wrapped connection instance.
-    * @param cl connection listener that wraps connection
-    * @param kill kill connection or not
-    */
-   public void returnManagedConnection(ConnectionListener cl, boolean kill);
-
-   /**
     * Unregister association.
     * @param cl connection listener
     * @param c connection

Modified: projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/ConnectionManagerFactory.java
===================================================================
--- projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/ConnectionManagerFactory.java	2011-03-22 18:25:09 UTC (rev 111000)
+++ projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/ConnectionManagerFactory.java	2011-03-22 19:22:35 UTC (rev 111001)
@@ -27,6 +27,8 @@
 import org.jboss.jca.core.connectionmanager.pool.api.Pool;
 import org.jboss.jca.core.connectionmanager.transaction.TransactionSynchronizer;
 import org.jboss.jca.core.connectionmanager.tx.TxConnectionManagerImpl;
+import org.jboss.jca.core.spi.transaction.TransactionIntegration;
+import org.jboss.jca.core.spi.transaction.usertx.UserTransactionRegistry;
 
 import javax.resource.spi.TransactionSupport.TransactionSupportLevel;
 import javax.transaction.TransactionManager;
@@ -87,7 +89,10 @@
             throw new IllegalArgumentException("Unknown transaction support level " + tsl);
       }
 
-      setProperties(cm, pool, subjectFactory, securityDomain, allocationRetry, allocationRetryWaitMillis, null);
+      setProperties(cm, pool,
+                    subjectFactory, securityDomain, 
+                    allocationRetry, allocationRetryWaitMillis, 
+                    null, null);
       setNoTxProperties(cm);
 
       return cm;
@@ -101,7 +106,7 @@
     * @param securityDomain The security domain 
     * @param allocationRetry The allocation retry value
     * @param allocationRetryWaitMillis The allocation retry millis value
-    * @param tm The transaction manager
+    * @param txIntegration The transaction manager integration
     * @param interleaving Enable interleaving
     * @param xaResourceTimeout The transaction timeout for XAResource
     * @param isSameRMOverride Should isSameRM be overridden
@@ -115,7 +120,7 @@
                                                   final String securityDomain,
                                                   final Integer allocationRetry,
                                                   final Long allocationRetryWaitMillis,
-                                                  final TransactionManager tm,
+                                                  final TransactionIntegration txIntegration,
                                                   final Boolean interleaving,
                                                   final Integer xaResourceTimeout,
                                                   final Boolean isSameRMOverride,
@@ -128,8 +133,8 @@
       if (pool == null)
          throw new IllegalArgumentException("Pool is null");
 
-      if (tm == null)
-         throw new IllegalArgumentException("TransactionManager is null");
+      if (txIntegration == null)
+         throw new IllegalArgumentException("TransactionIntegration is null");
 
       TxConnectionManagerImpl cm = null;
 
@@ -139,20 +144,23 @@
             throw new IllegalArgumentException("Non transactional connection manager not supported");
 
          case LocalTransaction:
-            cm = new TxConnectionManagerImpl(tm, true);
+            cm = new TxConnectionManagerImpl(txIntegration, true);
             break;
 
          case XATransaction:
-            cm = new TxConnectionManagerImpl(tm, false);
+            cm = new TxConnectionManagerImpl(txIntegration, false);
             break;
 
          default:
             throw new IllegalArgumentException("Unknown transaction support level " + tsl);
       }
 
-      setProperties(cm, pool, subjectFactory, securityDomain, allocationRetry, allocationRetryWaitMillis, tm);
+      setProperties(cm, pool, 
+                    subjectFactory, securityDomain, 
+                    allocationRetry, allocationRetryWaitMillis,
+                    txIntegration.getTransactionManager(), txIntegration.getUserTransactionRegistry());
       setTxProperties(cm, interleaving, xaResourceTimeout, isSameRMOverride, wrapXAResource, padXid);
-      handleTxIntegration(tm);
+      handleTxIntegration(txIntegration.getTransactionManager());
 
       return cm;
    }
@@ -166,6 +174,7 @@
     * @param allocationRetry The allocation retry value
     * @param allocationRetryWaitMillis The allocation retry millis value
     * @param tm The transaction manager
+    * @param utr The user transaction registry
     */
    private void setProperties(AbstractConnectionManager cm,
                               Pool pool,
@@ -173,7 +182,8 @@
                               String securityDomain,
                               Integer allocationRetry,
                               Long allocationRetryWaitMillis,
-                              TransactionManager tm)
+                              TransactionManager tm,
+                              UserTransactionRegistry utr)
    {
       pool.setConnectionListenerFactory(cm);
       cm.setPool(pool);
@@ -187,6 +197,8 @@
       if (allocationRetryWaitMillis != null)
          cm.setAllocationRetryWaitMillis(allocationRetryWaitMillis.longValue());
 
+      cm.setUserTransactionRegistry(utr);
+
       CachedConnectionManager ccm = new CachedConnectionManager(tm);
       cm.setCachedConnectionManager(ccm);
    }

Modified: projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/TxConnectionManager.java
===================================================================
--- projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/TxConnectionManager.java	2011-03-22 18:25:09 UTC (rev 111000)
+++ projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/TxConnectionManager.java	2011-03-22 19:22:35 UTC (rev 111001)
@@ -1,6 +1,6 @@
 /*
  * JBoss, Home of Professional Open Source.
- * Copyright 2008-2009, Red Hat Middleware LLC, and individual contributors
+ * Copyright 2011, 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.
  *
@@ -21,23 +21,19 @@
  */
 package org.jboss.jca.core.connectionmanager;
 
-import org.jboss.jca.core.api.connectionmanager.transaction.JTATransactionChecker;
+import org.jboss.jca.core.spi.transaction.TransactionTimeoutConfiguration;
 
-import org.jboss.tm.TransactionTimeoutConfiguration;
-
 /**
  * Internal connection manager contract for transactional contexts.
  * <p>
  * <ul>
- *    <li>Responsible for managing transaction operations via 
- *    {@link TransactionTimeoutConfiguration} and {@link JTATransactionChecker}</li>.
+ *    <li>Responsible for managing transaction operations via {@link TransactionTimeoutConfiguration}</li>
  * </ul>
  * </p> 
+ *
  * @author <a href="mailto:jesper.pedersen at jboss.org">Jesper Pedersen</a> 
  */
-public interface TxConnectionManager extends ConnectionManager,
-                                             TransactionTimeoutConfiguration, 
-                                             JTATransactionChecker
+public interface TxConnectionManager extends ConnectionManager, TransactionTimeoutConfiguration
 {
    /**
     * Get the interleaving status

Modified: projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/ccm/CachedConnectionManager.java
===================================================================
--- projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/ccm/CachedConnectionManager.java	2011-03-22 18:25:09 UTC (rev 111000)
+++ projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/ccm/CachedConnectionManager.java	2011-03-22 19:22:35 UTC (rev 111001)
@@ -26,6 +26,8 @@
 import org.jboss.jca.core.connectionmanager.listener.ConnectionListener;
 import org.jboss.jca.core.connectionmanager.transaction.TransactionSynchronizer;
 import org.jboss.jca.core.spi.connectionmanager.ComponentStack;
+import org.jboss.jca.core.spi.transaction.TxUtils;
+import org.jboss.jca.core.spi.transaction.usertx.UserTransactionListener;
 
 import java.lang.reflect.Method;
 import java.util.Collection;
@@ -49,9 +51,6 @@
 import javax.transaction.TransactionManager;
 
 import org.jboss.logging.Logger;
-import org.jboss.tm.TxUtils;
-import org.jboss.tm.usertx.UserTransactionListener;
-import org.jboss.tm.usertx.client.ServerVMClientUserTransaction.UserTransactionStartedListener;
 import org.jboss.util.Strings;
 
 /**
@@ -59,10 +58,7 @@
  *
  * @author <a href="mailto:jesper.pedersen at jboss.org">Jesper Pedersen</a>
  */
-public class CachedConnectionManager implements
-   UserTransactionStartedListener,
-   UserTransactionListener,
-   ComponentStack
+public class CachedConnectionManager implements UserTransactionListener, ComponentStack
 {
    /** Log instance */
    private static Logger log = Logger.getLogger(CachedConnectionManager.class);

Modified: projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/listener/ConnectionListener.java
===================================================================
--- projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/listener/ConnectionListener.java	2011-03-22 18:25:09 UTC (rev 111000)
+++ projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/listener/ConnectionListener.java	2011-03-22 19:22:35 UTC (rev 111001)
@@ -24,33 +24,24 @@
 import org.jboss.jca.core.connectionmanager.pool.api.Pool;
 
 import javax.resource.ResourceException;
-import javax.resource.spi.ConnectionEventListener;
-import javax.resource.spi.ManagedConnection;
 import javax.transaction.SystemException;
 
 /**
  * Connection listener.
  * 
- * @version $Rev: $
  * @author <a href="mailto:gurkanerdogdu at yahoo.com">Gurkan Erdogdu</a>
  * @author <a href="mailto:adrian at jboss.org">Adrian Brock</a>
  * @author <a href="weston.price at jboss.com">Weston Price</a>
+ * @author <a href="jesper.pedersen at jboss.org">Jesper Pedersen</a>
  */
-public interface ConnectionListener extends ConnectionEventListener, Comparable
+public interface ConnectionListener extends org.jboss.jca.core.api.connectionmanager.listener.ConnectionListener
 {
    /**
-    * Retrieve the managed connection for this listener.
-    * 
-    * @return the managed connection
-    */
-   ManagedConnection getManagedConnection();
-
-   /**
     * Retrieve the pool for this listener.
     * 
     * @return the pool
     */
-   Pool getPool();
+   public Pool getPool();
 
    /**
     * Tidyup
@@ -60,28 +51,28 @@
     * 
     * @throws ResourceException for any error
     */
-   void tidyup() throws ResourceException;
+   public void tidyup() throws ResourceException;
 
    /**
     * Retrieve the context used by the pool.
     * 
     * @return the context
     */
-   Object getContext();
+   public Object getContext();
 
    /**
     * Retrieve the state of this connection.
     * 
     * @return the state
     */
-   ConnectionState getState();
+   public ConnectionState getState();
 
    /**
     * Set the state of this connection.
     * 
     * @param newState new state
     */
-   void setState(ConnectionState newState);
+   public void setState(ConnectionState newState);
 
    /**
     * Has the connection timed out?
@@ -89,68 +80,68 @@
     * @param timeout the timeout
     * @return true for timed out, false otherwise
     */
-   boolean isTimedOut(long timeout);
+   public boolean isTimedOut(long timeout);
 
    /**
     * Mark the connection as used
     */
-   void used();
+   public void used();
 
    /**
     * Register a new connection
     * 
     * @param handle the connection handle
     */
-   void registerConnection(Object handle);
+   public void registerConnection(Object handle);
 
    /**
     * Unregister a connection
     * 
     * @param handle the connection handle
     */
-   void unregisterConnection(Object handle);
+   public void unregisterConnection(Object handle);
 
    /**
     * Is the managed connection free?
     * 
     * @return true when it is free
     */
-   boolean isManagedConnectionFree();
+   public boolean isManagedConnectionFree();
 
    /**
     * Enlist the managed connection
     * 
     * @throws SystemException for errors
     */
-   void enlist() throws SystemException;
+   public void enlist() throws SystemException;
 
    /**
     * Delist the managed connection
     * 
     * @throws ResourceException if exception occurs
     */
-   void delist() throws ResourceException;
+   public void delist() throws ResourceException;
 
    /**
     * Get whether the listener is track by transaction
     * 
     * @return true for track by transaction, false otherwise
     */
-   boolean isTrackByTx();
+   public boolean isTrackByTx();
 
    /**
     * Set whether the listener is track by transaction
     * 
     * @param trackByTx true for track by transaction, false otherwise
     */
-   void setTrackByTx(boolean trackByTx);
+   public void setTrackByTx(boolean trackByTx);
 
    /**
     * Retrieve the last time this connection was validated.
     * 
     * @return the last time the connection was validated
     */
-   long getLastValidatedTime();
+   public long getLastValidatedTime();
 
    /**
     * Set the last time, in milliseconds, that this connection was validated.
@@ -158,5 +149,5 @@
     * @param lastValidated the last time the connection was validated in
     *           milliseconds.
     */
-   void setLastValidatedTime(long lastValidated);
+   public void setLastValidatedTime(long lastValidated);
 }

Modified: projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/listener/TxConnectionListener.java
===================================================================
--- projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/listener/TxConnectionListener.java	2011-03-22 18:25:09 UTC (rev 111000)
+++ projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/listener/TxConnectionListener.java	2011-03-22 19:22:35 UTC (rev 111001)
@@ -26,7 +26,8 @@
 import org.jboss.jca.core.connectionmanager.pool.api.Pool;
 import org.jboss.jca.core.connectionmanager.transaction.TransactionSynchronizer;
 import org.jboss.jca.core.connectionmanager.tx.TxConnectionManagerImpl;
-import org.jboss.jca.core.connectionmanager.xa.LocalXAResource;
+import org.jboss.jca.core.spi.transaction.TxUtils;
+import org.jboss.jca.core.spi.transaction.local.LocalXAResource;
 
 import java.util.List;
 import java.util.concurrent.atomic.AtomicBoolean;
@@ -42,17 +43,13 @@
 import javax.transaction.TransactionManager;
 import javax.transaction.xa.XAResource;
 
-import org.jboss.tm.TxUtils;
-
-
 /**
  * Tx connection listener.
  * @author <a href="mailto:gurkanerdogdu at yahoo.com">Gurkan Erdogdu</a>
- * @version $Rev$
+ * @author <a href="mailto:jesper.pedersen at jboss.org">Jesper Pedersen</a>
  */
 public class TxConnectionListener extends AbstractConnectionListener
 {
-
    /**Transaction synch. instance*/
    private TransactionSynchronization transactionSynchronization;
 

Modified: projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/tx/TxConnectionManagerImpl.java
===================================================================
--- projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/tx/TxConnectionManagerImpl.java	2011-03-22 18:25:09 UTC (rev 111000)
+++ projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/tx/TxConnectionManagerImpl.java	2011-03-22 19:22:35 UTC (rev 111001)
@@ -29,8 +29,9 @@
 import org.jboss.jca.core.connectionmanager.listener.TxConnectionListener;
 import org.jboss.jca.core.connectionmanager.pool.SubPoolContext;
 import org.jboss.jca.core.connectionmanager.pool.mcp.ManagedConnectionPool;
-import org.jboss.jca.core.connectionmanager.xa.LocalXAResource;
-import org.jboss.jca.core.connectionmanager.xa.XAResourceWrapperImpl;
+import org.jboss.jca.core.spi.transaction.TransactionIntegration;
+import org.jboss.jca.core.spi.transaction.TransactionTimeoutConfiguration;
+import org.jboss.jca.core.spi.transaction.TxUtils;
 
 import java.io.IOException;
 import java.io.ObjectInputStream;
@@ -45,7 +46,6 @@
 import javax.resource.spi.ManagedConnection;
 import javax.security.auth.Subject;
 import javax.transaction.RollbackException;
-import javax.transaction.Status;
 import javax.transaction.SystemException;
 import javax.transaction.Transaction;
 import javax.transaction.TransactionManager;
@@ -53,8 +53,6 @@
 import javax.transaction.xa.XAResource;
 
 import org.jboss.tm.TransactionLocal;
-import org.jboss.tm.TransactionTimeoutConfiguration;
-import org.jboss.tm.TxUtils;
 import org.jboss.util.NestedRuntimeException;
 import org.jboss.util.NotImplementedException;
 
@@ -135,39 +133,44 @@
    /** Serial version uid */
    private static final long serialVersionUID = 1L;
 
-   /**Transaction manager instance*/
+   /** Transaction manager instance */
    private transient TransactionManager transactionManager;
 
-   /**Interleaving or not*/
+   /** Transaction integration */
+   private TransactionIntegration txIntegration;
+
+   /** Interleaving or not */
    private boolean interleaving;
 
-   /**Local tx or not*/
+   /** Local tx or not */
    private boolean localTransactions;
    
-   /**XA resource timeout*/
+   /** XA resource timeout */
    private int xaResourceTimeout = 0;
    
-   /**Xid pad*/
+   /** Xid pad */
    private boolean padXid;
    
-   /**XA resource wrapped or not*/
+   /** XA resource wrapped or not */
    private boolean wrapXAResource = true;
 
-   /**Same RM override*/
+   /** Same RM override */
    private boolean isSameRMOverride;
    
-   /**Log trace*/
-   private boolean trace = getLog().isTraceEnabled();
-      
    /**
     * Constructor
-    * @param tm The transaction manager
+    * @param txIntegration The transaction integration layer
     * @param localTransactions Is local transactions enabled
     */
-   public TxConnectionManagerImpl(final TransactionManager tm, final boolean localTransactions)
+   public TxConnectionManagerImpl(final TransactionIntegration txIntegration,
+                                  final boolean localTransactions)
    {
-      transactionManager = tm;
+      if (txIntegration == null)
+         throw new IllegalArgumentException("TransactionIntegration is null");
 
+      this.transactionManager = txIntegration.getTransactionManager();
+      this.txIntegration = txIntegration;
+
       setLocalTransactions(localTransactions);
    }
 
@@ -316,31 +319,6 @@
    /**
     * {@inheritDoc}
     */
-   @Override
-   public void checkTransactionActive() throws RollbackException, SystemException
-   {
-      if (transactionManager == null)
-      {
-         throw new IllegalStateException("No transaction manager: " + getCachedConnectionManager());  
-      }
-      
-      Transaction tx = transactionManager.getTransaction();
-      if (tx != null)
-      {
-         int status = tx.getStatus();
-
-         // Only allow states that will actually succeed
-         if (status != Status.STATUS_ACTIVE && status != Status.STATUS_PREPARING && 
-             status != Status.STATUS_PREPARED && status != Status.STATUS_COMMITTING)
-         {
-            throw new RollbackException("Transaction " + tx + " cannot proceed " + TxUtils.getStatusAsString(status));  
-         }
-      }
-   }
-
-   /**
-    * {@inheritDoc}
-    */
    public ConnectionListener getManagedConnection(Subject subject, ConnectionRequestInfo cri)
       throws ResourceException
    {
@@ -363,10 +341,7 @@
          JBossResourceException.rethrowAsResourceException("Error checking for a transaction.", t);
       }
 
-      if (trace)
-      {
-         getLog().trace("getManagedConnection interleaving=" + interleaving + " tx=" + trackByTransaction);  
-      }
+      getLog().tracef("getManagedConnection interleaving=%s , tx=%s", interleaving, trackByTransaction);  
       
       return super.getManagedConnection(trackByTransaction, subject, cri);
    }
@@ -425,10 +400,8 @@
       }
       catch (Throwable t)
       {
-         if (trace)
-         {
-            getLog().trace("Could not enlist in transaction on entering meta-aware object! " + cl, t);  
-         }
+         getLog().trace("Could not enlist in transaction on entering meta-aware object! " + cl, t);  
+
          throw new JBossResourceException("Could not enlist in transaction on entering meta-aware object!", t);
       }
    }
@@ -451,14 +424,13 @@
       //if there are no more handles and tx is complete, we can return to pool.
       if (cl.isManagedConnectionFree())
       {
-         if (trace)
-            getLog().trace("Disconnected isManagedConnectionFree=true" + " cl=" + cl);
+         getLog().tracef("Disconnected isManagedConnectionFree=true cl=%s", cl);
 
          returnManagedConnection(cl, false);
       }
-      else if (trace)
+      else
       {
-         getLog().trace("Disconnected isManagedConnectionFree=false" + " cl=" + cl);
+         getLog().tracef("Disconnected isManagedConnectionFree=false cl=%s", cl);
       }
 
       // Rethrow the error
@@ -479,7 +451,7 @@
       
       if (localTransactions)
       {
-         xaResource = new LocalXAResource(this);
+         xaResource = txIntegration.createLocalXAResource(this);
     
          if (xaResourceTimeout != 0)
          {
@@ -512,18 +484,16 @@
             if (eisProductVersion == null)
                eisProductVersion = getJndiName();
 
-            if (trace)
-               getLog().trace("Generating XAResourceWrapper for TxConnectionManager" + this);
+            getLog().tracef("Generating XAResourceWrapper for TxConnectionManager (%s)", this);
 
-            xaResource = new XAResourceWrapperImpl(mc.getXAResource(), padXid, 
-                                                   isSameRMOverride, 
-                                                   eisProductName, eisProductVersion,
-                                                   getJndiName());
+            xaResource = txIntegration.createXAResourceWrapper(mc.getXAResource(), padXid, 
+                                                               isSameRMOverride, 
+                                                               eisProductName, eisProductVersion,
+                                                               getJndiName());
          }
          else
          {
-            if (trace)
-               getLog().trace("Not wrapping XAResource.");
+            getLog().tracef("Not wrapping XAResource.");
 
             xaResource = mc.getXAResource();
          }
@@ -552,7 +522,14 @@
     */
    public boolean isTransactional()
    {
-      return !TxUtils.isCompleted(transactionManager);
+      try
+      {
+         return !TxUtils.isCompleted(transactionManager.getTransaction());
+      }
+      catch (SystemException se)
+      {
+         throw new RuntimeException("Error during isTransactional()", se);
+      }
    }
    
    /**

Deleted: projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/recovery/XAResourceRecoveryImpl.java
===================================================================
--- projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/recovery/XAResourceRecoveryImpl.java	2011-03-22 18:25:09 UTC (rev 111000)
+++ projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/recovery/XAResourceRecoveryImpl.java	2011-03-22 19:22:35 UTC (rev 111001)
@@ -1,434 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2011, 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.jca.core.recovery;
-
-import org.jboss.jca.core.connectionmanager.xa.XAResourceWrapperImpl;
-import org.jboss.jca.core.spi.recovery.RecoveryPlugin;
-
-import java.security.AccessController;
-import java.security.Principal;
-import java.security.PrivilegedAction;
-import java.util.Set;
-
-import javax.resource.ResourceException;
-import javax.resource.spi.ManagedConnection;
-import javax.resource.spi.ManagedConnectionFactory;
-import javax.resource.spi.security.PasswordCredential;
-import javax.security.auth.Subject;
-import javax.transaction.xa.XAResource;
-
-import org.jboss.logging.Logger;
-import org.jboss.security.SecurityContext;
-import org.jboss.security.SecurityContextAssociation;
-import org.jboss.security.SecurityContextFactory;
-import org.jboss.security.SimplePrincipal;
-import org.jboss.security.SubjectFactory;
-import org.jboss.tm.XAResourceRecovery;
-
-/**
- * An XAResourceRecovery implementation.
- *
- * @author <a href="stefano.maestri at jboss.com">Stefano Maestri</a>
- * @author <a href="jesper.pedersen at jboss.org">Jesper Pedersen</a>
- */
-public class XAResourceRecoveryImpl implements XAResourceRecovery
-{
-   /** Log instance */
-   private static Logger log = Logger.getLogger(XAResourceRecoveryImpl.class);
-
-   private final ManagedConnectionFactory mcf;
-
-   private final Boolean padXid;
-
-   private final Boolean isSameRMOverrideValue;
-
-   private final Boolean wrapXAResource;
-
-   private final String recoverUserName;
-
-   private final String recoverPassword;
-
-   private final String recoverSecurityDomain;
-
-   private final SubjectFactory subjectFactory;
-
-   private final RecoveryPlugin plugin;
-
-   private ManagedConnection recoverMC;
-
-   private String jndiName;
-
-   /**
-    * Create a new XAResourceRecoveryImpl.
-    *
-    * @param mcf mcf
-    * @param padXid padXid
-    * @param isSameRMOverrideValue isSameRMOverrideValue
-    * @param wrapXAResource wrapXAResource
-    * @param recoverUserName recoverUserName
-    * @param recoverPassword recoverPassword
-    * @param recoverSecurityDomain recoverSecurityDomain
-    * @param subjectFactory subjectFactory
-    * @param plugin recovery plugin
-    */
-   public XAResourceRecoveryImpl(ManagedConnectionFactory mcf,
-                                 Boolean padXid, Boolean isSameRMOverrideValue, Boolean wrapXAResource,
-                                 String recoverUserName, String recoverPassword, String recoverSecurityDomain,
-                                 SubjectFactory subjectFactory,
-                                 RecoveryPlugin plugin)
-   {
-      if (mcf == null)
-         throw new IllegalArgumentException("MCF is null");
-
-      if (plugin == null)
-         throw new IllegalArgumentException("Plugin is null");
-
-      this.mcf = mcf;
-      this.padXid = padXid;
-      this.isSameRMOverrideValue = isSameRMOverrideValue;
-      this.wrapXAResource = wrapXAResource;
-      this.recoverUserName = recoverUserName;
-      this.recoverPassword = recoverPassword;
-      this.recoverSecurityDomain = recoverSecurityDomain;
-      this.subjectFactory = subjectFactory;
-      this.plugin = plugin;
-      this.recoverMC = null;
-      this.jndiName = null;
-   }
-
-   /**
-    * Set the jndiName.
-    *
-    * @param jndiName The jndiName to set.
-    */
-   public void setJndiName(String jndiName)
-   {
-      this.jndiName = jndiName;
-   }
-
-   /**
-    * Provides XAResource(s) to the transaction system for recovery purposes.
-    *
-    * @return An array of XAResource objects for use in transaction recovery
-    * In most cases the implementation will need to return only a single XAResource in the array.
-    * For more sophisticated cases, such as where multiple different connection types are supported,
-    * it may be necessary to return more than one.
-    *
-    * The Resource should be instantiated in such a way as to carry the necessary permissions to
-    * allow transaction recovery. For some deployments it may therefore be necessary or desirable to
-    * provide resource(s) based on e.g. database connection parameters such as username other than those
-    * used for the regular application connections to the same resource manager.
-    */
-   @Override
-   public XAResource[] getXAResources()
-   {
-      try
-      {
-         Subject subject = getSubject();
-
-         // Check if we got a valid Subject instance; requirement for recovery
-         if (subject != null)
-         {
-            ManagedConnection mc = open(subject);
-            XAResource xaResource = null;
-
-            Object connection = null;
-            try
-            {
-               connection = openConnection(mc, subject);
-               xaResource = mc.getXAResource();
-            }
-            catch (ResourceException reconnect)
-            {
-               closeConnection(connection);
-               connection = null;
-               close(mc);
-               mc = open(subject);
-               xaResource = mc.getXAResource();
-            }
-            finally
-            {
-               boolean forceDestroy = closeConnection(connection);
-               connection = null;
-
-               if (forceDestroy)
-               {
-                  close(mc);
-                  mc = open(subject);
-                  xaResource = mc.getXAResource();
-               }
-            }
-            
-            if (wrapXAResource)
-            {
-               String eisProductName = null;
-               String eisProductVersion = null;
-
-               try
-               {
-                  if (mc.getMetaData() != null)
-                  {
-                     eisProductName = mc.getMetaData().getEISProductName();
-                     eisProductVersion = mc.getMetaData().getEISProductVersion();
-                  }
-               }
-               catch (ResourceException re)
-               {
-                  // Ignore
-               }
-
-               if (eisProductName == null)
-                  eisProductName = jndiName;
-
-               if (eisProductVersion == null)
-                  eisProductVersion = jndiName;
-
-               xaResource = new XAResourceWrapperImpl(xaResource,
-                                                      padXid,
-                                                      isSameRMOverrideValue,
-                                                      eisProductName,
-                                                      eisProductVersion,
-                                                      jndiName);
-            }
-
-            log.debugf("Recovery XAResource=%s for %s", xaResource, jndiName);
-
-            return new XAResource[]{xaResource};
-         }
-         else
-         {
-            log.debugf("Subject for recovery was null");
-         }
-      }
-      catch (ResourceException re)
-      {
-         log.debugf("Error during recovery", re);
-      }
-
-      return new XAResource[0];
-   }
-
-   /**
-    * This method provide the Subject used for the XA Resource Recovery
-    * integration with the XAResourceRecoveryRegistry.
-    *
-    * This isn't done through the SecurityAssociation functionality of JBossSX
-    * as the Subject returned here should only be used for recovery.
-    *
-    * @return The recovery subject; <code>null</code> if no Subject could be created
-    */
-   private Subject getSubject()
-   {
-      return AccessController.doPrivileged(new PrivilegedAction<Subject>()
-      {
-         /**
-          * run method
-          */
-         public Subject run()
-         {
-            if (recoverUserName != null && recoverPassword != null)
-            {
-               log.debugf("Recovery user name=%s", recoverUserName);
-
-               // User name and password use-case
-               Subject subject = new Subject();
-
-               // Principals
-               Principal p = new SimplePrincipal(recoverUserName);
-               subject.getPrincipals().add(p);
-
-               // PrivateCredentials
-               PasswordCredential pc = new PasswordCredential(recoverUserName, recoverPassword.toCharArray());
-               pc.setManagedConnectionFactory(mcf);
-               subject.getPrivateCredentials().add(pc);
-
-               // PublicCredentials
-               // None
-
-               log.debugf("Recovery Subject=%s", subject);
-
-               return subject;
-            }
-            else
-            {
-               // Security-domain use-case
-               try
-               {
-                  // Create a security context on the association
-                  SecurityContext securityContext = SecurityContextFactory
-                     .createSecurityContext(recoverSecurityDomain);
-                  SecurityContextAssociation.setSecurityContext(securityContext);
-
-                  // Unauthenticated
-                  Subject unauthenticated = new Subject();
-
-                  // Leave the subject empty as we don't have any information to do the
-                  // authentication with - and we only need it to be able to get the
-                  // real subject from the SubjectFactory
-
-                  // Set the authenticated subject
-                  securityContext.getSubjectInfo().setAuthenticatedSubject(unauthenticated);
-
-                  // Select the domain
-                  String domain = recoverSecurityDomain;
-
-                  if (domain != null && subjectFactory != null)
-                  {
-                     // Use the unauthenticated subject to get the real recovery subject instance
-                     Subject subject = subjectFactory.createSubject(domain);
-                     
-                     Set<PasswordCredential> pcs = subject.getPrivateCredentials(PasswordCredential.class);
-                     if (pcs != null && pcs.size() > 0)
-                     {
-                        for (PasswordCredential pc : pcs)
-                        {
-                           pc.setManagedConnectionFactory(mcf);
-                        }
-                     }
-
-                     log.debugf("Recovery Subject=%s", subject);
-
-                     return subject;
-                  }
-                  else
-                  {
-                     log.debugf("RecoverySecurityDomain was empty");
-                  }
-               }
-               catch (Throwable t)
-               {
-                  log.debugf("Exception during getSubject() - %s", t.getMessage(), t);
-               }
-
-               return null;
-            }
-         }
-      });
-   }
-
-   /**
-    * Open a managed connection
-    * @param s The subject
-    * @return The managed connection
-    * @exception ResourceException Thrown in case of an error
-    */
-   private ManagedConnection open(Subject s) throws ResourceException
-   {
-      log.debugf("Open managed connection (%s)", s);
-
-      if (recoverMC == null)
-         recoverMC = mcf.createManagedConnection(s, null);
-
-      return recoverMC;
-   }
-
-   /**
-    * Close a managed connection
-    * @param mc The managed connection
-    */
-   private void close(ManagedConnection mc)
-   {
-      log.debugf("Closing managed connection for recovery (%s)", mc);
-
-      if (mc != null)
-      {
-         try
-         {
-            mc.cleanup();
-         }
-         catch (ResourceException ire)
-         {
-            log.debugf("Error during recovery cleanup", ire);
-         }
-      }
-
-      if (mc != null)
-      {
-         try
-         {
-            mc.destroy();
-         }
-         catch (ResourceException ire)
-         {
-            log.debugf("Error during recovery destroy", ire);
-         }
-      }
-
-      mc = null;
-
-      // The managed connection for recovery is now gone
-      recoverMC = null;
-   }
-
-   /**
-    * Open a connection
-    * @param mc The managed connection
-    * @param s The subject
-    * @return The connection handle
-    * @exception ResourceException Thrown in case of an error
-    */
-   private Object openConnection(ManagedConnection mc, Subject s) throws ResourceException
-   {
-      log.debugf("Open connection (%s, %s)", mc, s);
-
-      return mc.getConnection(s, null);
-   }
-
-   /**
-    * Close a connection
-    * @param c The connection
-    * @return Should the managed connection be forced closed
-    */
-   private boolean closeConnection(Object c)
-   {
-      log.debugf("Closing connection for recovery check (%s)", c);
-
-      boolean forceClose = false;
-
-      if (c != null)
-      {
-         try
-         {
-            forceClose = !plugin.isValid(c);
-         }
-         catch (ResourceException re)
-         {
-            log.debugf("Error during recovery plugin isValid()", re);
-            forceClose = true;
-         }
-
-         try
-         {
-            plugin.close(c);
-         }
-         catch (ResourceException re)
-         {
-            log.debugf("Error during recovery plugin close()", re);
-            forceClose = true;
-         }
-      }
-
-      log.debugf("Force close=%s", forceClose);
-
-      return forceClose;
-   }
-}

Added: projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/spi/transaction/LastResource.java
===================================================================
--- projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/spi/transaction/LastResource.java	                        (rev 0)
+++ projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/spi/transaction/LastResource.java	2011-03-22 19:22:35 UTC (rev 111001)
@@ -0,0 +1,35 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, 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.jca.core.spi.transaction;
+
+/**
+ * A tagging interface to identify an XAResource that does
+ * not support prepare and should be used in the last resource
+ * gambit. i.e. It is committed after the resources are
+ * prepared. If it fails to commit, roll everybody back.
+ * 
+ * @author <a href="mailto:adrian at jboss.org">Adrian Brock</a>
+ * @author <a href="mailto:jesper.pedersen at jboss.org">Jesper Pedersen</a>
+ */
+public interface LastResource
+{
+}

Added: projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/spi/transaction/TransactionIntegration.java
===================================================================
--- projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/spi/transaction/TransactionIntegration.java	                        (rev 0)
+++ projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/spi/transaction/TransactionIntegration.java	2011-03-22 19:22:35 UTC (rev 111001)
@@ -0,0 +1,129 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, 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.jca.core.spi.transaction;
+
+import org.jboss.jca.core.api.connectionmanager.ConnectionManager;
+import org.jboss.jca.core.spi.recovery.RecoveryPlugin;
+import org.jboss.jca.core.spi.transaction.local.LocalXAResource;
+import org.jboss.jca.core.spi.transaction.recovery.XAResourceRecovery;
+import org.jboss.jca.core.spi.transaction.recovery.XAResourceRecoveryRegistry;
+import org.jboss.jca.core.spi.transaction.usertx.UserTransactionRegistry;
+import org.jboss.jca.core.spi.transaction.xa.XAResourceWrapper;
+import org.jboss.jca.core.spi.transaction.xa.XATerminator;
+
+import javax.resource.spi.ManagedConnectionFactory;
+import javax.transaction.TransactionManager;
+import javax.transaction.TransactionSynchronizationRegistry;
+import javax.transaction.xa.XAResource;
+
+import org.jboss.security.SubjectFactory;
+
+/**
+ * This interface defines the contract for a transaction manager integration
+ * with the IronJacamar container.
+ *
+ * The methods allows the IronJacamar container to create or get transaction
+ * related information from the transaction manager implementation and allows
+ * the implementation of this information to be specific for each instance of
+ * this interface.
+ *
+ * If a feature isn't supported by the transaction manager a <code>null</code>
+ * value should be returned. That way it is disabled in the IronJacamar container. 
+ *
+ * @author <a href="mailto:jesper.pedersen at jboss.org">Jesper Pedersen</a>
+ */
+public interface TransactionIntegration
+{
+   /**
+    * Get the transaction manager
+    * @return The value
+    */
+   public TransactionManager getTransactionManager();
+
+   /**
+    * Get the transaction synchronization registry
+    * @return The value
+    */
+   public TransactionSynchronizationRegistry getTransactionSynchronizationRegistry();
+
+   /**
+    * Get the user transaction registry
+    * @return The value
+    */
+   public UserTransactionRegistry getUserTransactionRegistry();
+
+   /**
+    * Get the recovery registry
+    * @return The value
+    */
+   public XAResourceRecoveryRegistry getRecoveryRegistry();
+
+   /**
+    * Get the XATerminator
+    * @return The value
+    */
+   public XATerminator getXATerminator();
+
+   /**
+    * Create an XAResourceRecovery instance
+    *
+    * @param mcf The managed connection factory
+    * @param pad Should the branch qualifier for Xid's be padded
+    * @param override Should the isSameRM value be overriden; <code>null</code> for instance equally check
+    * @param wrapXAResource Should the XAResource be wrapped
+    * @param recoverUserName The user name for recovery
+    * @param recoverPassword The password for recovery
+    * @param recoverSecurityDomain The security domain for recovery
+    * @param subjectFactory The subject factory
+    * @param plugin The recovery plugin
+    * @return The value
+    */
+   public XAResourceRecovery createXAResourceRecovery(ManagedConnectionFactory mcf,
+                                                      Boolean pad, Boolean override, 
+                                                      Boolean wrapXAResource,
+                                                      String recoverUserName, String recoverPassword, 
+                                                      String recoverSecurityDomain,
+                                                      SubjectFactory subjectFactory,
+                                                      RecoveryPlugin plugin);
+
+   /**
+    * Create a LocalXAResource instance
+    * @param cm The connection manager
+    * @return The value
+    */
+   public LocalXAResource createLocalXAResource(ConnectionManager cm);
+
+   /**
+    * Create an XAResource wrapper instance
+    * @param xares The XAResource instance
+    * @param pad Should the branch qualifier for Xid's be padded
+    * @param override Should the isSameRM value be overriden; <code>null</code> for instance equally check
+    * @param productName The product name
+    * @param productVersion The product version
+    * @param jndiName The JNDI name for the resource
+    * @return The value
+    */
+   public XAResourceWrapper createXAResourceWrapper(XAResource xares,
+                                                    boolean pad, Boolean override, 
+                                                    String productName, String productVersion,
+                                                    String jndiName);
+}

Added: projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/spi/transaction/TransactionTimeoutConfiguration.java
===================================================================
--- projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/spi/transaction/TransactionTimeoutConfiguration.java	                        (rev 0)
+++ projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/spi/transaction/TransactionTimeoutConfiguration.java	2011-03-22 19:22:35 UTC (rev 111001)
@@ -0,0 +1,55 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, 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.jca.core.spi.transaction;
+
+import javax.transaction.RollbackException;
+import javax.transaction.SystemException;
+
+/**
+ * The interface to implementated by a transaction manager
+ * that supports retrieving the current threads transaction timeout
+ *
+ * @author <a href="mailto:adrian at jboss.org">Adrian Brock</a>
+ * @author <a href="mailto:jesper.pedersen at jboss.org">Jesper Pedersen</a>
+ */
+public interface TransactionTimeoutConfiguration
+{
+   /**
+    * Get the transaction timeout.
+    * 
+    * @return The timeout in seconds associated with this thread
+    * @throws SystemException For any error
+    */
+   public int getTransactionTimeout() throws SystemException;
+
+   /**
+    * Get the time left before transaction timeout.
+    * 
+    * @param errorRollback throw an error if the transaction is marked for rollback
+    * @return The remaining in the current transaction or -1
+    * if there is no transaction
+    * @throws RollbackException If the transaction is marked for rollback and
+    * errorRollback is true
+    */
+   public long getTimeLeftBeforeTransactionTimeout(boolean errorRollback) throws RollbackException;
+}

Added: projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/spi/transaction/TxUtils.java
===================================================================
--- projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/spi/transaction/TxUtils.java	                        (rev 0)
+++ projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/spi/transaction/TxUtils.java	2011-03-22 19:22:35 UTC (rev 111001)
@@ -0,0 +1,143 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, 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.jca.core.spi.transaction;
+
+import javax.transaction.Status;
+import javax.transaction.SystemException;
+import javax.transaction.Transaction;
+
+/**
+ * Helper methods for transaction status and textual representation
+ *
+ * @author <a href="mailto:jesper.pedersen at jboss.org">Jesper Pedersen</a>
+ */
+public class TxUtils
+{
+   /** Transaction status strings */
+   private static final String[] TX_STATUS_STRINGS =
+   {
+      "STATUS_ACTIVE",
+      "STATUS_MARKED_ROLLBACK",
+      "STATUS_PREPARED",
+      "STATUS_COMMITTED",
+      "STATUS_ROLLEDBACK",
+      "STATUS_UNKNOWN",
+      "STATUS_NO_TRANSACTION",
+      "STATUS_PREPARING",
+      "STATUS_COMMITTING",
+      "STATUS_ROLLING_BACK"
+   };
+
+   /**
+    * No instances
+    */
+   private TxUtils()
+   {
+   }
+
+   /**
+    * Is the transaction active
+    * @param tx The transaction
+    * @return True if active; otherwise false
+    */
+   public static boolean isActive(Transaction tx)
+   {
+      if (tx == null)
+         return false;
+      
+      try
+      {
+         int status = tx.getStatus();
+
+         return status == Status.STATUS_ACTIVE;
+      }
+      catch (SystemException error)
+      {
+         throw new RuntimeException("Error during isCompleted()", error);
+      }
+   }
+
+   /**
+    * Is the transaction uncommitted
+    * @param tx The transaction
+    * @return True if uncommitted; otherwise false
+    */
+   public static boolean isUncommitted(Transaction tx)
+   {
+      if (tx == null)
+         return false;
+      
+      try
+      {
+         int status = tx.getStatus();
+
+         return status == Status.STATUS_ACTIVE || status == Status.STATUS_MARKED_ROLLBACK;
+      }
+      catch (SystemException error)
+      {
+         throw new RuntimeException("Error during isCompleted()", error);
+      }
+   }
+
+   /**
+    * Is the transaction completed
+    * @param tx The transaction
+    * @return True if completed; otherwise false
+    */
+   public static boolean isCompleted(Transaction tx)
+   {
+      if (tx == null)
+         return true;
+      
+      try
+      {
+         int status = tx.getStatus();
+
+         return status == Status.STATUS_COMMITTED ||
+            status == Status.STATUS_ROLLEDBACK ||
+            status == Status.STATUS_NO_TRANSACTION;
+      }
+      catch (SystemException error)
+      {
+         throw new RuntimeException("Error during isCompleted()", error);
+      }
+   }
+
+   /**
+    * Converts a transaction status to a text representation
+    * 
+    * @param status The status index
+    * @return status as String or "STATUS_INVALID(value)"
+    * @see javax.transaction.Status
+    */
+   public static String getStatusAsString(int status)
+   {
+      if (status >= Status.STATUS_ACTIVE && status <= Status.STATUS_ROLLING_BACK)
+      {
+         return TX_STATUS_STRINGS[status];
+      }
+      else
+      {
+         return "STATUS_INVALID(" + status + ")";
+      }
+   }
+}

Copied: projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/spi/transaction/local/LocalXAException.java (from rev 110929, projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/xa/JBossLocalXAException.java)
===================================================================
--- projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/spi/transaction/local/LocalXAException.java	                        (rev 0)
+++ projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/spi/transaction/local/LocalXAException.java	2011-03-22 19:22:35 UTC (rev 111001)
@@ -0,0 +1,58 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, 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.jca.core.spi.transaction.local;
+
+import javax.transaction.xa.XAException;
+
+/**
+ * LocalXAException
+ *
+ * @author <a href="mailto:jesper.pedersen at jboss.org">Jesper Pedersen</a>
+ */
+public class LocalXAException extends XAException
+{
+   /** Serial version UID */
+   private static final long serialVersionUID = 1299192262106064112L;
+   
+   /**
+    * Creates a new instance.
+    * @param message message
+    * @param errorcode error code
+    */   
+   public LocalXAException(String message, int errorcode)
+   {
+      this(message, errorcode, null);
+   }
+
+   /**
+    * Creates a new instance.
+    * @param message message
+    * @param t cause
+    * @param errorcode error code
+    */   
+   public LocalXAException(String message, int errorcode, Throwable t)
+   {
+      super(message);
+      this.errorCode = errorcode;
+      initCause(t);
+   }
+}

Added: projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/spi/transaction/local/LocalXAResource.java
===================================================================
--- projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/spi/transaction/local/LocalXAResource.java	                        (rev 0)
+++ projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/spi/transaction/local/LocalXAResource.java	2011-03-22 19:22:35 UTC (rev 111001)
@@ -0,0 +1,48 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, 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.jca.core.spi.transaction.local;
+
+import org.jboss.jca.core.api.connectionmanager.ConnectionManager;
+import org.jboss.jca.core.api.connectionmanager.listener.ConnectionListener;
+import org.jboss.jca.core.spi.transaction.LastResource;
+
+import javax.transaction.xa.XAResource;
+
+/**
+ * Local XA resource.
+ * 
+ * @author <a href="mailto:jesper.pedersen at jboss.org">Jesper Pedersen</a>
+ */
+public interface LocalXAResource extends XAResource, LastResource
+{
+   /**
+    * Set the connection manager.
+    * @param cm The value
+    */
+   public void setConnectionManager(ConnectionManager cm);
+
+   /**
+    * Set the connection listener.
+    * @param cl The value
+    */
+   public void setConnectionListener(ConnectionListener cl);
+}

Added: projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/spi/transaction/local/package.html
===================================================================
--- projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/spi/transaction/local/package.html	                        (rev 0)
+++ projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/spi/transaction/local/package.html	2011-03-22 19:22:35 UTC (rev 111001)
@@ -0,0 +1,3 @@
+<body>
+This package contains extensions towards LocalTransaction.
+</body>

Added: projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/spi/transaction/package.html
===================================================================
--- projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/spi/transaction/package.html	                        (rev 0)
+++ projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/spi/transaction/package.html	2011-03-22 19:22:35 UTC (rev 111001)
@@ -0,0 +1,3 @@
+<body>
+This package contains the transaction SPI that defines extensions to JTA 1.1
+</body>

Added: projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/spi/transaction/recovery/XAResourceRecovery.java
===================================================================
--- projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/spi/transaction/recovery/XAResourceRecovery.java	                        (rev 0)
+++ projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/spi/transaction/recovery/XAResourceRecovery.java	2011-03-22 19:22:35 UTC (rev 111001)
@@ -0,0 +1,57 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, 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.jca.core.spi.transaction.recovery;
+
+import javax.transaction.xa.XAResource;
+
+/**
+ * During recovery of crashed XA transactions, the transaction system may use instances
+ * of this interface to obtain XAResources on which to perform recovery calls.
+ * Resource managers should register instances of this interface with the transaction
+ * recovery system via an XAResourceRecoveryRegistry.
+ *
+ * @author Jonathan Halliday (jonathan.halliday at redhat.com)
+ * @see XAResourceRecoveryRegistry
+ */
+public interface XAResourceRecovery
+{
+   /**
+    * Provides XAResource(s) to the transaction system for recovery purposes.
+    *
+    * @return An array of XAResource objects for use in transaction recovery
+    * In most cases the implementation will need to return only a single XAResource in the array.
+    * For more sophisticated cases, such as where multiple different connection types are supported,
+    * it may be necessary to return more than one.
+    *
+    * The Resource should be instantiated in such a way as to carry the necessary permissions to
+    * allow transaction recovery. For some deployments it may therefore be necessary or desirable to
+    * provide resource(s) based on e.g. database connection parameters such as username other than those
+    * used for the regular application connections to the same resource manager. 
+    */
+   public XAResource[] getXAResources();
+
+   /**
+    * Set the JNDI name for the resource
+    * @param jndiName The value
+    */
+   public void setJndiName(String jndiName);
+}

Added: projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/spi/transaction/recovery/XAResourceRecoveryRegistry.java
===================================================================
--- projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/spi/transaction/recovery/XAResourceRecoveryRegistry.java	                        (rev 0)
+++ projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/spi/transaction/recovery/XAResourceRecoveryRegistry.java	2011-03-22 19:22:35 UTC (rev 111001)
@@ -0,0 +1,76 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, 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.jca.core.spi.transaction.recovery;
+
+/**
+ * The transaction management system may require assistance from resource
+ * managers in order to recover crashed XA transactions. By registering
+ * an XAResourceRecovery instance with the XAResourceRecoveryRegistry,
+ * resource manager connectors provide a way for the recovery system to
+ * callback to them and obtain the necessary information.
+ *
+ * This is useful for e.g. JDBC connection pools or JCA connectors that
+ * don't want to expose connection parameters to the transaction system.
+ * The connectors are responsible for instantiating a connection and
+ * using it to instantiate a set of XAResources. These are then exposed to
+ * the recovery system via the registered XAResourceRecovery instance.
+ *
+ * @author Jonathan Halliday (jonathan.halliday at redhat.com)
+ * @version $Revision$
+ * @see XAResourceRecovery
+ */
+public interface XAResourceRecoveryRegistry
+{
+   /*
+     Implementor's note:
+     Although the transaction manager in JBossAS is pluggable, reading the JBossTS
+     recovery documentation may give some insight into the design of this
+     recovery system interface. The forum thread at
+     http://www.jboss.com/index.html?module=bb&op=viewtopic&t=100435
+     may also be of interest.
+   */
+
+   /**
+    * Register an XAResourceRecovery instance with the transaction recovery system.
+    * This should be called by deployers that are deploying a new XA aware
+    * module that needs recovery support. For example, a database
+    * connection pool, JMS adapter or JCA connector.
+    *
+    * @param recovery The XAResourceRecovery instance to register.
+    */
+   public void addXAResourceRecovery(XAResourceRecovery recovery);
+
+   /**
+    * Unregister an XAResourceRecovery instance from the transaction recovery system.
+    * This should be called when an XA aware module is undeployed, to inform the
+    * recovery system that recovery is no longer required or supported.
+    *
+    * Note this method may block whilst an ongoing recovery operation is completed.
+    * Recovery behavior is undefined if the undeployment does not wait for this
+    * operation to complete.
+    *
+    * @param recovery The XAResourceRecovery instance to unregister.
+    * Implementations should fail silent if an attempt is made to unregister
+    * an XAResourceRecovery instance that is not currently registered.
+    */
+   public void removeXAResourceRecovery(XAResourceRecovery recovery);
+}

Added: projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/spi/transaction/recovery/package.html
===================================================================
--- projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/spi/transaction/recovery/package.html	                        (rev 0)
+++ projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/spi/transaction/recovery/package.html	2011-03-22 19:22:35 UTC (rev 111001)
@@ -0,0 +1,3 @@
+<body>
+This package defines a recovery extension.
+</body>

Added: projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/spi/transaction/usertx/UserTransactionListener.java
===================================================================
--- projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/spi/transaction/usertx/UserTransactionListener.java	                        (rev 0)
+++ projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/spi/transaction/usertx/UserTransactionListener.java	2011-03-22 19:22:35 UTC (rev 111001)
@@ -0,0 +1,40 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, 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.jca.core.spi.transaction.usertx;
+
+import java.util.EventListener;
+
+import javax.transaction.SystemException;
+
+/**
+ * UserTransactionListener.
+ * 
+ * @author <a href="mailto:jesper.pedersen at jboss.org">Jesper Pedersen</a>
+ */
+public interface UserTransactionListener extends EventListener
+{
+   /**
+    * An user transaction has started
+    * @exception SystemException Thrown in case of an error
+    */
+   public void userTransactionStarted() throws SystemException;
+}

Added: projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/spi/transaction/usertx/UserTransactionRegistry.java
===================================================================
--- projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/spi/transaction/usertx/UserTransactionRegistry.java	                        (rev 0)
+++ projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/spi/transaction/usertx/UserTransactionRegistry.java	2011-03-22 19:22:35 UTC (rev 111001)
@@ -0,0 +1,42 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, 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.jca.core.spi.transaction.usertx;
+
+/**
+ * UserTransactionRegistry.
+ * 
+ * @author <a href="jesper.pedersen at jboss.org">Jesper Pedersen</a>
+ */
+public interface UserTransactionRegistry
+{
+   /**
+    * Add a listener
+    * @param listener The listener
+    */
+   public void addListener(UserTransactionListener listener);
+   
+   /**
+    * Remove a listener
+    * @param listener The listener
+    */
+   public void removeListener(UserTransactionListener listener);
+}

Added: projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/spi/transaction/usertx/package.html
===================================================================
--- projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/spi/transaction/usertx/package.html	                        (rev 0)
+++ projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/spi/transaction/usertx/package.html	2011-03-22 19:22:35 UTC (rev 111001)
@@ -0,0 +1,3 @@
+<body>
+This package contains interfaces and classes for integration with UserTransactions.
+</body>

Copied: projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/spi/transaction/xa/XAResourceWrapper.java (from rev 110929, projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/spi/connectionmanager/xa/XAResourceWrapper.java)
===================================================================
--- projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/spi/transaction/xa/XAResourceWrapper.java	                        (rev 0)
+++ projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/spi/transaction/xa/XAResourceWrapper.java	2011-03-22 19:22:35 UTC (rev 111001)
@@ -0,0 +1,56 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, 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.jca.core.spi.transaction.xa;
+
+import javax.transaction.xa.XAResource;
+
+/**
+ * An XAResource wrapper.
+ * 
+ * @author <a href="jesper.pedersen at jboss.org">Jesper Pedersen</a>
+ */
+public interface XAResourceWrapper extends XAResource
+{
+   /**
+    * Get the XAResource that is being wrapped
+    * @return The XAResource
+    */
+   public XAResource getResource();
+
+   /**
+    * Get product name
+    * @return Product name of the instance that created the wrapper if defined; otherwise <code>null</code>
+    */
+   public String getProductName();
+
+   /**
+    * Get product version
+    * @return Product version of the instance that created the warpper if defined; otherwise <code>null</code>
+    */
+   public String getProductVersion();
+
+   /**
+    * Get the JNDI name
+    * @return The value
+    */
+   public String getJndiName();
+}

Added: projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/spi/transaction/xa/XATerminator.java
===================================================================
--- projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/spi/transaction/xa/XATerminator.java	                        (rev 0)
+++ projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/spi/transaction/xa/XATerminator.java	2011-03-22 19:22:35 UTC (rev 111001)
@@ -0,0 +1,73 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, 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.jca.core.spi.transaction.xa;
+
+import javax.resource.spi.work.Work;
+import javax.resource.spi.work.WorkCompletedException;
+import javax.transaction.xa.Xid;
+
+/**
+ * Extends XATerminator to include registration calls
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @author <a href="jesper.pedersen at jboss.org">Jesper Pedersen</a>
+ */
+public interface XATerminator extends javax.resource.spi.XATerminator
+{
+   /**
+    * Invoked for transaction inflow of work
+    * 
+    * @param work The work starting
+    * @param xid The xid of the work
+    * @param timeout The transaction timeout
+    * @throws WorkCompletedException with error code WorkException.TX_CONCURRENT_WORK_DISALLOWED
+    *         when work is already present for the xid or whose completion is in progress, only
+    *         the global part of the xid must be used for this check.
+    */
+   public void registerWork(Work work, Xid xid, long timeout) throws WorkCompletedException;
+   
+   /**
+    * Invoked for transaction inflow of work
+    * 
+    * @param work The work starting
+    * @param xid The xid of the work
+    * @throws WorkCompletedException With error code WorkException.TX_RECREATE_FAILED if it is unable 
+    *         to recreate the transaction context
+    */
+   public void startWork(Work work, Xid xid) throws WorkCompletedException;
+
+   /**
+    * Invoked when transaction inflow work ends
+    * 
+    * @param work The work ending
+    * @param xid The xid of the work
+    */
+   public void endWork(Work work, Xid xid);
+
+   /**
+    * Invoked when the work fails
+    * 
+    * @param work The work ending
+    * @param xid The xid of the work
+    */
+   public void cancelWork(Work work, Xid xid);
+}

Copied: projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/spi/transaction/xa/XidWrapper.java (from rev 110929, projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/spi/connectionmanager/xa/XidWrapper.java)
===================================================================
--- projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/spi/transaction/xa/XidWrapper.java	                        (rev 0)
+++ projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/spi/transaction/xa/XidWrapper.java	2011-03-22 19:22:35 UTC (rev 111001)
@@ -0,0 +1,41 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, 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.jca.core.spi.transaction.xa;
+
+import java.io.Serializable;
+
+import javax.transaction.xa.Xid;
+
+/**
+ * A XidWrapper.
+ * 
+ * @author <a href="jesper.pedersen at jboss.org">Jesper Pedersen</a>
+ * @version $Revision: 85945 $
+ */
+public interface XidWrapper extends Serializable, Xid
+{
+   /**
+    * Get the JNDI name
+    * @return The value
+    */
+   public String getJndiName();
+}

Added: projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/spi/transaction/xa/package.html
===================================================================
--- projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/spi/transaction/xa/package.html	                        (rev 0)
+++ projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/spi/transaction/xa/package.html	2011-03-22 19:22:35 UTC (rev 111001)
@@ -0,0 +1,3 @@
+<body>
+This package contains extensions for XA functionality.
+</body>

Copied: projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/tx/jbossts/LocalXAResourceImpl.java (from rev 110929, projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/xa/LocalXAResource.java)
===================================================================
--- projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/tx/jbossts/LocalXAResourceImpl.java	                        (rev 0)
+++ projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/tx/jbossts/LocalXAResourceImpl.java	2011-03-22 19:22:35 UTC (rev 111001)
@@ -0,0 +1,232 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, 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.jca.core.tx.jbossts;
+
+import org.jboss.jca.core.api.connectionmanager.ConnectionManager;
+import org.jboss.jca.core.api.connectionmanager.listener.ConnectionListener;
+import org.jboss.jca.core.spi.transaction.local.LocalXAException;
+import org.jboss.jca.core.spi.transaction.local.LocalXAResource;
+
+import javax.resource.ResourceException;
+import javax.transaction.xa.XAException;
+import javax.transaction.xa.XAResource;
+import javax.transaction.xa.Xid;
+
+import org.jboss.logging.Logger;
+
+/**
+ * Local XA resource implementation.
+ * 
+ * @author <a href="mailto:gurkanerdogdu at yahoo.com">Gurkan Erdogdu</a>
+ * @author <a href="mailto:jesper.pedersen at jboss.org">Jesper Pedersen</a>
+ */
+public class LocalXAResourceImpl implements LocalXAResource
+{
+   /** Log instance */
+   private static Logger log = Logger.getLogger(LocalXAResourceImpl.class);
+
+   /** Connection listener */
+   private ConnectionListener cl;
+
+   /**Connection manager*/
+   private ConnectionManager connectionManager = null;
+
+   /**
+    * <code>warned</code> is set after one warning about a local participant in
+    * a multi-branch jta transaction is logged.
+    */
+   private boolean warned = false;
+
+   /** Current transction branch id */
+   private Xid currentXid;
+
+   /**
+    * Creates a new instance.
+    */
+   public LocalXAResourceImpl()
+   {
+   }
+
+   /**
+    * {@inheritDoc}
+    */
+   public void setConnectionManager(ConnectionManager connectionManager)
+   {
+      this.connectionManager = connectionManager;
+   }
+
+   /**
+    * {@inheritDoc}
+    */
+   public void setConnectionListener(ConnectionListener cl)
+   {
+      this.cl = cl;
+   }
+
+   /**
+    * {@inheritDoc}
+    */
+   public void start(Xid xid, int flags) throws XAException
+   {
+      log.tracef("start(%s, %s)", xid, flags);  
+      
+      if (currentXid != null && flags == XAResource.TMNOFLAGS)
+      {
+         throw new LocalXAException("Trying to start a new tx when old is not complete! old: " +
+               currentXid + ", new " + xid + ", flags " + flags, XAException.XAER_PROTO);
+      }
+      
+      if (currentXid == null && flags != XAResource.TMNOFLAGS)
+      {
+         throw new LocalXAException("Trying to start a new tx with wrong flags!  new " + xid +
+               ", flags " + flags, XAException.XAER_PROTO);
+      }
+
+      if (currentXid == null)
+      {
+         try
+         {
+            cl.getManagedConnection().getLocalTransaction().begin();
+         }
+         catch (ResourceException re)
+         {
+            throw new LocalXAException("Error trying to start local tx: ", XAException.XAER_RMERR, re);
+         }
+         catch (Throwable t)
+         {
+            throw new LocalXAException("Throwable trying to start local transaction!", XAException.XAER_RMERR, t);
+         }
+
+         currentXid = xid;
+      }
+   }
+
+   /**
+    * {@inheritDoc}
+    */
+   public void end(Xid xid, int flags) throws XAException
+   {
+      log.tracef("end(%s,%s)", xid, flags);  
+   }
+
+   /**
+    * {@inheritDoc}
+    */
+   public void commit(Xid xid, boolean onePhase) throws XAException
+   {
+      if (!xid.equals(currentXid))
+      {
+         throw new LocalXAException("Wrong xid in commit: expected: " + currentXid +
+               ", got: " + xid, XAException.XAER_PROTO);
+         
+      }
+      
+      currentXid = null;
+
+      try
+      {
+         cl.getManagedConnection().getLocalTransaction().commit();
+      }
+      catch (ResourceException re)
+      {
+         connectionManager.returnManagedConnection(cl, true);
+         throw new LocalXAException("Could not commit local tx", XAException.XA_RBROLLBACK, re);
+      }
+   }
+
+   /**
+    * {@inheritDoc}
+    */
+   public void forget(Xid xid) throws XAException
+   {
+      throw new LocalXAException("Forget not supported in local tx", XAException.XAER_RMERR);
+   }
+   
+   /**
+    * {@inheritDoc}
+    */
+   public int getTransactionTimeout() throws XAException
+   {
+      return 0;
+   }
+
+   /**
+    * {@inheritDoc}
+    */
+   public boolean isSameRM(XAResource xaResource) throws XAException
+   {
+      return xaResource == this;
+   }
+
+   /**
+    * {@inheritDoc}
+    */
+   public int prepare(Xid xid) throws XAException
+   {
+      if (!warned)
+      {
+         log.warn("Prepare called on a local tx. Use of local transactions on a jta transaction with more " +
+               "than one branch may result in inconsistent data in some cases of failure.");  
+      }
+      warned = true;
+      
+      return XAResource.XA_OK;
+   }
+
+   /**
+    * {@inheritDoc}
+    */
+   public Xid[] recover(int flag) throws XAException
+   {
+      throw new LocalXAException("No recover with local-tx only resource managers", XAException.XAER_RMERR);
+   }
+
+   /**
+    * {@inheritDoc}
+    */
+   public void rollback(Xid xid) throws XAException
+   {
+      if (!xid.equals(currentXid))
+      {
+         throw new LocalXAException("Wrong xid in rollback: expected: " +
+               currentXid + ", got: " + xid, XAException.XAER_PROTO);  
+      }
+      currentXid = null;
+      try
+      {
+         cl.getManagedConnection().getLocalTransaction().rollback();
+      }
+      catch (ResourceException re)
+      {
+         connectionManager.returnManagedConnection(cl, true);
+         throw new LocalXAException("Could not rollback local tx", XAException.XAER_RMERR, re);
+      }
+   }
+
+   /**
+    * {@inheritDoc}
+    */
+   public boolean setTransactionTimeout(int seconds) throws XAException
+   {
+      return false;
+   }
+}

Added: projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/tx/jbossts/TransactionIntegrationImpl.java
===================================================================
--- projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/tx/jbossts/TransactionIntegrationImpl.java	                        (rev 0)
+++ projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/tx/jbossts/TransactionIntegrationImpl.java	2011-03-22 19:22:35 UTC (rev 111001)
@@ -0,0 +1,192 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, 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.jca.core.tx.jbossts;
+
+import org.jboss.jca.core.api.connectionmanager.ConnectionManager;
+import org.jboss.jca.core.spi.recovery.RecoveryPlugin;
+import org.jboss.jca.core.spi.transaction.TransactionIntegration;
+import org.jboss.jca.core.spi.transaction.local.LocalXAResource;
+import org.jboss.jca.core.spi.transaction.recovery.XAResourceRecovery;
+import org.jboss.jca.core.spi.transaction.recovery.XAResourceRecoveryRegistry;
+import org.jboss.jca.core.spi.transaction.usertx.UserTransactionRegistry;
+import org.jboss.jca.core.spi.transaction.xa.XAResourceWrapper;
+import org.jboss.jca.core.spi.transaction.xa.XATerminator;
+
+import javax.resource.spi.ManagedConnectionFactory;
+import javax.transaction.TransactionManager;
+import javax.transaction.TransactionSynchronizationRegistry;
+import javax.transaction.xa.XAResource;
+
+import org.jboss.logging.Logger;
+import org.jboss.security.SubjectFactory;
+import org.jboss.tm.JBossXATerminator;
+
+/**
+ * This class provide an implementation of the transaction integration for
+ * the IronJacamar container using JBossTS.
+ *
+ * @author <a href="mailto:jesper.pedersen at jboss.org">Jesper Pedersen</a>
+ */
+public class TransactionIntegrationImpl implements TransactionIntegration
+{
+   /** The logger */
+   private static Logger log = Logger.getLogger(TransactionIntegrationImpl.class);
+
+   /** The transaction manager */
+   private TransactionManager tm;
+
+   /** The transaction synchronization registry */
+   private TransactionSynchronizationRegistry tsr;
+
+   /** User transaction registry */
+   private org.jboss.tm.usertx.UserTransactionRegistry utr;
+
+   /** XATerminator */
+   private JBossXATerminator terminator;
+
+   /** Recovery registry */
+   private org.jboss.tm.XAResourceRecoveryRegistry rr;
+
+   /**
+    * Constructor
+    * @param tm The transaction manager
+    * @param tsr The transaction synchronization registry
+    * @param utr The user transaction registry
+    * @param terminator The XA terminator
+    * @param rr The recovery registry
+    */
+   public TransactionIntegrationImpl(TransactionManager tm,
+                                     TransactionSynchronizationRegistry tsr,
+                                     org.jboss.tm.usertx.UserTransactionRegistry utr,
+                                     JBossXATerminator terminator,
+                                     org.jboss.tm.XAResourceRecoveryRegistry rr)
+   {
+      this.tm = tm;
+      this.tsr = tsr;
+      this.utr = utr;
+      this.terminator = terminator;
+      this.rr = rr;
+   }
+
+   /**
+    * Get the transaction manager
+    * @return The value
+    */
+   public TransactionManager getTransactionManager()
+   {
+      return tm;
+   }
+
+   /**
+    * Get the transaction synchronization registry
+    * @return The value
+    */
+   public TransactionSynchronizationRegistry getTransactionSynchronizationRegistry()
+   {
+      return tsr;
+   }
+
+   /**
+    * Get the user transaction registry
+    * @return The value
+    */
+   public UserTransactionRegistry getUserTransactionRegistry()
+   {
+      return new UserTransactionRegistryImpl(utr);
+   }
+
+   /**
+    * Get the recovery registry
+    * @return The value
+    */
+   public XAResourceRecoveryRegistry getRecoveryRegistry()
+   {
+      return new XAResourceRecoveryRegistryImpl(rr);
+   }
+
+   /**
+    * Get the XATerminator
+    * @return The value
+    */
+   public XATerminator getXATerminator()
+   {
+      return new XATerminatorImpl(terminator);
+   }
+
+   /**
+    * Create an XAResourceRecovery instance
+    *
+    * @param mcf The managed connection factory
+    * @param pad Should the branch qualifier for Xid's be padded
+    * @param override Should the isSameRM value be overriden; <code>null</code> for instance equally check
+    * @param wrapXAResource Should the XAResource be wrapped
+    * @param recoverUserName The user name for recovery
+    * @param recoverPassword The password for recovery
+    * @param recoverSecurityDomain The security domain for recovery
+    * @param subjectFactory The subject factory
+    * @param plugin The recovery plugin
+    * @return The value
+    */
+   public XAResourceRecovery createXAResourceRecovery(ManagedConnectionFactory mcf,
+                                                      Boolean pad, Boolean override, 
+                                                      Boolean wrapXAResource,
+                                                      String recoverUserName, String recoverPassword, 
+                                                      String recoverSecurityDomain,
+                                                      SubjectFactory subjectFactory,
+                                                      RecoveryPlugin plugin)
+   {
+      return new XAResourceRecoveryImpl(this, mcf, pad, override, wrapXAResource,
+                                        recoverUserName, recoverPassword, recoverSecurityDomain,
+                                        subjectFactory, plugin);
+   }
+
+   /**
+    * Create a LocalXAResource instance
+    * @param cm The connection manager
+    * @return The value
+    */
+   public LocalXAResource createLocalXAResource(ConnectionManager cm)
+   {
+      LocalXAResource result = new LocalXAResourceImpl();
+      result.setConnectionManager(cm);
+
+      return result;
+   }
+
+   /**
+    * Create an XAResource wrapper instance
+    * @param xares The XAResource instance
+    * @param pad Should the branch qualifier for Xid's be padded
+    * @param override Should the isSameRM value be overriden; <code>null</code> for instance equally check
+    * @param productName The product name
+    * @param productVersion The product version
+    * @param jndiName The JNDI name for the resource
+    * @return The value
+    */
+   public XAResourceWrapper createXAResourceWrapper(XAResource xares,
+                                                    boolean pad, Boolean override, 
+                                                    String productName, String productVersion,
+                                                    String jndiName)
+   {
+      return new XAResourceWrapperImpl(xares, pad, override, productName, productVersion, jndiName);
+   }
+}

Added: projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/tx/jbossts/UserTransactionListenerImpl.java
===================================================================
--- projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/tx/jbossts/UserTransactionListenerImpl.java	                        (rev 0)
+++ projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/tx/jbossts/UserTransactionListenerImpl.java	2011-03-22 19:22:35 UTC (rev 111001)
@@ -0,0 +1,54 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, 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.jca.core.tx.jbossts;
+
+import javax.transaction.SystemException;
+
+/**
+ * UserTransactionListener implementation
+ * 
+ * @author <a href="mailto:jesper.pedersen at jboss.org">Jesper Pedersen</a>
+ */
+public class UserTransactionListenerImpl implements org.jboss.jca.core.spi.transaction.usertx.UserTransactionListener,
+                                                    org.jboss.tm.usertx.UserTransactionListener
+{
+   /** The user transaction listener */
+   private org.jboss.jca.core.spi.transaction.usertx.UserTransactionListener utl;
+
+   /**
+    * Constructor
+    * @param utl The user transaction listener
+    */
+   public UserTransactionListenerImpl(org.jboss.jca.core.spi.transaction.usertx.UserTransactionListener utl)
+   {
+      this.utl = utl;
+   }
+
+   /**
+    * An user transaction has started
+    * @exception SystemException Thrown in case of an error
+    */
+   public void userTransactionStarted() throws SystemException
+   {
+      utl.userTransactionStarted();
+   }
+}

Added: projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/tx/jbossts/UserTransactionRegistryImpl.java
===================================================================
--- projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/tx/jbossts/UserTransactionRegistryImpl.java	                        (rev 0)
+++ projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/tx/jbossts/UserTransactionRegistryImpl.java	2011-03-22 19:22:35 UTC (rev 111001)
@@ -0,0 +1,85 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, 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.jca.core.tx.jbossts;
+
+import org.jboss.jca.core.spi.transaction.usertx.UserTransactionListener;
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.jboss.logging.Logger;
+
+/**
+ * UserTransactionRegistry implementation
+ * 
+ * @author <a href="jesper.pedersen at jboss.org">Jesper Pedersen</a>
+ */
+public class UserTransactionRegistryImpl implements org.jboss.jca.core.spi.transaction.usertx.UserTransactionRegistry
+{
+   /** The logger */
+   private static Logger log = Logger.getLogger(UserTransactionRegistryImpl.class);
+
+   /** The delegator */
+   private org.jboss.tm.usertx.UserTransactionRegistry delegator;
+
+   /** Listener map */
+   private Map<UserTransactionListener, UserTransactionListenerImpl> listeners;
+
+   /**
+    * Constructor
+    * @param delegator The delegator instance
+    */
+   public UserTransactionRegistryImpl(org.jboss.tm.usertx.UserTransactionRegistry delegator)
+   {
+      this.delegator = delegator;
+      this.listeners =
+         Collections.synchronizedMap(new HashMap<UserTransactionListener, UserTransactionListenerImpl>());
+   }
+
+   /**
+    * Add a listener
+    * @param listener The listener
+    */
+   public void addListener(UserTransactionListener listener)
+   {
+      UserTransactionListenerImpl impl = new UserTransactionListenerImpl(listener);
+
+      delegator.addListener(impl);
+      listeners.put(listener, impl);
+   }
+   
+   /**
+    * Remove a listener
+    * @param listener The listener
+    */
+   public void removeListener(UserTransactionListener listener)
+   {
+      UserTransactionListenerImpl impl = listeners.get(listener);
+
+      if (impl != null)
+      {
+         delegator.removeListener(impl);
+         listeners.remove(listener);
+      }
+   }
+}

Copied: projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/tx/jbossts/XAResourceRecoveryImpl.java (from rev 110996, projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/recovery/XAResourceRecoveryImpl.java)
===================================================================
--- projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/tx/jbossts/XAResourceRecoveryImpl.java	                        (rev 0)
+++ projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/tx/jbossts/XAResourceRecoveryImpl.java	2011-03-22 19:22:35 UTC (rev 111001)
@@ -0,0 +1,442 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, 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.jca.core.tx.jbossts;
+
+import org.jboss.jca.core.spi.recovery.RecoveryPlugin;
+import org.jboss.jca.core.spi.transaction.TransactionIntegration;
+
+import java.security.AccessController;
+import java.security.Principal;
+import java.security.PrivilegedAction;
+import java.util.Set;
+
+import javax.resource.ResourceException;
+import javax.resource.spi.ManagedConnection;
+import javax.resource.spi.ManagedConnectionFactory;
+import javax.resource.spi.security.PasswordCredential;
+import javax.security.auth.Subject;
+import javax.transaction.xa.XAResource;
+
+import org.jboss.logging.Logger;
+import org.jboss.security.SecurityContext;
+import org.jboss.security.SecurityContextAssociation;
+import org.jboss.security.SecurityContextFactory;
+import org.jboss.security.SimplePrincipal;
+import org.jboss.security.SubjectFactory;
+
+/**
+ * An XAResourceRecovery implementation.
+ *
+ * @author <a href="stefano.maestri at jboss.com">Stefano Maestri</a>
+ * @author <a href="jesper.pedersen at jboss.org">Jesper Pedersen</a>
+ */
+public class XAResourceRecoveryImpl implements org.jboss.jca.core.spi.transaction.recovery.XAResourceRecovery,
+                                               org.jboss.tm.XAResourceRecovery
+{
+   /** Log instance */
+   private static Logger log = Logger.getLogger(XAResourceRecoveryImpl.class);
+
+   private final TransactionIntegration ti;
+
+   private final ManagedConnectionFactory mcf;
+
+   private final Boolean padXid;
+
+   private final Boolean isSameRMOverrideValue;
+
+   private final Boolean wrapXAResource;
+
+   private final String recoverUserName;
+
+   private final String recoverPassword;
+
+   private final String recoverSecurityDomain;
+
+   private final SubjectFactory subjectFactory;
+
+   private final RecoveryPlugin plugin;
+
+   private ManagedConnection recoverMC;
+
+   private String jndiName;
+
+   /**
+    * Create a new XAResourceRecoveryImpl.
+    *
+    * @param ti ti
+    * @param mcf mcf
+    * @param padXid padXid
+    * @param isSameRMOverrideValue isSameRMOverrideValue
+    * @param wrapXAResource wrapXAResource
+    * @param recoverUserName recoverUserName
+    * @param recoverPassword recoverPassword
+    * @param recoverSecurityDomain recoverSecurityDomain
+    * @param subjectFactory subjectFactory
+    * @param plugin recovery plugin
+    */
+   public XAResourceRecoveryImpl(TransactionIntegration ti,
+                                 ManagedConnectionFactory mcf,
+                                 Boolean padXid, Boolean isSameRMOverrideValue, Boolean wrapXAResource,
+                                 String recoverUserName, String recoverPassword, String recoverSecurityDomain,
+                                 SubjectFactory subjectFactory,
+                                 RecoveryPlugin plugin)
+   {
+      if (ti == null)
+         throw new IllegalArgumentException("TransactionIntegration is null");
+
+      if (mcf == null)
+         throw new IllegalArgumentException("MCF is null");
+
+      if (plugin == null)
+         throw new IllegalArgumentException("Plugin is null");
+
+      this.ti = ti;
+      this.mcf = mcf;
+      this.padXid = padXid;
+      this.isSameRMOverrideValue = isSameRMOverrideValue;
+      this.wrapXAResource = wrapXAResource;
+      this.recoverUserName = recoverUserName;
+      this.recoverPassword = recoverPassword;
+      this.recoverSecurityDomain = recoverSecurityDomain;
+      this.subjectFactory = subjectFactory;
+      this.plugin = plugin;
+      this.recoverMC = null;
+      this.jndiName = null;
+   }
+
+   /**
+    * Set the jndiName.
+    *
+    * @param jndiName The jndiName to set.
+    */
+   public void setJndiName(String jndiName)
+   {
+      this.jndiName = jndiName;
+   }
+
+   /**
+    * Provides XAResource(s) to the transaction system for recovery purposes.
+    *
+    * @return An array of XAResource objects for use in transaction recovery
+    * In most cases the implementation will need to return only a single XAResource in the array.
+    * For more sophisticated cases, such as where multiple different connection types are supported,
+    * it may be necessary to return more than one.
+    *
+    * The Resource should be instantiated in such a way as to carry the necessary permissions to
+    * allow transaction recovery. For some deployments it may therefore be necessary or desirable to
+    * provide resource(s) based on e.g. database connection parameters such as username other than those
+    * used for the regular application connections to the same resource manager.
+    */
+   @Override
+   public XAResource[] getXAResources()
+   {
+      try
+      {
+         Subject subject = getSubject();
+
+         // Check if we got a valid Subject instance; requirement for recovery
+         if (subject != null)
+         {
+            ManagedConnection mc = open(subject);
+            XAResource xaResource = null;
+
+            Object connection = null;
+            try
+            {
+               connection = openConnection(mc, subject);
+               xaResource = mc.getXAResource();
+            }
+            catch (ResourceException reconnect)
+            {
+               closeConnection(connection);
+               connection = null;
+               close(mc);
+               mc = open(subject);
+               xaResource = mc.getXAResource();
+            }
+            finally
+            {
+               boolean forceDestroy = closeConnection(connection);
+               connection = null;
+
+               if (forceDestroy)
+               {
+                  close(mc);
+                  mc = open(subject);
+                  xaResource = mc.getXAResource();
+               }
+            }
+            
+            if (wrapXAResource)
+            {
+               String eisProductName = null;
+               String eisProductVersion = null;
+
+               try
+               {
+                  if (mc.getMetaData() != null)
+                  {
+                     eisProductName = mc.getMetaData().getEISProductName();
+                     eisProductVersion = mc.getMetaData().getEISProductVersion();
+                  }
+               }
+               catch (ResourceException re)
+               {
+                  // Ignore
+               }
+
+               if (eisProductName == null)
+                  eisProductName = jndiName;
+
+               if (eisProductVersion == null)
+                  eisProductVersion = jndiName;
+
+               xaResource = ti.createXAResourceWrapper(xaResource,
+                                                       padXid,
+                                                       isSameRMOverrideValue,
+                                                       eisProductName,
+                                                       eisProductVersion,
+                                                       jndiName);
+            }
+
+            log.debugf("Recovery XAResource=%s for %s", xaResource, jndiName);
+
+            return new XAResource[]{xaResource};
+         }
+         else
+         {
+            log.debugf("Subject for recovery was null");
+         }
+      }
+      catch (ResourceException re)
+      {
+         log.debugf("Error during recovery", re);
+      }
+
+      return new XAResource[0];
+   }
+
+   /**
+    * This method provide the Subject used for the XA Resource Recovery
+    * integration with the XAResourceRecoveryRegistry.
+    *
+    * This isn't done through the SecurityAssociation functionality of JBossSX
+    * as the Subject returned here should only be used for recovery.
+    *
+    * @return The recovery subject; <code>null</code> if no Subject could be created
+    */
+   private Subject getSubject()
+   {
+      return AccessController.doPrivileged(new PrivilegedAction<Subject>()
+      {
+         /**
+          * run method
+          */
+         public Subject run()
+         {
+            if (recoverUserName != null && recoverPassword != null)
+            {
+               log.debugf("Recovery user name=%s", recoverUserName);
+
+               // User name and password use-case
+               Subject subject = new Subject();
+
+               // Principals
+               Principal p = new SimplePrincipal(recoverUserName);
+               subject.getPrincipals().add(p);
+
+               // PrivateCredentials
+               PasswordCredential pc = new PasswordCredential(recoverUserName, recoverPassword.toCharArray());
+               pc.setManagedConnectionFactory(mcf);
+               subject.getPrivateCredentials().add(pc);
+
+               // PublicCredentials
+               // None
+
+               log.debugf("Recovery Subject=%s", subject);
+
+               return subject;
+            }
+            else
+            {
+               // Security-domain use-case
+               try
+               {
+                  // Create a security context on the association
+                  SecurityContext securityContext = SecurityContextFactory
+                     .createSecurityContext(recoverSecurityDomain);
+                  SecurityContextAssociation.setSecurityContext(securityContext);
+
+                  // Unauthenticated
+                  Subject unauthenticated = new Subject();
+
+                  // Leave the subject empty as we don't have any information to do the
+                  // authentication with - and we only need it to be able to get the
+                  // real subject from the SubjectFactory
+
+                  // Set the authenticated subject
+                  securityContext.getSubjectInfo().setAuthenticatedSubject(unauthenticated);
+
+                  // Select the domain
+                  String domain = recoverSecurityDomain;
+
+                  if (domain != null && subjectFactory != null)
+                  {
+                     // Use the unauthenticated subject to get the real recovery subject instance
+                     Subject subject = subjectFactory.createSubject(domain);
+                     
+                     Set<PasswordCredential> pcs = subject.getPrivateCredentials(PasswordCredential.class);
+                     if (pcs != null && pcs.size() > 0)
+                     {
+                        for (PasswordCredential pc : pcs)
+                        {
+                           pc.setManagedConnectionFactory(mcf);
+                        }
+                     }
+
+                     log.debugf("Recovery Subject=%s", subject);
+
+                     return subject;
+                  }
+                  else
+                  {
+                     log.debugf("RecoverySecurityDomain was empty");
+                  }
+               }
+               catch (Throwable t)
+               {
+                  log.debugf("Exception during getSubject() - %s", t.getMessage(), t);
+               }
+
+               return null;
+            }
+         }
+      });
+   }
+
+   /**
+    * Open a managed connection
+    * @param s The subject
+    * @return The managed connection
+    * @exception ResourceException Thrown in case of an error
+    */
+   private ManagedConnection open(Subject s) throws ResourceException
+   {
+      log.debugf("Open managed connection (%s)", s);
+
+      if (recoverMC == null)
+         recoverMC = mcf.createManagedConnection(s, null);
+
+      return recoverMC;
+   }
+
+   /**
+    * Close a managed connection
+    * @param mc The managed connection
+    */
+   private void close(ManagedConnection mc)
+   {
+      log.debugf("Closing managed connection for recovery (%s)", mc);
+
+      if (mc != null)
+      {
+         try
+         {
+            mc.cleanup();
+         }
+         catch (ResourceException ire)
+         {
+            log.debugf("Error during recovery cleanup", ire);
+         }
+      }
+
+      if (mc != null)
+      {
+         try
+         {
+            mc.destroy();
+         }
+         catch (ResourceException ire)
+         {
+            log.debugf("Error during recovery destroy", ire);
+         }
+      }
+
+      mc = null;
+
+      // The managed connection for recovery is now gone
+      recoverMC = null;
+   }
+
+   /**
+    * Open a connection
+    * @param mc The managed connection
+    * @param s The subject
+    * @return The connection handle
+    * @exception ResourceException Thrown in case of an error
+    */
+   private Object openConnection(ManagedConnection mc, Subject s) throws ResourceException
+   {
+      log.debugf("Open connection (%s, %s)", mc, s);
+
+      return mc.getConnection(s, null);
+   }
+
+   /**
+    * Close a connection
+    * @param c The connection
+    * @return Should the managed connection be forced closed
+    */
+   private boolean closeConnection(Object c)
+   {
+      log.debugf("Closing connection for recovery check (%s)", c);
+
+      boolean forceClose = false;
+
+      if (c != null)
+      {
+         try
+         {
+            forceClose = !plugin.isValid(c);
+         }
+         catch (ResourceException re)
+         {
+            log.debugf("Error during recovery plugin isValid()", re);
+            forceClose = true;
+         }
+
+         try
+         {
+            plugin.close(c);
+         }
+         catch (ResourceException re)
+         {
+            log.debugf("Error during recovery plugin close()", re);
+            forceClose = true;
+         }
+      }
+
+      log.debugf("Force close=%s", forceClose);
+
+      return forceClose;
+   }
+}

Added: projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/tx/jbossts/XAResourceRecoveryRegistryImpl.java
===================================================================
--- projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/tx/jbossts/XAResourceRecoveryRegistryImpl.java	                        (rev 0)
+++ projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/tx/jbossts/XAResourceRecoveryRegistryImpl.java	2011-03-22 19:22:35 UTC (rev 111001)
@@ -0,0 +1,70 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, 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.jca.core.tx.jbossts;
+
+import org.jboss.jca.core.spi.transaction.recovery.XAResourceRecovery;
+
+import org.jboss.logging.Logger;
+
+/**
+ * An XAResourceRecoveryRegistry implementation
+ */
+public class XAResourceRecoveryRegistryImpl
+   implements org.jboss.jca.core.spi.transaction.recovery.XAResourceRecoveryRegistry
+{
+   /** The logger */
+   private static Logger log = Logger.getLogger(XAResourceRecoveryRegistryImpl.class);
+
+   /** Delegator */
+   private org.jboss.tm.XAResourceRecoveryRegistry delegator;
+
+   /**
+    * Constructor
+    * @param delegator The delegator
+    */
+   public XAResourceRecoveryRegistryImpl(org.jboss.tm.XAResourceRecoveryRegistry delegator)
+   {
+      this.delegator = delegator;
+   }
+
+   /**
+    * {@inheritDoc}
+    */
+   public void addXAResourceRecovery(XAResourceRecovery recovery)
+   {
+      if (!(recovery instanceof XAResourceRecoveryImpl))
+         throw new IllegalArgumentException("Recovery is not a XAResourceRecoveryImpl instance");
+
+      delegator.addXAResourceRecovery((XAResourceRecoveryImpl)recovery);
+   }
+
+   /**
+    * {@inheritDoc}
+    */
+   public void removeXAResourceRecovery(XAResourceRecovery recovery)
+   {
+      if (!(recovery instanceof XAResourceRecoveryImpl))
+         throw new IllegalArgumentException("Recovery is not a XAResourceRecoveryImpl instance");
+
+      delegator.removeXAResourceRecovery((XAResourceRecoveryImpl)recovery);
+   }
+}

Copied: projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/tx/jbossts/XAResourceWrapperImpl.java (from rev 110929, projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/xa/XAResourceWrapperImpl.java)
===================================================================
--- projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/tx/jbossts/XAResourceWrapperImpl.java	                        (rev 0)
+++ projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/tx/jbossts/XAResourceWrapperImpl.java	2011-03-22 19:22:35 UTC (rev 111001)
@@ -0,0 +1,257 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, 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.jca.core.tx.jbossts;
+
+import org.jboss.jca.core.spi.transaction.xa.XidWrapper;
+
+import javax.transaction.xa.XAException;
+import javax.transaction.xa.XAResource;
+import javax.transaction.xa.Xid;
+
+import org.jboss.logging.Logger;
+
+/**
+ * A XAResourceWrapper.
+ * 
+ * @author <a href="weston.price at jboss.com">Weston Price</a>
+ * @author <a href="jesper.pedersen at jboss.org">Jesper Pedersen</a>
+ */
+public class XAResourceWrapperImpl implements org.jboss.jca.core.spi.transaction.xa.XAResourceWrapper,
+                                              org.jboss.tm.XAResourceWrapper
+{
+   /** Serial version UID */
+   private static final long serialVersionUID = 2147435420748633848L;
+
+   /** Log instance */
+   private static Logger log = Logger.getLogger(XAResourceWrapperImpl.class);
+   
+   /** The XA resource */
+   private XAResource xaResource;
+   
+   /** Pad */
+   private boolean pad;
+
+   /** Override Rm Value */
+   private Boolean overrideRmValue;
+
+   /** Product name */
+   private String productName;
+
+   /** Product version */
+   private String productVersion;
+   
+   /** Product version */
+   private String jndiName;
+   
+   /**
+    * Creates a new wrapper instance.
+    * @param resource xaresource
+    * @param pad pad
+    * @param override override
+    * @param productName product name
+    * @param productVersion product version
+    * @param jndiName jndi name
+    */   
+   public XAResourceWrapperImpl(XAResource resource, boolean pad, Boolean override, 
+                                String productName, String productVersion,
+                                String jndiName)
+   {
+      this.overrideRmValue = override;
+      this.pad = pad;
+      this.xaResource = resource;
+      this.productName = productName;
+      this.productVersion = productVersion;
+      this.jndiName = jndiName;
+   }
+
+   /**
+    * {@inheritDoc}
+    */
+   public void commit(Xid xid, boolean onePhase) throws XAException
+   {
+      xid = convertXid(xid);
+      xaResource.commit(xid, onePhase);
+   }
+
+   /**
+    * {@inheritDoc}
+    */
+   public void end(Xid xid, int flags) throws XAException
+   {
+      xid = convertXid(xid);
+      xaResource.end(xid, flags);
+   }
+
+   /**
+    * {@inheritDoc}
+    */
+   public void forget(Xid xid) throws XAException
+   {
+      xid = convertXid(xid);
+      xaResource.forget(xid);
+   }
+
+   /**
+    * {@inheritDoc}
+    */
+   public int getTransactionTimeout() throws XAException
+   {
+      return xaResource.getTransactionTimeout();
+   }
+
+   /**
+    * {@inheritDoc}
+    */
+   public boolean isSameRM(XAResource resource) throws XAException
+   {
+      if (overrideRmValue != null)
+      {
+         if (log.isTraceEnabled())
+         {
+            log.trace("Executing isSameRM with override value" + overrideRmValue + " for XAResourceWrapper" + this);
+         }
+         return overrideRmValue.booleanValue();
+      }
+      else
+      {
+         if (resource instanceof org.jboss.jca.core.spi.transaction.xa.XAResourceWrapper)
+         {
+            org.jboss.jca.core.spi.transaction.xa.XAResourceWrapper other =
+               (org.jboss.jca.core.spi.transaction.xa.XAResourceWrapper)resource;
+            return xaResource.isSameRM(other.getResource());
+         }
+         else
+         {
+            return xaResource.isSameRM(resource);
+         }
+         
+      }
+   }
+
+   /**
+    * {@inheritDoc}
+    */
+   public int prepare(Xid xid) throws XAException
+   {
+      xid = convertXid(xid);
+      return xaResource.prepare(xid);
+   }
+
+   /**
+    * {@inheritDoc}
+    */
+   public Xid[] recover(int flag) throws XAException
+   {
+      return xaResource.recover(flag);
+   }
+
+   /**
+    * {@inheritDoc}
+    */
+   public void rollback(Xid xid) throws XAException
+   {
+      xid = convertXid(xid);      
+      xaResource.rollback(xid);
+   }
+
+   /**
+    * {@inheritDoc}
+    */
+   public boolean setTransactionTimeout(int flag) throws XAException
+   {
+      return xaResource.setTransactionTimeout(flag);
+   }
+
+   /**
+    * {@inheritDoc}
+    */
+   public void start(Xid xid, int flags) throws XAException
+   {
+      xid = convertXid(xid);
+      xaResource.start(xid, flags);
+   }
+
+   /**
+    * Get the XAResource that is being wrapped
+    * @return The XAResource
+    */
+   public XAResource getResource()
+   {
+      return xaResource;
+   }
+
+   /**
+    * Get product name
+    * @return Product name of the instance if defined; otherwise <code>null</code>
+    */
+   public String getProductName()
+   {
+      return productName;
+   }
+
+   /**
+    * Get product version
+    * @return Product version of the instance if defined; otherwise <code>null</code>
+    */
+   public String getProductVersion()
+   {
+      return productVersion;
+   }
+
+   /**
+    * {@inheritDoc}
+    */
+   public String getJndiName()
+   {
+      return jndiName;
+   }
+   
+   /**
+    * Return wrapper for given xid.
+    * @param xid xid
+    * @return return wrapper
+    */
+   private Xid convertXid(Xid xid)
+   {
+      if (xid instanceof XidWrapper)
+         return xid;
+      else
+         return new XidWrapperImpl(xid, pad, jndiName);
+   }
+
+   /**
+    * {@inheritDoc}
+    */
+   public String toString()
+   {
+      StringBuilder sb = new StringBuilder();
+      sb.append("XAResourceWrapperImpl@").append(Integer.toHexString(System.identityHashCode(this)));
+      sb.append("[xaResource=").append(xaResource);
+      sb.append(" pad=").append(pad);
+      sb.append(" overrideRmValue=").append(overrideRmValue);
+      sb.append(" productName=").append(productName);
+      sb.append(" productVersion=").append(productVersion);
+      sb.append(" jndiName=").append(jndiName);
+      sb.append("]");
+      return sb.toString();
+   }
+}

Added: projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/tx/jbossts/XATerminatorImpl.java
===================================================================
--- projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/tx/jbossts/XATerminatorImpl.java	                        (rev 0)
+++ projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/tx/jbossts/XATerminatorImpl.java	2011-03-22 19:22:35 UTC (rev 111001)
@@ -0,0 +1,139 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, 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.jca.core.tx.jbossts;
+
+import javax.resource.spi.work.Work;
+import javax.resource.spi.work.WorkCompletedException;
+import javax.transaction.xa.XAException;
+import javax.transaction.xa.Xid;
+
+import org.jboss.tm.JBossXATerminator;
+
+/**
+ * XATerminator implementation
+ *
+ * @author <a href="jesper.pedersen at jboss.org">Jesper Pedersen</a>
+ */
+public class XATerminatorImpl implements org.jboss.jca.core.spi.transaction.xa.XATerminator
+{
+   /** Delegator */
+   private JBossXATerminator delegator;
+
+   /**
+    * Constructor
+    * @param delegator The delegator
+    */
+   public XATerminatorImpl(JBossXATerminator delegator)
+   {
+      this.delegator = delegator;
+   }
+
+   /**
+    * {@inheritDoc}
+    */
+   public void commit(Xid xid, boolean onePhase) throws XAException
+   {
+      delegator.commit(xid, onePhase);
+   } 
+
+   /**
+    * {@inheritDoc}
+    */
+   public void forget(Xid xid) throws XAException
+   {
+      delegator.forget(xid);
+   } 
+
+   /**
+    * {@inheritDoc}
+    */
+   public int prepare(Xid xid) throws XAException
+   {
+      return delegator.prepare(xid);
+   } 
+
+   /**
+    * {@inheritDoc}
+    */
+   public Xid[] recover(int flags) throws XAException
+   {
+      return delegator.recover(flags);
+   } 
+
+   /**
+    * {@inheritDoc}
+    */
+   public void rollback(Xid xid) throws XAException
+   {
+      delegator.rollback(xid);
+   } 
+
+   /**
+    * Invoked for transaction inflow of work
+    * 
+    * @param work The work starting
+    * @param xid The xid of the work
+    * @param timeout The transaction timeout
+    * @throws WorkCompletedException with error code WorkException.TX_CONCURRENT_WORK_DISALLOWED
+    *         when work is already present for the xid or whose completion is in progress, only
+    *         the global part of the xid must be used for this check.
+    */
+   public void registerWork(Work work, Xid xid, long timeout) throws WorkCompletedException
+   {
+      delegator.registerWork(work, xid, timeout);
+   }
+   
+   /**
+    * Invoked for transaction inflow of work
+    * 
+    * @param work The work starting
+    * @param xid The xid of the work
+    * @throws WorkCompletedException With error code WorkException.TX_RECREATE_FAILED if it is unable 
+    *         to recreate the transaction context
+    */
+   public void startWork(Work work, Xid xid) throws WorkCompletedException
+   {
+      delegator.startWork(work, xid);
+   }
+
+   /**
+    * Invoked when transaction inflow work ends
+    * 
+    * @param work The work ending
+    * @param xid The xid of the work
+    */
+   public void endWork(Work work, Xid xid)
+   {
+      delegator.endWork(work, xid);
+   }
+
+   /**
+    * Invoked when the work fails
+    * 
+    * @param work The work ending
+    * @param xid The xid of the work
+    */
+   public void cancelWork(Work work, Xid xid)
+   {
+      delegator.cancelWork(work, xid);
+   }
+}

Copied: projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/tx/jbossts/XidWrapperImpl.java (from rev 110929, projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/xa/XidWrapperImpl.java)
===================================================================
--- projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/tx/jbossts/XidWrapperImpl.java	                        (rev 0)
+++ projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/tx/jbossts/XidWrapperImpl.java	2011-03-22 19:22:35 UTC (rev 111001)
@@ -0,0 +1,160 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, 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.jca.core.tx.jbossts;
+
+import org.jboss.jca.core.spi.transaction.xa.XidWrapper;
+
+import java.util.Arrays;
+
+import javax.transaction.xa.Xid;
+
+/**
+ * A XidWrapper.
+ * 
+ * @author <a href="weston.price at jboss.com">Weston Price</a>
+ * @author <a href="jesper.pedersen at jboss.org">Jesper Pedersen</a>
+ */
+public class XidWrapperImpl implements XidWrapper
+{
+   /** The serialVersionUID */
+   private static final long serialVersionUID = 3223859423961011795L;
+
+   /** The formatId */
+   private int formatId;
+   
+   /** The globalTransactionId */
+   private byte[] globalTransactionId;
+   
+   /** The branchQualifier */
+   private byte[] branchQualifier;
+
+   /** The jndi name */
+   private String jndiName;
+   
+   /** Cached toString() */
+   private transient String cachedToString;
+
+   /** Cached hashCode() */
+   private transient int cachedHashCode;
+   
+   /**
+    * Creates a new XidWrapperImpl instance.
+    * @param xid The Xid instances
+    * @param pad Should the branch qualifier be padded
+    * @param jndiName The JNDI name
+    */
+   public XidWrapperImpl(Xid xid, boolean pad, String jndiName)
+   {
+      this.branchQualifier = pad ? new byte[Xid.MAXBQUALSIZE] : new byte[xid.getBranchQualifier().length];      
+      System.arraycopy(xid.getBranchQualifier(), 0, branchQualifier, 0, xid.getBranchQualifier().length);      
+
+      this.globalTransactionId = xid.getGlobalTransactionId();
+      this.formatId = xid.getFormatId();
+      this.jndiName = jndiName;
+   }
+
+   /**
+    * {@inheritDoc}
+    */
+   public byte[] getBranchQualifier()
+   {
+      return branchQualifier.clone();
+   }
+
+   /**
+    * {@inheritDoc}
+    */
+   public int getFormatId()
+   {
+      return formatId;
+   }
+
+   /**
+    * {@inheritDoc}
+    */
+   public byte[] getGlobalTransactionId()
+   {
+      return globalTransactionId.clone();
+   }
+   
+   /**
+    * {@inheritDoc}
+    */
+   public String getJndiName()
+   {
+      return jndiName;
+   }
+   
+   /**
+    * {@inheritDoc}
+    */
+   public boolean equals(Object object)
+   {
+      if (object == this)
+         return true;
+
+      if (object == null || !(object instanceof Xid))
+         return false;  
+
+      Xid other = (Xid)object;
+      return
+         (
+            formatId == other.getFormatId() && 
+            Arrays.equals(globalTransactionId, other.getGlobalTransactionId()) &&
+            Arrays.equals(branchQualifier, other.getBranchQualifier())
+         );
+   }
+
+   /**
+    * {@inheritDoc}
+    */
+   public int hashCode()
+   {
+      if (cachedHashCode == 0)
+      {
+         cachedHashCode = formatId;
+         for (int i = 0; i < globalTransactionId.length; ++i)
+            cachedHashCode += globalTransactionId[i];
+      }
+      return cachedHashCode;
+   }
+
+   /**
+    * {@inheritDoc}
+    */
+   public String toString()
+   {
+      if (cachedToString == null)
+      {
+         StringBuilder sb = new StringBuilder();
+         sb.append("XidWrapperImpl@").append(Integer.toHexString(System.identityHashCode(this)));
+         sb.append("[formatId=").append(getFormatId());
+         sb.append(" globalTransactionId=").append(new String(getGlobalTransactionId()).trim());
+         sb.append(" branchQualifier=").append(new String(getBranchQualifier()).trim());
+         sb.append(" jndiName=").append(jndiName);
+         sb.append("]");
+         cachedToString = sb.toString();
+      }
+
+      return cachedToString;
+   }
+}

Added: projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/tx/jbossts/package.html
===================================================================
--- projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/tx/jbossts/package.html	                        (rev 0)
+++ projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/tx/jbossts/package.html	2011-03-22 19:22:35 UTC (rev 111001)
@@ -0,0 +1,3 @@
+<body>
+This package contains an implementation of the transaction SPI using JBossTS as its backend.
+</body>

Modified: projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/workmanager/WorkManagerImpl.java
===================================================================
--- projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/workmanager/WorkManagerImpl.java	2011-03-22 18:25:09 UTC (rev 111000)
+++ projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/workmanager/WorkManagerImpl.java	2011-03-22 19:22:35 UTC (rev 111001)
@@ -24,6 +24,7 @@
 
 import org.jboss.jca.core.api.workmanager.WorkManager;
 import org.jboss.jca.core.spi.security.Callback;
+import org.jboss.jca.core.spi.transaction.xa.XATerminator;
 
 import java.lang.reflect.Method;
 import java.util.HashSet;
@@ -52,7 +53,6 @@
 import org.jboss.logging.Logger;
 import org.jboss.threads.BlockingExecutor;
 import org.jboss.threads.ExecutionTimedOutException;
-import org.jboss.tm.JBossXATerminator;
 
 /**
  * The work manager implementation.
@@ -87,7 +87,7 @@
    private BlockingExecutor longRunningExecutor;
 
    /** The XA terminator */
-   private JBossXATerminator xaTerminator;
+   private XATerminator xaTerminator;
 
    /** Validated work instances */
    private Set<String> validatedWork;
@@ -152,7 +152,7 @@
     * Get the XATerminator
     * @return The XA terminator
     */
-   public JBossXATerminator getXATerminator()
+   public XATerminator getXATerminator()
    {
       return xaTerminator;
    }
@@ -161,7 +161,7 @@
     * Set the XATerminator
     * @param xaTerminator The XA terminator
     */
-   public void setXATerminator(JBossXATerminator xaTerminator)
+   public void setXATerminator(XATerminator xaTerminator)
    {
       this.xaTerminator = xaTerminator;
    }

Modified: projects/jboss-jca/trunk/core/src/test/java/org/jboss/jca/core/connectionmanager/listener/TxConnectionListenerTestCase.java
===================================================================
--- projects/jboss-jca/trunk/core/src/test/java/org/jboss/jca/core/connectionmanager/listener/TxConnectionListenerTestCase.java	2011-03-22 18:25:09 UTC (rev 111000)
+++ projects/jboss-jca/trunk/core/src/test/java/org/jboss/jca/core/connectionmanager/listener/TxConnectionListenerTestCase.java	2011-03-22 19:22:35 UTC (rev 111001)
@@ -31,6 +31,7 @@
 import org.jboss.jca.core.connectionmanager.pool.api.PoolFactory;
 import org.jboss.jca.core.connectionmanager.pool.api.PoolStrategy;
 import org.jboss.jca.core.connectionmanager.tx.TxConnectionManagerTestCase;
+import org.jboss.jca.core.spi.transaction.TransactionIntegration;
 import org.jboss.jca.embedded.Embedded;
 import org.jboss.jca.embedded.EmbeddedFactory;
 
@@ -666,7 +667,7 @@
       embedded.deploy(naming);
       embedded.deploy(transaction);
 
-      TransactionManager tm = embedded.lookup("RealTransactionManager", TransactionManager.class);
+      TransactionIntegration ti = embedded.lookup("TransactionIntegration", TransactionIntegration.class);
 
       mcf = new MockManagedConnectionFactory();
       PoolConfiguration pc = new PoolConfiguration();
@@ -677,7 +678,7 @@
       ConnectionManagerFactory cmf = new ConnectionManagerFactory();
       ConnectionManager connectionManager =
          cmf.createTransactional(TransactionSupportLevel.LocalTransaction, pool,
-                                 null, null, null, null, tm, null, null, null, null, null);
+                                 null, null, null, null, ti, null, null, null, null, null);
 
       txConnectionManager = (TxConnectionManager) connectionManager;
    }

Modified: projects/jboss-jca/trunk/core/src/test/java/org/jboss/jca/core/connectionmanager/tx/SerializableTestCase.java
===================================================================
--- projects/jboss-jca/trunk/core/src/test/java/org/jboss/jca/core/connectionmanager/tx/SerializableTestCase.java	2011-03-22 18:25:09 UTC (rev 111000)
+++ projects/jboss-jca/trunk/core/src/test/java/org/jboss/jca/core/connectionmanager/tx/SerializableTestCase.java	2011-03-22 19:22:35 UTC (rev 111001)
@@ -28,6 +28,7 @@
 import org.jboss.jca.core.connectionmanager.pool.api.Pool;
 import org.jboss.jca.core.connectionmanager.pool.api.PoolFactory;
 import org.jboss.jca.core.connectionmanager.pool.api.PoolStrategy;
+import org.jboss.jca.core.spi.transaction.TransactionIntegration;
 import org.jboss.jca.embedded.Embedded;
 import org.jboss.jca.embedded.EmbeddedFactory;
 
@@ -38,7 +39,6 @@
 
 import javax.resource.spi.ManagedConnectionFactory;
 import javax.resource.spi.TransactionSupport.TransactionSupportLevel;
-import javax.transaction.TransactionManager;
 
 import org.junit.AfterClass;
 import org.junit.BeforeClass;
@@ -62,8 +62,8 @@
    @Test(expected = IOException.class)
    public void testSerializable() throws Throwable
    {
-      TransactionManager tm = embedded.lookup("RealTransactionManager", TransactionManager.class);
-      assertNotNull(tm);
+      TransactionIntegration ti = embedded.lookup("TransactionIntegration", TransactionIntegration.class);
+      assertNotNull(ti);
 
       ManagedConnectionFactory mcf = new MockManagedConnectionFactory();
       PoolConfiguration pc = new PoolConfiguration();
@@ -73,7 +73,7 @@
 
       ConnectionManagerFactory cmf = new ConnectionManagerFactory();
       ConnectionManager connectionManager = cmf.createTransactional(TransactionSupportLevel.XATransaction,
-                                                                    pool, null, null, null, null, tm, 
+                                                                    pool, null, null, null, null, ti, 
                                                                     Boolean.FALSE, null, null, null, null);
       assertNotNull(connectionManager);
 

Modified: projects/jboss-jca/trunk/core/src/test/java/org/jboss/jca/core/connectionmanager/tx/TxConnectionManagerTestCase.java
===================================================================
--- projects/jboss-jca/trunk/core/src/test/java/org/jboss/jca/core/connectionmanager/tx/TxConnectionManagerTestCase.java	2011-03-22 18:25:09 UTC (rev 111000)
+++ projects/jboss-jca/trunk/core/src/test/java/org/jboss/jca/core/connectionmanager/tx/TxConnectionManagerTestCase.java	2011-03-22 19:22:35 UTC (rev 111001)
@@ -34,6 +34,7 @@
 import org.jboss.jca.core.connectionmanager.pool.api.PoolFactory;
 import org.jboss.jca.core.connectionmanager.pool.api.PoolStrategy;
 import org.jboss.jca.core.connectionmanager.transaction.TransactionSynchronizer;
+import org.jboss.jca.core.spi.transaction.TransactionIntegration;
 import org.jboss.jca.embedded.Embedded;
 import org.jboss.jca.embedded.EmbeddedFactory;
 
@@ -309,7 +310,8 @@
       embedded.deploy(naming);
       embedded.deploy(transaction);
 
-      TransactionManager tm = embedded.lookup("RealTransactionManager", TransactionManager.class);
+      TransactionIntegration ti = embedded.lookup("TransactionIntegration", TransactionIntegration.class);
+      assertNotNull(ti);
 
       mcf = new MockManagedConnectionFactory();
       PoolConfiguration pc = new PoolConfiguration();
@@ -320,7 +322,7 @@
       ConnectionManagerFactory cmf = new ConnectionManagerFactory();
       ConnectionManager connectionManager = 
          cmf.createTransactional(TransactionSupportLevel.LocalTransaction, pool,
-                                 null, null, null, null, tm, null, null, null, null, null);
+                                 null, null, null, null, ti, null, null, null, null, null);
 
       txConnectionManager = (TxConnectionManager) connectionManager;
    }

Modified: projects/jboss-jca/trunk/core/src/test/java/org/jboss/jca/core/connectionmanager/tx/XATxConnectionManagerTestCase.java
===================================================================
--- projects/jboss-jca/trunk/core/src/test/java/org/jboss/jca/core/connectionmanager/tx/XATxConnectionManagerTestCase.java	2011-03-22 18:25:09 UTC (rev 111000)
+++ projects/jboss-jca/trunk/core/src/test/java/org/jboss/jca/core/connectionmanager/tx/XATxConnectionManagerTestCase.java	2011-03-22 19:22:35 UTC (rev 111001)
@@ -33,6 +33,7 @@
 import org.jboss.jca.core.connectionmanager.pool.api.PoolFactory;
 import org.jboss.jca.core.connectionmanager.pool.api.PoolStrategy;
 import org.jboss.jca.core.connectionmanager.transaction.TransactionSynchronizer;
+import org.jboss.jca.core.spi.transaction.TransactionIntegration;
 import org.jboss.jca.embedded.Embedded;
 import org.jboss.jca.embedded.EmbeddedFactory;
 
@@ -276,8 +277,8 @@
       embedded.deploy(naming);
       embedded.deploy(transaction);
 
-      TransactionManager tm = embedded.lookup("RealTransactionManager", TransactionManager.class);
-      assertNotNull(tm);
+      TransactionIntegration ti = embedded.lookup("TransactionIntegration", TransactionIntegration.class);
+      assertNotNull(ti);
 
       mcf = new MockManagedConnectionFactory();
       PoolConfiguration pc = new PoolConfiguration();
@@ -288,7 +289,7 @@
       ConnectionManagerFactory cmf = new ConnectionManagerFactory();
       ConnectionManager connectionManager =
          cmf.createTransactional(TransactionSupportLevel.XATransaction, pool,
-                                 null, null, null, null, tm, Boolean.FALSE, null, null, null, null);
+                                 null, null, null, null, ti, Boolean.FALSE, null, null, null, null);
       assertNotNull(connectionManager);
 
       assertTrue(connectionManager instanceof TxConnectionManager);

Modified: projects/jboss-jca/trunk/core/src/test/java/org/jboss/jca/core/inflow/PureInflowTestCase.java
===================================================================
--- projects/jboss-jca/trunk/core/src/test/java/org/jboss/jca/core/inflow/PureInflowTestCase.java	2011-03-22 18:25:09 UTC (rev 111000)
+++ projects/jboss-jca/trunk/core/src/test/java/org/jboss/jca/core/inflow/PureInflowTestCase.java	2011-03-22 19:22:35 UTC (rev 111001)
@@ -30,7 +30,6 @@
 
 import java.net.URL;
 import java.util.List;
-import java.util.Locale;
 import java.util.Set;
 
 import javax.naming.InitialContext;

Modified: projects/jboss-jca/trunk/core/src/test/java/org/jboss/jca/core/workmanager/unit/WorkManagerTestCase.java
===================================================================
--- projects/jboss-jca/trunk/core/src/test/java/org/jboss/jca/core/workmanager/unit/WorkManagerTestCase.java	2011-03-22 18:25:09 UTC (rev 111000)
+++ projects/jboss-jca/trunk/core/src/test/java/org/jboss/jca/core/workmanager/unit/WorkManagerTestCase.java	2011-03-22 19:22:35 UTC (rev 111001)
@@ -102,7 +102,7 @@
 
       assertNotNull(workManager);
       assertNotNull(workManager.getXATerminator());
-      assertTrue(workManager.getXATerminator() instanceof org.jboss.tm.JBossXATerminator);
+      assertTrue(workManager.getXATerminator() instanceof org.jboss.jca.core.spi.transaction.xa.XATerminator);
    }
 
    // --------------------------------------------------------------------------------||

Modified: projects/jboss-jca/trunk/core/src/test/java/org/jboss/jca/test/txmgr/JBossXATerminatorImpl.java
===================================================================
--- projects/jboss-jca/trunk/core/src/test/java/org/jboss/jca/test/txmgr/JBossXATerminatorImpl.java	2011-03-22 18:25:09 UTC (rev 111000)
+++ projects/jboss-jca/trunk/core/src/test/java/org/jboss/jca/test/txmgr/JBossXATerminatorImpl.java	2011-03-22 19:22:35 UTC (rev 111001)
@@ -21,6 +21,8 @@
  */
 package org.jboss.jca.test.txmgr;
 
+import org.jboss.jca.core.spi.transaction.xa.XATerminator;
+
 import java.io.Serializable;
 
 import javax.resource.spi.work.Work;
@@ -29,13 +31,11 @@
 import javax.transaction.xa.XAResource;
 import javax.transaction.xa.Xid;
 
-import org.jboss.tm.JBossXATerminator;
-
 /**
  * A JBoss XATerminator implementation
  * @author <a href="mailto:jesper.pedersen at jboss.org">Jesper Pedersen</a>
  */
-public class JBossXATerminatorImpl implements JBossXATerminator, Serializable
+public class JBossXATerminatorImpl implements XATerminator, Serializable
 {
    private static final long serialVersionUID = 1L;
 

Modified: projects/jboss-jca/trunk/core/src/test/java/org/jboss/jca/test/txmgr/TransactionManagerImpl.java
===================================================================
--- projects/jboss-jca/trunk/core/src/test/java/org/jboss/jca/test/txmgr/TransactionManagerImpl.java	2011-03-22 18:25:09 UTC (rev 111000)
+++ projects/jboss-jca/trunk/core/src/test/java/org/jboss/jca/test/txmgr/TransactionManagerImpl.java	2011-03-22 19:22:35 UTC (rev 111001)
@@ -21,6 +21,8 @@
  */
 package org.jboss.jca.test.txmgr;
 
+import org.jboss.jca.core.spi.transaction.xa.XATerminator;
+
 import javax.transaction.HeuristicMixedException;
 import javax.transaction.HeuristicRollbackException;
 import javax.transaction.InvalidTransactionException;
@@ -31,8 +33,6 @@
 import javax.transaction.Transaction;
 import javax.transaction.TransactionManager;
 
-import org.jboss.tm.JBossXATerminator;
-
 /**
  * A transaction manager implementation
  * @author <a href="mailto:jesper.pedersen at jboss.org">Jesper Pedersen</a>
@@ -40,7 +40,7 @@
 public class TransactionManagerImpl implements TransactionManager
 {
    private TxRegistry registry;
-   private JBossXATerminator terminator;
+   private XATerminator terminator;
 
    /**
     * Constructor
@@ -62,7 +62,7 @@
     * Get the terminator
     * @return The value
     */
-   public JBossXATerminator getXATerminator()
+   public XATerminator getXATerminator()
    {
       return terminator;
    }
@@ -71,7 +71,7 @@
     * Set the terminator
     * @param v The value
     */
-   public void setXATerminator(JBossXATerminator v)
+   public void setXATerminator(XATerminator v)
    {
       terminator = v;
    }

Modified: projects/jboss-jca/trunk/core/src/test/resources/rejecting-workmanager.xml
===================================================================
--- projects/jboss-jca/trunk/core/src/test/resources/rejecting-workmanager.xml	2011-03-22 18:25:09 UTC (rev 111000)
+++ projects/jboss-jca/trunk/core/src/test/resources/rejecting-workmanager.xml	2011-03-22 19:22:35 UTC (rev 111001)
@@ -26,7 +26,7 @@
     <property name="LongRunningThreadPool"><inject bean="LongRunningThreadPool"/></property>
 
     <!-- The XA terminator -->
-    <property name="XATerminator"><inject bean="TransactionManager" property="XATerminator"/></property>
+    <property name="XATerminator"><inject bean="TransactionIntegration" property="XATerminator"/></property>
   </bean>
 
 </deployment>

Modified: projects/jboss-jca/trunk/core/src/test/resources/transaction.xml
===================================================================
--- projects/jboss-jca/trunk/core/src/test/resources/transaction.xml	2011-03-22 18:25:09 UTC (rev 111000)
+++ projects/jboss-jca/trunk/core/src/test/resources/transaction.xml	2011-03-22 19:22:35 UTC (rev 111001)
@@ -227,4 +227,17 @@
     <depends>NamingServer</depends>
   </bean>
   
+  <!-- Transaction integration -->
+  <bean name="TransactionIntegration"
+        interface="org.jboss.jca.core.spi.transaction.TransactionIntegration"
+        class="org.jboss.jca.core.tx.jbossts.TransactionIntegrationImpl">
+    <constructor>
+      <parameter><inject bean="RealTransactionManager"/></parameter>
+      <parameter><inject bean="TransactionSynchronizationRegistry"/></parameter>
+      <parameter><inject bean="UserTransactionRegistry"/></parameter>
+      <parameter><inject bean="TransactionManager" property="XATerminator"/></parameter>
+      <parameter><inject bean="RecoveryManager"/></parameter>
+    </constructor>
+  </bean>
+
 </deployment>

Modified: projects/jboss-jca/trunk/core/src/test/resources/workmanager.xml
===================================================================
--- projects/jboss-jca/trunk/core/src/test/resources/workmanager.xml	2011-03-22 18:25:09 UTC (rev 111000)
+++ projects/jboss-jca/trunk/core/src/test/resources/workmanager.xml	2011-03-22 19:22:35 UTC (rev 111001)
@@ -54,7 +54,7 @@
     <property name="LongRunningThreadPool"><inject bean="LongRunningThreadPool"/></property>
 
     <!-- The XA terminator -->
-    <property name="XATerminator"><inject bean="TransactionManager" property="XATerminator"/></property>
+    <property name="XATerminator"><inject bean="TransactionIntegration" property="XATerminator"/></property>
   </bean>
 
 </deployment>

Modified: projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/common/AbstractDsDeployer.java
===================================================================
--- projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/common/AbstractDsDeployer.java	2011-03-22 18:25:09 UTC (rev 111000)
+++ projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/common/AbstractDsDeployer.java	2011-03-22 19:22:35 UTC (rev 111001)
@@ -44,9 +44,11 @@
 import org.jboss.jca.core.connectionmanager.pool.api.PoolFactory;
 import org.jboss.jca.core.connectionmanager.pool.api.PoolStrategy;
 import org.jboss.jca.core.recovery.DefaultRecoveryPlugin;
-import org.jboss.jca.core.recovery.XAResourceRecoveryImpl;
 import org.jboss.jca.core.spi.mdr.MetadataRepository;
 import org.jboss.jca.core.spi.recovery.RecoveryPlugin;
+import org.jboss.jca.core.spi.transaction.TransactionIntegration;
+import org.jboss.jca.core.spi.transaction.recovery.XAResourceRecovery;
+import org.jboss.jca.core.spi.transaction.recovery.XAResourceRecoveryRegistry;
 
 import java.lang.reflect.Method;
 import java.net.URL;
@@ -58,12 +60,9 @@
 
 import javax.resource.spi.ManagedConnectionFactory;
 import javax.resource.spi.TransactionSupport.TransactionSupportLevel;
-import javax.transaction.TransactionManager;
 
 import org.jboss.logging.Logger;
 import org.jboss.security.SubjectFactory;
-import org.jboss.tm.XAResourceRecovery;
-import org.jboss.tm.XAResourceRecoveryRegistry;
 
 /**
  * An abstract deployer implementation for datasources
@@ -76,8 +75,8 @@
    /** log **/
    protected Logger log;
 
-   /** The transaction manager */
-   protected TransactionManager transactionManager;
+   /** The transaction integration */
+   protected TransactionIntegration transactionIntegration;
 
    /** Metadata repository */
    protected MetadataRepository mdr;
@@ -92,26 +91,26 @@
    public AbstractDsDeployer(Logger log)
    {
       this.log = log;
-      this.transactionManager = null;
+      this.transactionIntegration = null;
       this.mdr = null;
    }
 
    /**
-    * Set the transaction manager
+    * Set the transaction integration
     * @param value The value
     */
-   public void setTransactionManager(TransactionManager value)
+   public void setTransactionIntegration(TransactionIntegration value)
    {
-      transactionManager = value;
+      transactionIntegration = value;
    }
 
    /**
-    * Get the transaction manager
+    * Get the transaction integration
     * @return The value
     */
-   public TransactionManager getTransactionManager()
+   public TransactionIntegration getTransactionIntegration()
    {
-      return transactionManager;
+      return transactionIntegration;
    }
 
    /**
@@ -325,7 +324,8 @@
       ConnectionManager cm =
          cmf.createTransactional(tsl, pool, getSubjectFactory(securityDomain), securityDomain,
                                  allocationRetry, allocationRetryWaitMillis,
-                                 getTransactionManager(), null, null, null, null, null);
+                                 getTransactionIntegration(),
+                                 null, null, null, null, null);
 
       cm.setJndiName(jndiName);
 
@@ -468,7 +468,7 @@
       ConnectionManager cm =
          cmf.createTransactional(tsl, pool, getSubjectFactory(securityDomain), securityDomain,
                                  allocationRetry, allocationRetryWaitMillis,
-                                 getTransactionManager(), interleaving,
+                                 getTransactionIntegration(), interleaving,
                                  xaResourceTimeout, isSameRMOverride, wrapXAResource, padXid);
 
       cm.setJndiName(jndiName);
@@ -535,7 +535,7 @@
       String recoverUser = defaultUserName;
       String recoverPassword = defaultPassword;
 
-      XAResourceRecoveryImpl recoveryImpl = null;
+      XAResourceRecovery recoveryImpl = null;
 
       if (recoveryMD == null || !recoveryMD.getNoRecovery())
       {
@@ -594,22 +594,23 @@
             plugin = new DefaultRecoveryPlugin();
          }
 
-         recoveryImpl = new XAResourceRecoveryImpl(mcf,
-                                                   padXid,
-                                                   isSameRMOverride,
-                                                   wrapXAResource,
-                                                   recoverUser,
-                                                   recoverPassword,
-                                                   recoverSecurityDomain,
-                                                   getSubjectFactory(recoverSecurityDomain),
-                                                   plugin);
+         recoveryImpl = 
+            getTransactionIntegration().createXAResourceRecovery(mcf,
+                                                                 padXid,
+                                                                 isSameRMOverride,
+                                                                 wrapXAResource,
+                                                                 recoverUser,
+                                                                 recoverPassword,
+                                                                 recoverSecurityDomain,
+                                                                 getSubjectFactory(recoverSecurityDomain),
+                                                                 plugin);
 
       }
 
-      if (getXAResourceRecoveryRegistry() != null && recoveryImpl != null)
+      if (getTransactionIntegration().getRecoveryRegistry() != null && recoveryImpl != null)
       {
          recoveryImpl.setJndiName(cm.getJndiName());
-         getXAResourceRecoveryRegistry().addXAResourceRecovery(recoveryImpl);
+         getTransactionIntegration().getRecoveryRegistry().addXAResourceRecovery(recoveryImpl);
 
          recovery = recoveryImpl;
       }

Modified: projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/common/AbstractResourceAdapterDeployer.java
===================================================================
--- projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/common/AbstractResourceAdapterDeployer.java	2011-03-22 18:25:09 UTC (rev 111000)
+++ projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/common/AbstractResourceAdapterDeployer.java	2011-03-22 19:22:35 UTC (rev 111001)
@@ -51,8 +51,9 @@
 import org.jboss.jca.core.connectionmanager.pool.api.PoolFactory;
 import org.jboss.jca.core.connectionmanager.pool.api.PoolStrategy;
 import org.jboss.jca.core.recovery.DefaultRecoveryPlugin;
-import org.jboss.jca.core.recovery.XAResourceRecoveryImpl;
 import org.jboss.jca.core.spi.recovery.RecoveryPlugin;
+import org.jboss.jca.core.spi.transaction.TransactionIntegration;
+import org.jboss.jca.core.spi.transaction.recovery.XAResourceRecovery;
 import org.jboss.jca.validator.Failure;
 import org.jboss.jca.validator.FailureHelper;
 import org.jboss.jca.validator.Key;
@@ -92,8 +93,6 @@
 
 import org.jboss.logging.Logger;
 import org.jboss.security.SubjectFactory;
-import org.jboss.tm.XAResourceRecovery;
-import org.jboss.tm.XAResourceRecoveryRegistry;
 
 /**
  * An abstract resource adapter deployer which contains common functionality
@@ -115,9 +114,6 @@
    /** The configuration */
    private Configuration configuration = null;
 
-   /** xaResourceRecoveryRegistry */
-   protected org.jboss.tm.XAResourceRecoveryRegistry xaResourceRecoveryRegistry;
-
    /**
     * Create a new AbstractResourceAdapterDeployer.
     *
@@ -152,24 +148,6 @@
    }
 
    /**
-    * Get the xAResourceRecoveryRegistry.
-    * @return The value
-    */
-   public XAResourceRecoveryRegistry getXAResourceRecoveryRegistry()
-   {
-      return xaResourceRecoveryRegistry;
-   }
-
-   /**
-    * Set the XAResourcRecoveryRegistry.
-    * @param value The value
-    */
-   public void setXAResourceRecoveryRegistry(XAResourceRecoveryRegistry value)
-   {
-      xaResourceRecoveryRegistry = value;
-   }
-
-   /**
     * validate archive
     *
     * @param url url url of the archive
@@ -1067,7 +1045,7 @@
                         cm = cmf.createTransactional(tsl, pool,
                                                      getSubjectFactory(securityDomain), securityDomain,
                                                      allocationRetry, allocationRetryWaitMillis,
-                                                     getTransactionManager(), interleaving,
+                                                     getTransactionIntegration(), interleaving,
                                                      xaResourceTimeout, isSameRMOverride,
                                                      wrapXAResource, padXid);
                      }
@@ -1350,7 +1328,7 @@
                                     tsl = ((TransactionSupport) mcf).getTransactionSupport();
 
                                  // XAResource recovery
-                                 XAResourceRecoveryImpl recoveryImpl = null;
+                                 XAResourceRecovery recoveryImpl = null;
 
                                  // Connection manager properties
                                  Integer allocationRetry = null;
@@ -1420,7 +1398,8 @@
                                     cm = cmf.createTransactional(tsl, pool,
                                                                  getSubjectFactory(securityDomain), securityDomain,
                                                                  allocationRetry, allocationRetryWaitMillis,
-                                                                 getTransactionManager(), interleaving,
+                                                                 getTransactionIntegration(),
+                                                                 interleaving,
                                                                  xaResourceTimeout, isSameRMOverride,
                                                                  wrapXAResource, padXid);
                                     if (tsl == TransactionSupportLevel.XATransaction)
@@ -1497,16 +1476,18 @@
                                              plugin = new DefaultRecoveryPlugin();
                                           }
 
-                                          recoveryImpl = new XAResourceRecoveryImpl(mcf,
-                                                                                    padXid,
-                                                                                    isSameRMOverride,
-                                                                                    wrapXAResource,
-                                                                                    recoverUser,
-                                                                                    recoverPassword,
-                                                                                    recoverSecurityDomain,
-                                                                                    getSubjectFactory(
-                                                                                       recoverSecurityDomain),
-                                                                                    plugin);
+                                          recoveryImpl =
+                                             getTransactionIntegration().
+                                                createXAResourceRecovery(mcf,
+                                                                         padXid,
+                                                                         isSameRMOverride,
+                                                                         wrapXAResource,
+                                                                         recoverUser,
+                                                                         recoverPassword,
+                                                                         recoverSecurityDomain,
+                                                                         getSubjectFactory(
+                                                                            recoverSecurityDomain),
+                                                                         plugin);
                                        }
                                     }
                                  }
@@ -1603,10 +1584,12 @@
                                        pool.setName(poolName);
                                     }
 
-                                    if (getXAResourceRecoveryRegistry() != null && recoveryImpl != null)
+                                    if (getTransactionIntegration().getRecoveryRegistry() != null &&
+                                        recoveryImpl != null)
                                     {
                                        recoveryImpl.setJndiName(cm.getJndiName());
-                                       getXAResourceRecoveryRegistry().addXAResourceRecovery(recoveryImpl);
+                                       getTransactionIntegration().
+                                          getRecoveryRegistry().addXAResourceRecovery(recoveryImpl);
 
                                        recoveryModules.add(recoveryImpl);
                                     }
@@ -1846,14 +1829,18 @@
    protected abstract String registerResourceAdapterToResourceAdapterRepository(ResourceAdapter instance);
 
    /**
-    *
-    * get The transaction Manager. Implementers have to provide right implementation to find and get it
-    *
-    * @return the transaction manager to be used
+    * Get the transaction Manager. Implementers have to provide right implementation to find and get it
+    * @return The value
     */
    protected abstract TransactionManager getTransactionManager();
 
    /**
+    * Get the transaction integration. Implementers have to provide right implementation to find and get it
+    * @return The value
+    */
+   protected abstract TransactionIntegration getTransactionIntegration();
+
+   /**
     *
     * get a PrintWriter where logger will put its output
     *

Modified: projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/common/CommonDeployment.java
===================================================================
--- projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/common/CommonDeployment.java	2011-03-22 18:25:09 UTC (rev 111000)
+++ projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/common/CommonDeployment.java	2011-03-22 19:22:35 UTC (rev 111001)
@@ -22,6 +22,7 @@
 package org.jboss.jca.deployers.common;
 
 import org.jboss.jca.core.api.management.Connector;
+import org.jboss.jca.core.spi.transaction.recovery.XAResourceRecovery;
 
 import java.net.URL;
 import java.util.Arrays;
@@ -29,7 +30,6 @@
 import javax.resource.spi.ResourceAdapter;
 
 import org.jboss.logging.Logger;
-import org.jboss.tm.XAResourceRecovery;
 
 /**
  *

Modified: projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/fungal/AbstractFungalDeployment.java
===================================================================
--- projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/fungal/AbstractFungalDeployment.java	2011-03-22 18:25:09 UTC (rev 111000)
+++ projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/fungal/AbstractFungalDeployment.java	2011-03-22 19:22:35 UTC (rev 111001)
@@ -27,6 +27,8 @@
 import org.jboss.jca.core.spi.mdr.MetadataRepository;
 import org.jboss.jca.core.spi.naming.JndiStrategy;
 import org.jboss.jca.core.spi.rar.ResourceAdapterRepository;
+import org.jboss.jca.core.spi.transaction.recovery.XAResourceRecovery;
+import org.jboss.jca.core.spi.transaction.recovery.XAResourceRecoveryRegistry;
 
 import java.io.Closeable;
 import java.io.IOException;
@@ -38,8 +40,6 @@
 import javax.resource.spi.ResourceAdapter;
 
 import org.jboss.logging.Logger;
-import org.jboss.tm.XAResourceRecovery;
-import org.jboss.tm.XAResourceRecoveryRegistry;
 
 import com.github.fungal.spi.deployers.Deployment;
 

Modified: projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/fungal/AbstractFungalRADeployer.java
===================================================================
--- projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/fungal/AbstractFungalRADeployer.java	2011-03-22 18:25:09 UTC (rev 111000)
+++ projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/fungal/AbstractFungalRADeployer.java	2011-03-22 19:22:35 UTC (rev 111001)
@@ -26,6 +26,7 @@
 import org.jboss.jca.common.api.metadata.ra.ConfigProperty;
 import org.jboss.jca.common.api.metadata.ra.Connector;
 import org.jboss.jca.core.spi.naming.JndiStrategy;
+import org.jboss.jca.core.spi.transaction.TransactionIntegration;
 import org.jboss.jca.deployers.common.AbstractResourceAdapterDeployer;
 import org.jboss.jca.deployers.common.DeployException;
 
@@ -368,10 +369,16 @@
    @Override
    protected TransactionManager getTransactionManager()
    {
-      return ((RAConfiguration) getConfiguration()).getTransactionManager();
+      return ((RAConfiguration) getConfiguration()).getTransactionIntegration().getTransactionManager();
    }
 
    @Override
+   protected TransactionIntegration getTransactionIntegration()
+   {
+      return ((RAConfiguration) getConfiguration()).getTransactionIntegration();
+   }
+
+   @Override
    protected void registerResourceAdapterToMDR(URL url, File root, Connector cmd, IronJacamar ijmd)
       throws org.jboss.jca.core.spi.mdr.AlreadyExistsException
    {

Modified: projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/fungal/DsXmlDeployer.java
===================================================================
--- projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/fungal/DsXmlDeployer.java	2011-03-22 18:25:09 UTC (rev 111000)
+++ projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/fungal/DsXmlDeployer.java	2011-03-22 19:22:35 UTC (rev 111001)
@@ -274,8 +274,8 @@
     */
    public void start()
    {
-      if (transactionManager == null)
-         throw new IllegalStateException("TransactionManager not defined");
+      if (transactionIntegration == null)
+         throw new IllegalStateException("TransactionIntegration not defined");
 
       if (mdr == null)
          throw new IllegalStateException("MetadataRepository not defined");

Modified: projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/fungal/DsXmlDeployment.java
===================================================================
--- projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/fungal/DsXmlDeployment.java	2011-03-22 18:25:09 UTC (rev 111000)
+++ projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/fungal/DsXmlDeployment.java	2011-03-22 19:22:35 UTC (rev 111001)
@@ -24,14 +24,14 @@
 
 import org.jboss.jca.core.naming.ExplicitJndiStrategy;
 import org.jboss.jca.core.spi.naming.JndiStrategy;
+import org.jboss.jca.core.spi.transaction.recovery.XAResourceRecovery;
+import org.jboss.jca.core.spi.transaction.recovery.XAResourceRecoveryRegistry;
 
 import java.io.Closeable;
 import java.io.IOException;
 import java.net.URL;
 
 import org.jboss.logging.Logger;
-import org.jboss.tm.XAResourceRecovery;
-import org.jboss.tm.XAResourceRecoveryRegistry;
 
 import com.github.fungal.spi.deployers.Deployment;
 

Modified: projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/fungal/RAActivator.java
===================================================================
--- projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/fungal/RAActivator.java	2011-03-22 18:25:09 UTC (rev 111000)
+++ projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/fungal/RAActivator.java	2011-03-22 19:22:35 UTC (rev 111001)
@@ -275,7 +275,7 @@
                                           jndiStrategy, metadataRepository, resourceAdapterRepository,
                                           c.getCfs(), c.getCfJndiNames(), 
                                           c.getAos(), c.getAoJndiNames(),
-                                          c.getRecovery(), getXAResourceRecoveryRegistry(),
+                                          c.getRecovery(), getTransactionIntegration().getRecoveryRegistry(),
                                           ((RAConfiguration)getConfiguration()).getManagementRepository(), 
                                           c.getConnector(),
                                           kernel.getMBeanServer(), ons,

Modified: projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/fungal/RAActivatorDeployment.java
===================================================================
--- projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/fungal/RAActivatorDeployment.java	2011-03-22 18:25:09 UTC (rev 111000)
+++ projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/fungal/RAActivatorDeployment.java	2011-03-22 19:22:35 UTC (rev 111001)
@@ -27,6 +27,8 @@
 import org.jboss.jca.core.spi.mdr.MetadataRepository;
 import org.jboss.jca.core.spi.naming.JndiStrategy;
 import org.jboss.jca.core.spi.rar.ResourceAdapterRepository;
+import org.jboss.jca.core.spi.transaction.recovery.XAResourceRecovery;
+import org.jboss.jca.core.spi.transaction.recovery.XAResourceRecoveryRegistry;
 
 import java.net.URL;
 import java.util.List;
@@ -36,8 +38,6 @@
 import javax.resource.spi.ResourceAdapter;
 
 import org.jboss.logging.Logger;
-import org.jboss.tm.XAResourceRecovery;
-import org.jboss.tm.XAResourceRecoveryRegistry;
 
 /**
  * A resource adapter activator deployment for JCA/SJC

Modified: projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/fungal/RAConfiguration.java
===================================================================
--- projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/fungal/RAConfiguration.java	2011-03-22 18:25:09 UTC (rev 111000)
+++ projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/fungal/RAConfiguration.java	2011-03-22 19:22:35 UTC (rev 111001)
@@ -27,14 +27,13 @@
 import org.jboss.jca.core.spi.mdr.MetadataRepository;
 import org.jboss.jca.core.spi.naming.JndiStrategy;
 import org.jboss.jca.core.spi.rar.ResourceAdapterRepository;
+import org.jboss.jca.core.spi.transaction.TransactionIntegration;
 import org.jboss.jca.deployers.common.Configuration;
 
 import java.io.PrintStream;
 import java.util.Map;
 import java.util.concurrent.atomic.AtomicBoolean;
 
-import javax.transaction.TransactionManager;
-
 import org.jboss.logging.Logger;
 
 /**
@@ -47,8 +46,8 @@
 
    private static boolean trace = log.isTraceEnabled();
 
-   /** The transaction manager */
-   private TransactionManager transactionManager = null;
+   /** The transaction integration */
+   private TransactionIntegration transactionIntegration = null;
 
    /** Preform bean validation */
    private final AtomicBoolean beanValidation = new AtomicBoolean(true);
@@ -94,21 +93,21 @@
    }
 
    /**
-    * Set the transaction manager
+    * Set the transaction integration
     * @param value The value
     */
-   public void setTransactionManager(TransactionManager value)
+   public void setTransactionIntegration(TransactionIntegration value)
    {
-      transactionManager = value;
+      transactionIntegration = value;
    }
 
    /**
-    * Get the transaction manager
+    * Get the transaction integration
     * @return The value
     */
-   public TransactionManager getTransactionManager()
+   public TransactionIntegration getTransactionIntegration()
    {
-      return transactionManager;
+      return transactionIntegration;
    }
 
    /**

Modified: projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/fungal/RADeployer.java
===================================================================
--- projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/fungal/RADeployer.java	2011-03-22 18:25:09 UTC (rev 111000)
+++ projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/fungal/RADeployer.java	2011-03-22 19:22:35 UTC (rev 111001)
@@ -173,7 +173,7 @@
                                  jndiStrategy, metadataRepository, resourceAdapterRepository,
                                  c.getCfs(), c.getCfJndiNames(), 
                                  c.getAos(), c.getAoJndiNames(), 
-                                 c.getRecovery(), getXAResourceRecoveryRegistry(),
+                                 c.getRecovery(), getTransactionIntegration().getRecoveryRegistry(),
                                  destination, 
                                  ((RAConfiguration)getConfiguration()).getManagementRepository(), c.getConnector(),
                                  kernel.getMBeanServer(), ons,

Modified: projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/fungal/RADeployment.java
===================================================================
--- projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/fungal/RADeployment.java	2011-03-22 18:25:09 UTC (rev 111000)
+++ projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/fungal/RADeployment.java	2011-03-22 19:22:35 UTC (rev 111001)
@@ -27,6 +27,8 @@
 import org.jboss.jca.core.spi.mdr.MetadataRepository;
 import org.jboss.jca.core.spi.naming.JndiStrategy;
 import org.jboss.jca.core.spi.rar.ResourceAdapterRepository;
+import org.jboss.jca.core.spi.transaction.recovery.XAResourceRecovery;
+import org.jboss.jca.core.spi.transaction.recovery.XAResourceRecoveryRegistry;
 
 import java.io.File;
 import java.io.IOException;
@@ -38,8 +40,6 @@
 import javax.resource.spi.ResourceAdapter;
 
 import org.jboss.logging.Logger;
-import org.jboss.tm.XAResourceRecovery;
-import org.jboss.tm.XAResourceRecoveryRegistry;
 
 import com.github.fungal.api.util.FileUtil;
 

Modified: projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/fungal/RaXmlDeployer.java
===================================================================
--- projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/fungal/RaXmlDeployer.java	2011-03-22 18:25:09 UTC (rev 111000)
+++ projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/fungal/RaXmlDeployer.java	2011-03-22 19:22:35 UTC (rev 111001)
@@ -287,7 +287,7 @@
                                     jndiStrategy, metadataRepository, resourceAdapterRepository,
                                     c.getCfs(), c.getCfJndiNames(),
                                     c.getAos(), c.getAoJndiNames(), 
-                                    c.getRecovery(), getXAResourceRecoveryRegistry(),
+                                    c.getRecovery(), getTransactionIntegration().getRecoveryRegistry(),
                                     ((RAConfiguration)getConfiguration()).getManagementRepository(), c.getConnector(),
                                     kernel.getMBeanServer(), ons, 
                                     c.getCl(), c.getLog());

Modified: projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/fungal/RaXmlDeployment.java
===================================================================
--- projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/fungal/RaXmlDeployment.java	2011-03-22 18:25:09 UTC (rev 111000)
+++ projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/fungal/RaXmlDeployment.java	2011-03-22 19:22:35 UTC (rev 111001)
@@ -28,6 +28,8 @@
 import org.jboss.jca.core.spi.mdr.NotFoundException;
 import org.jboss.jca.core.spi.naming.JndiStrategy;
 import org.jboss.jca.core.spi.rar.ResourceAdapterRepository;
+import org.jboss.jca.core.spi.transaction.recovery.XAResourceRecovery;
+import org.jboss.jca.core.spi.transaction.recovery.XAResourceRecoveryRegistry;
 
 import java.net.URL;
 import java.util.List;
@@ -37,8 +39,6 @@
 import javax.resource.spi.ResourceAdapter;
 
 import org.jboss.logging.Logger;
-import org.jboss.tm.XAResourceRecovery;
-import org.jboss.tm.XAResourceRecoveryRegistry;
 
 /**
  * A -ra.xml deployment for JCA/SJC

Modified: projects/jboss-jca/trunk/embedded/src/main/resources/ds.xml
===================================================================
--- projects/jboss-jca/trunk/embedded/src/main/resources/ds.xml	2011-03-22 18:25:09 UTC (rev 111000)
+++ projects/jboss-jca/trunk/embedded/src/main/resources/ds.xml	2011-03-22 19:22:35 UTC (rev 111001)
@@ -5,7 +5,7 @@
         class="org.jboss.jca.deployers.fungal.DsXmlDeployer">
     <property name="JDBCLocal">jdbc-local.rar</property>
     <property name="JDBCXA">jdbc-xa.rar</property>
-    <property name="TransactionManager"><inject bean="RealTransactionManager"/></property>
+    <property name="TransactionIntegration"><inject bean="TransactionIntegration"/></property>
     <property name="MetadataRepository"><inject bean="MDR"/></property>
     <property name="Kernel"><inject bean="Kernel"/></property>
   </bean>

Modified: projects/jboss-jca/trunk/embedded/src/main/resources/jca.xml
===================================================================
--- projects/jboss-jca/trunk/embedded/src/main/resources/jca.xml	2011-03-22 18:25:09 UTC (rev 111000)
+++ projects/jboss-jca/trunk/embedded/src/main/resources/jca.xml	2011-03-22 19:22:35 UTC (rev 111001)
@@ -103,7 +103,7 @@
     <property name="LongRunningThreadPool"><inject bean="LongRunningThreadPool"/></property>
 
     <!-- The XA terminator -->
-    <property name="XATerminator"><inject bean="TransactionManager" property="XATerminator"/></property>
+    <property name="XATerminator"><inject bean="TransactionIntegration" property="XATerminator"/></property>
 
     <!-- The callback security module -->
     <property name="CallbackSecurity"><inject bean="UsersRoles"/></property>
@@ -121,7 +121,7 @@
     <property name="WorkManager"><inject bean="WorkManager"/></property>
 
     <!-- The XA terminator -->
-    <property name="XATerminator"><inject bean="TransactionManager" property="XATerminator"/></property>
+    <property name="XATerminator"><inject bean="TransactionIntegration" property="XATerminator"/></property>
   </bean>
 
   <!-- Explicit JNDI strategy -->
@@ -169,7 +169,7 @@
     <property name="PrintStream"><inject bean="JBossStdioContext" property="Out"/></property>
     <property name="DefaultBootstrapContext"><inject bean="DefaultBootstrapContext"/></property>
     <property name="JndiStrategy"><inject bean="ExplicitJndiStrategy"/></property>
-    <property name="TransactionManager"><inject bean="RealTransactionManager"/></property>
+    <property name="TransactionIntegration"><inject bean="TransactionIntegration"/></property>
     <property name="MetadataRepository"><inject bean="MDR"/></property>
     <property name="ManagementRepository"><inject bean="ManagementRepository"/></property>
     <property name="ResourceAdapterRepository"><inject bean="ResourceAdapterRepository"/></property>
@@ -185,7 +185,7 @@
     <property name="PrintStream"><inject bean="JBossStdioContext" property="Out"/></property>
     <property name="DefaultBootstrapContext"><inject bean="DefaultBootstrapContext"/></property>
     <property name="JndiStrategy"><inject bean="SimpleJndiStrategy"/></property>
-    <property name="TransactionManager"><inject bean="RealTransactionManager"/></property>
+    <property name="TransactionIntegration"><inject bean="TransactionIntegration"/></property>
     <property name="MetadataRepository"><inject bean="MDR"/></property>
     <property name="ManagementRepository"><inject bean="ManagementRepository"/></property>
     <property name="ResourceAdapterRepository"><inject bean="ResourceAdapterRepository"/></property>

Modified: projects/jboss-jca/trunk/embedded/src/main/resources/transaction.xml
===================================================================
--- projects/jboss-jca/trunk/embedded/src/main/resources/transaction.xml	2011-03-22 18:25:09 UTC (rev 111000)
+++ projects/jboss-jca/trunk/embedded/src/main/resources/transaction.xml	2011-03-22 19:22:35 UTC (rev 111001)
@@ -227,4 +227,17 @@
     <depends>NamingServer</depends>
   </bean>
   
+  <!-- Transaction integration -->
+  <bean name="TransactionIntegration"
+        interface="org.jboss.jca.core.spi.transaction.TransactionIntegration"
+        class="org.jboss.jca.core.tx.jbossts.TransactionIntegrationImpl">
+    <constructor>
+      <parameter><inject bean="RealTransactionManager"/></parameter>
+      <parameter><inject bean="TransactionSynchronizationRegistry"/></parameter>
+      <parameter><inject bean="UserTransactionRegistry"/></parameter>
+      <parameter><inject bean="TransactionManager" property="XATerminator"/></parameter>
+      <parameter><inject bean="RecoveryManager"/></parameter>
+    </constructor>
+  </bean>
+
 </deployment>

Modified: projects/jboss-jca/trunk/sjc/src/main/resources/bootstrap/ds.xml
===================================================================
--- projects/jboss-jca/trunk/sjc/src/main/resources/bootstrap/ds.xml	2011-03-22 18:25:09 UTC (rev 111000)
+++ projects/jboss-jca/trunk/sjc/src/main/resources/bootstrap/ds.xml	2011-03-22 19:22:35 UTC (rev 111001)
@@ -6,7 +6,7 @@
         class="org.jboss.jca.deployers.fungal.DsXmlDeployer">
     <property name="JDBCLocal">jdbc-local.rar</property>
     <property name="JDBCXA">jdbc-xa.rar</property>
-    <property name="TransactionManager"><inject bean="RealTransactionManager"/></property>
+    <property name="TransactionIntegration"><inject bean="TransactionIntegration"/></property>
     <property name="MetadataRepository"><inject bean="MDR"/></property>
     <property name="Kernel"><inject bean="Kernel"/></property>
   </bean>

Modified: projects/jboss-jca/trunk/sjc/src/main/resources/bootstrap/jca.xml
===================================================================
--- projects/jboss-jca/trunk/sjc/src/main/resources/bootstrap/jca.xml	2011-03-22 18:25:09 UTC (rev 111000)
+++ projects/jboss-jca/trunk/sjc/src/main/resources/bootstrap/jca.xml	2011-03-22 19:22:35 UTC (rev 111001)
@@ -106,7 +106,7 @@
     <property name="LongRunningThreadPool"><inject bean="LongRunningThreadPool"/></property>
 
     <!-- The XA terminator -->
-    <property name="XATerminator"><inject bean="TransactionManager" property="XATerminator"/></property>
+    <property name="XATerminator"><inject bean="TransactionIntegration" property="XATerminator"/></property>
 
     <!-- The callback security module -->
     <property name="CallbackSecurity"><inject bean="UsersRoles"/></property>
@@ -124,7 +124,7 @@
     <property name="WorkManager"><inject bean="WorkManager"/></property>
 
     <!-- The XA terminator -->
-    <property name="XATerminator"><inject bean="TransactionManager" property="XATerminator"/></property>
+    <property name="XATerminator"><inject bean="TransactionIntegration" property="XATerminator"/></property>
   </bean>
 
   <!-- Explicit JNDI strategy -->
@@ -163,7 +163,7 @@
     <property name="PrintStream"><inject bean="JBossStdioContext" property="Out"/></property>
     <property name="DefaultBootstrapContext"><inject bean="DefaultBootstrapContext"/></property>
     <property name="JndiStrategy"><inject bean="ExplicitJndiStrategy"/></property>
-    <property name="TransactionManager"><inject bean="RealTransactionManager"/></property>
+    <property name="TransactionIntegration"><inject bean="TransactionIntegration"/></property>
     <property name="MetadataRepository"><inject bean="MDR"/></property>
     <property name="ManagementRepository"><inject bean="ManagementRepository"/></property>
     <property name="ResourceAdapterRepository"><inject bean="ResourceAdapterRepository"/></property>
@@ -179,7 +179,7 @@
     <property name="PrintStream"><inject bean="JBossStdioContext" property="Out"/></property>
     <property name="DefaultBootstrapContext"><inject bean="DefaultBootstrapContext"/></property>
     <property name="JndiStrategy"><inject bean="SimpleJndiStrategy"/></property>
-    <property name="TransactionManager"><inject bean="RealTransactionManager"/></property>
+    <property name="TransactionIntegration"><inject bean="TransactionIntegration"/></property>
     <property name="MetadataRepository"><inject bean="MDR"/></property>
     <property name="ManagementRepository"><inject bean="ManagementRepository"/></property>
     <property name="ResourceAdapterRepository"><inject bean="ResourceAdapterRepository"/></property>

Modified: projects/jboss-jca/trunk/sjc/src/main/resources/bootstrap/transaction.xml
===================================================================
--- projects/jboss-jca/trunk/sjc/src/main/resources/bootstrap/transaction.xml	2011-03-22 18:25:09 UTC (rev 111000)
+++ projects/jboss-jca/trunk/sjc/src/main/resources/bootstrap/transaction.xml	2011-03-22 19:22:35 UTC (rev 111001)
@@ -227,4 +227,17 @@
     <depends>NamingServer</depends>
   </bean>
   
+  <!-- Transaction integration -->
+  <bean name="TransactionIntegration"
+        interface="org.jboss.jca.core.spi.transaction.TransactionIntegration"
+        class="org.jboss.jca.core.tx.jbossts.TransactionIntegrationImpl">
+    <constructor>
+      <parameter><inject bean="RealTransactionManager"/></parameter>
+      <parameter><inject bean="TransactionSynchronizationRegistry"/></parameter>
+      <parameter><inject bean="UserTransactionRegistry"/></parameter>
+      <parameter><inject bean="TransactionManager" property="XATerminator"/></parameter>
+      <parameter><inject bean="RecoveryManager"/></parameter>
+    </constructor>
+  </bean>
+
 </deployment>



More information about the jboss-cvs-commits mailing list