-
Request context (3 messages)
- Posted by: Martin Voelkle
- Posted on: September 21 2006 08:29 EDT
Hello I would like to put objects in an EJB transaction context, using something like ServletRequest.setAttribute/getAttribute, to access them later (but always in the same transaction). In my case, it's a single stateless session bean method that creates a transaction, calls methods on local entity beans, and the entity beans have to share this object pool for the duration of the transaction. Is there a way to do this? I am aware of ThreadLocal storage, but what if the application server decides to serve a call to an EJB method with one thread an other call with an other thread? Does the J2EE spec prohibit this behaviour? Thanks, MartinThreaded Messages (3)
- Re: Request context by arijit dey on September 21 2006 08:39 EDT
- Re: Request context by Martin Voelkle on September 21 2006 11:38 EDT
- TransactionLocal by Martin Voelkle on September 21 2006 11:49 EDT
-
Re: Request context[ Go to top ]
- Posted by: arijit dey
- Posted on: September 21 2006 08:39 EDT
- in response to Martin Voelkle
With container managed transaction, you cannot do it but if you can use UserTransaction to demarcate your own transaction boundaries and you can TransactionManager.getTransaction() to get the transaction object associated with current thread, here you can enlist your resource and retrieve later. try and tell me if it works. http://javaicillusion.blogspot.com/ -
Re: Request context[ Go to top ]
- Posted by: Martin Voelkle
- Posted on: September 21 2006 11:38 EDT
- in response to arijit dey
Enlisting XAResources seems quite elegant, but I don't see how I could retrieve the XAResource. My first idea was to have a static map with Transaction objects as keys. But this will never scale... Could any spec guru tell me if the ThreadLocal is a safe option? -
TransactionLocal[ Go to top ]
- Posted by: Martin Voelkle
- Posted on: September 21 2006 11:49 EDT
- in response to Martin Voelkle
This is what I want: http://docs.jboss.org/jbossas/javadoc/3.2.7/transaction/org/jboss/tm/TransactionLocal.html Does anybody know if it is portable (to websphere 6 in particular)? Thanks, Martin