• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

when should Handle or EJBHome been cached?

 
M Zhang
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a question to access stateful session bean:
In my service locator, I can either cache the EJBHome or Handle for EJBObject. So when the client wants to access the session bean, it can call the delegate and the call the service locator to either getHandle.getEJBObject(), or getRemoteHome.create().

What are the pros and cons for these 2 approach?

Thanks,
 
Devender Thareja
Ranch Hand
Posts: 187
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I would assume that the your service locater class is a singleton. Since it returns stateful session beans which are different for all clients you should be using getRemoteHome.create().
getHandle.getEjbObject would be inappropriate because service locater class has no knowledge about state of the bean.
Right?
 
M Zhang
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you, Devender. I understand that the first time I need to call EJBHome.create to get the EJBObject. But after the first time, will that be more efficient if I can cache the EJBHandle of EJBObject, therefore, the client can find its stateful session bean faster?

This may be out of the scope of SCEA exam but I am curious to know.
 
Devender Thareja
Ranch Hand
Posts: 187
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I would keep the service locater simple. The client should cache it to improve performance and should reuse cached object whenever appropriate.

Originally posted by M Zhang:
I understand that the first time I need to call EJBHome.create to get the EJBObject. But after the first time, will that be more efficient if I can cache the EJBHandle of EJBObject, therefore, the client can find its stateful session bean faster?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic