Package javax.transaction.xa

Examples of javax.transaction.xa.XAException


    public String toString() {
        return getTraceObjectName() + ": " + physicalConn;
    }

    private static XAException convertException(SQLException e) {
        XAException xa = new XAException(e.getMessage());
        xa.initCause(e);
        return xa;
    }
View Full Code Here


        return buff.toString().substring(1);
    }

    private void checkOpen() throws XAException {
        if (physicalConn == null) {
            throw new XAException(XAException.XAER_RMERR);
        }
    }
View Full Code Here

        try {
            physicalConnection.commit();
        } catch (SQLException e) {
            logger.error("Cannot commit transaction", e);
            notifyError(proxy, e);
            throw new XAException("Error on commit");
        }
    }
View Full Code Here

        // Make sure that we are not in AutoCommit mode
        try {
            if (physicalConnection.getAutoCommit()) {
                logger.error("Rollback called on XAResource with AutoCommit set");
                throw (new XAException(XAException.XA_HEURCOM));
            }
        } catch (SQLException e) {
            logger.error("Cannot getAutoCommit", e);
            notifyError(proxy, e);
            throw (new XAException("Error on getAutoCommit"));
        }

        // Rollback the transaction
        try {
            physicalConnection.rollback();
        } catch (SQLException e) {
            logger.error("Cannot rollback transaction", e);
            notifyError(proxy, e);
            throw (new XAException("Error on rollback"));
        }
    }
View Full Code Here

         else if (_xaFailureMode.equals(ASFailureMode.XAEXCEPTION))
         {
            _xaException = xaCodeMap.get(args[0]);

            if (_xaException == null)
               _xaException = new XAException(XAException.XAER_RMFAIL);
         }
         else if (_xaFailureMode.equals(ASFailureMode.EJBEXCEPTION))
         {
            _ejbException = new EJBException(args[0]);
         }
View Full Code Here

   public String getEISProductVersion() { return "v666.0";}

   @SuppressWarnings({"ThrowableInstanceNeverThrown"})
   private static void init()
   {
      xaCodeMap.put("XA_HEURCOM", new XAException(XAException.XA_HEURCOM));
      xaCodeMap.put("XA_HEURHAZ", new XAException(XAException.XA_HEURHAZ));
      xaCodeMap.put("XA_HEURMIX", new XAException(XAException.XA_HEURMIX));
      xaCodeMap.put("XA_HEURRB", new XAException(XAException.XA_HEURRB));
      xaCodeMap.put("XA_NOMIGRATE", new XAException(XAException.XA_NOMIGRATE));
      xaCodeMap.put("XA_RBBASE", new XAException(XAException.XA_RBBASE));
      xaCodeMap.put("XA_RBCOMMFAIL", new XAException(XAException.XA_RBCOMMFAIL));
      xaCodeMap.put("XA_RBDEADLOCK", new XAException(XAException.XA_RBDEADLOCK));
      xaCodeMap.put("XA_RBEND", new XAException(XAException.XA_RBEND));
      xaCodeMap.put("XA_RBINTEGRITY", new XAException(XAException.XA_RBINTEGRITY));
      xaCodeMap.put("XA_RBOTHER", new XAException(XAException.XA_RBOTHER));
      xaCodeMap.put("XA_RBPROTO", new XAException(XAException.XA_RBPROTO));
      xaCodeMap.put("XA_RBROLLBACK", new XAException(XAException.XA_RBROLLBACK));
      xaCodeMap.put("XA_RBTIMEOUT", new XAException(XAException.XA_RBTIMEOUT));
      xaCodeMap.put("XA_RBTRANSIENT", new XAException(XAException.XA_RBTRANSIENT));
      xaCodeMap.put("XA_RDONLY", new XAException(XAException.XA_RDONLY));
      xaCodeMap.put("XA_RETRY", new XAException(XAException.XA_RETRY));
      xaCodeMap.put("XAER_ASYNC", new XAException(XAException.XAER_ASYNC));
      xaCodeMap.put("XAER_DUPID", new XAException(XAException.XAER_DUPID));
      xaCodeMap.put("XAER_INVAL", new XAException(XAException.XAER_INVAL));
      xaCodeMap.put("XAER_NOTA", new XAException(XAException.XAER_NOTA));
      xaCodeMap.put("XAER_OUTSIDE", new XAException(XAException.XAER_OUTSIDE));
      xaCodeMap.put("XAER_PROTO", new XAException(XAException.XAER_PROTO));
      xaCodeMap.put("XAER_RMERR", new XAException(XAException.XAER_RMERR));
      xaCodeMap.put("XAER_RMFAIL ", new XAException(XAException.XAER_RMFAIL));
   }
View Full Code Here

      synchronized (this)
      {
         if(failInStart)
         {
            XAException xaex = new XAException(xaCode + "for" + this);
            xaex.errorCode = xaCode;
            broadcastConnectionError(xaex);
            throw xaex;
         }

         GlobalXID gid = new GlobalXID(xid);
         String flagString = TxUtils.getXAResourceFlagsAsString(flags);
         log.info("start with xid=" + gid + " flags=" + flagString + " for " + this);
         checkDestroyedXAException();
         Map xids = getXids();
         synchronized (xids)
         {
            String state = (String) xids.get(gid);
            if (state == null && flags != TMNOFLAGS)
            {
                XAException xaex = new XAException("Invalid start state=" + state + " xid=" + gid + " flags=" + flagString + " for " + this);
                xaex.errorCode = XAException.XAER_PROTO;
                throw xaex;
            }
            if (state != null && state != SUSPENDED && state != ENDED
                  && (state != STARTED || ((flags & TMJOIN) == 0))
                  && (state != STARTED || ((flags & TMRESUME) == 0))
               )
            {
                XAException xaex = new XAException("Invalid start state=" + state + " xid=" + gid + " flags=" + flagString + " for " + this);
                xaex.errorCode = XAException.XAER_PROTO;
                throw xaex;
            }

            if ((flags & TMJOIN) != 0 && mcf.failJoin)
            {
                XAException xaex = new XAException("Join is not allowed " + state + " xid=" + gid + " flags=" + flagString + " for " + this);
                xaex.errorCode = XAException.XAER_PROTO;
                throw xaex;
            }
            xids.put(gid, STARTED);
         }
View Full Code Here

   public void end(final Xid xid, final int flags) throws XAException
   {

      if(failInEnd)
      {
          XAException xaex = new XAException(xaCode + "for" + this);
          xaex.errorCode = xaCode;
          broadcastConnectionError(xaex);
          throw xaex;
      }

      long sleepInEnd = mcf.getSleepInEnd();
      if (flags != TMSUCCESS && sleepInEnd != 0)
         doSleep(sleepInEnd);

      synchronized (this)
      {
         GlobalXID gid = new GlobalXID(xid);
         String flagString = TxUtils.getXAResourceFlagsAsString(flags);
         log.info("end with xid=" + gid + " flags=" + flagString + " for " + this);
         // checkDestroyedXAException(); (check is broken, don't use with JBossTS)
         Map xids = getXids();
         synchronized (xids)
         {
            String state = (String) xids.get(gid);
            if (state != STARTED && state != SUSPENDED && state != ENDED)
            {
                XAException xaex = new XAException("Invalid end state=" + state + " xid=" + gid + " " + this);
                xaex.errorCode = XAException.XAER_PROTO;
                throw xaex;
            }
            if ((flags & TMSUSPEND) == 0)
               xids.put(gid, ENDED);
View Full Code Here

      GlobalXID gid = new GlobalXID(xid);
      log.info("commit with xid=" + gid + " onePhase=" + onePhase + " for " + this);
      checkDestroyedXAException();
      if (failInCommit)
      {
          XAException xaex = new XAException(xaCode + " for " + this);
          xaex.errorCode = xaCode;
          throw xaex;
      }
      Map xids = getXids();
      synchronized (xids)
      {
         String state = (String) xids.get(gid);
         if (onePhase)
         {
            if (state != SUSPENDED && state != ENDED)
            {
               XAException xaex = new XAException("Invalid one phase commit state=" + state + " xid=" + gid + " " + this);
               xaex.errorCode = XAException.XAER_PROTO;
               throw xaex;
            }
         }
         else
         {
            if (state != PREPARED)
            {
               XAException xaex = new XAException("Invalid two phase commit state=" + state + " xid=" + gid + " " + this);
               xaex.errorCode = XAException.XAER_PROTO;
               throw xaex;
            }
         }
         xids.remove(gid);
View Full Code Here

      synchronized (xids)
      {
         String state = (String) xids.get(gid);
         if (state != SUSPENDED && state != ENDED && state != PREPARED)
         {
            XAException xaex = new XAException("Invalid rollback state=" + state + " xid=" + gid + " " + this);
            xaex.errorCode = XAException.XAER_PROTO;
            throw xaex;
         }
         xids.remove(gid);
      }
View Full Code Here

TOP

Related Classes of javax.transaction.xa.XAException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.