[cdi-dev] TransactionScope proposal

Rick Hightower richardhightower at gmail.com
Mon Oct 24 14:32:43 EDT 2011


*Section 2.4.1.*

TODO There are six standard scopes...  (not five)

TODO (Then list @TransactionScope as one of those scopes.)
*Section 6.7.8 Transaction Context Lifecycle*

This should work with various types of transaction management systems, but
it is defined in terms of JTA for ease of documentation by associating it
with a known, specified JSR standard.

The transaction context is provided by a built-in context object for the
built-in scope type @TransactionScoped. The transaction scope is active when
TransactionManager.begin is called (when the status goes to active), and
ends when TransactionManager.commit or TransactionManager.rollback is
called.

The transaction context is shared between all beans involved in the
transaction. The transaction context is destroyed when transaction is
rolledback, or committed.

An event with the TransactionEvent as payload and with qualifier
@Initialized(TransactionScoped.class) is fired when the transaction context
is initialized and moved to the active state and an event with qualifier
@Destroyed(TransactionScoped.class) when the transaction context is
destroyed.
Design Notes: CDI transaction context could work with JTA by registering
with a Synchronization callback with the Transaction object in JTA. Then CDI
will listen for the STATUS_ACTIVE state to indicate a transaction is active,
 STATUS_ROLLEDBACK to be notified of a rollback and lastly STATUS_COMMITTED
to be notified of a commit. The contextual instances will be stored directly
or indirectly in the TransactionSynchronizationRegistry when STATUS_ACTIVE
is handled, and removed when the STATUS_ROLLEDBACK or STATUS_COMMITTED is
handled.

If a transaction is suspended, the transactional scoped data is not
impacted. It is only the transaction active status or its final state of
committed or rolledback that impacts the lifecycle of the CDI transaction
context.

-- 
*Rick Hightower*
(415) 968-9037
Profile <http://www.google.com/profiles/RichardHightower>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/cdi-dev/attachments/20111024/0215fec6/attachment.html 


More information about the cdi-dev mailing list