aspose file tools*
The moose likes EJB and other Java EE Technologies and the fly likes JNDI - Location Transparency ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "JNDI - Location Transparency ?" Watch "JNDI - Location Transparency ?" New topic
Author

JNDI - Location Transparency ?

Malli Raman
Ranch Hand

Joined: Nov 07, 2001
Posts: 312
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
Valentin Tanase
Ranch Hand

Joined: Feb 17, 2005
Posts: 704
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.


I think, therefore I exist -- Rene Descartes
Malli Raman
Ranch Hand

Joined: Nov 07, 2001
Posts: 312
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?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JNDI - Location Transparency ?