question about ServiceLocator pattern

Hi,

I was wondering what would be the most approproate way to modify the serviceLocator pattern (from the core j2ee patterns book) to handle multiple initialContext? I.e, how do I modify the ServiceLocator to get the home from multiple remote servers?

Do I get the client to pass in the InitialContext to be used?

If I cache the homes - what should you use as the key? I.e. what can uniqeuly identify an InitialContext?

Cheers,

Nim

[469 byte] By [Nim_Sathia] at [2007-9-29 14:12:12]
# 1
Hey.You could store your context information into a properties file. Associate an alias with each context. Use alias as a key into map of some sort where you cache home interfaces for each context. Cheers
Vvanherka at 2007-7-15 4:48:47 > top of Java-index,Other Topics,Patterns & OO Design...
# 2

An InitialContext is probably uniquely identified by the provider URL. I'd rather set up some kind of mapping, though, so that you just say "service this" and "service that", and the ServiceLocator, through configuration info, figures out what JNDI service to lookup as well as what to ask for.

joarea at 2007-7-15 4:48:47 > top of Java-index,Other Topics,Patterns & OO Design...