• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Valentin Crettaz's cheat sheets Exception Handling

 
ravi janap
Ranch Hand
Posts: 389
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

On the first page in the ExceptionHandling.pdf document, it is mentioned under the heading "Client View":

if(ctx.getRollbackOnly())
//impossible to commit tx
else
//do more work and commit tx

What is this ctx? Is it SessionContext/EntityContext? If the answer is yes then how the standalone/remote client (non-EJB) gets access to SessionContext/EntityContext? This can only be true this were a EJB making call on other EJB? Please clarify my doubt.

Thanks

-- Ravi
 
Leena Diwan
Ranch Hand
Posts: 351
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A bean calling another bean may be called a client.

Any bean's way of knowing if 'setRollbakOnly()' has been called by some bean and/or method earlier is to query its own context by calling 'getRollbackOnly()'

So if Bean A calls Bean B,
1. Bean A is said to be a client of Bean B
2. Bean B might query its own context to check if any bean in the call stack has already called 'setRollbackOnly()'. If yes, Bean B might not go ahead with all the processing and waste time.

Regards,
Leena
 
ravi janap
Ranch Hand
Posts: 389
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Leena

Thanks for the detailed explanation.

Regards

-- Ravi
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic