I am reading about CMP life cycle on HFEJB, and observed some behaviors in Weblogic which is not consistent with what I think the book says. That wouldn't surprise me
When an entity bean moves from pooled to method ready, does it mean that the bean is pulled out Bean Pool? Yes, see section 10.5.1 of the EJB 2.0 specification.
If it is true, then why Weblogic container calls
1. ejbActivate()
2. ejbLoad()
3. ejbStore()
when the client calls ejbFindByPrimaryKey() on EJBHome There are two ways for a bean to transit from the pooled state to the method ready state:
- ejbCreate or ejbPostCreate methods (not the case here)
- ejbActivate because a bean needs to service a client's call
You are right when you say that when ejbFind method are called, the bean instances are NOT pulled out of the pooled state.
I don't really have an explanation of why Weblogic works that way. All I can say is that I have been delving in Weblogic's code for a couple months now and I can tell you that I somehow understand why this is so
Second question is, why does the container call ejbLoad() and ejbStore() on every getter and setter method. I would think ejbStore() is only needed for setter and ejbLoad() is only needed for getter. Again, having delved into WL's code, I can tell you that it is far from being efficient. I suspect that there is code generation behind that... I'm sorry I don't have any further explanation. Maybe someone else could help.
Isn't it inefficient for EJB to behave this way ? Well, unneeded method calls are always inefficient.