Class XAResourceImpl

  • All Implemented Interfaces:
    XAResource

    public class XAResourceImpl
    extends Object
    implements XAResource
    XAResource wrapper for Generic JDBC Connector.
    Version:
    1.0, 02/08/23
    Author:
    Evani Sai Surya Kiran
    • Constructor Detail

      • XAResourceImpl

        public XAResourceImpl​(XAResource xar,
                              ManagedConnectionImpl mc)
        Constructor for XAResourceImpl
        Parameters:
        xar - XAResource
        mc - ManagedConnection
    • Method Detail

      • commit

        public void commit​(Xid xid,
                           boolean onePhase)
                    throws XAException
        Commit the global transaction specified by xid.
        Specified by:
        commit in interface XAResource
        Parameters:
        xid - A global transaction identifier
        onePhase - If true, the resource manager should use a one-phase commit protocol to commit the work done on behalf of xid.
        Throws:
        XAException
      • end

        public void end​(Xid xid,
                        int flags)
                 throws XAException
        Ends the work performed on behalf of a transaction branch.
        Specified by:
        end in interface XAResource
        Parameters:
        xid - A global transaction identifier that is the same as what was used previously in the start method.
        flags - One of TMSUCCESS, TMFAIL, or TMSUSPEND
        Throws:
        XAException
      • forget

        public void forget​(Xid xid)
                    throws XAException
        Tell the resource manager to forget about a heuristically completed transaction branch.
        Specified by:
        forget in interface XAResource
        Parameters:
        xid - A global transaction identifier
        Throws:
        XAException
      • getTransactionTimeout

        public int getTransactionTimeout()
                                  throws XAException
        Obtain the current transaction timeout value set for this XAResource instance.
        Specified by:
        getTransactionTimeout in interface XAResource
        Returns:
        the transaction timeout value in seconds
        Throws:
        XAException
      • isSameRM

        public boolean isSameRM​(XAResource xares)
                         throws XAException
        This method is called to determine if the resource manager instance represented by the target object is the same as the resouce manager instance represented by the parameter xares.
        Specified by:
        isSameRM in interface XAResource
        Parameters:
        xares - An XAResource object whose resource manager instance is to be compared with the resource
        Returns:
        true if it's the same RM instance; otherwise false.
        Throws:
        XAException
      • prepare

        public int prepare​(Xid xid)
                    throws XAException
        Ask the resource manager to prepare for a transaction commit of the transaction specified in xid.
        Specified by:
        prepare in interface XAResource
        Parameters:
        xid - A global transaction identifier
        Returns:
        A value indicating the resource manager's vote on the outcome of the transaction. The possible values are: XA_RDONLY or XA_OK. If the resource manager wants to roll back the transaction, it should do so by raising an appropriate XAException in the prepare method.
        Throws:
        XAException
      • recover

        public Xid[] recover​(int flag)
                      throws XAException
        Obtain a list of prepared transaction branches from a resource manager.
        Specified by:
        recover in interface XAResource
        Parameters:
        flag - One of TMSTARTRSCAN, TMENDRSCAN, TMNOFLAGS. TMNOFLAGS must be used when no other flags are set in flags.
        Returns:
        The resource manager returns zero or more XIDs for the transaction branches that are currently in a prepared or heuristically completed state. If an error occurs during the operation, the resource manager should throw the appropriate XAException.
        Throws:
        XAException
      • rollback

        public void rollback​(Xid xid)
                      throws XAException
        Inform the resource manager to roll back work done on behalf of a transaction branch
        Specified by:
        rollback in interface XAResource
        Parameters:
        xid - A global transaction identifier
        Throws:
        XAException
      • setTransactionTimeout

        public boolean setTransactionTimeout​(int seconds)
                                      throws XAException
        Set the current transaction timeout value for this XAResource instance.
        Specified by:
        setTransactionTimeout in interface XAResource
        Parameters:
        seconds - the transaction timeout value in seconds.
        Returns:
        true if transaction timeout value is set successfully; otherwise false.
        Throws:
        XAException