• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

ejbFind and bean state change

 
Vipin Mohan
Ranch Hand
Posts: 79
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi all
The EJB Specs (age: 169) state this
"The instance does not move to the ready state during the execution of a finder or a home method."
That means a bean remains in the pooled state even after ejbFind is called. In that case, how does the bean serve the business methods of the client ? Will ejbActivate get called for the first business method call, to move the bean to ready state ?
Thanks
Vipin
 
Kathy Sierra
Cowgirl and Author
Rancher
Posts: 1589
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Vipin Mohan:
hi all
The EJB Specs (age: 169) state this
"The instance does not move to the ready state during the execution of a finder or a home method."
Will ejbActivate get called for the first business method call, to move the bean to ready state ?
Thanks
Vipin

You got it. The job of a finder is JUST to return a primary key (or a collection of primary keys... which then become EJB object references for the client) *without* going to the trouble of allocating a bean and populating its persistent fields with data from the persistent store (i.e. database).
The server doesn't want to waste anyone's time loading beans when the client *might* not ever use the references it "found".
But you're right, as soon as the client calls an actual business method on one of the component interfaces it got back, the server says, "Oh, I guess this client is SERIOUS, so NOW we have to move a bean out of the pool and call ejbActivate() and ejbLoad()...)"
Unless it's a Home business method, of course. In which case the bean still stays in the pool, since a Home business method is not invoked on any specific entity. Home business methods are the same as finders, in terms of not causing a state change in the bean.
cheers,
Kathy
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic