my dog learned polymorphism*
The moose likes EJB and other Java EE Technologies and the fly likes A tough one for experienced EJB people - Stateless session bean spec question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "A tough one for experienced EJB people - Stateless session bean spec question" Watch "A tough one for experienced EJB people - Stateless session bean spec question" New topic
Author

A tough one for experienced EJB people - Stateless session bean spec question

John Donahue
Greenhorn

Joined: Mar 24, 2004
Posts: 1
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?
Augg Stine
Greenhorn

Joined: Mar 24, 2004
Posts: 27
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

Vishwa Kumba
Ranch Hand

Joined: Aug 27, 2003
Posts: 1064
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: A tough one for experienced EJB people - Stateless session bean spec question
 
Similar Threads
stateless session bean's ejbCreate method
ejbCreate in session bean
getEJBObject() in ejbCreate() for SLSB
SessionContext and ejbCreate (for stateless session beans)
ejbCreate in session bean