public class TransactionHelper extends Object
Modifier and Type | Method and Description |
---|---|
static void |
commitOrRollbackTransaction()
Commits or rolls back the User Transaction depending on the transaction status.
|
static List<Exception> |
getSuppressedExceptions()
Gets the suppressed exceptions, and stops remembering.
|
static String |
getUserTransactionJNDIName()
Returns the UserTransaction JNDI binding name.
|
static boolean |
isNoTransaction()
Checks if there is no transaction
|
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 boolean |
isTransactionTimedOut()
Checks if the current User Transaction has already timed out, i.e., whether a commit would immediately abort with
a timeout exception.
|
static TransactionSynchronizationRegistry |
lookupSynchronizationRegistry()
Looks up the TransactionSynchronizationRegistry in JNDI.
|
static TransactionManager |
lookupTransactionManager()
Looks up the TransactionManager in JNDI.
|
static UserTransaction |
lookupUserTransaction()
Looks up the User Transaction in JNDI.
|
static void |
noteSuppressedException(Exception e)
If activated by , remembers the exception.
|
static void |
noteSuppressedExceptions()
After this, some exceptions during transaction commit may be suppressed and remembered.
|
static void |
registerSynchronization(Synchronization handler) |
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 |
setTransactionRollbackOnlyIfTimedOut()
Sets the current User Transaction as rollback only if it has timed out.
|
static boolean |
startTransaction()
Starts a new User Transaction.
|
static boolean |
startTransaction(int timeout)
Starts a new User Transaction with the specified timeout.
|
static Transaction |
suspendTransaction() |
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 TransactionSynchronizationRegistry lookupSynchronizationRegistry() throws NamingException
NamingException
- if not foundpublic static boolean isNoTransaction()
public static boolean isTransactionActive()
public static boolean isTransactionMarkedRollback()
public static boolean isTransactionActiveOrMarkedRollback()
public static boolean isTransactionTimedOut()
true
if there is a current transaction that has timed out, false
otherwisepublic static boolean startTransaction()
true
if the transaction was successfully started, false
otherwisepublic static Transaction requireNewTransaction()
TransactionRuntimeException
public static Transaction suspendTransaction()
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 void noteSuppressedExceptions()
public static void noteSuppressedException(Exception e)
public static List<Exception> getSuppressedExceptions()
public static boolean setTransactionRollbackOnly()
true
if the transaction was successfully marked rollback only, false
otherwisepublic static boolean setTransactionRollbackOnlyIfTimedOut()
true
if the transaction was successfully marked rollback only, false
otherwisepublic static void registerSynchronization(Synchronization handler)
Copyright © 2015 Nuxeo SA. All rights reserved.