Win a copy of Pipeline as Code this week in the Cloud/Virtualization 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
  • Ron McLeod
  • Paul Clapham
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Rob Spoor
  • Henry Wong
  • Liutauras Vilda
Saloon Keepers:
  • Tim Moores
  • Carey Brown
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
Bartenders:
  • Frits Walraven
  • Himai Minh
  • Jj Roberts

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

 
Ranch Hand
Posts: 354
Eclipse IDE Oracle Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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).
 
Ranch Hand
Posts: 69
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 Oracle Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 452
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
Ranch Hand
Posts: 1646
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.




 
If you are using a wood chipper, you are doing it wrong. Even on this tiny ad:
SKIP - a book about connecting industrious people with elderly land owners
https://coderanch.com/t/skip-book
reply
    Bookmark Topic Watch Topic
  • New Topic