-
@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 JTA transaction. This annotation has no effect on classes which have non-contextual references such those defined as managed beans by the Java EE specification.
The transaction scope is active when the return from a call toUserTransaction.getStatus
orTransactionManager.getStatus
is one of the following states:- Status.STATUS_ACTIVE
- Status.STATUS_MARKED_ROLLBACK
- Status.STATUS_PREPARED
- Status.STATUS_UNKNOWN
- Status.STATUS_PREPARING
- Status.STATUS_COMMITTING
- Status.STATUS_ROLLING_BACK
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 JTA 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. AnySynchronization.afterCompletion
methods will be invoked in an undefined context. The way in which the JTA transaction is begun and completed (for example via UserTransaction, Transactional interceptor, etc.) is of no consequence. The contextual references used across different JTA transactions are distinct. Refer to the CDI specification for more details on contextual references. Ajavax.enterprise.context.ContextNotActiveException
will be thrown if an object with this annotation is used when the transaction context is not active.- Since:
- JTA1.2
Document created the 11/06/2005, last modified the 18/08/2025
Source of the printed document:https://www.gaudry.be/en/java-api-javaee-rf-javax/transaction/transactionscoped.html
The infobrol is a personal site whose content is my sole responsibility. The text is available under CreativeCommons license (BY-NC-SA). More info on the terms of use and the author.
References
These references and links indicate documents consulted during the writing of this page, or which may provide additional information, but the authors of these sources can not be held responsible for the content of this page.
The author of this site is solely responsible for the way in which the various concepts, and the freedoms that are taken with the reference works, are presented here. Remember that you must cross multiple source information to reduce the risk of errors.