Class XAResourceMngr


  • public class XAResourceMngr
    extends Object
    Utility class used by XA connections for managing XA resources.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      (package private) Connection cnx
      The connection this manager belongs to.
      private static org.objectweb.util.monolog.api.Logger logger  
      static int PREPARED
      Prepared transaction.
      static int ROLLBACK_ONLY
      Failed transaction.
      (package private) Hashtable sessionTable
      table of Session (key Xid).
      static int STARTED
      Transaction active.
      static int SUCCESS
      Transaction successful.
      static int SUSPENDED
      Transaction suspended.
      private Hashtable transactions
      The table of known transactions.
    • Constructor Summary

      Constructors 
      Constructor Description
      XAResourceMngr​(Connection cnx)
      Creates a XAResourceMngr instance.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      (package private) void commit​(Xid xid)
      Notifies the RM that a transaction is commited.
      (package private) void end​(Xid xid, int flag, Session sess)
      Notifies the RM that a transaction is ended.
      boolean equals​(Object o)
      Resource managers are equal if they belong to the same connection.
      private int getStatus​(Xid xid)
      Gets the status of a transaction.
      int hashCode()  
      (package private) void prepare​(Xid xid)
      Notifies the RM that a transaction is prepared.
      (package private) Xid[] recover​(int flag)
      Notifies the RM to recover the prepared transactions.
      (package private) void rollback​(Xid xid)
      Notifies the RM that a transaction is rolled back.
      private void setStatus​(Xid xid, int status)
      Sets the status of a transaction.
      (package private) void start​(Xid xid, int flag, Session sess)
      Notifies the RM that a transaction is starting.
    • Field Detail

      • ROLLBACK_ONLY

        public static final int ROLLBACK_ONLY
        Failed transaction.
        See Also:
        Constant Field Values
      • logger

        private static org.objectweb.util.monolog.api.Logger logger
      • transactions

        private Hashtable transactions
        The table of known transactions.

        Key: transaction identifier
        Object: XAContext instance

      • cnx

        Connection cnx
        The connection this manager belongs to.
      • sessionTable

        Hashtable sessionTable
        table of Session (key Xid).
    • Constructor Detail

      • XAResourceMngr

        public XAResourceMngr​(Connection cnx)
        Creates a XAResourceMngr instance.
        Parameters:
        cnx - The connection this manager belongs to.
    • Method Detail

      • start

        void start​(Xid xid,
                   int flag,
                   Session sess)
            throws XAException
        Notifies the RM that a transaction is starting.
        Throws:
        XAException - If the specified transaction is already known by the RM in an incompatible state with the start request.
      • end

        void end​(Xid xid,
                 int flag,
                 Session sess)
          throws XAException
        Notifies the RM that a transaction is ended.
        Throws:
        XAException - If the specified transaction is in an incompatible state with the end request.
      • prepare

        void prepare​(Xid xid)
              throws XAException
        Notifies the RM that a transaction is prepared.
        Throws:
        XAException - If the specified transaction is in an incompatible state with the prepare request, or if the request fails.
      • commit

        void commit​(Xid xid)
             throws XAException
        Notifies the RM that a transaction is commited.
        Throws:
        XAException - If the specified transaction is in an incompatible state with the commit request, or if the request fails.
      • rollback

        void rollback​(Xid xid)
               throws XAException
        Notifies the RM that a transaction is rolled back.
        Throws:
        XAException - If the specified transaction is in an incompatible state with the rollback request, or if the request fails.
      • recover

        Xid[] recover​(int flag)
               throws XAException
        Notifies the RM to recover the prepared transactions.
        Throws:
        XAException - If the specified flag is invalid, or if the request fails.
      • setStatus

        private void setStatus​(Xid xid,
                               int status)
                        throws XAException
        Sets the status of a transaction.
        Throws:
        XAException - If the transaction is unknown.
      • getStatus

        private int getStatus​(Xid xid)
                       throws XAException
        Gets the status of a transaction.
        Throws:
        XAException - If the transaction is unknown.
      • equals

        public boolean equals​(Object o)
        Resource managers are equal if they belong to the same connection.
        Overrides:
        equals in class Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object