I am using InitialContext in my application to search for remote EJBs. There are some external systems that notify me of some events, and when that happens, I will delegate this notification to the correct remote EJB.
I always thought that I should create a new InitialContext for each group of searches (and maybe even close the initial context after them). In the above case, this is one instance of InitialContext for each search. Although some members of my team are not sure.
So the question is: Should I cache an instance of InitialContext? If so, how long should I keep this instance alive and why?
source
share