Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

ServiceLocator for multiple JNDI contexts

 
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
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?
 
author
Posts: 14112
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
Hi Alec!
First, please don't cross-post! Please continue the discussion in the thread in the J2EE forum.
Second, besides our "Be Nice" rule, there is only one more thing we'd like to ask you to do: please adjust your display name so that it conforms to our Naming Policy. You can do so in your profile.
Thank you very much, and have a nice time at the Ranch!
 
Honk if you love justice! And honk twice for tiny ads!
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
    Bookmark Topic Watch Topic
  • New Topic