Nuxeo ECM Projects 5.4.3-SNAPSHOT

org.nuxeo.runtime.transaction
Class TransactionHelper

java.lang.Object
  extended by org.nuxeo.runtime.transaction.TransactionHelper

public class TransactionHelper
extends Object

Utilities to work with transactions.


Field Summary
static String[] TM_NAMES
          Various binding names for the TransactionManager.
static String[] UT_NAMES
          Various binding names for the UserTransaction.
 
Method Summary
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 boolean setTransactionRollbackOnly()
          Sets the current User Transaction as rollback only.
static boolean startTransaction()
          Starts a new User Transaction.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

UT_NAMES

public static final String[] UT_NAMES
Various binding names for the UserTransaction. They depend on the application server used and how the configuration is done.


TM_NAMES

public static final String[] TM_NAMES
Various binding names for the TransactionManager. They depend on the application server used and how the configuration is done.

Method Detail

lookupUserTransaction

public static UserTransaction lookupUserTransaction()
                                             throws NamingException
Looks up the User Transaction in JNDI.

Returns:
the User Transaction
Throws:
NamingException - if not found

getUserTransactionJNDIName

public static String getUserTransactionJNDIName()
Returns the UserTransaction JNDI binding name.

Assumes lookupUserTransaction() has been called once before.


lookupTransactionManager

public static TransactionManager lookupTransactionManager()
                                                   throws NamingException
Looks up the TransactionManager in JNDI.

Returns:
the TransactionManager
Throws:
NamingException - if not found

isTransactionActive

public static boolean isTransactionActive()
Checks if the current User Transaction is active.


isTransactionMarkedRollback

public static boolean isTransactionMarkedRollback()
Checks if the current User Transaction is marked rollback only.


isTransactionActiveOrMarkedRollback

public static boolean isTransactionActiveOrMarkedRollback()
Checks if the current User Transaction is active or marked rollback only.


startTransaction

public static boolean startTransaction()
Starts a new User Transaction.

Returns:
true if the transaction was successfully started, false otherwise

commitOrRollbackTransaction

public static void commitOrRollbackTransaction()
Commits or rolls back the User Transaction depending on the transaction status.

Throws:
SystemException
HeuristicRollbackException
HeuristicMixedException
RollbackException
IllegalStateException
SecurityException

setTransactionRollbackOnly

public static boolean setTransactionRollbackOnly()
Sets the current User Transaction as rollback only.

Returns:
true if the transaction was successfully marked rollback only, false otherwise

Nuxeo ECM Projects 5.4.3-SNAPSHOT

Copyright © 2011 Nuxeo SAS. All Rights Reserved.