• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Transactional context

 
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If bean A calls a class X with a certain transactional context, and then class X invokes bean B, does B gets the transactional context from A?

Regards
Pjrm
 
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The Transactional Context is carried in the Thread Context of the call. Therefore if you call a Pojo from an EJB then the transactional context is also available to a EJB called from that Pojo. That said this is only the case if you use the Local/Remote interface to call the EJB.
Be aware that if you call a method of an EJB without going through the Local/Remote interface then none of the EJB services like transaction, security etc are used. In case you need to call another method in your EJB then you need to obtain the Remote interface from the EJB context.

-Andy
 
Ranch Hand
Posts: 775
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Andreas Schaefer:
Be aware that if you call a method of an EJB without going through the Local/Remote interface then none of the EJB services like transaction, security etc are used. In case you need to call another method in your EJB then you need to obtain the Remote interface from the EJB context.



If you call a method of the class directly without going through the container there is no ejb context. You only get an ejb context because the container provided you with one via the setSession(etc)Context callback. If you've created your own instance of the class, the container never had the option of invoking those callbacks, so you have no hooks to the container at all except JNDI - and not even reliable access to the ENC, just the global JNDI tree. Also if you do all this via threads you've spawned, you can seriously mess with the container's ability to manage resources, stop and undeploy applications, etc.
 
reply
    Bookmark Topic Watch Topic
  • New Topic