Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Why not passivating SessionContext with SFSB?  RSS feed

 
Patrio Jensen
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

"Mastering EJB" mentions that container retains container-implemented objects (e.g. EJBContext) across passivation/activation call. In other words, container does not passivate SessionContext object while passivating SFSB.

Is there any specific reason behind not passivating EJBContext?

Thanks.
 
Greg Charles
Sheriff
Posts: 3015
12
Firefox Browser IntelliJ IDE Java Mac Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think there's just no reason to do it. The session context is just used to access various services of the bean. It's not dependent on the values of the state variables (i.e., the ones that do get passivated). Think of the SFSB like a rental car. You rent it to one person who drives it around for awhile and then returns it. That driver has to take all his personal stuff with him when he returns the car ... CDs, used tissues, wife and kids, etc. ... but he can leave the steering wheel for the next driver.
 
Patrio Jensen
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That driver has to take all his personal stuff with him when he returns the car

Understood.

but he can leave the steering wheel for the next driver.

This caused some confusion. I am under impression that SessionContext of one SFSB is of no use to another SFSB. Is it correct?
 
Greg Charles
Sheriff
Posts: 3015
12
Firefox Browser IntelliJ IDE Java Mac Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well you're correct in a sense. You use the SessionContext to get the home interface, to manage transactions, to find out credential information about the caller, etc. It's true that you can't just hand it over to a different bean and expect it to work, but here you are reusing the same bean, just on behalf of a different caller. Going back to my analogy, each car needs its own steering wheel, but different drivers can drive a car at different times without swapping out that car's wheel.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!