• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Getting EJBObject from ejbCreate() on stateless bean

 
Nicholas Way
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
According to the spec (table on page 90), a stateless session bean can call getEJBObject from its ejbCreate() method. My understanding is that ejbCreate() is called when the bean is created, which does not necessarily relate to any client interaction, which means, presumably, that there will be no EJBObject. Is this right, and if so, what happens when getEJBObject is called in such a case. Does it return null (which can be checked for in code), or does it throw an exception?
 
Frederic Esnault
Ranch Hand
Posts: 284
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The stateless session bean case is quite simple. In fact, each stateless SB TYPE has ONE EJBObject. Which mean each client accessing the same type of stateless bean will access the SAME EJBObject.

Now on to the creation time. When client calls create(), what is actually created (if not already existing) is the EJBObject. Later, when the bean is needed for business method needs, then container calls its constructor, ties it to an EJBObject, sets its context, and then calls the ejbCreate() method. But at this time, the EJBObject for this type of stateless bean exists for a long time already, so its available in the ejbCreate() method.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic