Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

SLSB creation

 
Christopher Arthur
Ranch Hand
Posts: 149
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Question:
According to the spec on page 89, the container calls ejbCreate() when it decides to make a stateless session bean. Now this doesn't have anything to do with a client, so there shouldn't yet be any EJBObject, not until the client calls create() on the home interface. Yet in the table on page 90, it asserts that from ejbCreate(), one can call getEJBObject() on the SessionContext. But how can this be if there is not yet an EJBObject?
Am I not reading this table properly?
C.Arthur
 
Nathaniel Stoddard
Ranch Hand
Posts: 1258
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is definitely one of the finer points you'll encounter on the exam .. or on the job .. if you are lucky enough to have one.
However ... in the meantime: when SLSBs are created the container knows everything about the bean in order to make it work. Therefore it can create the EJBObject at that point and put the bean in the pool. Contrast this with a CMP entity bean, where upon ejbCreate, the container doesn't know enough about the bean in order to actually create it.
For a SLSB, ejbCreate is a good time to use its context to do whatever needs to be done in preparation for client invocations. After ejbCreate it doesn't have a chance. And therefore the container needs to make it all available through the context, EJBObject, and so forth.
[Double-check all this ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic