Package java.lang

Examples of java.lang.IllegalStateException


    @Override
    public void delete(String name) throws Exception {
        File connectionFactoryFile = getConnectionFactoryFile(name);
        if (!connectionFactoryFile.exists()) {
            throw new IllegalStateException("The JMS connection factory file " + connectionFactoryFile.getPath() + " doesn't exist");
        }
        connectionFactoryFile.delete();
    }
View Full Code Here


            copyDataSourceFile(outFile, "connectionfactory-activemq.xml", properties);
        } else {
            // webspheremq
            String[] splitted = url.split("/");
            if (splitted.length != 4) {
                throw new IllegalStateException("WebsphereMQ URI should be in the following format: host/port/queuemanager/channel");
            }
            HashMap<String, String> properties = new HashMap<String, String>();
            properties.put("${name}", name);
            properties.put("${host}", splitted[0]);
            properties.put("${port}", splitted[1]);
View Full Code Here

    public void delete(String name) throws Exception {
        File karafBase = new File(System.getProperty("karaf.base"));
        File deployFolder = new File(karafBase, "deploy");
        File connectionFactoryFile = new File(deployFolder, "connectionfactory-" + name + ".xml");
        if (!connectionFactoryFile.exists()) {
            throw new IllegalStateException("The JMS connection factory file " + connectionFactoryFile.getPath() + " doesn't exist");
        }
        connectionFactoryFile.delete();
    }
View Full Code Here

        throw new InactiveTransactionException(
            jtaLogger.loggerI18N.getString("com.arjuna.ats.internal.jta.transaction.jts.wrongstatetx"));
      }
      catch (org.omg.CosTransactions.NoTransaction e1)
      {
        throw new IllegalStateException(
            jtaLogger.loggerI18N.getString("com.arjuna.ats.internal.jta.transaction.jts.notx"));
      }
      catch (org.omg.CosTransactions.HeuristicMixed e2)
      {
        throw new javax.transaction.HeuristicMixedException();
      }
      catch (org.omg.CosTransactions.HeuristicHazard e3)
      {
        throw new javax.transaction.HeuristicMixedException();
      }
      catch (TRANSACTION_ROLLEDBACK e4)
      {
        throw new RollbackException(e4.toString());
      }
      catch (org.omg.CORBA.NO_PERMISSION e5)
      {
        throw new SecurityException();
      }
      catch (INVALID_TRANSACTION e6)
      {
        throw new InactiveTransactionException(
            jtaLogger.loggerI18N.getString("com.arjuna.ats.internal.jta.transaction.jts.invalidtx2"));
      }
      catch (org.omg.CORBA.SystemException e7)
      {
        throw new javax.transaction.SystemException();
      }
      finally
      {
        TransactionImple.removeTransaction(this);
      }
    }
    else
      throw new IllegalStateException(
          jtaLogger.loggerI18N.getString("com.arjuna.ats.internal.jta.transaction.jts.inactivetx"));
  }
View Full Code Here

        throw new InactiveTransactionException(
            jtaLogger.loggerI18N.getString("com.arjuna.ats.internal.jta.transaction.jts.invalidtx2"));
      }
      catch (NoTransaction e4)
      {
        throw new IllegalStateException(
            jtaLogger.loggerI18N.getString("com.arjuna.ats.internal.jta.transaction.jts.notx"));
      }
      catch (org.omg.CORBA.SystemException e5)
      {
        throw new javax.transaction.SystemException();
      }
      finally
      {
        TransactionImple.removeTransaction(this);
      }

      if (endSuspendedFailed)
        throw new InvalidTerminationStateException (
            jtaLogger.loggerI18N.getString("com.arjuna.ats.internal.jta.transaction.jts.endsuspendfailed2"));
    }
    else
      throw new IllegalStateException(
          jtaLogger.loggerI18N.getString("com.arjuna.ats.internal.jta.transaction.jts.inactivetx"));
  }
View Full Code Here

                    _rollbackOnlyCallerStacktrace = new Throwable("setRollbackOnly called from:");
                }
      }
      catch (org.omg.CosTransactions.NoTransaction e3)
      {
        throw new IllegalStateException(
            jtaLogger.loggerI18N.getString("com.arjuna.ats.internal.jta.transaction.jts.notx"));
      }
      catch (org.omg.CORBA.SystemException e4)
      {
        throw new javax.transaction.SystemException();
      }
    }
    else
      throw new IllegalStateException(
          jtaLogger.loggerI18N.getString("com.arjuna.ats.internal.jta.transaction.jts.inactivetx"));
  }
View Full Code Here

      {
        throw new javax.transaction.RollbackException(e2.toString());
      }
      catch (org.omg.CosTransactions.Inactive e3)
      {
        throw new IllegalStateException(
            jtaLogger.loggerI18N.getString("com.arjuna.ats.internal.jta.transaction.jts.inactivetx"));
      }
      catch (org.omg.CosTransactions.SynchronizationUnavailable e4)
      {
        throw new IllegalStateException(
            jtaLogger.loggerI18N.getString("com.arjuna.ats.internal.jta.transaction.jts.syncerror"));
      }
      catch (INVALID_TRANSACTION e5)
      {
        throw new IllegalStateException(
            jtaLogger.loggerI18N.getString("com.arjuna.ats.internal.jta.transaction.jts.invalidtx2"));
      }
      catch (org.omg.CORBA.SystemException e6)
      {
        throw new javax.transaction.SystemException();
      }
    }
    else
      throw new IllegalStateException(
          jtaLogger.loggerI18N.getString("com.arjuna.ats.internal.jta.transaction.jts.inactivetx"));
  }
View Full Code Here

      throw new RollbackException("TransactionImple.enlistResource - "
                    + jtaLogger.loggerI18N.getString("com.arjuna.ats.internal.jta.transaction.jts.markedrollback"));
    case javax.transaction.Status.STATUS_ACTIVE:
      break;
    default:
      throw new IllegalStateException(
          jtaLogger.loggerI18N.getString("com.arjuna.ats.internal.jta.transaction.jts.inactivetx"));
    }

    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.
             */

            xaRes.start(info.xid(), XAResource.TMRESUME);

            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.
             */
            xaRes.start(info.xid(), XAResource.TMJOIN);

            info.setState(TxInfo.ASSOCIATED);

            return true;
          }
          default:
          {
            // Note: this exception will be caught by our catch
            // block
            throw new IllegalStateException(
                "TransactionImple.enlistResource - "
                    + jtaLogger.loggerI18N.getString("com.arjuna.ats.internal.jta.transaction.jts.illegalstate")
                    + 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.loggerI18N.getString("com.arjuna.ats.internal.jta.transaction.jts.inactivetx"));
    }

    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.jts.unknownres", 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 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.loggerI18N.getString("com.arjuna.ats.internal.jta.transaction.jts.ressusp"));
            }
            else
            {
              xaRes.end(info.xid(), XAResource.TMFAIL);
              info.setState(TxInfo.FAILED);

              synchronized (this)
              {
                _suspendCount--;
              }
            }
          }
        }
          break;
        default:
          if (!optimizedRollback)
            throw new IllegalStateException(
                "TransactionImple.delistResource - "
                    + jtaLogger.loggerI18N.getString("com.arjuna.ats.internal.jta.transaction.jts.illegalstate")
                    + info.getState());
        }

View Full Code Here

      {
        _theTransaction.commit(true);
      }
      catch (org.omg.CosTransactions.WrongTransaction wt)
      {
        throw new IllegalStateException(
            jtaLogger.loggerI18N.getString("com.arjuna.ats.internal.jta.transaction.jts.wrongstatetx"));
      }
      catch (org.omg.CosTransactions.NoTransaction e1)
      {
        throw new IllegalStateException(
            jtaLogger.loggerI18N.getString("com.arjuna.ats.internal.jta.transaction.jts.notx"));
      }
      catch (org.omg.CosTransactions.HeuristicMixed e2)
      {
        throw new javax.transaction.HeuristicMixedException();
      }
      catch (org.omg.CosTransactions.HeuristicHazard e3)
      {
        throw new javax.transaction.HeuristicMixedException();
      }
      catch (TRANSACTION_ROLLEDBACK e4)
      {
        RollbackException rollbackException = new RollbackException(e4.toString());
                if(_rollbackOnlyCallerStacktrace != null) {
                    // we rolled back beacuse the user explicitly told us not to commit. Attach the trace of who did that for debug:
                    rollbackException.initCause(_rollbackOnlyCallerStacktrace);
                }
                throw rollbackException;
      }
      catch (org.omg.CORBA.NO_PERMISSION e5)
      {
        throw new SecurityException();
      }
      catch (INVALID_TRANSACTION e6)
      {
          /*
           * In JTS/OTS we can indicate that something was terminated by another thread.
           * JTA doesn't really prevent this, but ...
           */
         
        //throw new IllegalStateException(
        //    jtaLogger.loggerI18N.getString("com.arjuna.ats.internal.jta.transaction.jts.invalidtx2"));
      }
      catch (org.omg.CORBA.SystemException e7)
      {
        throw new InvalidTerminationStateException();
      }
      finally
      {
        TransactionImple.removeTransaction(this);
      }
    }
    else
      throw new IllegalStateException(
          jtaLogger.loggerI18N.getString("com.arjuna.ats.internal.jta.transaction.jts.inactivetx"));
  }
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.