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

M

Mick

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.
 
M

Marcin Grunwald

Mick said:
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.

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://java.sun.com/j2ee/1.4/docs/tutorial/doc/Overview6.html#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 :)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,733
Messages
2,569,440
Members
44,832
Latest member
GlennSmall

Latest Threads

Top