Package java.lang

Examples of java.lang.IllegalStateException


      {
      case ActionStatus.RUNNING:
      case ActionStatus.ABORT_ONLY:
        break;
      default:
        throw new IllegalStateException(
            jtaLogger.logMesg
                .getString("com.arjuna.ats.internal.jta.transaction.arjunacore.inactive"));
      }

      /*
       * Call end on any suspended resources. If this fails, then the
       * transaction will be rolled back.
       */

      if (!endSuspendedRMs())
        _theTransaction.preventCommit();

      // use end of TwoPhaseCoordinator to avoid thread changes.

      int status = _theTransaction.end(true);

      TransactionImple.removeTransaction(this);

      switch (status)
      {
      case ActionStatus.COMMITTED:
      case ActionStatus.COMMITTING: // in case of async commit
        break;
      case ActionStatus.H_MIXED:
        throw new javax.transaction.HeuristicMixedException();
      case ActionStatus.H_HAZARD:
        throw new javax.transaction.HeuristicMixedException();
      case ActionStatus.H_ROLLBACK:
      case ActionStatus.ABORTED:
        RollbackException rollbackException = new RollbackException(
            jtaLogger.logMesg
                .getString("com.arjuna.ats.internal.jta.transaction.arjunacore.commitwhenaborted"));
        if (_theTransaction.getDeferredThrowable() != null)
        {
          rollbackException.initCause(_theTransaction
              .getDeferredThrowable());
        }
        throw rollbackException;
      default:
        throw new IllegalStateException(
            jtaLogger.logMesg
                .getString("com.arjuna.ats.internal.jta.transaction.arjunacore.invalidstate"));
      }
    }
    else
      throw new IllegalStateException(
          jtaLogger.logMesg
              .getString("com.arjuna.ats.internal.jta.transaction.arjunacore.inactive"));
  }
View Full Code Here


      {
      case ActionStatus.RUNNING:
      case ActionStatus.ABORT_ONLY:
        break;
      default:
        throw new IllegalStateException(
            jtaLogger.logMesg
                .getString("com.arjuna.ats.internal.jta.transaction.arjunacore.inactive"));
      }

      /*
       * Call end on any suspended resources. If this fails, then there's
       * not a lot else we can do because the transaction is about to roll
       * back anyway!
       */

      boolean endSuspendedFailed = !endSuspendedRMs();

      if (endSuspendedFailed)
      {
        if (jtaLogger.loggerI18N.isWarnEnabled())
        {
          jtaLogger.loggerI18N
              .warn("com.arjuna.ats.internal.jta.transaction.arjunacore.endsuspendfailed1");
        }
      }

      int outcome = _theTransaction.cancel(); // use cancel of
      // TwoPhaseCoordinator to
      // avoid thread changes.

      TransactionImple.removeTransaction(this);

      switch (outcome)
      {
      case ActionStatus.ABORTED:
      case ActionStatus.ABORTING: // in case of async rollback
        break;
      default:
        throw new IllegalStateException(
            jtaLogger.logMesg
                .getString("com.arjuna.ats.internal.jta.transaction.arjunacore.rollbackstatus")
                + ActionStatus.stringForm(outcome));
      }

      if (endSuspendedFailed)
        throw new IllegalStateException(
            jtaLogger.logMesg
                .getString("com.arjuna.ats.internal.jta.transaction.arjunacore.endsuspendfailed2"));
    }
    else
      throw new IllegalStateException(
          jtaLogger.logMesg
              .getString("com.arjuna.ats.internal.jta.transaction.arjunacore.inactive"));
  }
View Full Code Here

        {
        case ActionStatus.ABORTED:
        case ActionStatus.ABORTING:
          break;
        default:
          throw new IllegalStateException(
              jtaLogger.logMesg
                  .getString("com.arjuna.ats.internal.jta.transaction.arjunacore.inactive"));
        }
      }
    }
    else
      throw new IllegalStateException(
          jtaLogger.logMesg
              .getString("com.arjuna.ats.internal.jta.transaction.arjunacore.inactive"));
  }
View Full Code Here

        case ActionStatus.ABORTED:
          throw new javax.transaction.RollbackException(
              jtaLogger.logMesg
                  .getString("com.arjuna.ats.internal.jta.transaction.arjunacore.syncwhenaborted"));
        case ActionStatus.CREATED:
          throw new IllegalStateException(
              jtaLogger.logMesg
                  .getString("com.arjuna.ats.internal.jta.transaction.arjunacore.inactive"));
        default:
          throw new IllegalStateException(
              jtaLogger.logMesg
                  .getString("com.arjuna.ats.internal.jta.transaction.arjunacore.syncsnotallowed"));
        }
      }
    }
    else
      throw new IllegalStateException(
          jtaLogger.logMesg
              .getString("com.arjuna.ats.internal.jta.transaction.arjunacore.inactive"));
  }
View Full Code Here

              + jtaLogger.logMesg
                  .getString("com.arjuna.ats.internal.jta.transaction.arjunacore.nullres"));
    case javax.transaction.Status.STATUS_ACTIVE:
      break;
    default:
      throw new IllegalStateException(
          jtaLogger.logMesg
              .getString("com.arjuna.ats.internal.jta.transaction.arjunacore.inactive"));
    }

    XAModifier theModifier = null;

    if (params != null)
    {
      if (params.length >= XAMODIFIER + 1)
      {
        if (params[XAMODIFIER] instanceof XAModifier)
        {
          theModifier = (XAModifier) params[XAMODIFIER];
        }
      }
    }

    try
    {
      /*
       * For each transaction we maintain a list of resources registered
       * with it. Each element on this list also contains a list of
       * threads which have registered this resource, and what their XID
       * was for that registration.
       */

      TxInfo info = null;

      /*
       * Have we seen this specific resource instance before? Do this
       * trawl first before checking the RM instance later. Saves time.
       */

      try
      {
        synchronized (this)
        {
          info = (TxInfo) _resources.get(xaRes);

          if (info == null)
          {
            /*
             * Null info means it's not in the main resources list,
             * but may be in the duplicates.
             */

            info = (TxInfo) _duplicateResources.get(xaRes);
          }
        }

        if (info != null)
        {
          switch (info.getState())
          {
          case TxInfo.ASSOCIATION_SUSPENDED:
          {
            /*
             * Have seen resource before, so do a resume. The
             * Resource instance will still be registered with the
             * transaction though.
             */

            int xaStartResume = ((theModifier == null) ? XAResource.TMRESUME
                : theModifier
                    .xaStartParameters(XAResource.TMRESUME));

            xaRes.start(info.xid(), xaStartResume);

            info.setState(TxInfo.ASSOCIATED);

            synchronized (this)
            {
              _suspendCount--;
            }

            return true; // already registered resource with this
            // transaction!
          }
          case TxInfo.ASSOCIATED:
          {
            /*
             * Already active on this transaction.
             */

            return true;
          }
          case TxInfo.NOT_ASSOCIATED:
          {
            /*
             * Resource was associated, but was presumably delisted.
             */

            int xaStartJoin = ((theModifier == null) ? XAResource.TMJOIN
                : theModifier
                    .xaStartParameters(XAResource.TMJOIN));

            xaRes.start(info.xid(), xaStartJoin);

            info.setState(TxInfo.ASSOCIATED);

            return true;
          }
          default:
          {
            // Note: this exception will be caught by our catch
            // block

            throw new IllegalStateException(
                "TransactionImple.enlistResource - "
                    + jtaLogger.logMesg
                        .getString("com.arjuna.ats.internal.jta.transaction.arjunacore.illresstate")
                    + ":" + info.getState());
          }
View Full Code Here

    case javax.transaction.Status.STATUS_ACTIVE:
      break;
    case javax.transaction.Status.STATUS_MARKED_ROLLBACK:
      break;
    default:
      throw new IllegalStateException(
          jtaLogger.logMesg
              .getString("com.arjuna.ats.internal.jta.transaction.arjunacore.inactive"));
    }

    TxInfo info = null;

    try
    {
      synchronized (this)
      {
        info = (TxInfo) _resources.get(xaRes);

        if (info == null)
          info = (TxInfo) _duplicateResources.get(xaRes);
      }

      if (info == null)
      {
        if (jtaLogger.loggerI18N.isWarnEnabled())
        {
          jtaLogger.loggerI18N
              .warn(
                  "com.arjuna.ats.internal.jta.transaction.arjunacore.unknownresource",
                  new Object[]
                  { "TransactionImple.delistResource" });
        }

        return false;
      }
      else
      {
        boolean optimizedRollback = false;

        try
        {
          /*
           * If we know the transaction is going to rollback, then we
           * can try to rollback the RM now. Just an optimisation.
           */

          if (status == javax.transaction.Status.STATUS_MARKED_ROLLBACK)
          {
            if (XAUtils.canOptimizeDelist(xaRes))
            {
              xaRes.end(info.xid(), XAResource.TMFAIL);
              xaRes.rollback(info.xid());

              info.setState(TxInfo.OPTIMIZED_ROLLBACK);

              optimizedRollback = true;
            }
          }
        }
        catch (Exception e)
        {
          // failed, so try again when transaction does rollback
        }

        switch (info.getState())
        {
        case TxInfo.ASSOCIATED:
        {
          if ((flags & XAResource.TMSUCCESS) != 0)
          {
            xaRes.end(info.xid(), XAResource.TMSUCCESS);
            info.setState(TxInfo.NOT_ASSOCIATED);
          }
          else
          {
            if ((flags & XAResource.TMSUSPEND) != 0)
            {
              xaRes.end(info.xid(), XAResource.TMSUSPEND);
              info.setState(TxInfo.ASSOCIATION_SUSPENDED);

              synchronized (this)
              {
                _suspendCount++;
              }
            }
            else
            {
              xaRes.end(info.xid(), XAResource.TMFAIL);
              info.setState(TxInfo.FAILED);
            }
          }
        }
          break;
        case TxInfo.ASSOCIATION_SUSPENDED:
        {
          if ((flags & XAResource.TMSUCCESS) != 0)
          {
            // Oracle barfs if we don't send resume first, despite
            // what XA says!

            if (XAUtils.mustEndSuspendedRMs(xaRes))
              xaRes.start(info.xid(), XAResource.TMRESUME);

            xaRes.end(info.xid(), XAResource.TMSUCCESS);
            info.setState(TxInfo.NOT_ASSOCIATED);

            synchronized (this)
            {
              _suspendCount--;
            }
          }
          else
          {
            if ((flags & XAResource.TMSUSPEND) != 0)
            {
              // Note: this exception will be caught by our catch
              // block

              throw new IllegalStateException(
                  "TransactionImple.delistResource - "
                      + jtaLogger.logMesg
                          .getString("com.arjuna.ats.internal.jta.transaction.arjunacore.ressuspended"));
            }
            else
            {
              xaRes.end(info.xid(), XAResource.TMFAIL);
              info.setState(TxInfo.FAILED);

              synchronized (this)
              {
                _suspendCount--;
              }
            }
          }
        }
          break;
        default:
        {
          if (!optimizedRollback)
            throw new IllegalStateException(
                "TransactionImple.delistResource - "
                    + jtaLogger.logMesg
                        .getString("com.arjuna.ats.internal.jta.transaction.arjunacore.illresstate")
                    + ":" + info.getState());
        }
View Full Code Here

        switch (_theTransaction.status())
        {
          case ActionStatus.ABORTED:
          case ActionStatus.ABORTING:
            _theTransaction.abort(); // assure thread disassociation
            throw new IllegalStateException(
                jtaLogger.logMesg.getString("com.arjuna.ats.internal.jta.transaction.arjunacore.inactive"));

          case ActionStatus.COMMITTED:
          case ActionStatus.COMMITTING: // in case of async commit
            _theTransaction.commit(true); // assure thread disassociation
            throw new IllegalStateException(
                jtaLogger.logMesg.getString("com.arjuna.ats.internal.jta.transaction.arjunacore.inactive"));
        }

        switch (_theTransaction.commit(true))
        {
          case ActionStatus.COMMITTED:
          case ActionStatus.COMMITTING: // in case of async commit
            break;
          case ActionStatus.H_MIXED:
            throw new javax.transaction.HeuristicMixedException();
          case ActionStatus.H_HAZARD:
            throw new javax.transaction.HeuristicMixedException();
          case ActionStatus.H_ROLLBACK:
          case ActionStatus.ABORTED:
          case ActionStatus.ABORTING:
            RollbackException rollbackException = new RollbackException(jtaLogger.logMesg.getString("com.arjuna.ats.internal.jta.transaction.arjunacore.commitwhenaborted"));
            if(_theTransaction.getDeferredThrowable() != null) {
              rollbackException.initCause(_theTransaction.getDeferredThrowable());
            }
            throw rollbackException;
          default:
            throw new IllegalStateException(
                jtaLogger.logMesg.getString("com.arjuna.ats.internal.jta.transaction.arjunacore.invalidstate"));
        }
      }
      else
        throw new IllegalStateException(
            jtaLogger.logMesg.getString("com.arjuna.ats.internal.jta.transaction.arjunacore.inactive"));
    }
    finally
    {
      TransactionImple.removeTransaction(this);
View Full Code Here

        {
          case ActionStatus.ABORTED:
          case ActionStatus.ABORTING: // in case of async rollback
            break;
          default:
            throw new IllegalStateException(
                jtaLogger.logMesg.getString("com.arjuna.ats.internal.jta.transaction.arjunacore.rollbackstatus")
                    + ActionStatus.stringForm(outcome));
        }
      }

      if(_theTransaction == null || !statusIsValid) {
        throw new IllegalStateException(
            jtaLogger.logMesg.getString("com.arjuna.ats.internal.jta.transaction.arjunacore.inactive"));
      }
    }
    finally
    {
View Full Code Here

      javax.transaction.HeuristicMixedException,
      javax.transaction.HeuristicRollbackException,
      java.lang.SecurityException, javax.transaction.SystemException,
      java.lang.IllegalStateException
  {
    throw new IllegalStateException(
        jtaLogger.logMesg.getString("com.arjuna.ats.internal.jta.transaction.arjunacore.subordinate.invalidstate"));
  }
View Full Code Here

   */

  public void rollback () throws java.lang.IllegalStateException,
      java.lang.SecurityException, javax.transaction.SystemException
  {
    throw new IllegalStateException(
        jtaLogger.logMesg.getString("com.arjuna.ats.internal.jta.transaction.arjunacore.subordinate.invalidstate"));
  }
View Full Code Here

TOP

Related Classes of java.lang.IllegalStateException

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.