Class TransactionSupportUtil


  • public abstract class TransactionSupportUtil
    extends java.lang.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 Detail

      • TransactionSupportUtil

        public TransactionSupportUtil()
    • Method Detail

      • 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 java.lang.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​(java.lang.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​(java.lang.Object key,
                                        java.lang.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​(java.lang.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 java.util.Set<TransactionListener> getListeners()
        Returns:
        Returns all the listeners in a list disconnected from the original set