• Post Reply Bookmark Topic Watch Topic
  • New Topic

Cache in a ServiceLocator

 
Henrique Sousa
Ranch Hand
Posts: 92
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi folks,
I am currently using the ServiceLocator pattern (mostly) to locate EJBHome classes, and now that I got used to it I am considering to cache the home objects in order to improve performance. At first, I want to keep these home objects in a java.util.Map once they are used:

Ok, that should work. However, I have some questions: could the references in my cache become invalid? I mean, is there a chance that I take an EJBHome from the cache and it does not work anymore? And finally, has anyone got reasons why I should not cache the home objects? Thanks in advance
 
Mat Robinson
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In my opinion the single most important reason to use the ServiceLocator pattern, is to cache the EJBHome objects. This is a relatively expensive operation in the server, and therefore should be cached.

There is no reason that the EJBHome objects will become invalid, unless anyone else knows different? I have used almost this exact code on many occasions and never had any problems.

Mat.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!