I have a doubt about a Stateless Session Bean ejb Create method. It was mentioned in the Head First EJB that clients calls create() method and bean instance creation are completely different & Unrelated time.
But when tested with weblogic server, I found that following:
1. Client gets the ejb Home stub Object. 2. On calling the create method on Home, clients get remote stub object.(EJBObject is created here as per Head First EJB BOOK). 3. The missing point is even after some time, class.newInstance(), setSessionContext() and ejbCreate() methods were not invoked.
4. But when I call the business methods, the above methods are called in the first business method call!!!.
In Head First EJB it was mentioned that, after the home create method and before the business method call , in an unrelated time the bean instances are created and pooled, but here only after the first business method invocation the bean instances are created. Also I found that in the bean pool have only one instance for the business method invocation. Is it not possible that initially we can create 10 beans in the pool like connection pool?
1. while server starting it-self it will create the pool of stateless bean object 2. Then while calling create(), it will create a EJBObject - Remote Interface (NOT Implementation class ie., not bean object) stub and pass it to the client. 3. While calling first business method the EJBObject will be coupled with the Bean (Bean class object).
So as per your testing, till point-2 things we're ok. Then it after calling first busioness method all object creation, setSessionContext().. are called later.