C# Класс Spring.Transaction.Support.TransactionSynchronizationManager

Internal class that manages resources and transaction synchronizations per thread.
Supports one resource per key without overwriting, i.e. a resource needs to be removed before a new one can be set for the same key. Supports a list of transaction synchronizations if synchronization is active.

Resource management code should check for thread-bound resources via GetResource(). It is normally not supposed to bind resources to threads, as this is the responsiblity of transaction managers. A further option is to lazily bind on first use if transaction synchronization is active, for performing transactions that span an arbitrary number of resources.

Transaction synchronization must be activated and deactivated by a transaction manager via InitSynchronization and ClearSynchronization. This is automatically supported by Spring.Transaction.Support.AbstractPlatformTransactionManager.

Resource management code should only register synchronizations when this manager is active, and perform resource cleanup immediately else. If transaction synchronization isn't active, there is either no current transaction, or the transaction manager doesn't support synchronizations.

Note that this class uses following naming convention for the named 'data slots' for storage of thread local data, 'Spring.Transaction:Name' where Name is either
Показать файл Открыть проект Примеры использования класса

Открытые методы

Метод Описание
BindResource ( Object key, Object value ) : void

Bind the given resource for teh given key to the current thread

Clear ( ) : void

Clears the entire transaction synchronization state for the current thread, registered synchronizations as well as the various transaction characteristics.

ClearSynchronization ( ) : void

Deactivate transaction synchronization for the current thread.

Called by transaction manager on transaction cleanup.

GetResource ( Object key ) : object

Retrieve a resource for the given key that is bound to the current thread.

HasResource ( Object key ) : bool

Check if there is a resource for the given key bound to the current thread.

InitSynchronization ( ) : void

Activate transaction synchronization for the current thread.

Called by transaction manager at the beginning of a transaction.

RegisterSynchronization ( ITransactionSynchronization synchronization ) : void

Register a new transaction synchronization for the current thread.

Typically called by resource management code.

UnbindResource ( Object key ) : object

Unbind a resource for the given key from the current thread

Приватные методы

Метод Описание
Describe ( object obj ) : string

Описание методов

BindResource() публичный статический Метод

Bind the given resource for teh given key to the current thread
public static BindResource ( Object key, Object value ) : void
key Object key to bind the value to
value Object value to bind
Результат void

Clear() публичный статический Метод

Clears the entire transaction synchronization state for the current thread, registered synchronizations as well as the various transaction characteristics.
public static Clear ( ) : void
Результат void

ClearSynchronization() публичный статический Метод

Deactivate transaction synchronization for the current thread.
Called by transaction manager on transaction cleanup.
/// If synchronization is not active. ///
public static ClearSynchronization ( ) : void
Результат void

GetResource() публичный статический Метод

Retrieve a resource for the given key that is bound to the current thread.
public static GetResource ( Object key ) : object
key Object key to check
Результат object

HasResource() публичный статический Метод

Check if there is a resource for the given key bound to the current thread.
public static HasResource ( Object key ) : bool
key Object key to check
Результат bool

InitSynchronization() публичный статический Метод

Activate transaction synchronization for the current thread.
Called by transaction manager at the beginning of a transaction.
/// If synchronization is already active. ///
public static InitSynchronization ( ) : void
Результат void

RegisterSynchronization() публичный статический Метод

Register a new transaction synchronization for the current thread.
Typically called by resource management code.
/// If synchronization is not active. ///
public static RegisterSynchronization ( ITransactionSynchronization synchronization ) : void
synchronization ITransactionSynchronization
Результат void

UnbindResource() публичный статический Метод

Unbind a resource for the given key from the current thread
if there is no value bound to the thread
public static UnbindResource ( Object key ) : object
key Object key to check
Результат object