• 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:
  • Campbell Ritchie
  • Ron McLeod
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Rob Spoor
  • Junilu Lacar
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Carey Brown
Bartenders:

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!
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic