Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Agile forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JNDI relativity

 
Kai Witte
Ranch Hand
Posts: 356
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hello,

the name tags of <env-entry>, <ejb-ref>, <ejb-local-ref>, <resource-ref>, <resource-env-ref> are all relative to java:comp/env, right?

So <env-entry-name>Test</env-entry-name> would be looked up for example this way:


Now if i would use <env-entry-name>/Test</env-entry-name> would the name be absolute and the lookup be c.lookup("Test")? Can I also use c.lookup("/Test") in that case?

Are there other ways regarding the relativity of the naming that I should be aware of for the exam?

Kai
 
seemapanth Joshi
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am attempting to answer because I want to understand. Now what is it you are asking when you say

Now if i would use <env-entry-name>/Test</env-entry-name> would the name be absolute and the lookup be c.lookup("Test")? Can I also use c.lookup("/Test") in that case?

From what I understand from the specs is that these environment entries are stored in JNDI contexts and when we say lookup you need to give the entire path of the JNDI context. You can at the most save the subcontext and then directly say lookup as illustrated in the example given in spec excerpted here:

where maxExemptions would be declared as:

Spec page 411.

Though I have not tried it but I guess saying <env-entry-name>/Test</env-entry-name> would be wrong or not achieve anything because it would be looking for "java:comp/env/Test" and would not find it.

Am I right?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic