[cdi-dev] [JBoss JIRA] Commented: (CDI-121) TransactionScope
Reza Rahman (JIRA)
jira-events at lists.jboss.org
Thu Sep 8 15:45:26 EDT 2011
[ https://issues.jboss.org/browse/CDI-121?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12627343#comment-12627343 ]
Reza Rahman commented on CDI-121:
Just to add a bit more detail to this, the basis for Rick's initial proposal for @TransactionScoped is rooted in our implementation for Resin and is inspired largely by the JPA transactional persistence context (it has nothing to do with the current notion of CDI conversations). You can browse the initial version of it here: http://www.opensourcejavaphp.net/java/resin/com/caucho/server/webbeans/TransactionScope.java.html. The basic idea is to have beans scoped to the active JTA transaction. While the current Resin @TransactionScoped is not implemented this way right now, I think the scope also needs to "downgrade" to "per-bean-method-invocation" scope (a la stateless session beans without a pool) if an active transaction is not present. Currently, Resin will throw a context not active exception if no transaction is found, which I don't think is too usable as a fall-back strategy.
Here is sample code that uses this scope: http://www.caucho.com/articles/CanDI_demo_2.zip. The basic use case for it is when Java EE end-users need to integrate their own transactional back-end resources via CDI into any managed bean (including EJBs).
I don't think straight @TransactionScoped is really the right answer for JMS 2 though. The most obvious reason is that besides being transaction scoped, JMS objects in the same scope will also need to be created and destroyed in a specific order, which a general purpose scope will still not do (short of maybe standardizing something like EJB @DependsOn in CDI).
Let me know if I can explain further. I'll coordinate on this with Rick/Scott too.
> Key: CDI-121
> URL: https://issues.jboss.org/browse/CDI-121
> Project: CDI Specification Issues
> Issue Type: Feature Request
> Components: Contexts
> Environment: Java EE
> Reporter: Richard Hightower
> Assignee: Richard Hightower
> Priority: Minor
> Fix For: 1.1 (Proposed)
> Original Estimate: 3 days
> Remaining Estimate: 3 days
> Add TransctionalScope as a standard scope to define beans whose lifecycle is the same as a given transaction.
> This scope should start automatically when a transaction starts (but lazily when actually needed).
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira
More information about the cdi-dev