code: public void enlist(ManagedConnection mc) throws ResourceException
     {
        if (cm.getTransactionSupport() == TransactionSupportLevel.NoTransaction)
           return;
  
        ConnectionListener cl = findConnectionListener(mc, null);
        if (cl != null)
        {
           if (cl.isEnlisted())
              throw new ResourceException();
  
           try
           {
              TransactionalConnectionManager txCM = (TransactionalConnectionManager) cm;
              Transaction tx = txCM.getTransactionIntegration().getTransactionManager().getTransaction();
  
              if (TxUtils.isUncommitted(tx))
              {
                 Object id = txCM.getTransactionIntegration().getTransactionSynchronizationRegistry().getTransactionKey();
  
                 Map<ManagedConnectionPool, ConnectionListener> currentMap = transactionMap.get(id);
  
                 if (currentMap == null)
                 {
                    Map<ManagedConnectionPool, ConnectionListener> map = new HashMap<>();
  
                    currentMap = transactionMap.putIfAbsent(id, map);
                    if (currentMap == null)
                    {
                       currentMap = map;
                    }
                 }
  
                 ConnectionListener existing = currentMap.get(cl.getManagedConnectionPool());
  
                 if (existing == null)
                 {
                    if (TxUtils.isActive(tx))
                    {
                       cl.enlist();
                       
                       currentMap.put(cl.getManagedConnectionPool(), cl);
  
                       txCM.getTransactionIntegration().getTransactionSynchronizationRegistry().
                          registerInterposedSynchronization(new TransactionMapCleanup(id, transactionMap));
                    }
                    else
                    {
                       throw new ResourceException();
                    }
                 }
                 else
                 {
                    log.tracef("Already a connection listener in the pool tracked by transaction=%s (existing=%s)",
                               id, existing);
  
                    if (existing.equals(cl))
                    {
                       if (TxUtils.isActive(tx))
                       {
                          cl.enlist();
                       }
                       else
                       {
                          throw new ResourceException();
                       }
                    }
                    else
                    {
                       throw new ResourceException();
                    }
                 }
              }
              else
              {
                 throw new ResourceException();
              }
           }
           catch (ResourceException re)
           {
              throw re;
           }
           catch (Throwable t)
           {
              throw new ResourceException(t);
           }
        }
        else
        {
           throw new ResourceException();
        }
     }
docs: {@inheritDoc}