Forums Register Login

Cache in a ServiceLocator

+Pie Number of slices to send: Send
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
+Pie Number of slices to send: Send
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.
I brought this back from the farm where they grow the tiny ads:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 550 times.
Similar Threads
ClassCastException at PortableRemoteObject.narrow
Providing sessionbeans through init()
Service Locator Pattern
Doubt in Narrowing
ServiceLocator with stateful session beans EJB 3.0
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 29, 2024 05:57:14.