• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

ejbCreate for stateless sessions beans

 
William Parker
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

I am studying for the SCBCD exam and I would appreciate if someone is able to shed some light on a puzzling aspect of the specification....

According to HFEJB and the spec, within the ejbCreate method of a stateless session bean, you should be able to get a reference to your EJBObject through the SessionContext. How is this possible?

It seems to contradict the lifecycle of a stateless session, which states that the constructor, setSessionContext and ejbCreate are called by the container at a completely independent time from a call by the client, and are taken from the pool only to service a business method call, then put back immediatly after. This would seem to indicate that the bean is only connetced to an EJBOBject at the time the client calls a business method, and could be linked to a different EJBObject each time it is pulled from the pool.

So, as the ejbCreate method is only called once, at bean creation, (unlike entity beans), I can't understand how the SessionContext can have a reference to an EJBObject???

Me is very confused.....can anyone help?
 
Mudi Appu
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It should be something like connection pool. J2EE server implementation is done in order to store live references of EJB objects in somewhere and passing it when it is required. This is not an impossible task. And also we don�t need to worry about this as far as we are not going to implement a J2EE server.
 
Poobhathy Kannan
Ranch Hand
Posts: 94
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi William

yes it's a confusing one..but read this Kathy's explanation

It is giving a good understanding.
 
William Parker
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks guys - Kathy's explanation helps to make sense of this!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic