Nuxeo Enterprise Platform 5.4

org.nuxeo.runtime.transaction
Class TransactionHelper

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

public class TransactionHelper
extends java.lang.Object

Utilities to work with transactions.


Field Summary
static java.lang.String[] TM_NAMES
          Various binding names for the TransactionManager.
static java.lang.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 java.lang.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 javax.transaction.TransactionManager lookupTransactionManager()
          Looks up the TransactionManager in JNDI.
static javax.transaction.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 java.lang.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 java.lang.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 javax.transaction.UserTransaction lookupUserTransaction()
                                                               throws javax.naming.NamingException
Looks up the User Transaction in JNDI.

Returns:
the User Transaction
Throws:
javax.naming.NamingException - if not found

getUserTransactionJNDIName

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

Assumes lookupUserTransaction() has been called once before.


lookupTransactionManager

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

Returns:
the TransactionManager
Throws:
javax.naming.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:
javax.transaction.SystemException
javax.transaction.HeuristicRollbackException
javax.transaction.HeuristicMixedException
javax.transaction.RollbackException
java.lang.IllegalStateException
java.lang.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 Enterprise Platform 5.4

Copyright © 2010 Nuxeo SAS. All Rights Reserved.