Class JBossContextXATerminator

  • All Implemented Interfaces:
    jakarta.resource.spi.XATerminator, org.jboss.tm.JBossXATerminator

    public class JBossContextXATerminator
    extends Object
    implements org.jboss.tm.JBossXATerminator
    • Constructor Summary

      Constructors 
      Constructor Description
      JBossContextXATerminator​(org.wildfly.transaction.client.LocalTransactionContext transactionContext, org.jboss.tm.JBossXATerminator jbossXATerminator)  
    • Constructor Detail

      • JBossContextXATerminator

        public JBossContextXATerminator​(org.wildfly.transaction.client.LocalTransactionContext transactionContext,
                                        org.jboss.tm.JBossXATerminator jbossXATerminator)
    • Method Detail

      • commit

        public void commit​(Xid xid,
                           boolean onePhase)
                    throws XAException
        Specified by:
        commit in interface jakarta.resource.spi.XATerminator
        Throws:
        XAException
      • forget

        public void forget​(Xid xid)
                    throws XAException
        Specified by:
        forget in interface jakarta.resource.spi.XATerminator
        Throws:
        XAException
      • prepare

        public int prepare​(Xid xid)
                    throws XAException
        Specified by:
        prepare in interface jakarta.resource.spi.XATerminator
        Throws:
        XAException
      • recover

        public Xid[] recover​(int flag)
                      throws XAException
        Specified by:
        recover in interface jakarta.resource.spi.XATerminator
        Throws:
        XAException
      • rollback

        public void rollback​(Xid xid)
                      throws XAException
        Specified by:
        rollback in interface jakarta.resource.spi.XATerminator
        Throws:
        XAException
      • registerWork

        public void registerWork​(jakarta.resource.spi.work.Work work,
                                 Xid xid,
                                 long timeout)
                          throws jakarta.resource.spi.work.WorkCompletedException

        Interception of register work call to get transaction being imported to wildfly transacton client.

        For importing a transaction Wildfly transaction client eventually calls SubordinationManager as Narayana XATerminators do. This wrapping then let wildfly transacton client to register the transaction for itself, wildfly transacton client then import transaction to Narayana too and finally this method uses Narayana's XATerminator to register all Works binding.
        Narayana's XATerminator tries to import transaction too but as transaction is already imported it just gets instance of transaction already imported via call of wildfly transacton client.

        Specified by:
        registerWork in interface org.jboss.tm.JBossXATerminator
        Throws:
        jakarta.resource.spi.work.WorkCompletedException
      • startWork

        public void startWork​(jakarta.resource.spi.work.Work work,
                              Xid xid)
                       throws jakarta.resource.spi.work.WorkCompletedException

        Start work gets imported transaction and assign it to current thread.

        This method mimics behavior of Narayana's JBossXATerminator.

        Specified by:
        startWork in interface org.jboss.tm.JBossXATerminator
        Throws:
        jakarta.resource.spi.work.WorkCompletedException
      • endWork

        public void endWork​(jakarta.resource.spi.work.Work work,
                            Xid xid)

        Suspending transaction and canceling the work.

        Suspend transaction has to be called on the wildfly transaction manager and the we delegate work cancellation to JBossXATerminator.
        First we have to cancel the work for jboss terminator would not work with suspended transaction.

        Specified by:
        endWork in interface org.jboss.tm.JBossXATerminator
      • cancelWork

        public void cancelWork​(jakarta.resource.spi.work.Work work,
                               Xid xid)

        Calling JBossXATerminator to cancel the work for us.

        There should not be need any action to be processed by wildfly transaction client.

        Specified by:
        cancelWork in interface org.jboss.tm.JBossXATerminator