org.multiverse.api
Class StmUtils

java.lang.Object
  extended by org.multiverse.api.StmUtils

public final class StmUtils
extends Object

A utility class with convenience methods to access the Stm or Transaction. These methods can be imported using the static import for a less ugly (but potentially more confusing) syntax.

Author:
Peter Veentjer.

Method Summary
static void abort()
          Aborts the Transaction in the ThreadLocalTransaction transaction.
static void commit()
          Commits the Transaction in the ThreadLocalTransaction transaction.
static void prepare()
          Prepares the Transaction in the ThreadLocalTransaction transaction.
static void retry()
          Does a retry.
static void scheduleCompensatingTask(Runnable task)
          Scheduled an compensating task on the Transaction in the ThreadLocalTransaction.
static void scheduleDeferredTask(Runnable task)
          Scheduled an deferred task on the Transaction in the ThreadLocalTransaction.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

retry

public static void retry()
Does a retry.

Under the hood the retry throws an Retry that will be caught up the chain (by the TransactionTemplate for example).

Throws:
NoTransactionFoundException - if no transaction is found in the ThreadLocalTransaction.

prepare

public static void prepare()
Prepares the Transaction in the ThreadLocalTransaction transaction.

For more information see Transaction.prepare().


abort

public static void abort()
Aborts the Transaction in the ThreadLocalTransaction transaction.

For more information see Transaction.abort() ()}.


commit

public static void commit()
Commits the Transaction in the ThreadLocalTransaction transaction.

For more information see Transaction.abort() ()}.


scheduleDeferredTask

public static void scheduleDeferredTask(Runnable task)
Scheduled an deferred task on the Transaction in the ThreadLocalTransaction. This task is executed after the transaction commits and one of the use cases is starting transactions.

For more information see Transaction.registerLifecycleListener(TransactionLifecycleListener).

Parameters:
task - the deferred task to execute.
Throws:
NullPointerException - if task is null.

scheduleCompensatingTask

public static void scheduleCompensatingTask(Runnable task)
Scheduled an compensating task on the Transaction in the ThreadLocalTransaction. This task is executed after the transaction aborts and one of the use cases is cleaning up non transaction resources like the file system.

For more information see Transaction.registerLifecycleListener(TransactionLifecycleListener).

Parameters:
task - the deferred task to execute.
Throws:
NullPointerException - if task is null.


Copyright © 2008-2010 Multiverse. All Rights Reserved.