@Retention(value=RUNTIME) @Target(value={TYPE,METHOD,FIELD}) @NormalScope(passivating=true) public @interface TransactionScoped
The javax.transaction.TransactionScoped annotation provides the ability to specify a standard CDI scope to define bean instances whose lifecycle is scoped to the currently active Jakarta Transactions transaction. This annotation has no effect on classes which have non-contextual references such those defined as managed beans by the Jakarta EE specification.
The transaction scope is active when the return from a call toUserTransaction.getStatus
or
TransactionManager.getStatus
is one of the following states:
It is not intended that the term "active" as defined here in relation to the
TransactionScoped annotation should also apply to its use in relation to
transaction context, lifecycle, etc. mentioned elsewhere in this
specification. The object with this annotation will be associated with the
current active Jakarta Transactions transaction when the object is used. This association must
be retained through any transaction suspend or resume calls as well as any
Synchronization.beforeCompletion
callbacks. Any
Synchronization.afterCompletion
methods will be invoked in an undefined
context. The way in which the Jakarta Transactions transaction is begun and completed
(for example via UserTransaction, Transactional interceptor, etc.) is of no consequence.
The contextual references used across different Jakarta Transactions transactions are distinct.
Refer to the CDI specification for more details on contextual references.
A javax.enterprise.context.ContextNotActiveException
will be thrown if an object with this annotation is used when the
transaction context is not active.