guys , i am confused Is this sentance true ? "Whenever client calls home.create() then ejbCreate is called" Think about stateless session beans say the max pool size is 50 and there are 50 instances of bean now say there are 100 clients and no. 101 client calls home.create() so what does container do ? pick an ejb instance of ready state and call ejbCreate() on it (That makes no sense to me) or try to make new instance (remember, the limit is reached already) I know the story could be different for statefull/entity bean !
The stateless session bean lifecycle has only two states, does not exist, and method-ready. In this lifecycle, ejbCreate is only called once. I think all that the create method does is to obtain a reference to the EJB object so as to call business methods on a pooled bean.
SCJP, SCWCD, SCBCD
posted 16 years ago
fine so it means that home.create() for stateless session beans would not call ejbCreate() NECESSARILY but for statefull session beans and entity beans it has to right ?
Test 094, IBM WID 6.0 cert
SCBCD 1.3 Beta
SCWCD 1.4 Beta
posted 16 years ago
That does seem to be the case. I could only imagine that ejbCreate would be called to add another stateless session bean to the pool. Otherwise there is no reason for the container to call ejbCreate. As you say, ejbCreate is always called for stateful session beans and entity beans when you call create, that's mentioned in the EJB spec I believe.
Hmmm, my recent class notes for stateless session shows this life cycle (with a few left out) DoesNotExist-> ejbCreate -> MethodReady -> ejbRemove -> DNE And this for stateful DNE -> ejbCreate -> MethodReady -> ejbPassivate -> Passive -> ejbActivate -> MethodReady -> ejbRemove -> DNE I think going back to DNE after remove is logical, not physical. The bean instance might be put back in the pool at the container's discretion. Is the pool a requirement of the spec or a common implementation? Still talking beyond my actual knowledge - I think the Passive state is also logical, not physical. The container might actually recycle the bean instance to another client while you're not looking.
A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
If you have a bad day in October, have a slice of banana cream pie. And this tiny ad: