Hello, The container is supposed to maintain a pool of beans. Let's say there are 10 stateful session beans ready in a pool. During the creation of these 10 objects, the container would have called setSessionContext and ejbCreate(). As it is stateful session beans, let's say I write some code in ejbCreate that is going to setup my state initially which is crucial for my bean.
Now, when the client calls homeObject.create(), even though the bean has been already created and is present in the pool, will the container make a call to setSessionContext and ejbCreate?
Unlike stateless session beans a pool is not maintained for stateful session beans. SFSB are created as the requests for the new beans come in. Here is the flow for SFSB creation. I hope it helps:
client calls create on home container makes EJBObject and session context container constructs bean instance and links the bean to its ctx and ejbobject container sends the client a stub to the ejbobject ... ...business methods invocation ... client calls remove on either componenet or home interface container calls ejbREmove on the b ean container kills the bean and EJBobject THE BEAN IS KILLED