I am busy learning more about EJBs and came across something confusing regarding the legal operations in the various container callback methods for stateless session beans. Specifically, the EJB spec states that in the ejbCreate() method, the SessionContext can be used to obtain a reference to the EJB Object. Now this makes perfect sense with stateful session beans, since the ejbCreate() method isn't called until a client is creating a bean and the container has linked that bean to the client's EJB Object. However, it is my understanding that when it comes to stateless session beans, the container creates the beans and adds them to the bean pool at its leisure. It is not until a business method is called by a client that a stateless bean is actually linked to an EJB object. So, how is it possible that a stateless bean could ever obtain a reference to an EJB Object from within ejbCreate(). Which EJB Object would it be linked to? This operation just doesn't appear to make sense in that context. Can anyone clarify this for me?
Hi, your understanding is correct. But what i feel is that for stateless session Bean, there is no EjbObject which is specific to a particular client. Though the client uses the ejbobject reference to call the Business methods of stateless session bean, it is associated with the client only for that method call. So when we call getEjbObject() on context object for stateless session bean, it returns the common ejbobect ur thoughts on this are welcome rgds/ Augg
Originally posted by Augg Augg: So when we call getEjbObject() on context object for stateless session bean, it returns the common ejbobect
The implementation could be vendor-specific.The Container might return some Common or Dummy EJBObject used by all SLSB, for a create() method. When a business method is actually called later, this may be replaced with an actual EJBObject. By the way, this is my guess only.
Bring me the box labeled "thinking cap" ... and then read this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop