• Post Reply Bookmark Topic Watch Topic
  • New Topic

Transactional context

 
Jorge Ribeiro
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • 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
 
Andreas Schaefer
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
  • 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
 
Reid M. Pinchback
Ranch Hand
Posts: 775
  • Mark post as helpful
  • send pies
  • 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.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!