• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Bear Bibeault
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Jj Roberts
  • Tim Holloway
  • Piet Souris
Bartenders:
  • Himai Minh
  • Carey Brown
  • salvin francis

SessionContext and ejbCreate (for stateless session beans)

 
Ranch Hand
Posts: 116
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • 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
  • 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
  • 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!
 
I don't always make ads but when I do they're tiny
the value of filler advertising in 2020
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic