This week's book giveaway is in the Java in General forum.
We're giving away four copies of Beginning Java 17 Fundamentals: Object-Oriented Programming in Java 17 and have ishori Sharan & Adam L Davis on-line!
See this thread for details.
Win a copy of Beginning Java 17 Fundamentals: Object-Oriented Programming in Java 17 this week in the Java in General forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

SLSB creation

 
Ranch Hand
Posts: 149
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 1258
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
WHAT is your favorite color? Blue, no yellow, ahhhhhhh! Tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic