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

SessionContext and ejbCreate (for stateless session beans)

 
Ranch Hand
Posts: 116
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
For stateless session beans' ejbCreate method, we can use SessionContext to access EJB Object. This is written in spec and HF EJB. But I don't know why ? stateless session beans are created separately from any client invocation. So when ejbCreate is called, there can be no client yet, and EJB Object is only created when a client calls "create" on the Home interface to let container create a EJB Object. So, when "ejbCreate" is called how can you know which EJB Object the bean is associated with (there can be no EJB Object yet) ??
 
Ranch Hand
Posts: 61
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think we should try to understand create() for stateless bean in this way: Bean is created and pooled by container, while create() give you a way to get EJB object. It's not to create a bean, but an EJB object.
 
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Container calls the ejbCreate() when it needes to create new bean instance in the beans' pool at server so and this is Independent to the client invaocation of create(), so How the container can create the client's EJBObject when there is not clinet call for create(). Moreover the creation of the EJBObject need some information of the clinet hence it can not be independent of client call of create().
 
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
my understanding is that there may only be one EJBObject per stateless session bean deployed to the container. the construction of an EJBObject isn't tied to a client's create() call. client's create only returns a reference that'll let them call methods on the slsb. client information isn't needed by the slsb (container) until the business method is executed.
 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
According to the Head First book, the EJBObject is created per client (p. 224), and the bean is not connected to the EJBObject until a business call on the stateless session bean is made, so I must say that I'm also perplexed - accordingly, there can be no way to get a reference to the EJBObject in create() or remove(). Either the HF book is in error about EJBObjects per client, or it's wrong about getting a reference to the EJBObject in the create() or remove(). I'd really like a definitive answer on which is correct!
 
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