Win a copy of Learn Spring Security (video course) this week in the Spring forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Stateless Session Bean setSessionContext operations

 
Suresh Ramamurthy
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi ,
I was going through the Stateless Session Bean OID Diagrams and operations allowed in the Stateless Session Methods.
In setSessionContext, we do have access to getEJBHome and getEJBLocalHome methods.
I am pretty much confused on why/how it was allowed to have access to these methods when the Session objects are pooled.
 
Keerthi P
Ranch Hand
Posts: 203
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes. Session objects are pooled. But before they are put into the pool, according to the spec, the container must ensure that
1. EJB[Local]Home object is created for the family of session objects
2. setSessionContext() is called for the session bean instances so that the bean instances can access their context and EJB[Local]Objects.
 
Subhash Bhushan C
Ranch Hand
Posts: 106
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's basically about who is accessible and who is not. As you know, a Stateless Session bean's creation is not linked to client calls in any way. The container creates the Stateless Session bean whenever it sees fit. When it does this, there will be no EJB Object, since there is no client yet. But there has to be a home already existing for this session bean gets created in the first place. Consequently, setSessionContext() allows you to get a reference to your home object.

Though the Stateless Session objects are pooled, it does not mean that they are de-linked from their home. They still are within the domain of and within the control of the Home that created them.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic