= @TransactionScope
:Notice: Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at. http://www.apache.org/licenses/LICENSE-2.0 . Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR  CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

_@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 xref:refguide:applib:index/annotation/InteractionScope.adoc[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

[source,java]
.TransactionScope.java
----
@interface TransactionScope {
  String SCOPE_NAME;
  @AliasFor(annotation = Scope.class)
ScopedProxyMode proxyMode() default ScopedProxyMode.TARGET_CLASS;     // <.>
}
----

<.> xref:#proxyMode[proxyMode]
+
--
Proxying _must_ be enabled, because we inject xref:refguide:applib:index/annotation/TransactionScope.adoc[TransactionScope] d beans into beans with wider scopes.
--

== Members

[#proxyMode]
=== proxyMode

Proxying _must_ be enabled, because we inject xref:refguide:applib:index/annotation/TransactionScope.adoc[TransactionScope] d beans into beans with wider scopes.

Alias for _Scope#proxyMode_ .
