public class TransactionHelper extends Object
Modifier and Type | Field and Description |
---|---|
static String[] |
TM_NAMES
Various binding names for the TransactionManager.
|
static String[] |
UT_NAMES
Various binding names for the UserTransaction.
|
Modifier and Type | Method and Description |
---|---|
static void |
commitOrRollbackTransaction()
Commits or rolls back the User Transaction depending on the transaction
status.
|
static String |
getUserTransactionJNDIName()
Returns the UserTransaction JNDI binding name.
|
static boolean |
isTransactionActive()
Checks if the current User Transaction is active.
|
static boolean |
isTransactionActiveOrMarkedRollback()
Checks if the current User Transaction is active or marked rollback only.
|
static boolean |
isTransactionMarkedRollback()
Checks if the current User Transaction is marked rollback only.
|
static TransactionManager |
lookupTransactionManager()
Looks up the TransactionManager in JNDI.
|
static UserTransaction |
lookupUserTransaction()
Looks up the User Transaction in JNDI.
|
static Transaction |
requireNewTransaction()
Suspend the current transaction if active and start a new transaction
|
static void |
resumeTransaction(Transaction tx)
Commit the current transaction if active and resume the principal
transaction
|
static boolean |
setTransactionRollbackOnly()
Sets the current User Transaction as rollback only.
|
static boolean |
startTransaction()
Starts a new User Transaction.
|
static boolean |
startTransaction(int timeout)
Starts a new User Transaction with the specified timeout.
|
public static final String[] UT_NAMES
public static final String[] TM_NAMES
public static UserTransaction lookupUserTransaction() throws NamingException
NamingException
- if not foundpublic static String getUserTransactionJNDIName()
Assumes lookupUserTransaction()
has been called once before.
public static TransactionManager lookupTransactionManager() throws NamingException
NamingException
- if not foundpublic static boolean isTransactionActive()
public static boolean isTransactionMarkedRollback()
public static boolean isTransactionActiveOrMarkedRollback()
public static boolean startTransaction()
true
if the transaction was successfully started,
false
otherwisepublic static Transaction requireNewTransaction()
TransactionRuntimeException
public static void resumeTransaction(Transaction tx)
tx
- public static boolean startTransaction(int timeout)
timeout
- the timeout in seconds, <= 0 for the defaulttrue
if the transaction was successfully started,
false
otherwisepublic static void commitOrRollbackTransaction()
public static boolean setTransactionRollbackOnly()
true
if the transaction was successfully marked rollback
only, false
otherwiseCopyright © 2013 Nuxeo SA. All Rights Reserved.