Class TransactionSupportUtil

java.lang.Object
org.alfresco.util.transaction.TransactionSupportUtil

public abstract class TransactionSupportUtil extends Object
Helper class to manage transaction synchronization. This provides helpers to ensure that the necessary TransactionSynchronization instances are registered on behalf of the application code.
Author:
mrogers
  • Constructor Details

    • TransactionSupportUtil

      public TransactionSupportUtil()
  • Method Details

    • getTransactionStartTime

      public static long getTransactionStartTime()
      Returns:
      Returns the system time when the transaction started, or -1 if there is no current transaction.
    • getTransactionId

      public static String getTransactionId()
      Get a unique identifier associated with each transaction of each thread. Null is returned if no transaction is currently active.
      Returns:
      Returns the transaction ID, or null if no transaction is present
    • isActualTransactionActive

      public static boolean isActualTransactionActive()
    • getResource

      public static <R> R getResource(Object key)
      Gets a resource associated with the current transaction
      Parameters:
      key - the thread resource map key
      Returns:
      Returns a thread resource of null if not present
    • bindResource

      public static void bindResource(Object key, Object resource)
      Binds a resource to the current transaction

      All necessary synchronization instances will be registered automatically, if required.

      Parameters:
      key - Object
      resource - Object
    • unbindResource

      public static void unbindResource(Object key)
      Unbinds a resource from the current transaction, which must be active.
      Parameters:
      key - Object
    • bindListener

      public static boolean bindListener(TransactionListener listener, int priority)
      Bind listener to the specified priority. Duplicate bindings The priority specifies the position for the listener during commit. For example flushing of caches needs to happen very late.
      Parameters:
      listener - the listener to bind.
      priority - 0 = Normal priority
      Returns:
      true if the new listener was bound. False if the listener was already bound.
    • getListeners

      public static Set<TransactionListener> getListeners()
      Returns:
      Returns all the listeners in a list disconnected from the original set