Package org.alfresco.util.transaction
Class TransactionSupportUtil
java.lang.Object
org.alfresco.util.transaction.TransactionSupportUtil
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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic boolean
bindListener
(TransactionListener listener, int priority) Bind listener to the specified priority.static void
bindResource
(Object key, Object resource) Binds a resource to the current transactionstatic Set<TransactionListener>
static <R> R
getResource
(Object key) Gets a resource associated with the current transactionstatic String
Get a unique identifier associated with each transaction of each thread.static long
static boolean
static void
unbindResource
(Object key) Unbinds a resource from the current transaction, which must be active.
-
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
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
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
Binds a resource to the current transactionAll necessary synchronization instances will be registered automatically, if required.
- Parameters:
key
- Objectresource
- Object
-
unbindResource
Unbinds a resource from the current transaction, which must be active.- Parameters:
key
- Object
-
bindListener
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
- Returns:
- Returns all the listeners in a list disconnected from the original set
-