Meaningless Drivel is fun!*
The moose likes EJB Certification (SCBCD/OCPJBCD) and the fly likes EJBObject Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Certification » EJB Certification (SCBCD/OCPJBCD)
Bookmark "EJBObject" Watch "EJBObject" New topic
Author

EJBObject

Amin Rais
Greenhorn

Joined: Aug 28, 2002
Posts: 20
Hi,
In the spec it says that in ejbCreate of Stateless Session Bean, we can get the reference of EJBObject. But as I know when container calls ejbCreate of Stateless it doesn't bind the bean to EJBObject yet.
So how can ejbCreate can access EJBObject then ?
Please give me a light ...
Thanks
Sagar Salapaka
Greenhorn

Joined: Feb 06, 2002
Posts: 12
Good question.
The container associates the EJBObject to the session bean instance before calling ejbCreate() on that instance. Because there is no reason to believe otherwise
The OID in the spec (figure 6 - page 83) clearly shows how a session object gets created.
How and exactly when the EJBObject is bound to the session context is container implementation specific.
Amin Rais
Greenhorn

Joined: Aug 28, 2002
Posts: 20
Thanks for the reply.
I understand what you said in your reply, your explaination is right for Statefull Session Bean.
In Stateless Session Bean, Page 90 of the spec it says that ejbCreate can access EJBObject. On the other hand in page 94 of the spec, it doesn't write EJBObject in the sequence diagram. Thus EJBObject is not available yet... so how can we access EJBObject from ejbCreate then ? this really confuses me...
Any more help ?
[ November 09, 2003: Message edited by: Amin Rais ]
Kathy Sierra
Cowgirl and Author
Ranch Hand

Joined: Oct 10, 2002
Posts: 1572
Howdy,
Amin, this one used to bother me too... for exactly the same reason. But the best way to think about it is that for a *stateLESS* bean, the EJB object is not tied to a particular bean anyway, so the Container can do whatever it wants to make it work. For example, if you have a stateless bean, and it wants to give a reference to itself to someone else, inside its ejbCreate() method, it can ask for a reference to its EJB object. But... we don't see the EJB object being made yet? That doesn't matter, because the bean isn't *really* tied to a particular EJB object, since each stateless bean is the same as the rest, and each EJB object for a stateless bean is the same as the rest. So a stateless bean just needs a reference to *something* that acts as "an EJB object for any stateless bean of this type."
Again, if I give someone a reference to my EJB object, and I'm a stateless bean, I'm not REALLY giving them a reference to ME -- this exact stateless bean. Instead, I'm giving them a *generic* EJB object reference that will work for ANY bean of that type.
I guess the real answer is "don't worry about it -- the Container takes care of making it work." And that's all we know. It's up to the Container to implement it any way that they want. Remember that the diagrams in the spec are merely "examples of how it MIGHT be implemented" but they do not represent the actual way that it MUST be implemented. The diagrams are more *conceptual* -- giving you a way to THINK about it, even if behind the scenes the Container is doing something very different. The only thing you care about is that the Container is required to make it BEHAVE as though things are implemented exactly as they are shown in the diagram. But how many real objects, and of which type, are actually created is a completely different story...
cheers,
Kathy
Amin Rais
Greenhorn

Joined: Aug 28, 2002
Posts: 20
Kathy....
Thanks for the reply, your reply is really amazing !
Also for my question in other Thread.
Thanks so much..... now I don't feel confuse anymore
 
GeeCON Prague 2014
 
subject: EJBObject