Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

What if we do not set the sessionContext in our ejb ?  RSS feed

 
Abhinav Srivastava
Ranch Hand
Posts: 354
Eclipse IDE Java Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What if we do not set the SessionContext in our ejb ?
(In the case that the program doesn't use it).
 
Brian Tinnel
Ranch Hand
Posts: 69
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Won't cause a problem. If you don't need it, don't save it.
 
Abhinav Srivastava
Ranch Hand
Posts: 354
Eclipse IDE Java Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Would it affect Container Managed Transactions in any way?
1. When ejb - method starts its own transaction.
2. When it inherits a tx.
 
Prakash Dwivedi
Ranch Hand
Posts: 452
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Jonathan Harker:
Would it affect Container Managed Transactions in any way?
1. When ejb - method starts its own transaction.
2. When it inherits a tx.


I think you won't be able to rollback the transaction programatically, as setRollBackOnly() method is present in SessionContext (the reference of which you are not saving), otherwise i don't think there should be any problem.
 
Paymon Asadinia
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You must save the sessionContext (or any other bean contexts), This is the only way that your bean can be aware of it's environment. If you fail to do so, you won't get another chance to refrence it later. This is a must
for the bean provider. (best practice).


SCJP,SCWCD SCBCD(in progress)

[ January 13, 2005: Message edited by: schrodinger's cat ]
[ January 13, 2005: Message edited by: schrodinger's cat ]
 
David Harkness
Ranch Hand
Posts: 1646
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by schrodinger's cat:
This is the only way that your bean can be aware of it's environment. This is a must for the bean provider.
Ah, but you've contradicted yourself. Let me rephrase your statements:

Storing the context reference is a must for the bean provider in order to be aware of its environment.

So, if you don't need any of the methods exposed by the context (rolling back transactions programatically in CMT, for example), then clearly you don't need to store the context. Granted, I don't see much reason not to include the member field and one-line method needed to store the context, but it's not mandatory that you do.
 
Paymon Asadinia
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi David,

Yes, Prehaps I should have been a bit more careful with my diction.
Nevertheless, I did mention that it would be considered a "(best practice)" to save the reference to the bean's context.




 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!