Can I cache the context and ejb home references in the Service Locator?

I am trying to increase the performance of a system that makes calls to about 7 enterprise java beans. I have created a service locator object to help streamline this by putting all the jndi information here. This service locator is a singleton object. I was wondering if I could keep a local reference to the context inside this service locator so I don't have to get another reference without hurting anything. I would also like to cache and keep a reference to the EJB Home objects of all the beans on our system, and just pull the home out of the cache and call create on it rather than looking it up every time.. Can I do this or are there problems associated with this design? I'm not really sure what holding onto a home or context will do... Will this be more problematic for stateful/stateless session beans or entity beans?

Thanks

Nic

[874 byte] By [holbrng] at [2007-9-26 6:56:27]
# 1

Hi Nic,

a few months ago i had exactly the same question!

Go to http://www.theserverside.com/resources/patterns_review.jsp and search for "EJB Home Factory". You'll have to login...This article will help you a lot i think, like it helped me a few months ago.

Javamad.

javamad at 2007-7-1 16:28:42 > top of Java-index,Other Topics,Patterns & OO Design...