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

Discussion in 'Java' started by Mick, Feb 3, 2005.

  1. Mick

    Mick Guest

    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.
     
    Mick, Feb 3, 2005
    #1
    1. Advertising

  2. Mick

    Mick Guest

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

    (Mick) wrote in message news:<>...
    > 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.
     
    Mick, Feb 23, 2005
    #2
    1. Advertising

  3. Mick wrote:

    > 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 :)

    --
    Cheers
    grundig
     
    Marcin Grunwald, Feb 23, 2005
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.

Share This Page