This week's book giveaway is in the Java 8 forum.
We're giving away four copies of Java 8 in Action and have Raoul-Gabriel Urma, Mario Fusco, and Alan Mycroft on-line!
See this thread for details.
The moose likes EJB and other Java EE Technologies and the fly likes ServiceLocator for multiple JNDI contexts Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "ServiceLocator for multiple JNDI contexts" Watch "ServiceLocator for multiple JNDI contexts" New topic
Author

ServiceLocator for multiple JNDI contexts

Alec Shcherbakov
Greenhorn

Joined: Feb 04, 2004
Posts: 19
Hi there,
My question is mostly about J2EE component design.
There is a complex distributed J2EE application with multiple JNDI namespaces, running on WebSphere. Web and EJB components use ServiceLocator in order to locate business services.
Initially I decided to use a specific ServiceLocator for every component that lives in a separate container, with BaseServiceLocator defining all the common functionality.
Another approach I am thinking of is to create a single ServiceLocator that would keep a HashMap of JNDI contexts. The benefit that I see in this way: whenever there is a need in a new JNDI context, you don't need to create a new ServiceLocator. You just add a new naming factory/provider pair into the configuration file and call getInstance(KEY) of the ServiceLocator. ServiceLocator will use the KEY to obtain JNDI properties from the configuration file, check if the HashMap contains a corresponding initial context, and, depending on the result, either return an existing initial context, or create a new one and store it in the HashMap.
Perhaps this HashMap has to be synchronized.
What do you, dear experts, think about this? Which approach you think is the most appropriate in terms of scalability and performance?


Thank you.<br /> <br />Alec
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: ServiceLocator for multiple JNDI contexts
 
Similar Threads
object synchronization
how to connect EJB without using runclient
Service Locator
ServiceLocator for multiple JNDI contexts
ServiceLocator with stateful session beans EJB 3.0