• Post Reply 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
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

JNDI - Location Transparency ?

 
Ranch Hand
Posts: 312
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi

Location Transparency can by achieved by using JNDI object. How is it possible?

Context ctx = null;
java.util.Hashtable ht = new java.util.Hashtable();
ht.put(-- Initial Context Factory --);
ht.put(-- Provider URL --);
ctx =new InitialContext(ht);

If we give the provider url details then how will it become location transparency?

I think in using ejb-ref we can achieve the location transparency for the server side clients (servlets/bean client). But what about standalone application uses datasources/beans etc?

If we put Context ctx = new InitialContext(); then how can achieve the location transparency?

Regards,
M.S.Raman
 
Ranch Hand
Posts: 704
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
One way is to use application resource files. Having a file named jndi.properties that defines all properties required to build the initial context will help achieving the location transparency. This file must be located in the application's classpath or it might be located under the $JAVA_HOME/lib folder. Another way is to use an IoC container like PicoContainer or Spring framework that does that job for you.
Regards.
 
Malli Raman
Ranch Hand
Posts: 312
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Valentin Tanase:
One way is to use application resource files. Having a file named jndi.properties that defines all properties required to build the initial context will help achieving the location transparency. This file must be located in the application's classpath or it might be located under the $JAVA_HOME/lib folder. Another way is to use an IoC container like PicoContainer or Spring framework that does that job for you.
Regards.



Hi,
I tried this and it is working fine. By doing this way I can say that the client don't require to hardcode the "provider_url" in the code to get the initial context.

Now it brings me another question. In the jndi.properties file you are mentioning the Provider URL to locate the context. Fine, If that is the case how will you say that it is location transparent to the client since the client knows the Provider URL in his $java_home/lib folder. Also whether the client can able to speak with two different context at the same time?
 
Space pants. Tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic