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.
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.
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.
Regards,<br />Subhash Bhushan.
I am not young enough to know everything. - Oscar Wilde This tiny ad thinks it knows more than Oscar: