Package org.alfresco.repo.transaction
Class TransactionAwareSingleton<T>
java.lang.Object
org.alfresco.repo.transaction.TransactionListenerAdapter
org.alfresco.repo.transaction.TransactionAwareSingleton<T>
- All Implemented Interfaces:
TransactionListener,org.alfresco.util.transaction.TransactionListener
A transactionally-safe storage class for singleton objects. Changes to the singleton are only visibly promoted when the transaction is committed.
private static final TransactionAwareSingleton
All modifications to the singleton via get() and put(Object) are made in a transaction-local manner and promoted to the shared value in a thread-safe manner upon transacton completion. Transaction-local changes take precedence over the shared value.
- Author:
- Derek Hulley
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidPromotes the storage value to the single value, if requiredget()voidStore the value in a transaction- and thread-safe manner.Methods inherited from class org.alfresco.repo.transaction.TransactionListenerAdapter
afterRollback, beforeCommit, beforeCompletion, flushMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.alfresco.util.transaction.TransactionListener
getCustomOrder
-
Constructor Details
-
TransactionAwareSingleton
public TransactionAwareSingleton()
-
-
Method Details
-
get
- Returns:
- Returns the transaction- and thread-safe wrapped instance
-
put
Store the value in a transaction- and thread-safe manner. It will only be persisted at the end of the transaction but will be visible to the current transaction from this call onwards.- Parameters:
value- the value to store
-
afterCommit
public void afterCommit()Promotes the storage value to the single value, if required- Specified by:
afterCommitin interfaceTransactionListener- Specified by:
afterCommitin interfaceorg.alfresco.util.transaction.TransactionListener- Overrides:
afterCommitin classTransactionListenerAdapter
-