diff --git a/.gitignore b/.gitignore index b3b2c2ebc7..45fe24daba 100755 --- a/.gitignore +++ b/.gitignore @@ -33,4 +33,4 @@ tm.out .classpath .idea .scala_dependencies - +multiverse.log \ No newline at end of file diff --git a/akka-core/src/main/scala/stm/JTA.scala b/akka-core/src/main/scala/stm/JTA.scala index 510e9cf78c..fd2db0fc74 100644 --- a/akka-core/src/main/scala/stm/JTA.scala +++ b/akka-core/src/main/scala/stm/JTA.scala @@ -44,12 +44,12 @@ object TransactionContainer extends Logging { .transactionContainer } catch { case e: ClassNotFoundException => - throw new IllegalStateException( + throw new StmConfigurationException( "JTA provider defined as 'atomikos', but the AtomikosTransactionService classes can not be found." + "\n\tPlease make sure you have 'akka-jta' JAR and its dependencies on your classpath.") } case _ => - throw new IllegalStateException( + throw new StmConfigurationException( "No UserTransaction on TransactionManager could be found in scope." + "\n\tEither add 'akka-jta' to the classpath or make sure there is a" + "\n\tTransactionManager or UserTransaction defined in the JNDI.") @@ -122,53 +122,53 @@ class TransactionContainer private (val tm: Either[Option[UserTransaction], Opti def begin = tm match { case Left(Some(userTx)) => userTx.begin case Right(Some(txMan)) => txMan.begin - case _ => throw new IllegalStateException("Does not have a UserTransaction or TransactionManager in scope") + case _ => throw new StmConfigurationException("Does not have a UserTransaction or TransactionManager in scope") } def commit = tm match { case Left(Some(userTx)) => userTx.commit case Right(Some(txMan)) => txMan.commit - case _ => throw new IllegalStateException("Does not have a UserTransaction or TransactionManager in scope") + case _ => throw new StmConfigurationException("Does not have a UserTransaction or TransactionManager in scope") } def rollback = tm match { case Left(Some(userTx)) => userTx.rollback case Right(Some(txMan)) => txMan.rollback - case _ => throw new IllegalStateException("Does not have a UserTransaction or TransactionManager in scope") + case _ => throw new StmConfigurationException("Does not have a UserTransaction or TransactionManager in scope") } def getStatus = tm match { case Left(Some(userTx)) => userTx.getStatus case Right(Some(txMan)) => txMan.getStatus - case _ => throw new IllegalStateException("Does not have a UserTransaction or TransactionManager in scope") + case _ => throw new StmConfigurationException("Does not have a UserTransaction or TransactionManager in scope") } def isInExistingTransaction = tm match { case Left(Some(userTx)) => userTx.getStatus == Status.STATUS_ACTIVE case Right(Some(txMan)) => txMan.getStatus == Status.STATUS_ACTIVE - case _ => throw new IllegalStateException("Does not have a UserTransaction or TransactionManager in scope") + case _ => throw new StmConfigurationException("Does not have a UserTransaction or TransactionManager in scope") } def isRollbackOnly = tm match { case Left(Some(userTx)) => userTx.getStatus == Status.STATUS_MARKED_ROLLBACK case Right(Some(txMan)) => txMan.getStatus == Status.STATUS_MARKED_ROLLBACK - case _ => throw new IllegalStateException("Does not have a UserTransaction or TransactionManager in scope") + case _ => throw new StmConfigurationException("Does not have a UserTransaction or TransactionManager in scope") } def setRollbackOnly = tm match { case Left(Some(userTx)) => userTx.setRollbackOnly case Right(Some(txMan)) => txMan.setRollbackOnly - case _ => throw new IllegalStateException("Does not have a UserTransaction or TransactionManager in scope") + case _ => throw new StmConfigurationException("Does not have a UserTransaction or TransactionManager in scope") } def suspend = tm match { case Right(Some(txMan)) => txMan.suspend - case _ => throw new IllegalStateException("Does not have a TransactionManager in scope") + case _ => throw new StmConfigurationException("Does not have a TransactionManager in scope") } def resume(tx: JtaTransaction) = tm match { case Right(Some(txMan)) => txMan.resume(tx) - case _ => throw new IllegalStateException("Does not have a TransactionManager in scope") + case _ => throw new StmConfigurationException("Does not have a TransactionManager in scope") } } diff --git a/akka-core/src/main/scala/stm/Transaction.scala b/akka-core/src/main/scala/stm/Transaction.scala index 37b38b670b..fb9f14b62e 100644 --- a/akka-core/src/main/scala/stm/Transaction.scala +++ b/akka-core/src/main/scala/stm/Transaction.scala @@ -24,6 +24,7 @@ import org.multiverse.stms.alpha.AlphaStm class NoTransactionInScopeException extends RuntimeException class TransactionRetryException(message: String) extends RuntimeException(message) +class StmConfigurationException(message: String) extends RuntimeException(message) /** * FIXDOC: document AtomicTemplate @@ -357,17 +358,17 @@ object Transaction { private[akka] def register(uuid: String, storage: Committable) = persistentStateMap.put(uuid, storage) private def ensureIsActive = if (status != TransactionStatus.Active) - throw new IllegalStateException( + throw new StmConfigurationException( "Expected ACTIVE transaction - current status [" + status + "]: " + toString) private def ensureIsActiveOrAborted = if (!(status == TransactionStatus.Active || status == TransactionStatus.Aborted)) - throw new IllegalStateException( + throw new StmConfigurationException( "Expected ACTIVE or ABORTED transaction - current status [" + status + "]: " + toString) private def ensureIsActiveOrNew = if (!(status == TransactionStatus.Active || status == TransactionStatus.New)) - throw new IllegalStateException( + throw new StmConfigurationException( "Expected ACTIVE or NEW transaction - current status [" + status + "]: " + toString) // For reinitialize transaction after sending it over the wire diff --git a/akka-core/src/main/scala/stm/TransactionManagement.scala b/akka-core/src/main/scala/stm/TransactionManagement.scala index 371d57ad88..d551f7fd76 100644 --- a/akka-core/src/main/scala/stm/TransactionManagement.scala +++ b/akka-core/src/main/scala/stm/TransactionManagement.scala @@ -40,13 +40,13 @@ object TransactionManagement extends TransactionManagement { private[akka] def getTransactionSet: CountDownCommitBarrier = { val option = transactionSet.get - if ((option eq null) || option.isEmpty) throw new IllegalStateException("No Transaction set in scope") + if ((option eq null) || option.isEmpty) throw new StmConfigurationException("No Transaction set in scope") else option.get } private[akka] def getTransaction: Transaction = { val option = transaction.get - if ((option eq null) || option.isEmpty) throw new IllegalStateException("No Transaction in scope") + if ((option eq null) || option.isEmpty) throw new StmConfigurationException("No Transaction in scope") option.get } }