why use ENC JNDI (java:comp/env) instead of JNDI name ?

why use ENC JNDI (java:comp/env) instead of JNDI name ?

Post by clmichiel » Fri, 04 Feb 2005 18:03:07


Many guide lines in the books use the java:comp/env naming context
(ENC JNDI) to access ressources like Datasources, EJBs from EJBs or
Web application instead of the JNDI.

It works fine and I does not encounter problems but I never found a
clear explaination on the reason to do this. Is it to have local calls
and avoid network trafic ?

Thanks a lot for a quick explaination.
 
 
 

why use ENC JNDI (java:comp/env) instead of JNDI name ?

Post by clmichiel » Thu, 24 Feb 2005 19:21:38

I am sure that somebody has a quick and easy response to this question

 
 
 

why use ENC JNDI (java:comp/env) instead of JNDI name ?

Post by Marcin Gru » Thu, 24 Feb 2005 21:50:47


To separate code from configuration.

You can easily change Datasource, EJB without code modification.
For example:
- you want to change datasource for your application, thanks to ENC JNDI you
can do it without modifing code and recompiling, just edit xml file,
- you can write complete EJB and test it without complete design of whole
application (you don't have to know exact JNDI name of EJB),
- it's easy to write GUI application for configuring J2EE applications -
everything is in XML files not in code,
- and many, many, other reasons.

Look at Development Roles of J2EE application, especially "* Developer",
"Application Assembler", "Application Deployer and Administrator".
http://www.yqcomputer.com/ #wp79888
Someone else writes the code and someone else configures. "Application
Assembler" and "Application Deployer and Administrator" theoretically even
don't have to know Java :)

Cheers
grundig