Added StmConfigurationException
This commit is contained in:
parent
f58503a1c3
commit
8605b85ab0
4 changed files with 18 additions and 17 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
|
@ -33,4 +33,4 @@ tm.out
|
|||
.classpath
|
||||
.idea
|
||||
.scala_dependencies
|
||||
|
||||
multiverse.log
|
||||
|
|
@ -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")
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue