Win a copy of Learn Spring Security (video course) this week in the Spring forum!
    Bookmark Topic Watch Topic
  • New Topic

ServiceLocator for multiple JNDI contexts

 
Alec Shcherbakov
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • 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?
 
Ilja Preuss
author
Sheriff
Posts: 14112
  • Mark post as helpful
  • send pies
  • 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!
 
    Bookmark Topic Watch Topic
  • New Topic