• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Sequence order in running CREATE() of Statful session bean....

 
Harvey Chan
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I have a problem in understanding the sequence order of CREATE<METHOD>
in Session Bean.
According to the OID of creation of a session bean. EJBObject was instaniated before invoking setSessionContext( ).
However, why NO EJBObject was attached to the sessionContext in
setSessionContext() while the EJBObject suddenly appears in the
ejbCreate() method?
This is strange to me because EJBHome run the ejbCreate() method
immediately after the setSessionContext().(without any hints that
any other thing has been run in between)
I am wondering if the CONTAINER has done something to the sessionContext
before running ejbCreate()?
And what is the reason behind not attaching the EJBObject to the
sessionContext in the setSessionContext method??
Thanks for your help~~~~~
 
David Harrigan
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Whilst it's slightly confusing, it's just the way things are. The container has to follow three steps before your session bean is ready for the client.
1. Instantiate the session bean object.
2. Give the session bean object the sessionContext
3. Call ejbCreate on the session bean.
Invoking getEJBObject is disallowed from the bean's point of view, until that bean has a session associated with that, so, the container is thinking...
"I'm going to give this bean a sessionContext in the setSessionContext method - but I'm not going to allow this bean to getEJBObject until I've returned from the setSessionContext method."
It's only in ejbCreate does the client have any legal association with the bean (since the container has does all the housekeeping stuff beforehand).
Hope this helps.
-=david=-
 
Philippe Maquet
Bartender
Posts: 1872
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Harvey,
Similar reasonings as yours above (great BTW ! ) were the ones which confused me the most while learning EJB !
Why is it so ? And why not this way (would be smarter BTW and easier to remember...) ?, stuff like that.
EJB specs are *just* a bunch of *contracts*, which is useful too !
You probably will be a Bean Provider and/or an Application Assembler. Now just put on your head the Container's Developer's hat : he reads the specs as you do, but with the other party's viewpoint : he says "OK, in sessionContext() I don't need to make the EJBObject accessible, but well in ejbCreate(), (...)" etc. That kind of developer is not that much different that *you* are : he just follows his/yours specs. Why ? Because it's written in the specs. It could be different, but it's not.
I personally *hate* learning stuff where I cannot reply to all "Why ?" questions, but with EJB (as with *any* high level technology BTW), I think you have no other choice. Published final specifications are the result of negociations (and I guess they may be tough ) between multiple vendors *and* users. How the heck could they be "perfect" then ?
Regards,
Phil.
 
Harvey Chan
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Philippe, may be I should try to understand the real world.

And thanks for David for always giving me a helpful hand~~~~~
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic