@TransactionScope
@TransactionScope is a specialization of Scope @Scope for a service or component whose lifecycle is bound to the current top-level transaction, within an outer InteractionScope .
Such services should additional implement Spring’s org.springframework.transaction.support.TransactionSynchronization interface, defining the transaction lifecycle callbacks.
Specifically, @TransactionScope is a composed annotation that acts as a shortcut for @Scope("transaction") .
@TransactionScope may be used as a meta-annotation to create custom composed annotations.
Note that (apparently) the org.springframework.transaction.support.TransactionSynchronization infrastructure is only really intended to work with a single org.springframework.transaction.PlatformTransactionManager . And indeed, this is going to be typical case. However, our framework code does at least admit the possibility of multiple org.springframework.transaction.PlatformTransactionManager s being defined in the app. If that is the case, then (I believe) the callbacks of org.springframework.transaction.support.TransactionSynchronization might be called multiple times, once per org.springframework.transaction.PlatformTransactionManager . The framework currently doesn’t provide any way to distinguish between these calls.
API
@interface TransactionScope {
String SCOPE_NAME;
@AliasFor(annotation = Scope.class)
ScopedProxyMode proxyMode() default ScopedProxyMode.TARGET_CLASS; (1)
}
1 | proxyMode
Proxying must be enabled, because we inject TransactionScope d beans into beans with wider scopes. |
Members
proxyMode
Proxying must be enabled, because we inject TransactionScope d beans into beans with wider scopes.
Alias for Scope#proxyMode .