EJB enviromental variables

Discussions

EJB programming & troubleshooting: EJB enviromental variables

  1. EJB enviromental variables (1 messages)

    What is the purpose of creating env variables for a session bean.

    How does one configure these variables on the application server

    Threaded Messages (1)

  2. EJB enviromental variables[ Go to top ]

    Your question is not clear! developers assume a lot.
    So assuming that your question is on <env-entry>,
    They are used to configure certain reference values for the session bean. They are set through ejb-jar.xml entry and can be read using a JNDI look up
    consider example ejb-jar.xml fragment
    <session>
      ...
      ...
      <env-entry>
         <!-- Access in code using JNDI lookup("java:/comp/env/get_assumption_sql") -->
         <env-entry-name>get_assumption_sql</env-entry-name>
         <env-entry-type>String</env-entry-type>
         <env-entry-value>
             SELECT ASSUMPTION FROM MIND
         </env-entry-value>
         <description>This env entry is for ... </description>
       </env-entry>
       ...

    Now if your session bean want to get this SQL, you simply do a look up as:
       initCtx.lookUp("java:/comp/env/get_assumption_sql");

    HTH