• Post Reply Bookmark Topic Watch Topic
  • New Topic

caching the home object

 
Neil Goldsmith
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are there any disadvantages to caching the home object of an EJB? I've implemented the service locator pattern and one of the benefits is to cache the home object for the EJB so subsequent clients calls asking for the home interface will be more efficient.
I'm expecting a ton of requests, so this should be a big time saver, but not sure of the ramifications.
 
SAFROLE YUTANI
Ranch Hand
Posts: 257
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There is nothing wrong with caching something that does not change often; and a home interface is a good candidate.
Perform a jndi look-up of the home interface only once, and after you get a copy of the home interface, use that object for subsequent requests for obtaining the remote interface.
SAF
 
Anant Kadiyala
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As long as you are not doing it for Stateful Session Beans you are OK.
If the EJB server goes down or if the bean has timed out (then the container throws the bean out), you will lose the Sateful Session bean and hence the 'Handle' will be useless.
Another prob is that, the Handles rely on factors like EJB server, IP, JNDI name of ur bean, etc. If these are changed, then ur Handle will not work.
-anant
 
Thomas Paul
mister krabs
Ranch Hand
Posts: 13974
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You could try to use the handle and if it fails, you could try the lookup of the Home object again before you fail the transaction. You could also set a transation up to delete the handle so that if anything on the server changes you could just run the transaction.
 
Matjaz Juric
Author
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Caching home object references is ok and it can be a real performance improvement. Actually in the Professional EJB book you can find out how to develop smart stubs for EJBs, where you can cache some remote method invocations on the client side already. It's relatively transparent and easy to develop.
Cheers,
Matjaz
[ February 11, 2002: Message edited by: Matjaz Juric ]
 
Anant Kadiyala
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sure.. I didn't mean to say caching HomeObjects is a bad thing! There is definitely performance boost. But I just wanted to bringforth the things to we need to be vary of..
-anant
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!