488/158 ICE question: CMP entity bean life-cycle Ok, here goes...this sample question is driving me nuts. Please note my primary reference is the O'Reilly book, Enterprise JavaBeans, 3rd Ed. by Monson-Haefel. ICE Question asks to order these events once the client has invoked the create() method on a CMP entity bean. a. Container creates an EJBObject b. EJB home object invokes ejbCreate() on bean instance. c. Bean instance is associated with EJBObject. d. Container creates new bean instance. e. Container calls setEntityContext() on bean instance. f. Container creates the bean representation in a database. g. ejbPostCreate() method is invoked on the bean method Here's what I believe is the order: 1. d - Container creates multiple copies for each deployed bean for availability in the instance pool 2. e - The first method called after a bean is instantiated is setEntityContext() 3. (no letter...) - Client invokes create() on home stub 4. b - as a result of #3, ejbCreate() with matching parameters is invoked 5. a - Container creates EJB Object. (I believe the remote reference returned to the client will reference this object � is this true?) 6. f - insert new record in database 6. c - EJB Ojbect is associated with an instance from the instance pool with it's newly inserted record in the database 7. g - ejbPostCreate() is invoked Needless to say, my sequence isn't listed as an answer. I'd appreciate any feedback on this topic as I am trying to prepare for the new 158 (old 488) IBM exam for Websphere Application Server 4.0. Thanks ahead of time!
Your belief looks very close to one of the answers; b,f,a,c,g. And I agree with the answer leaving d and e out.... because they happen before the create() method where the question is asking you to start off.... The question may/should read, "After a client invokes the create() method... But, I still don't understand the placement of f. Data is not inserted into the database until after ejbPostCreate(). So, does f not mean data insertion into database? I would appreciate it, if someone could take the time and help out a little bit in explaining this, and/or reference some material to find the information. Thanks. kyle
Originally posted by danno: 488/158 ICE question: CMP entity bean life-cycle ... Needless to say, my sequence isn't listed as an answer. I'd appreciate any feedback on this topic as I am trying to prepare for the new 158 (old 488) IBM exam for Websphere Application Server 4.0. Thanks ahead of time!
OK, the right answer to this question is a). When you start the server it instantiates the bean d) and calls setEntityContext e). When the client tries to invoke create the server is already running and the steps d) and e) are already performed. So a), b), c), f) and g) are left and need to be put in the right order. When the client invokes create the EJB home object invokes ejbCreate() b). As it is a CMP Entity Bean ejbCreate() inserts a new record to the database f). That is a representation of the bean with the primary key to indentify the bean. After that the EJBObject is created a) and assigned to the bean instance c). Now follows ejbPostCreate() g). Hopefully this helps. Jochen [ May 02, 2002: Message edited by: Jochen van Waasen ]