C# Class 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
Afficher le fichier Open project: spring-projects/spring-net Class Usage Examples

Méthodes publiques

Méthode Description
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

Private Methods

Méthode Description
Describe ( object obj ) : string

Method Details

BindResource() public static méthode

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
Résultat void

Clear() public static méthode

Clears the entire transaction synchronization state for the current thread, registered synchronizations as well as the various transaction characteristics.
public static Clear ( ) : void
Résultat void

ClearSynchronization() public static méthode

Deactivate transaction synchronization for the current thread.
Called by transaction manager on transaction cleanup.
/// If synchronization is not active. ///
public static ClearSynchronization ( ) : void
Résultat void

GetResource() public static méthode

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
Résultat object

HasResource() public static méthode

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
Résultat bool

InitSynchronization() public static méthode

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
Résultat void

RegisterSynchronization() public static méthode

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
Résultat void

UnbindResource() public static méthode

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
Résultat object