Class XAResource

  • All Implemented Interfaces:
    XAResource

    public class XAResource
    extends Object
    implements XAResource
    A XAResource instance is used by a XASession instance as a delegate to a Transaction Manager.
    • Field Detail

      • enlisted

        private boolean enlisted
        true if the resource is enlisted in a transaction.
      • currentXid

        private Xid currentXid
        The current transaction identifier.
      • sess

        Session sess
        The session producing and consuming messages.
      • logger

        private static org.objectweb.util.monolog.api.Logger logger
    • Constructor Detail

      • XAResource

        public XAResource​(XAResourceMngr rm,
                          Session sess)
        Constructs an XA resource representing a given session.
    • Method Detail

      • start

        public void start​(Xid xid,
                          int flag)
                   throws XAException
        Enlists this resource in a given transaction.
        Specified by:
        start in interface XAResource
        Throws:
        XAException - If the resource is already enlisted in a transaction, or if the RM fails to enlist the resource.
      • end

        public void end​(Xid xid,
                        int flag)
                 throws XAException
        Delists this resource.
        Specified by:
        end in interface XAResource
        Throws:
        XAException - If the resource is not enlisted in the specified transaction, or if the RM fails to delist the resource.
      • commit

        public void commit​(Xid xid,
                           boolean onePhase)
                    throws XAException
        Commits the resource.
        Specified by:
        commit in interface XAResource
        Throws:
        XAException - If the RM fails to commit the resource.
      • recover

        public Xid[] recover​(int flag)
                      throws XAException
        Recovers the prepared transactions identifiers.
        Specified by:
        recover in interface XAResource
        Throws:
        XAException - If the RM fails to recover.
      • forget

        public void forget​(Xid xid)
                    throws XAException
        Not implemented as transactions are not heuristically completed.
        Specified by:
        forget in interface XAResource
        Throws:
        XAException - Always thrown.
      • isSameRM

        public boolean isSameRM​(XAResource o)
                         throws XAException
        Checks if this resource shares the same resource manager (XAConnection) with an other resource.
        Specified by:
        isSameRM in interface XAResource
        Throws:
        XAException - Never thrown.