Win a copy of Five Lines of Code this week in the OO, Patterns, UML and Refactoring forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

MessageDrivenBean - getUserTransaction?

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
On page 320 of the specs, it states:

For BMT, ejbCreate/ejbRemove have access to getUseTransaction. Does this mean it can execute methods within the UserTransaction interface. If so, why does it list UserTransaction methods for ejbCreate/ejbRemove - similiar to onMessage(). That is, onMessage states getUserTransaction() and UserTransaction methods.
[ November 09, 2004: Message edited by: Billy Hickory ]
 
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My understanding:
ejbRemove/ejbCreate in MDB is not triggered by client (no client in MDB). It's up to the container to determine when to use these callbacks. Therefore there is no meaningful transaction context during ejbCreate/ejbRemove, hense you cannot call getUserTransaction.

Yi
SCJP
SCBCD
 
Billy Hickory
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
True..the client can not call these methods - actually the container calls these methods. However, the provider can put code in these methods. On page 320 of the spec, it does state you can call getUserTransaction() method in ejbCreate and ejbRemove. If so, you have the Usertransaction object, which means you should be able to call the UserTransaction methods.

I believe it is an error in the specs. That is, if you have access to getUserTransaction(), you should be able to call the UserTransaction methods.
 
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
UserTransaction for MDB has nothing to do with the user who sent message. UserTransaction is a reference to Transaction Manager. On ejbCreate() bean stores a reference to Transaction Manager and then later multiple times uses it to begin and commit transaction in onMessage() method. It is more efficient then obtaining UserTransaction every time when container invokes bean onMessage() method.
 
I don't get it. A whale wearing overalls? How does that even work? It's like a tiny ad wearing overalls.
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic