This week's book giveaway is in the Agile and Other Processes forum.
We're giving away four copies of The Little Book of Impediments (e-book only) and have Tom Perry on-line!
See this thread for details.
Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

confusion over bean things

 
Prashant Neginahal
Ranch Hand
Posts: 77
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Guys,

I am having confusion over understanding bean things. The life cycle of stateless session bean and MessageDrivenBean is more or less same. In case of MDB, we can access getUserTransaction in ejbCreate/ejbRemove methods. But not in stateless session bean's ejbCreate/ejbRemove method. Why?

What are the rules for accessing getuserTransaction() method?

Thanks,
Prashant
 
Miki Muzsi
Ranch Hand
Posts: 120
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Prashant,this is a tricky thing. Actually if you look carefull at the spec you realise that SLSB and MDB are the same from the getUserTransaction() point of view.

So here it is a summary:

1. SLSB and MDB, are both allowed to call getUserTransaction() in ejbCreate() and ejbRemove() but they are not alowed to use it! That is why Kathy, on pg 228, puts these two things together: "get a transaction reference and call methods on it (BMT)" - is not allowed! See also pg 90 and 320 in the spec.
2. SFSB are alowed both to call getUserTransaction() and to call methods on it (see pg. 80).

However, to make it even more confusing, it is definately not recommended to use the UserTransaction even if you can, for SFSB, since they run in an UTC(unspoecified tx context). 7.5.6, pg 76.

Personally I think the spec could have dealed in the same way with getUserTransaction() as with "Resource manager access". Just say that you can not acess the user transaction in ejbCreate() and ejbRemove() for SLSB and MDB. Not to specify that you can call the getUSerTransaction() method, but you can not use the UserTransaction. Because you can look up a resource manager connection factory, and you can get a connection in ejbCreate() and ejbRemove(). But still you can not make JDBC calls on it!

Hope this is clear now.

Miki
 
Prashant Neginahal
Ranch Hand
Posts: 77
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ya it is clear now. Thanks Miki.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic