Index: sjc/src/main/resources/bootstrap/jca.xml
===================================================================
--- sjc/src/main/resources/bootstrap/jca.xml	(revision 111560)
+++ sjc/src/main/resources/bootstrap/jca.xml	(working copy)
@@ -150,6 +150,7 @@
         class="org.jboss.jca.core.connectionmanager.ccm.CachedConnectionManagerImpl">
     <constructor>
       <parameter><inject bean="TransactionIntegration" property="TransactionManager"/></parameter>
+      <parameter><inject bean="TransactionIntegration" property="TransactionSynchronizationRegistry"/></parameter>
     </constructor>
     <property name="Debug">false</property>
     <property name="Error">false</property>
Index: core/src/test/java/org/jboss/jca/core/connectionmanager/unit/AbstractConnectionManagerTestCase.java
===================================================================
--- core/src/test/java/org/jboss/jca/core/connectionmanager/unit/AbstractConnectionManagerTestCase.java	(revision 111560)
+++ core/src/test/java/org/jboss/jca/core/connectionmanager/unit/AbstractConnectionManagerTestCase.java	(working copy)
@@ -76,7 +76,7 @@
    {
       AbstractConnectionManager connectionManager = new MockConnectionManager();
       assertNull(connectionManager.getCachedConnectionManager());
-      connectionManager.setCachedConnectionManager(new CachedConnectionManagerImpl(null));
+      connectionManager.setCachedConnectionManager(new CachedConnectionManagerImpl(null, null));
       assertNotNull(connectionManager.getCachedConnectionManager());
    }
 
Index: core/src/test/java/org/jboss/jca/core/connectionmanager/ccm/CachedConnectionManagerTestCase.java
===================================================================
--- core/src/test/java/org/jboss/jca/core/connectionmanager/ccm/CachedConnectionManagerTestCase.java	(revision 111560)
+++ core/src/test/java/org/jboss/jca/core/connectionmanager/ccm/CachedConnectionManagerTestCase.java	(working copy)
@@ -34,6 +34,7 @@
 
 import javax.resource.spi.ConnectionRequestInfo;
 import javax.transaction.TransactionManager;
+import javax.transaction.TransactionSynchronizationRegistry;
 
 import org.junit.Test;
 
@@ -66,7 +67,8 @@
    {
       //given
       TransactionManager tm = mock(TransactionManager.class);
-      CachedConnectionManagerImpl ccm = new CachedConnectionManagerImpl(tm);
+      TransactionSynchronizationRegistry tsr = mock(TransactionSynchronizationRegistry.class);
+      CachedConnectionManagerImpl ccm = new CachedConnectionManagerImpl(tm, tsr);
       ConnectionCacheListener cm0 = mock(ConnectionCacheListener.class);
       ConnectionCacheListener cm1 = mock(ConnectionCacheListener.class);
       ConnectionRecord cr0 = mock(ConnectionRecord.class);
@@ -108,7 +110,8 @@
    {
       //given
       TransactionManager tm = mock(TransactionManager.class);
-      CachedConnectionManagerImpl ccm = new CachedConnectionManagerImpl(tm);
+      TransactionSynchronizationRegistry tsr = mock(TransactionSynchronizationRegistry.class);
+      CachedConnectionManagerImpl ccm = new CachedConnectionManagerImpl(tm, tsr);
 
       ccm.getCurrentObjects().set(null);
       //then
@@ -126,7 +129,8 @@
    {
       //given
       TransactionManager tm = mock(TransactionManager.class);
-      CachedConnectionManagerImpl ccm = new CachedConnectionManagerImpl(tm);
+      TransactionSynchronizationRegistry tsr = mock(TransactionSynchronizationRegistry.class);
+      CachedConnectionManagerImpl ccm = new CachedConnectionManagerImpl(tm, tsr);
       ConnectionCacheListener cm0 = mock(ConnectionCacheListener.class);
       ConnectionCacheListener cm1 = mock(ConnectionCacheListener.class);
       ConnectionRecord cr0 = mock(ConnectionRecord.class);
@@ -170,7 +174,8 @@
    {
       //given
       TransactionManager tm = mock(TransactionManager.class);
-      CachedConnectionManagerImpl ccm = new CachedConnectionManagerImpl(tm);
+      TransactionSynchronizationRegistry tsr = mock(TransactionSynchronizationRegistry.class);
+      CachedConnectionManagerImpl ccm = new CachedConnectionManagerImpl(tm, tsr);
 
       ccm.getCurrentObjects().set(null);
       //then (parameters are not important the key of this test is that given ccm have no associations
@@ -188,7 +193,8 @@
    {
       //given
       TransactionManager tm = mock(TransactionManager.class);
-      CachedConnectionManagerImpl ccm = new CachedConnectionManagerImpl(tm);
+      TransactionSynchronizationRegistry tsr = mock(TransactionSynchronizationRegistry.class);
+      CachedConnectionManagerImpl ccm = new CachedConnectionManagerImpl(tm, tsr);
       ConnectionCacheListener cm0 = mock(ConnectionCacheListener.class);
       ConnectionCacheListener cm1 = mock(ConnectionCacheListener.class);
       ConnectionRecord cr0 = mock(ConnectionRecord.class);
@@ -234,7 +240,8 @@
    {
       //given
       TransactionManager tm = mock(TransactionManager.class);
-      CachedConnectionManagerImpl ccm = new CachedConnectionManagerImpl(tm);
+      TransactionSynchronizationRegistry tsr = mock(TransactionSynchronizationRegistry.class);
+      CachedConnectionManagerImpl ccm = new CachedConnectionManagerImpl(tm, tsr);
       ConnectionCacheListener cm0 = mock(ConnectionCacheListener.class);
       ConnectionCacheListener cm1 = mock(ConnectionCacheListener.class);
       ConnectionCacheListener cm2 = mock(ConnectionCacheListener.class);
@@ -284,7 +291,8 @@
    {
       //given
       TransactionManager tm = mock(TransactionManager.class);
-      CachedConnectionManagerImpl ccm = new CachedConnectionManagerImpl(tm);
+      TransactionSynchronizationRegistry tsr = mock(TransactionSynchronizationRegistry.class);
+      CachedConnectionManagerImpl ccm = new CachedConnectionManagerImpl(tm, tsr);
 
       ccm.getCurrentObjects().set(null);
       //then (parameters are not important the key of this test is that given ccm have no associations
@@ -302,7 +310,8 @@
    {
       //given
       TransactionManager tm = mock(TransactionManager.class);
-      CachedConnectionManagerImpl ccm = new CachedConnectionManagerImpl(tm);
+      TransactionSynchronizationRegistry tsr = mock(TransactionSynchronizationRegistry.class);
+      CachedConnectionManagerImpl ccm = new CachedConnectionManagerImpl(tm, tsr);
       ConnectionCacheListener cm0 = mock(ConnectionCacheListener.class);
       ConnectionCacheListener cm1 = mock(ConnectionCacheListener.class);
       ConnectionRecord cr0 = mock(ConnectionRecord.class);
@@ -347,7 +356,8 @@
    {
       //given
       TransactionManager tm = mock(TransactionManager.class);
-      CachedConnectionManagerImpl ccm = new CachedConnectionManagerImpl(tm);
+      TransactionSynchronizationRegistry tsr = mock(TransactionSynchronizationRegistry.class);
+      CachedConnectionManagerImpl ccm = new CachedConnectionManagerImpl(tm, tsr);
       ConnectionCacheListener cm0 = mock(ConnectionCacheListener.class);
       ConnectionCacheListener cm1 = mock(ConnectionCacheListener.class);
       ConnectionRecord cr0 = mock(ConnectionRecord.class);
@@ -394,7 +404,8 @@
    {
       //given
       TransactionManager tm = mock(TransactionManager.class);
-      CachedConnectionManagerImpl ccm = new CachedConnectionManagerImpl(tm);
+      TransactionSynchronizationRegistry tsr = mock(TransactionSynchronizationRegistry.class);
+      CachedConnectionManagerImpl ccm = new CachedConnectionManagerImpl(tm, tsr);
 
       //when
       ccm.pushMetaAwareObject(mock(Object.class), null);
@@ -415,7 +426,8 @@
    {
       //given
       TransactionManager tm = mock(TransactionManager.class);
-      CachedConnectionManagerImpl ccm = new CachedConnectionManagerImpl(tm);
+      TransactionSynchronizationRegistry tsr = mock(TransactionSynchronizationRegistry.class);
+      CachedConnectionManagerImpl ccm = new CachedConnectionManagerImpl(tm, tsr);
 
       ConnectionCacheListener cm0 = mock(ConnectionCacheListener.class);
       ConnectionCacheListener cm1 = mock(ConnectionCacheListener.class);
@@ -464,7 +476,8 @@
    {
       //given
       TransactionManager tm = mock(TransactionManager.class);
-      CachedConnectionManagerImpl ccm = new CachedConnectionManagerImpl(tm);
+      TransactionSynchronizationRegistry tsr = mock(TransactionSynchronizationRegistry.class);
+      CachedConnectionManagerImpl ccm = new CachedConnectionManagerImpl(tm, tsr);
 
       ConnectionCacheListener cm0 = mock(ConnectionCacheListener.class);
       ConnectionCacheListener cm1 = mock(ConnectionCacheListener.class);
Index: core/src/main/java/org/jboss/jca/core/connectionmanager/ccm/CachedConnectionManagerImpl.java
===================================================================
--- core/src/main/java/org/jboss/jca/core/connectionmanager/ccm/CachedConnectionManagerImpl.java	(revision 111560)
+++ core/src/main/java/org/jboss/jca/core/connectionmanager/ccm/CachedConnectionManagerImpl.java	(working copy)
@@ -49,6 +49,7 @@
 import javax.transaction.SystemException;
 import javax.transaction.Transaction;
 import javax.transaction.TransactionManager;
+import javax.transaction.TransactionSynchronizationRegistry;
 
 import org.jboss.logging.Logger;
 import org.jboss.logging.Messages;
@@ -78,6 +79,8 @@
    /** Transaction Manager instance */
    private final TransactionManager transactionManager;
 
+   private final TransactionSynchronizationRegistry transactionSynchronizationRegistry;
+
    /**
     * ThreadLocal that holds current calling meta-programming aware
     * object, used in case someone is idiotic enough to cache a
@@ -105,10 +108,14 @@
    /**
     * Creates a new instance.
     * @param transactionManager The transaction manager
+    * @param transactionSynchronizationRegistry the transaction synchronization registry
     */
-   public CachedConnectionManagerImpl(final TransactionManager transactionManager)
+   public CachedConnectionManagerImpl(
+           final TransactionManager transactionManager,
+           final TransactionSynchronizationRegistry transactionSynchronizationRegistry)
    {
       this.transactionManager = transactionManager;
+      this.transactionSynchronizationRegistry = transactionSynchronizationRegistry;
    }
 
    /**
@@ -121,6 +128,15 @@
    }
 
    /**
+    * Gets transaction synchronization registry
+    * @return TransactionSynchronizationRegistry
+    */
+   public TransactionSynchronizationRegistry getTransactionSynchronizationRegistry()
+   {
+      return transactionSynchronizationRegistry;
+   }
+
+   /**
     * Set debug flag
     * @param v The value
     */
@@ -493,7 +509,7 @@
                if (cas == null && createIfNotFound && TxUtils.isActive(tx))
                {
                   cas = new CloseConnectionSynchronization();
-                  TransactionSynchronizer.registerCCMSynchronization(tx, cas);
+                  TransactionSynchronizer.registerCCMSynchronization(tx, cas, transactionSynchronizationRegistry);
                }
 
                return cas;
Index: core/src/main/java/org/jboss/jca/core/connectionmanager/listener/TxConnectionListener.java
===================================================================
--- core/src/main/java/org/jboss/jca/core/connectionmanager/listener/TxConnectionListener.java	(revision 111560)
+++ core/src/main/java/org/jboss/jca/core/connectionmanager/listener/TxConnectionListener.java	(working copy)
@@ -226,7 +226,9 @@
                log.trace("Get synchronizer " + this + " threadTx=" + threadTx);
             }
 
-            synchronizer = TransactionSynchronizer.getRegisteredSynchronizer(threadTx);
+            synchronizer =
+                    TransactionSynchronizer.getRegisteredSynchronizer(threadTx,
+                            getConnectionManager().getTransactionIntegration().getTransactionSynchronizationRegistry());
          }
          catch (Throwable t)
          {
@@ -298,7 +300,12 @@
             transactionSynchronization = null;
             if (TxUtils.isUncommitted(tx))
             {
-               TransactionSynchronizer synchronizer = TransactionSynchronizer.getRegisteredSynchronizer(tx);
+               TransactionSynchronizer synchronizer =
+                     TransactionSynchronizer.getRegisteredSynchronizer(
+                           tx,
+                           getConnectionManager().
+                           getTransactionIntegration().
+                           getTransactionSynchronizationRegistry());
                if (synchronization.enlisted)
                   synchronizer.removeEnlisted(synchronization);
                if (!tx.delistResource(getXAResource(), XAResource.TMSUSPEND))
Index: core/src/main/java/org/jboss/jca/core/connectionmanager/transaction/TransactionSynchronizer.java
===================================================================
--- core/src/main/java/org/jboss/jca/core/connectionmanager/transaction/TransactionSynchronizer.java	(revision 111560)
+++ core/src/main/java/org/jboss/jca/core/connectionmanager/transaction/TransactionSynchronizer.java	(working copy)
@@ -34,6 +34,7 @@
 import javax.transaction.Synchronization;
 import javax.transaction.SystemException;
 import javax.transaction.Transaction;
+import javax.transaction.TransactionSynchronizationRegistry;
 
 import org.jboss.logging.Logger;
 
@@ -178,15 +179,18 @@
       notifyAll();
    }
    
+
    /**
     * Get a registered transaction synchronizer.
     *
     * @param tx the transaction
+    * @param tsr the transaction synchronization registry
     * @throws SystemException sys. exception
     * @throws RollbackException rollback exception
     * @return the registered transaction synchronizer for this transaction
     */
-   public static TransactionSynchronizer getRegisteredSynchronizer(Transaction tx) 
+   public static TransactionSynchronizer getRegisteredSynchronizer(
+         Transaction tx, TransactionSynchronizationRegistry tsr)
       throws SystemException, RollbackException
    {
       TransactionSynchronizer result = txSynchs.get(tx);
@@ -197,12 +201,21 @@
          if (result == null)
          {
             result = newResult;
-            tx.registerSynchronization(result);
+            if (tsr != null)
+            {
+               tsr.registerInterposedSynchronization(result);
+            }
+            else
+            {
+               tx.registerSynchronization(result);
+            }
          }
       }
       return result;
    }
-   
+
+
+
    /**
     * Check whether we have a CCM synchronization
     * 
@@ -220,17 +233,22 @@
    
    /**
     * Register a new CCM synchronization
-    * 
+    *
     * @param tx the transaction
     * @param synch the synchronization
+    * @param tsr the transaction synchronization registry
     * @throws Exception e
     */
-   public static void registerCCMSynchronization(Transaction tx, Synchronization synch) 
+   public static void registerCCMSynchronization(
+           Transaction tx,
+           Synchronization synch,
+           TransactionSynchronizationRegistry tsr)
       throws Exception
    {
-      TransactionSynchronizer ts = getRegisteredSynchronizer(tx);
+      TransactionSynchronizer ts = getRegisteredSynchronizer(tx, tsr);
       ts.ccmSynch = synch;
    }
+
    
    /**
     * Lock for the given transaction
Index: embedded/src/main/resources/jca.xml
===================================================================
--- embedded/src/main/resources/jca.xml	(revision 111560)
+++ embedded/src/main/resources/jca.xml	(working copy)
@@ -147,6 +147,7 @@
         class="org.jboss.jca.core.connectionmanager.ccm.CachedConnectionManagerImpl">
     <constructor>
       <parameter><inject bean="TransactionIntegration" property="TransactionManager"/></parameter>
+      <parameter><inject bean="TransactionIntegration" property="TransactionSynchronizationRegistry"/></parameter>
     </constructor>
     <property name="Debug">false</property>
     <property name="Error">false</property>
